Hi
I have a play/stop button with a audio clip (sound.wav), say, 10 seconds long.
When I press the button, it plays the clip.
[blockcode]
local channel
local file = “sound.wav”
sound = audio.loadSound(file)
channel = audio.play(sound, {loops=-1})
[/blockcode]
When I release the button, it stops the clip.
[blockcode]
audio.stop(channel)
[/blockcode]
Quite simple actually.
I tried to use fade or fadeOut to smooth out the sound when it is stopped. But the button does not play the sound any more when it is pressed again. Basically, there is no sound. I have checked the channel volume. It is still at 1.
[blockcode]
audio.fadeOut({channel=channel, time=1000})
[/blockcode]
I tried various combination of rewind, setVolume and stop etc but still could not get it to play properly.
I guess I don’t know how to use the fadeOut function properly. Can someone share a small sample code? Thank you.
Alternatively, how can I call audio.stop at the end of the fadeOut?
Looking forward for your help.
Cheers
ec0000
[import]uid: 29942 topic_id: 7761 reply_id: 307761[/import]