<?xml version="1.0"?>
<feed xmlns="http://www.w3.org/2005/Atom" xml:lang="en">
		<id>https://solarstrike.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Sound_Functions</id>
		<title>Sound Functions - Revision history</title>
		<link rel="self" type="application/atom+xml" href="https://solarstrike.net/wiki/index.php?action=history&amp;feed=atom&amp;title=Sound_Functions"/>
		<link rel="alternate" type="text/html" href="https://solarstrike.net/wiki/index.php?title=Sound_Functions&amp;action=history"/>
		<updated>2026-06-17T13:38:38Z</updated>
		<subtitle>Revision history for this page on the wiki</subtitle>
		<generator>MediaWiki 1.30.0</generator>

	<entry>
		<id>https://solarstrike.net/wiki/index.php?title=Sound_Functions&amp;diff=961&amp;oldid=prev</id>
		<title>Elverion: Created page with 'Please note that, while playing sounds, that the sound resource must stay loaded. If the sound resource is unloaded at any time, the sound will be forcefully stopped. This means …'</title>
		<link rel="alternate" type="text/html" href="https://solarstrike.net/wiki/index.php?title=Sound_Functions&amp;diff=961&amp;oldid=prev"/>
				<updated>2011-08-02T03:05:12Z</updated>
		
		<summary type="html">&lt;p&gt;Created page with &amp;#039;Please note that, while playing sounds, that the sound resource must stay loaded. If the sound resource is unloaded at any time, the sound will be forcefully stopped. This means …&amp;#039;&lt;/p&gt;
&lt;p&gt;&lt;b&gt;New page&lt;/b&gt;&lt;/p&gt;&lt;div&gt;Please note that, while playing sounds, that the sound resource must stay loaded. If the sound resource is unloaded at any time, the sound will be forcefully stopped. This means that if your script finishes execution, all sounds are unloaded and stopped.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundLoad ==&lt;br /&gt;
'''sound soundLoad(filename)'''&lt;br /&gt;
&lt;br /&gt;
Loads a sound file (must be compatible with OpenAL). Nothing else. Returns the sound resource on success or nil on failure.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundPlay ==&lt;br /&gt;
'''soundPlay(sound)'''&lt;br /&gt;
&lt;br /&gt;
Plays a sound that has already been loaded.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
if( sound ) then -- make sure it was loaded&lt;br /&gt;
  soundPlay(sound);&lt;br /&gt;
end&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundStop ==&lt;br /&gt;
'''soundStop(sound)'''&lt;br /&gt;
&lt;br /&gt;
Stops a sound if it is playing.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
soundPlay(sound);&lt;br /&gt;
yrest(500); -- Let it play for 500ms, otherwise we won't hear anything&lt;br /&gt;
soundStop(sound);&lt;br /&gt;
soundPlay(sound); -- Starts playing the sound from the beginning&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundPause ==&lt;br /&gt;
'''soundPause(sound)'''&lt;br /&gt;
&lt;br /&gt;
Pauses a playing sound so that it can be continued later.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
soundPlay(sound);&lt;br /&gt;
yrest(500); -- Play the first 500ms of it&lt;br /&gt;
soundPause(sound);&lt;br /&gt;
yrest(1000); -- Wait one second, then resume playing&lt;br /&gt;
soundPlay(sound);&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundGetState ==&lt;br /&gt;
'''string soundGetState(sound)'''&lt;br /&gt;
&lt;br /&gt;
Returns the current state of a sound as a string. Possible returned values include: playing, paused, stopped, initial. &amp;quot;playing&amp;quot;, &amp;quot;paused&amp;quot;, and &amp;quot;stopped&amp;quot; are self explanatory, but &amp;quot;initial&amp;quot; refers to a sound resource that has been loaded and not messed with at all yet.&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
print(&amp;quot;State:&amp;quot;, soundGetState(sound));&lt;br /&gt;
-- This will print: State:  initial&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundSetVolume ==&lt;br /&gt;
'''soundSetVolume(sound, volume)'''&lt;br /&gt;
&lt;br /&gt;
Allows you to change the volume of a loaded sound resource. 'volume' should be between 0.0 (no sound) to 1.0 (max volume), normally. The volume can exceed 1.0 if your sound card supports it (this would effectively make the sound louder, obviously).&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
soundSetVolume(sound, 0.5);&lt;br /&gt;
soundPlay(sound); -- Will now not be as loud.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
== soundSetLooping ==&lt;br /&gt;
'''soundSetLooping(sound, loop)'''&lt;br /&gt;
&lt;br /&gt;
Sets whether a sound should loop or stop after it has finished playing. 'loop' should be either true (loop) or false (stop, the default). You should change this ''before'' playing the sound.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
'''Example'''&lt;br /&gt;
&amp;lt;source lang=&amp;quot;lua&amp;quot;&amp;gt;&lt;br /&gt;
local sound = soundLoad(getExecutionPath() .. &amp;quot;/sound.wav&amp;quot;);&lt;br /&gt;
soundSetLooping(sound, true);&lt;br /&gt;
soundPlay(sound); -- Will now loop continually until told to stop.&lt;br /&gt;
&amp;lt;/source&amp;gt;&lt;/div&gt;</summary>
		<author><name>Elverion</name></author>	</entry>

	</feed>