var sound:Sound = new Sound();
var req:URLRequest = new URLRequest(url);
sound.load(url)
I want to modify the sound data (an mp3) as it comes in. Specifically, the mp3 will be encrypted using a stream cipher and I want to decrypt the data as it comes in. Is this possible using some type of event?
To process an existing audio stream, you have to set up an output Sound object, without loading a sound into it. Then listen on that sound object for the SampleDataEvent.SAMPLE_DATA, which is fired whenever a Sound object, for which the buffer is empty, starts playing. You will need to fill it’s buffer with stereo PCM data (pairs of floating point numbers.)
To get those numbers, use the Sound.extract() method on your input Sound object (the one you’ve simply called sound in your code above) to read PCM data to a ByteArray. Process the data of that ByteArray however you want, and put it in the output buffer.
There’s also some sample code on the subject in the reference documentation for the extract() method.