Jump to navigation Jump to search
Sound.adjust changes the volume, pan, and/or speed of an already-playing sound. Call this on a Sound object after Sound.play.
|Parameter Name||Type||Default Value||Meaning|
|volume||number||1||volume (0-1) of the sound|
|pan||number||0||left (-1) to right (1) stereo pan of the sound|
|speed||number||1||speed multiplier (1 == standard speed)|
The sound will automatically stop if .loop is false, but will repeat until explicitly stopped if .loop is true. Note that speed will change both the duration and pitch of the sound, due to changing the speed of the waveforms being played.
The following example shows how to continuously adjust the speed and pan of a sound based on the position of the mouse.
snd = file.loadSound("/sys/sounds/celloLongC4.wav") snd.loop = true snd.play while not key.pressed("escape") // play a sound, panning left/right according to mouse X position pan = mouse.x / 480 - 1 speed = 1 + mouse.y / 320 - 0.5 snd.adjust 1, pan, speed yield end while snd.stop