<< Chennai Flex User Group

Discussion Area

ask questions, discuss topics, solve problems

Discussion Home | About | Threads By Date | Search

Flash Offline record - issue


Thread posted 09/06/11 by Dharmendran
6,444 views, 0 comments.

Title
Flash Offline record - issue

Content

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);
}
}


}