0 Replies Latest reply on Nov 4, 2011 12:04 AM by ShunShunLikLik

    Distortion in Audio Recording

    ShunShunLikLik

      Hi

       

      I have written a audio recorder. It works fine in my XP computer. However, when I test it on Vista, serious distortion found. Only half of the sentance is recorded and the rate of audio is different.

       

      Here is an extract of my source code:

         protected function recBtn_clickHandler(event:MouseEvent):void{ 

          if (event.currentTarget.selected == true){ 

           event.currentTarget.label = "Stop"; 

           rec=new ByteArray(); 

           mic = Microphone.getMicrophone();

           mic.setUseEchoSuppression(true); 

           mic.setSilenceLevel(10,5); 

           mic.rate=44;

           mic.addEventListener(SampleDataEvent.SAMPLE_DATA, getMicAudio); 

           ply_Btn.enabled=false;

           ps_Btn.enabled=false;

          } 

          else{ 

           mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, getMicAudio); 

           event.currentTarget.label = "Record"; 

           ply_Btn.enabled=true; 

           ps_Btn.enabled=true;

          } 

         }

       

         private function playRecorded(e:SampleDataEvent): void{ 

          //what must be done, for playing at same rate. 

          if (!rec.bytesAvailable > 0) return; 

          for (var i:int = 0; i < 8192; i++){ 

           var sample:Number = 0; 

           if (rec.bytesAvailable > 0) sample = rec.readFloat();  

           e.data.writeFloat(sample); 

           e.data.writeFloat(sample);     

          } 

         }

       

      I have tried to set different rate values but the results are even worse.

       

      The only difference that I found is the audio device, which is SoundMax Digital Audio in XP and SoundMax Integrated Digital HD Audio in Vista. Do you think this is a cause of the problem?