PDA

View Full Version : looping several sounds... a gap between the sounds


_marabout_
06-24-2004, 09:31 AM
Hi,

I planned to use several loops in a presentation, and queue them so it will sound like a longer piece of music.

I planned to use onSoundComplete with the following basic behavior :


snd1 = new Sound(this);
snd1.attachSound("loop1");
snd2 = new Sound(this);
snd2.attachSound("loop2");

snd1.onSoundComplete = function() {
snd2.start();
}

snd1.start();


The same principle has been suggested several times on this forum, like here :
http://www.actionscript.org/forums/showthread.php3?t=32921

But it doesn't work fine for me : there's a gap between the two sounds when I do so, a brief silence that cuts the music flow.

So I am considering using the setInterval function instead, something like this :



att = setInterval(function() {
clearInterval(att);
snd2.start();
}, snd1.duration-150);


which works, but I'm not found of it. Plus notice that I have to set the callback 150 milliseconds shorter than the snd1 duration in order to loop fine, otherwise it doesn't loop well.

So you're gonna tell me : there is something wrong with my loop files. Nope, if I make them one file, pasting the second sound at the end of the first, it works fine.

Please, does anyone has a solution ?

Thanks,
_marabout_