Load.sound
The load.sound command loads a sound resource on to the memory heap.
Syntax
load.sound(byt SOUNDNUM);
Remarks
This command loads sound SOUNDNUM onto the memory heap. Sound resources must be loaded before being played. If you try to play a sound before it is loaded, AGI will raise trappable error #9.
In early versions of AGI, there was no way to unload a sound resource once it was loaded. Beginning with version 2.936, AGI included a discard.sound command that allows a programmer to unload unneeded sound resources, but only in non-PC versions of AGI; in the PC version, this command points to a null function that doesn't do anything, and in fact will usually cause AGI to crash; see the discard.sound command for details.
AGI adds a script entry to the script stack each time a sound resource is loaded.
Possible Errors
If you attempt to load a sound that does not exist, AGI will raise a runtime error and crash.
Example
<syntaxhighlight lang="agi"> [ assume the resource ID for a sound is 'Theme' load.sound(Theme); sound(Theme, f55); if(isset(f55))
{ reset(f55); print("Thank you for listening to our theme song!"); }
</syntaxhighlight>
Technical Information
Required Interpreter Version: | Available in all AGI versions. |
Byte-Code Value: | 98 (0x62 hex) |