Archive for May, 2008

Friday, May 23rd, 2008

How to load MP3 files from a FileReference

FileReference.load is a nice new feature in Flash Player 10, but the only thing you get back from it is the FileReference.data property, which is a ByteArray. This is useless (well, not altogether, as we’ll see) in the case of MP3 audio files, because the built-in Sound API does not support loading from ByteArray.

When “making-some-noise” wasn’t quite so easy, I invested a bit of time messing around with MP3 data to see if my Flash sound hack for playing PCM audio data could be subverted to use MP3 data instead. While I got this partially working, I realised that it was a library without any application. What use was it? I tried to use it for shoutcast streams, but it is not possible to seamlessly stitch together arbitrarily small frames of MP3 data and fire them with a “silent sound”. Unfortunately the ramp-up time of the mp3 decoder means that the signal audibly drops out at the stitch points.

It turns out that my efforts were not in vain, because with the arrival of FileReference.load, I have been able to repurpose this library so that it is now possible to load a Sound object with the data provided from a FileReference instance.
(more…)

Friday, May 23rd, 2008

Running locally loaded MP3 files through an fx chain

Combining the work in the previous 2 posts gives the following coolness (Flash Player 10 required):

(more…)

Thursday, May 22nd, 2008

Loading MP3 files locally using the FileReference class

The new FileReference class in Flash Player 10 opens up a whole new side to web applications, where the barrier between the local file system and the network has (to some degree) been torn down.

Here’s an example of how to load MP3 files from the local file system. I’m sure you’ll appreciate why this is pretty cool…

(more…)

Wednesday, May 21st, 2008

Flash Player 10 Audio

So the Flash Player team have finally relegated the SOUND_COMPLETE hack to the dustbin of failed tech… but replaced it with a far superior technology. You can see all the details over at Tinic Uro’s blog (here, here and here).

Naturally quite excited by this news, I have been doing some development work. Here’s what I needed to get started:

Flash Player 10
Handy doc explaining where to get Flex SDK nightly build and how to use it to target FP10
Standalone Flash Player 10 (Debug Version)

I’ve been refactoring a class library that I have been writing over the last year and a half or so, to see how well this new stuff works. The main obstacle in the refactoring process has been the transition from using standard Arrays to ship the audio data through the application to the use of ByteArrays instead. This seems to offer a significant improvement in performance (although in the debug player it runs like a dog… about 4x slower).

Ultimately the aim is to publish this as a library for all to use, but while I am investigating licensing options and a new site for the library, I will be posting demos here.

Here is a demo application (requires Flash Player 10, it won’t try to auto-update if you don’t have FP10) that demonstrates the following features:

Extracting PCM audio data from MP3 sounds
A feedback delay module
A gain module
A mixing module
A resampler (changes the playback rate)

Below is a schematic of how these modules are chained together.

AudioProcessorSchematic