October 16th, 2008

Without telling anyone, Adobe changed the Sound API on the recent released Flash Player 10. When we released our AudioTool yesterday we encountered a ridiculous long latency of almost one second. The latency time is the time between computation of the sound and the point where you can listen to the actual sound. It is important to keep this value low for live experience. After hours of research some people figure out, that the amount of samples you pass to the sound card is changing the latency dynamically BUT will never decrease. If you once pass a higher number of samples you cannot go back easily.

Here is how we handled sound creation before in the AudioTool
We simply passed 2048 samples (minimum amount) every time the SampleCallbackEvent was fired. The playback was stable - even when scrolling the desktop with a lot of devices. For processes that would block the CPU for some time (e.g. create new plugin instances), we passed 8192 sample (maximum amount) to remain stable playback and execute the processes after. So we dynamically increased the latency once to have more space for heavy computation. Afterward we went back to normal (2048 samples). In fact this worked great!

The Release Player changed all that
With the latest player, every time you increase the number of samples you will increase the overall latency. And there is no way of decreasing it again without stopping the SoundChannel. So now we just pass 3072 samples (~160ms latency) all the time. Meaning that critical processes won't be caught and will cause gaps in playback.

Again we now have 4 times more latency, but playback is overall less stable.

The worst thing is, that nobody told us and I am still not sure, what that is all about. The new sound feature was great and worked great for all release candidates. And all the sudden they changed it - again - without telling anyone. If we had this information before, it would not have been so hard to accept it. And of course we may have found some workarounds.

16 Responses to “FP10 SoundAPI changes”

I truely hope this is a bug regression of some sort, but it’s unfortunate that it got introduced to the release version like this. Please do post when you’ve filed a bug report, and I’ll go in there and vote it up as well.

Part of this may be explained by this paragraph from Tinic’s original ‘Adobe Is Making Some Noise Part 2′ post:

“There is an internal buffer in the Flash Player which is about 0.2 to 0.5 seconds depending on the platform which is preventing drop outs. It will automatically be increased if drop outs occur. This internal buffer is the key for the high latency I was alluding to earlier. You should never depend on a certain latency with this API in your application. To enforce this there is a slight random factor in choosing this buffer size when the Flash Player launches.”

[...] There is actually nothing to add, but probably a better explanation is necessary to comprehend, why I was so disturbed of Adobes latest changes in the Sound API. I just want to make clear that I am not interest in spending time in fighting rather enhancing. [...]

Can anybody help in reading the header information from the ByteArray of an MP3 file loaded …. basically I want to find the BITRATE from the mp3 header. Thanks in advance … pls send the suggestions/solutions to lintoka123@gmail.com

[...] There are various flash apps online where you can try this. However, flash has a very limited sound support. Since Flash 10 this has been improved, but after a promising beta the final version has very bad latency. [...]