views:

71

answers:

1

I want to control the start of a sound very precisely, but it seems to wait for something before starting the sound. It is like there is an internal clock in the player that runs at approx 43 fps and that the sound can only start on that clock's beat. It does not matter what the framerate of the project or which computer it runts on, it is always 43 fps (at least for me).

To test this, start a sound, then each frame compare channel.position with the expected position, e.g. getTimer() - startTime. The difference is always (for me) 23 or 46 mS.

I found an article here http://stackoverflow.com/questions/929949/syncing-frames-to-audio-and-channel-position-acuracy which talks about the position property and that it is updated in its own rate, which in my case happens to be 43 fps, approx every 23 mS.

Is there a way to get control over both the play start of a sound and to know when the position property is updated? And if someone could explain what Flash is actually doing and when, it would be great!

I would really appreciate all input, this is so weird.

Edit: I noticed that the position property only contains multiples of 23.219954648526077, e.g. 46.439909297052154, 69.65986394557822? If you ask directly after creating a channel it contains the number I just set, but on the next frame it is only these specific numbers. Any idea someone?

A: 

The 23.219954648526077 ms interval comes from flash internally using 1024 samples as a buffer size and 44100 hz sample rate.

23.219954648526077 ms = (1024 samples / 44100 samples per sec) * (1000 ms per sec)

If you need sample accuracy, you can try using SampleDataEvent to output samples directly and Sound.extract to access loaded sound samples. It'll help if you're looking to sync multiple sounds with each other but not if you're syncing audio with display frames or video.

Dave
Thanks for your reply, it explains some part of the mystery. But it does not explain why the sound seems to be delayed. Could it be that soundchannels are not created directly any longer but put on hold until the next soundchannel update cycle, where also the position property is updated? If there is such a cycle, is there any event dispatched that could be used to know when this is happening?
Bob