From AGI Wiki
Jump to: navigation, search

The load.sound command loads a sound resource on to the memory heap.


load.sound(byt SOUNDNUM);


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.


[ assume the resource ID for a sound is 'Theme'
sound(Theme, f55);
  print("Thank you for listening to our theme song!");

Technical Information

Required Interpreter Version: Available in all AGI versions.
Byte-Code Value: 98 (0x62 hex)

See Also

Sound Commands
Memory Management
AGI Scripts