Difference between revisions of "GetSoundProperty"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(8 intermediate revisions by 2 users not shown)
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%">
+
==getSoundProperty==
<b>Command History</b>
 
<div class="mw-collapsible-content">
 
<div style="background:#ebebeb" width="100%">Available since <span style="color:orange">v3.8</span></div>
 
</div></div>
 
  
 +
<div class="command-min-version-info">Available since: <span class="command-min-version">v4.0</span></div>
  
Allows you to obtain various property values for the linked sound.id!
+
<div class="command-doc">Return the requested sound property</div>
<div class="toccolours mw-collapsible mw-collapsed" style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%">
 
<b>Additional Info</b>
 
<div class="mw-collapsible-content">
 
<div>Properties currently available:
 
<pre>volume, balance, offset, duration, paused & loop</pre></div>
 
</div></div>
 
  
 
+
Lua Syntax:
Syntax:
+
<pre class="command-syntax">getSoundProperty(soundID, property)</pre>
<syntaxhighlight>
+
===Arguments===
getSoundProperty(id, "property")
+
====soundID====
</syntaxhighlight>
+
:'''int''' - ID of sound to get property from.
 
+
====property====
 
+
:'''"string"''' - Property to retrieve.Currently supported properties: "volume" (0 mute ... 100 full volume, -1 if volume could not be retrieved), "balance" (-100 ... left, 0 ... center, +100 ... right, 0 if balance could not be retrieved), "offset" (current position from beginning of the sound in milliseconds, -1 if offset could not be retrieved), "duration" (total duration of sound in milliseconds, -1 if duration could not be retrieved), "loop" (true if sound is looped, false it is only played once, false if loop property could not be retrieved), "playing" (true if sound is currently playing, false otherwise)."paused" (true if sound is currently paused, false if sound is playing or not active at all).
Example:
+
===Flags===
 +
===Return Values===
 +
;property
 +
:requested property value.
 +
===Examples===
 +
Example 1: store the current playtime of a sound
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's store the sound.id into a variable!
+
local soundID = getSoundId('vispath:sounds/example.ogg')
local soundID = getSoundId("sounds/example.ogg")
 
 
 
-- let's store the current volume for the linked sound into a variable!
 
local soundVol = getSoundProperty(soundID, "volume")
 
 
 
-- let's store the current audio balance for the linked sound into a variable!
 
local soundBal = getSoundProperty(soundID, "balance")
 
 
 
-- let's store the current playtime of the linked sound into a variable!
 
 
local soundOffset = getSoundProperty(soundID, "offset")
 
local soundOffset = getSoundProperty(soundID, "offset")
 
-- let's store the duration of the linked sound into a variable!
 
local soundDur = getSoundProperty(soundID, "duration")
 
 
--let's check if the linked sound is paused & store the result into a variable!
 
local soundPaused = getSoundProperty(soundID, "paused")
 
 
--let's check if the linked sound is looping & store the result into a variable!
 
local soundLoop = getSoundProperty(soundID, "loop")
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
<b><u>Arguments</u></b>
 
 
<b>id</b>: integer (number) <br/>
 
The id for the currently playing audio file! ("sound.id")
 
 
<b>property:</b> "string"
 
* volume: returns the volume level of the linked sound.id as an integer value
 
* balance: returns the left/right audio balance of the linked sound.id as an integer value
 
* offset:  returns current playing time of the linked sound.id as an integer value (ms)
 
* duration: returns duration of the linked sound.id as an integer value (ms)
 
* paused: returns a boolean value of true or false depending on if linked sound is paused or playing
 
* loop: returns a boolean value of true or false depending on if linked sound.id is set to loop or not
 
 
 
<b><u>Flags</u></b>
 
 
none
 
 
<b><u>Return</u></b>
 
 
see arguments (above)
 
{{i18n|GetSoundProperty}} <br/>
 
{| style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
 
|-
 
|<b>Relevant Pages</b>: [[GetSoundId|getSoundId]] - [[SetSoundProperty|setSoundProperty]] - [[StartSound|startSound]] - [[StopSound|stopSound]] - [[ToggleSoundPause|toggleSoundPause]]
 
|}
 

Revision as of 22:27, 30 September 2014

getSoundProperty

Available since: v4.0
Return the requested sound property

Lua Syntax:

getSoundProperty(soundID, property)

Arguments

soundID

int - ID of sound to get property from.

property

"string" - Property to retrieve.Currently supported properties: "volume" (0 mute ... 100 full volume, -1 if volume could not be retrieved), "balance" (-100 ... left, 0 ... center, +100 ... right, 0 if balance could not be retrieved), "offset" (current position from beginning of the sound in milliseconds, -1 if offset could not be retrieved), "duration" (total duration of sound in milliseconds, -1 if duration could not be retrieved), "loop" (true if sound is looped, false it is only played once, false if loop property could not be retrieved), "playing" (true if sound is currently playing, false otherwise)."paused" (true if sound is currently paused, false if sound is playing or not active at all).

Flags

Return Values

property
requested property value.

Examples

Example 1: store the current playtime of a sound

local soundID = getSoundId('vispath:sounds/example.ogg')
local soundOffset = getSoundProperty(soundID, "offset")