SetSoundProperty: Difference between revisions

From The Official Visionaire Studio: Adventure Game Engine Wiki
Created page with "<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"> <b>Command History</b> <div class="mw-collapsible-co..."
 
No edit summary
Line 6: Line 6:




Allows you to obtain various property values for the linked sound.id!
Allows you to set various property values for the linked sound.id!
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%">
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%">
<b>Additional Info</b>
<b>Additional Info</b>
<div class="mw-collapsible-content">
<div class="mw-collapsible-content">
<div>Properties currently available:
<div>Properties currently available:
<pre>volume, balance, offset, duration & loop</pre></div>
<pre>volume, balance, offset, loop</pre>
Please note that only mono sounds can be panned using the balance property; all stereo channel sounds will remain centered!</div>
</div></div>
</div></div>


Line 17: Line 18:
Syntax:
Syntax:
<syntaxhighlight>
<syntaxhighlight>
getSoundProperty(id, {flags=1, property})
setSoundProperty(id, {flags=1, properties})
</syntaxhighlight>
</syntaxhighlight>


Line 26: Line 27:
local soundID = getSoundId("sounds/example.ogg")
local soundID = getSoundId("sounds/example.ogg")


-- let's store the current volume for the linked sound into a variable!
-- set the linked sound property values to:  volume=80%, audio=centered, keep current offset with loop mode on!
local soundVol = getSoundProperty(soundID, {flags=1, volume})
setSoundProperty("sounds/example.ogg", {flags=1, volume=100, balance=0, offset=0 loop=true})
 
-- let's store the current audio balance for the linked sound into a variable!
local soundBal = getSoundProperty(soundID, {flags=1, balance})
 
-- let's store the current playtime of the linked sound into a variable!
local soundOffset = getSoundProperty(soundID, {flags=1, offset})
 
-- let's store the duration of the linked sound into a variable!
local soundDur = getSoundProperty(soundID, {flags=1, duration})
 
--let's store the current loop value of the linked sound into a variable!
local soundLoop = getSoundProperty(soundID, {flags=1, loop})
</syntaxhighlight>
</syntaxhighlight>


Line 52: Line 41:
<b><u>Flags</u></b>
<b><u>Flags</u></b>


<b>property</b>
<b>properties</b>
* volume: returns the volume level of the linked sound.id as an integer value
* volume: allows you to set volume level via an integer value
* balance: returns the left/right audio balance of the linked sound.id as an integer value
* balance: allows you to set the left/right audio balance via an integer value (-1000/0/1000)
* offset: returns current playing time of the linked sound.id as an integer value (ms)
* offset: allows you to start audio file from x time via an integer value (in ms)
* duration: returns duration of the linked sound.id as an integer value (ms)
* loop: allows you to declare if audio file should loop via a boolean value (true/false)
* loop: returns a boolean value of true or false depending on if linked sound.id is set to loop or not




<b><u>Return</u></b>
<b><u>Return</u></b>


see flags (above)
none
{{i18n|GetSoundProperty}} <br/>
{{i18n|GetSoundProperty}} <br/>
{| style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
{| style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
|-
|-
|<b>Relevant Pages</b>: [[GetSoundId|getSoundId]] - [[SetSoundProperty|setSoundProperty]] - [[StartSound|startSound]] - [[StopSound|stopSound]] - [[ToggleSoundPause|toggleSoundPause]]
|<b>Relevant Pages</b>: [[GetSoundId|getSoundId]] - [[GetSoundProperty|GetSoundProperty]] - [[StartSound|startSound]] - [[StopSound|stopSound]] - [[ToggleSoundPause|toggleSoundPause]]
|}
|}

Revision as of 17:46, 14 March 2013

Command History

Available since v3.8


Allows you to set various property values for the linked sound.id!

Additional Info

Properties currently available:
volume, balance, offset, loop
Please note that only mono sounds can be panned using the balance property; all stereo channel sounds will remain centered!


Syntax:

setSoundProperty(id, {flags=1, properties})


Example:

-- let's store the sound.id into a variable!
local soundID = getSoundId("sounds/example.ogg")

-- set the linked sound property values to:  volume=80%, audio=centered, keep current offset with loop mode on!
setSoundProperty("sounds/example.ogg", {flags=1, volume=100, balance=0, offset=0 loop=true})


Arguments

id: integer (number)
The id for the currently playing audio file! ("sound.id")


Flags

properties

  • volume: allows you to set volume level via an integer value
  • balance: allows you to set the left/right audio balance via an integer value (-1000/0/1000)
  • offset: allows you to start audio file from x time via an integer value (in ms)
  • loop: allows you to declare if audio file should loop via a boolean value (true/false)


Return

none


Relevant Pages: getSoundId - GetSoundProperty - startSound - stopSound - toggleSoundPause