diff --git a/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm b/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm index 52e0d5e4f..832c7e997 100644 --- a/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm +++ b/Manual/contents/GameMaker_Language/GML_Overview/Variables/Builtin_Global_Variables/async_load.htm @@ -4,7 +4,7 @@
This variable is global in scope and is used to hold a DS map when used in the Asynchronous Events, and -1 at all other times. The actual contents of the DS map will depend on the type of asynchronous event callback, as well as the function that was used to trigger the event, so refer to the individual pages for those events for full details of all the possible DS map contents.
+This variable is global in scope and is used to hold a DS Map when used in the Asynchronous Events, and -1 at all other times. The actual contents of the DS map will depend on the type of asynchronous event callback, as well as the function that was used to trigger the event, so refer to the individual pages for those events for full details of all the possible DS map contents.
async_load;
+async_load
DS Map ID
+
sprite = sprite_add("site.com/path/image.png", 16, true, true, 0, 0);
-The above code would be called in an event to load a sprite from an external URL. This would then trigger the Image Loaded Asynchronous Event, where you would parse the async_load map:
-if (ds_map_find_value(async_load, "id") == sprite)
+
The above code would be called in an event to load a sprite from an external URL. This would then trigger the Image Loaded Asynchronous Event, where you would parse the async_load map:
+if (ds_map_find_value(async_load, "id") == sprite)
{
if (ds_map_find_value(async_load, "status") >= 0)
{
sprite_index = sprite;
}
}
The above code will first check the ID of the async_load map, then check the status of the callback. If the value is greater than or equal to 0 (signalling success) the result from the callback will then be used to set the sprite index of the instance to the newly loaded image.
+The above code will first check the ID of the async_load map, then check the status of the callback. If the value is greater than or equal to 0 (signalling success) the result from the callback will then be used to set the sprite index of the instance to the newly loaded image.
-
You can use audio buffers to load, save and manipulate audio files within your games. These buffers are created beforehand using the appropriate buffer functions and then you can use the following functions to create a sound to use in your project:
-
Note that once you have created a sound from an audio buffer, you are not creating a new sound in memory, but rather pointing to the position within the buffer where the sound is stored. You should not change this buffer after a sound has been associated with it otherwise you will get unexpected results, and you cannot delete the buffer while a sound is associated with it. Instead, free the sound (or sounds) first then delete the buffer.
-Once you have created your new audio resource from a buffer, you can use its handle in any of the regular audio functions to play it, change its gain or pitch, pause it, etc. Note that the buffer used to load the audio can only support PCM sounds, so formats like OGG will not be supported.
+When you create a sound from an audio buffer, you are not creating a new sound in memory, but rather pointing to the position within the buffer where the sound is stored. You should not change this buffer after a sound has been associated with it otherwise you will get unexpected results, and you cannot delete the buffer while a sound is associated with it. Instead, free the sound (or sounds) first then delete the buffer.
+Once you have created your new audio resource from a buffer, you can use its handle in any of the regular audio functions to play it, change its gain or pitch, pause it, etc.
+The buffer used to load the audio can only support PCM sounds, so formats like OGG are not supported.
Another feature of buffered audio is that you can use a buffer to create a queue of audio which can then be streamed to the device running your project. An audio queue takes a regular buffer which you have previously filled with audio data, and enables you to "point" to parts of it and tell GameMaker to stream the audio in a given order from that buffer. The available functions for audio queues are:
Once a queue has been created, you can then use the returned queue index just as you would the sound index for any normal sound to play it, pause it, restart it, or change it's gain and pitch. The only thing you cannot do is get the track length or set the track position, but other than that, an audio queue can be used just like any other sound. You should also note that some of the audio queue functions will also trigger an Audio Playback Asynchronous Event.
+Once a queue has been created, you can then use the returned queue index just as you would the sound index for any normal sound to play it, pause it, or change its gain and pitch. The few things you cannot do are get the track length, set the track position or use the loop functions, but other than that, an audio queue can be used just like any other sound. You should also note that some of the audio queue functions will also trigger an Audio Playback Asynchronous Event.
+Attempting to play an empty queue using the audio_play_sound* functions will not play anything and return a sound instance index of -1. You can queue new audio data after a queue has become empty and then play a new sound from the queue (creating a new sound instance).
Audio buffers will also permit you to record sound from any of the available sources (like microphones), which can then be queued and streamed using the above functions (for example). Recording audio will trigger an Audio Recording Asynchronous Event which will contain specific information about what is being recorded.
For recording audio, the following functions are available:
-
NOTE Most platforms except HTML5 support recording audio in some form, but that does not mean that all devices will permit it, even if the platform does, so you should always check that the audio_get_recorder_count() function returns a value greater than 0 to verify that recording devices are available before using the rest of the recording functions.
-+
Most platforms except HTML5 support recording audio in some form, but that does not mean that all devices will permit it, even if the platform does, so you should always check that the audio_get_recorder_count() function returns a value greater than 0 to verify that recording devices are available before using the rest of the recording functions.