Difference between revisions of "Load.sound"
(10 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
+ | The '''load.sound''' command loads a [[sound]] resource on to the [[memory heap]]. | ||
+ | == Syntax == | ||
+ | load.sound([[number|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]]. | |
− | [[Category: | + | 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 == | ||
+ | |||
+ | <div class="CodeBlockHeader">Code:</div> | ||
+ | <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 == | ||
+ | |||
+ | {| border="1" cellpadding="2" | ||
+ | | style="background-color: #efefef" width="200" | '''Required Interpreter Version:''' | ||
+ | | width="175" | Available in all AGI versions. | ||
+ | |- | ||
+ | | style="background-color: #efefef" | '''Byte-Code Value:''' | ||
+ | | 98 (0x62 hex) | ||
+ | |} | ||
+ | |||
+ | == See Also == | ||
+ | |||
+ | [[Sound Commands]]<br /> | ||
+ | [[Memory Management]]<br /> | ||
+ | [[AGI Scripts]]<br /> | ||
+ | [[Category:Commands]]<br /> |
Latest revision as of 20:34, 10 April 2019
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) |