2010-07-16 38 views
0

我正在构建一个Flash应用程序,它将允许用户混合两个mp3文件并将混合结果发送到我们的服务器。保存由Pixel Bender生成的ByteArray

使用Pixel Bender的我已经能够创建一个组合:

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 

} 

不知道,如果event.byteArray可以转化为一个mp3文件?理想情况下,我们会将mp3发送到我们的服务器进行上传。

回答

相关问题