Question

I'm making a flash, which is basically a very simple tracker. My question is about sequential playback and more specifically timing problems.

The SoundChannel-object conveniently provides a SoundCompleted-event, but relying on that results in tiny gaps between sounds, which (sadly) makes it useless.

All I've managed to dig up so far, are tutorials using events triggering every millisecond and manually watching for the tick where to start the next sound. This seems a little hackish and unnecessarily resource wasteful.

Is there a better way to timing sounds sequentially with gapless playback?

Was it helpful?

Solution 2

That could work, but timeouts are not independent of framerate, or not entirely anyway. They trigger, as you say, as close to the set timeout as possible but I've found that there is some variation in the exactness depending on the framerate.

But as to the original problem, I did some research and answered it myself.

OTHER TIPS

If you query the current sound's time (or remaining time) in milliseconds, and set a timeout for that period, and begin the next sound in the timeout handler, would that work? It's not something I've tried and found reliable, but timeout handlers will get called as close to the direct time as the Flash Player can manage (regardless of framerate, etc). So if it doesn't work, I can't really imagine what else would, unless it was some variation of estimating how many MS of leeway are required, and trying to start the next sound 5ms or whatever before the current one is scheduled to end.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top