Difference between revisions of "GetSoundProperty (CMS)"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(Redirected page to Global Command: getSoundProperty)
 
Line 1: Line 1:
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
+
#REDIRECT [[Global_Command:_getSoundProperty]]
<span class="bold">Function History</span>
 
<div class="mw-collapsible-content">
 
<div class="alt-bg">Available since v3.8</div>
 
</div></div>
 
 
 
 
 
Allows you to obtain various property values for the linked sound.id
 
<div class="toccolours mw-collapsible mw-collapsed tbl-ds">
 
<span class="bold">Additional Info</span>
 
<div class="mw-collapsible-content">
 
<div>Properties currently available:
 
<pre>volume, balance, offset, duration, playing, paused & loop</pre></div>
 
</div></div>
 
 
 
 
 
Syntax:
 
<syntaxhighlight>
 
getSoundProperty(id, "property")
 
</syntaxhighlight>
 
 
 
 
 
Example:
 
<syntaxhighlight>
 
-- let's store the sound.id into a variable
 
local soundID = getSoundId("vispath: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")
 
 
 
-- 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 playing & store the result into a variable
 
local soundPlaying = getSoundProperty(soundID, "playing")
 
 
 
--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")
 
 
 
-- let's print the sound properties to the log
 
print("volume=" .. soundVol .. ", balance=" .. soundBal .. ", offset=" .. soundOffset .. ", duration=" .. soundDur .. ", is playing=" .. soundPlaying .. ", is paused=" .. soundPaused .. ", is looping=" .. soundLoop)
 
</syntaxhighlight>
 
 
 
 
 
 
 
<span class="underline">'''Arguments'''</span>
 
 
 
'''id''': integer (number) <br/>
 
The id for the currently playing audio file! ("sound.id")
 
 
 
'''property''': "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)
 
* playing: returns a boolean value of true or false depending on if linked sound is playing or paused
 
* 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
 
 
 
 
 
<span class="bold underline">Flags</span>
 
 
 
none
 
 
 
 
 
<span class="bold underline">Return</span>
 
 
 
<span class="bold">property</span> <br/>
 
The requested property value
 
 
 
 
 
 
 
{| class="tbl-ds"
 
|-
 
|<span class="bold">Relevant Pages</span>: [[GetSoundId_(cms)|getSoundId]] - [[SetSoundProperty_(cms)|setSoundProperty]] - [[StartSound_(cms)|startSound]] - [[StopSound_(cms)|stopSound]] - [[ToggleSoundPause_(cms)|toggleSoundPause]]
 
|}
 

Latest revision as of 20:57, 4 May 2023