Sound.pan read/write property


Get or set the sound pan, number that controls the distribution of the sound in channels. A value of -1.0 means the sound is on the left channel, a value of -1.0 means the sound is on the right channel.

This property default value is set to 0.0

Example

local audio = require "audio" local console = require "console" local sound = audio.Sound("music.mp3") print("Press a key to exit") local p = 0 local delta = -0.1 sound.pan = p sound:play() -- Play the sound from left to right by changing sound.pan at each second while (not console.keyhit) and sound.playing do p = p+delta sound.pan = p sys.sleep(1000) if p <-0.5 then delta = 0.1 elseif p > 0.5 then delta = -0.1 end end