0 Replies Latest reply on Sep 6, 2011 10:55 PM by Dharmendran

    Flash offline audio recorder - issue

    Dharmendran

      Hi Everyone,

      I have created flash offline audio recorder using as3. Using ByteArray class, write the audio stream in the Buffer (Ex. ByteArray.writebytes(bytes:Object)) and playback it from buffer.  Using SampleDataEvent.SAMPLE_DATA to trigger the mic event.Its working fine in all browser.

      The problem is while accessing Adobe connect or DIMDIM web meeting and use my offline audio recorder, then the audio get choppy because of out of memory.

      I have tried many ways but I can't get a solutio for this problem.

       

      activeMic=Microphone.getMicrophone(0);
      activeMic.gain = 90;
      activeMic.rate=rate;
      activeMic.setSilenceLevel(1);
      //activeMic.setLoopBack(true);
      activeMic.setUseEchoSuppression(true);

       

      Anyone have any ideas, Please post me. Thanks in Advance.

       

      Code
      activeMic=Microphone.getMicrophone(0);

      activeMic.gain = 90;

      activeMic.rate=rate;

      activeMic.setSilenceLevel(1); //

      activeMic.setLoopBack(true);

      activeMic.setUseEchoSuppression(true);

      activeMic.addEventListener(SampleDataEvent.SAMPLE_DATA, getMicData);



      private function getMicData(evt:SampleDataEvent):void {
      //_txt.text = 'mic data: '+evt.data.bytesAvailable;     
      if(evt.data.bytesAvailable > 0) {
      //soundData.writeFloat(evt.data.readFloat());
      soundData.writeBytes(evt.data);     
      }

      }

      private function playMicSound() {     
      soundData.position = 0;
      micChannel = new SoundChannel();
      micsound=new Sound();     
      micsound.addEventListener(SampleDataEvent.SAMPLE_DATA, playHandler);     
      micChannel=micsound.play();     
      micChannel.addEventListener(Event.SOUND_COMPLETE, micSoundComplete);

      }


      private function playHandler(evt:SampleDataEvent):void {     
      if (! soundData.bytesAvailable) {
      return;
      }

      for (var i:int = 0; i<(8192/(44/rate)); i++) {
      var temp:Number=0;
      if (soundData.bytesAvailable) {
      temp=soundData.readFloat();
      }
      for (var j:int=0; j<int((44/rate)*2); j++) {
      evt.data.writeFloat(temp);
      }
      }     


      }