Difference between revisions of "SetSoundProperty"

From The Official Visionaire Studio: Adventure Game Engine Wiki
(5 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%">
+
==setSoundProperty==
<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 set various property values for the linked sound.id!
+
<div class="command-doc">Sets properties of the specified sound.</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 & 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>
 
  
 +
Lua Syntax:
 +
<pre class="command-syntax">setSoundProperty(soundID, {flags=1,
 +
    volume = int,
 +
    balance = int,
 +
    loop = true|false,
 +
    offset = int})</pre>
 +
===Arguments===
 +
====soundID====
 +
:'''int''' - ID specifying sound where properties will be set.
 +
===Flags===
 +
====vol/volume====
  
Syntax:
+
:Set sound volume (0 ... mute, 100 ... full volume).
<syntaxhighlight>
+
====bal/balance====
setSoundProperty(id, {flags=1, properties})
+
 
</syntaxhighlight>
+
:Set sound balance (-100 ... left, 0 ... center, +100 right).
 +
====lop/loop====
  
 +
:If true then loop sound, otherwise play it only once.
 +
====ofs/offset====
  
Example:
+
:Set the sound to a specific offset (seek) in milliseconds.
 +
===Return Values===
 +
;status
 +
:True if properties were set successfully, false if setting properties failed.
 +
===Examples===
 +
Example 1:  
 
<syntaxhighlight>
 
<syntaxhighlight>
-- let's store the sound.id into a variable!
+
local soundID = getSoundId('vispath:sounds/example.ogg')
local soundID = getSoundId("sounds/example.ogg")
 
  
-- set the linked sound property values to:  volume=80%, audio=centered, duration at 3 seconds, keep current offset with loop mode on!
+
setSoundProperty(soundID, {flags=1, volume=80, balance=20}
setSoundProperty(soundID, {flags=1, volume=100, balance=0, duration=3000, offset=0, loop=true})
 
 
</syntaxhighlight>
 
</syntaxhighlight>
 
 
 
<b><u>Arguments</u></b>
 
 
<b>id</b>: integer (number) <br/>
 
The id for the currently playing audio file! ("sound.id")
 
 
 
<b><u>Flags</u></b>
 
 
<b>properties</b>
 
* 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)
 
* duration: allows you to set a custom duration time for the linked sound
 
* 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)
 
 
 
<b><u>Return</u></b>
 
 
none
 
{{i18n|GetSoundProperty}} <br/>
 
{| style="background: #f0f0f0; border: 1px dashed darkgrey" width="100%"
 
|-
 
|<b>Relevant Pages</b>: [[GetSoundId|getSoundId]] - [[GetSoundProperty|GetSoundProperty]] - [[StartSound|startSound]] - [[StopSound|stopSound]] - [[ToggleSoundPause|toggleSoundPause]]
 
|}
 

Revision as of 22:28, 30 September 2014

setSoundProperty

Available since: v4.0
Sets properties of the specified sound.

Lua Syntax:

setSoundProperty(soundID, {flags=1, 
    volume = int, 
    balance = int, 
    loop = true|false, 
    offset = int})

Arguments

soundID

int - ID specifying sound where properties will be set.

Flags

vol/volume

Set sound volume (0 ... mute, 100 ... full volume).

bal/balance

Set sound balance (-100 ... left, 0 ... center, +100 right).

lop/loop

If true then loop sound, otherwise play it only once.

ofs/offset

Set the sound to a specific offset (seek) in milliseconds.

Return Values

status
True if properties were set successfully, false if setting properties failed.

Examples

Example 1:

local soundID = getSoundId('vispath:sounds/example.ogg')

setSoundProperty(soundID, {flags=1, volume=80, balance=20}