Audio Fade in/out
by Spinalkord · in Torque 2D Beginner · 11/17/2013 (11:40 pm) · 2 replies
Hi Guys and Gals,
What is the best way to fade Audio in and out. Currently I have this.
What is the best way to fade Audio in and out. Currently I have this.
function levi::create(%this)
{
$soundLevel=1.0;
alxSetChannelVolume(1,1.0);
levi.playIntroSong();
}
function levi::soundFade(%this)
{
$soundLevel-=0.0091;
if($soundLevel>0.001)
{
echo($soundLevel);
alxSetChannelVolume(1,$soundLevel);
%this.schedule(30,"soundFade");
}
else
{
echo("END") ;
alxStop($introSong);
echo("stopped Song");
echo(alxGetChannelVolume(1));
}
}
function levi::playIntroSong()
{
$introSong=alxPlay("levi:introMusic");
}About the author
Recent Threads
#2
As far as sound fade, this isn't directly supported in OpenAL (our underlying sound handler) but if you're feeling adventurous you could add it using something like what's described in this article. It would require you to complete the implementation of positional sources (or listeners) though.
11/18/2013 (6:26 am)
Note - script ticks are 32 milliseconds - scheduled times less than this are going to be at least 32 milliseconds and can occasionally cause the "flux capacitor" assert.As far as sound fade, this isn't directly supported in OpenAL (our underlying sound handler) but if you're feeling adventurous you could add it using something like what's described in this article. It would require you to complete the implementation of positional sources (or listeners) though.
Associate Mike Lilligreen
Retired T2Der