开发者

Save ByteArray generated by Pixel Bender

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++)
        {
      开发者_StackOverflow社区      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.


Shine MP3 is an open source mp3 encoder for Flash ported with Alchemy: http://code.google.com/p/flash-kikko/

Alternatively there is a WAV encoder in the sazameki audio manipulating library: http://www.libspark.org/svn/as3/sazameki/trunk/src/org/sazameki/audio/format/Wav.as

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜