I am building a Flash Application which will allow a user to mix two mp3 files and send the mixed result to our server.
Using Pixel Bender I am already able to create a mix:
public class Mixer
{
[Embed(source="mix.pbj", mimeType="application/octet-stream")]
protected var NewFilter:Class;
private var shader:Shader;
private var shaderJob:ShaderJob;
protected var _output:ByteArray;
shader = new Shader(new NewFilter() as ByteArray);
private function onSampleDataHandler(event:SampleDataEvent):void
{
var width:int = 1;
var height:Vector.<int> = new Vector.<int>(numOfTracks);
for (var i:int = 0; i < numOfTracks; i++)
{
buffer[i] = new ByteArray();
sound[i].extract(buffer[i],BUFFER_SIZE * 4);
height[i] = buffer[i].length >> 4;
buffer[i].position = 0;
shader.data["src"+i]["input"] = buffer[i];
shader.data["src"+i]["width"] = width;
shader.data["src"+i]["height"] = height[i];
}
shaderJob = new ShaderJob(shader, event.data,width, height[0]);
shaderJob.addEventListener(Event.COMPLETE, onShaderJobComplete, false, 0, true);
shaderJob.start(false);
}
protected function onShaderJobComplete(event:ShaderEvent):void
{
// event.byteArray is the result
}
Not sure if the event.byteArray can be transformed to an mp3 file? Ideally we'd send the mp3 to our server for uploading.