Difference between revisions of "StartSound"
From The Official Visionaire Studio: Adventure Game Engine Wiki
m |
|||
Line 1: | Line 1: | ||
− | + | ==startSound== | |
− | |||
− | |||
− | |||
− | |||
+ | <div class="command-min-version-info">Available since: <span class="command-min-version">v3.8</span></div> | ||
− | + | <div class="command-doc">Plays a sound file.</div> | |
− | <div class=" | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
+ | Lua Syntax: | ||
+ | <pre class="command-syntax">startSound(sounditem, {flags=1, | ||
+ | volume = int, | ||
+ | balance = int, | ||
+ | loop = true|false, | ||
+ | offset = int})</pre> | ||
+ | ===Arguments=== | ||
+ | ====sounditem==== | ||
+ | :'''"string" (string should contain 'vispath:' prefix)''' - Relative filename of sound which should be started. | ||
+ | ===Flags=== | ||
+ | ====vol/volume==== | ||
− | + | :Sound volume (0 ... mute, 100 ... full volume), default value is 100. | |
− | + | ====bal/balance==== | |
− | + | ||
− | + | :Sound balance (-100 ... left, 0 ... center, +100 right), default value is 0. | |
+ | ====lop/loop==== | ||
+ | :If true then loop sound, otherwise play it only once (default). | ||
+ | ====ofs/offset==== | ||
− | Example 1: | + | :Set the sound to a specific offset (seek) in milliseconds. Default value is 0. |
+ | ===Return Values=== | ||
+ | ;soundID | ||
+ | :Unique id referencing the started sound or -1 if the sound could not be started. | ||
+ | ===Examples=== | ||
+ | Example 1: play audio file, store sound id (for later use) and update sound balance of currently started sound | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | startSound( | + | local soundId = startSound('vispath:sounds/example.ogg') |
+ | setSoundProperty(soundId, {flags=1, balance=40}) | ||
</syntaxhighlight> | </syntaxhighlight> | ||
− | + | Example 2: play audio file and set volume, balance and offset | |
− | Example 2: | ||
<syntaxhighlight> | <syntaxhighlight> | ||
− | + | startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000}) | |
− | startSound( | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
</syntaxhighlight> | </syntaxhighlight> | ||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− | |||
− |
Revision as of 17:12, 22 November 2013
Contents
startSound
Available since: v3.8
Plays a sound file.
Lua Syntax:
startSound(sounditem, {flags=1, volume = int, balance = int, loop = true|false, offset = int})
Arguments
sounditem
- "string" (string should contain 'vispath:' prefix) - Relative filename of sound which should be started.
Flags
vol/volume
- Sound volume (0 ... mute, 100 ... full volume), default value is 100.
bal/balance
- Sound balance (-100 ... left, 0 ... center, +100 right), default value is 0.
lop/loop
- If true then loop sound, otherwise play it only once (default).
ofs/offset
- Set the sound to a specific offset (seek) in milliseconds. Default value is 0.
Return Values
- soundID
- Unique id referencing the started sound or -1 if the sound could not be started.
Examples
Example 1: play audio file, store sound id (for later use) and update sound balance of currently started sound
local soundId = startSound('vispath:sounds/example.ogg')
setSoundProperty(soundId, {flags=1, balance=40})
Example 2: play audio file and set volume, balance and offset
startSound('vispath:sounds/example.ogg', {flags=1, volume=70, balance=-10, offset=1000})