I'm streaming audio using NetConnection and NetStream. I know that you can modify sample data in real-time with the Sound object, however I cannot find the SampleDataEvent for audio playing with the NetStream object. Is there a way to pass the audio from the NetStream object to a Sound object and modify the sound at that object instead?
Edit: I'm willing to do any kind of crazy hacks, so any solution is OK!
you need to access the bytecode of the sound, if using netstream it's possible only by passing it to (requesting it by) NetStream.send()
/ NetConnection.call()
in addition to the data being streamed. else you'll need something like a direct url for a Sound
or URLStream
Depending on the quality you're looking for, it you can sacrifice it down to a mono signal with low-bitrate, you may be able to stream it to obtain it as a URLStream on the client side, and then feed the data of that URLStream to a SampleDataEvent of an empty Sound object, progressively at runtime.
The extra work would mostly be on the server side, decompressing your MP3 to a Waveform stream of floating-numbers (a stream of a single-channel [mono] signal or a blend of the two combined to mono) and then pushing that out to your client side application.
As the URLStream gets loaded, append it's downloaded bytes to the ByteArray available on the Sound's SampleDataEvent (also give it some buffer "time" to load sufficient waveform data). For each mono-sample's read from the URLStream, you should write the same value twice to the SampleDataEvent.data object (once to the Left channel, once to the Right).
All this being said, downgrading the WAV-like sound stream to mono may not be sufficient to cut down on bandwidth and reach a wide target audience. Perhaps a look at an OGG library for AS3 (which should exists) would be a better alternative, and should certainly support decoding partially downloaded streams.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With