Difference between revisions of "Load.sound"

From AGI Wiki
Jump to navigationJump to search
 
Line 1: Line 1:
The <code>load.sound()</code> command loads the SOUND resource number n, i.e. Sound(n) into memory.
+
The '''load.sound''' command loads a [[sound]] resource on to the [[memory heap]].
  
&nbsp;
+
== Syntax ==
  
== <br />Syntax ==
+
load.sound([[number|byt]] SOUNDNUM);
  
<code>load.sound(n);</code>
+
== 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]].
  
== <br />Description ==
+
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.
  
Sound 'n' is loaded into memory.
+
AGI adds a script entry to the [[script stack]] each time a [[sound]] resource is loaded.
  
== Remarks ==
+
== Possible Errors ==
  
There is no way of loading a sound with indirection. The command load.sound.v does not exist.
+
If you attempt to load a [[sound]] that does not exist, AGI will raise a [[runtime error]] and crash.
  
&nbsp;
 
 
== Example ==
 
== Example ==
  
 
<div class="CodeBlockHeader">Code:</div>
 
<div class="CodeBlockHeader">Code:</div>
 
<syntaxhighlight lang="agi">
 
<syntaxhighlight lang="agi">
load.sound(3);   //load sound 3
+
[ 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>
 
</syntaxhighlight>
 
&nbsp;
 
  
 
== Technical Information ==
 
== 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 ==
  
&nbsp;
+
[[Sound Commands]]<br />
== Sources ==
+
[[Memory Management]]<br />
 
+
[[AGI Scripts]]<br />
* [[WinAGI|WinAGI]] help file
+
[[Category:Commands]]<br />
 
&nbsp;
 
== Also See ==
 
 
 
* [[Sound Commands|Sound Commands]]
 
* <code>[[sound]]</code>
 
* <code>[[stop.sound]]</code>
 
* [[AGI Specifications: Chapter 4 - The Logic Language#load.sound|AGI Specifications: Chapter 4 - The Logic Language load.sound]]
 
 
 
&nbsp;
 
 
 
[[Category:Sound Commands]]
 

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

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