0 Replies Latest reply on Dec 13, 2011 2:04 AM by hincauti

    Actoinscript 3.0 concatinate two ByteArrays!!

    hincauti Level 1

      Hi there,

      Does anyone know how to concatinate two ByteArrays made of a sound file?


      public var sound1_ba:ByteArray = new ByteArray();          
      public var sound2_ba:ByteArray = new ByteArray();
      public var outputSound_ba:ByteArray = new ByteArray();
      public var sound1_URL:URLRequest = new URLRequest("/assets/sounds/sound1.mp3");     //a sound with 100ms in length
      public var sound2_URL:URLRequeat = new URLRequest("/assets/sounds/sound2.mp3");     //a sound with 50ms in lenght
      public var sound1:Sound = new Sound();
      public var sound2:Sound = new Sound();
      protected function concatBA():void{
           sound1.extract(sound1_ba, 8192);
           sound2.extract(sound2_ba, 8192);
           //here goes the concatination of the "sound1_ba" and "sound2_ba"
           /************ the "outputSound_ba" ByteArray, after encoding into .wav (using the wave encoder class) should be 150 milliseconds in lenght (sound1 + sound2); *********************/
           //I guess a possible solution could be:
           outputSound_ba.writeBytes(sound1_ba, offset: 'at the begining of the outputSound_ba');
           outputSound_ba.writeBytes(sound1_ba, offset: 'at the end of the existing sound1_ba inside the outputSound_ba');


      how to achieve that?

      Thank You!