Load.sound

From AGI Wiki
Jump to navigationJump to search
The printable version is no longer supported and may have rendering errors. Please update your browser bookmarks and please use the default browser print function instead.

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

Code:
[ 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!");
  }

Technical Information

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

See Also

Sound Commands
Memory Management
AGI Scripts