Re: flash.utils.Timer is distressingly inaccurate
"ReubenH" <webforumsuser@macromedia.com> wrote in message
news:ge4ab0$79v$1@forums.macromedia.com...
> Hi,
>
> I am writing a music synthesizer program. For it to play fast pieces of
> music
> where notes are, say, 100ms to 200ms apart, accurate timing is essential.
> Yet
> the Flex Timer class has a relatively large error... on my XP laptop the
> timer
> events arrive 0 to 30ms late (and thats with GUI updates turned off!),
> which is
> sufficient to make playback sound very bad indeed.
>
> I am wondering if there is anything I can do about this? At the moment I
> think
> my best bet is have my timer events complete 50ms early (assuming 50ms is
> worst-case lateness) and busy-wait the last up-to-50ms bit of time before
> playing the next note. But that seems pretty hideous.
>
> Questions:
>
> #1. Is there anything I can do to reduce the delay, or at least make it
> more
> predictable?
>
> #2. Is there a "nice" way to busy-wait? AFAICS all I can do is spin until
> flash.utils.getTimer() >= desired_timer_time...
>
> #3. Maybe my whole design could be better. Is there a way to play two
> consecutive MP3s (on the same SoundChannel) with an accurate period of
> time
> between them that doesnt involve the Timer class?
I think the timer logic may be in the enterFrameHandler function, so it is
tied to when the playhead enters the next frame. I think your only solution
is to go with a really high frame rate.
|