Sound.new: Difference between revisions

From GiderosMobile
No edit summary
Line 15: Line 15:
'''rate''': (number) the sampling rate of the waveform<br/>
'''rate''': (number) the sampling rate of the waveform<br/>
'''stereo''': (boolean) set to true if the array contains two channels<br/>
'''stereo''': (boolean) set to true if the array contains two channels<br/>
=== Example ===
<syntaxhighlight lang="lua">
local snd = Sound.new("audio/sfx01.wav")
local channel = snd:play()
if channel then channel:setVolume(0.5) end
</syntaxhighlight>


{{Sound}}
{{Sound}}

Revision as of 10:11, 19 September 2026

Available since: Gideros 2011.6
Class: Sound

Description

Creates a new Sound object.

Sound.new(filename)
Sound.new(data,rate,stereo)

Parameters

filename: (string) the path of the sound file to be loaded
data: (table) an array of values between -1 and 1 describing the waveform of the sound
rate: (number) the sampling rate of the waveform
stereo: (boolean) set to true if the array contains two channels

Example

local snd = Sound.new("audio/sfx01.wav")
local channel = snd:play()
if channel then channel:setVolume(0.5) end