dndr
dndr

Reputation: 2359

ActionScript USB microphone stutter

I have a problem with USB mic input. When using my laptops internal microphone the following recorded buffer plays back just fine:

microphone = Microphone.getMicrophone();
microphone.codec = SoundCodec.SPEEX;
microphone.setLoopBack(false);
microphone.rate = 16;
microphone.addEventListener(SampleDataEvent.SAMPLE_DATA, processMicData);

private function gotMicData(micData:SampleDataEvent):void {
   micBuffer.writeBytes(micData.data);
}

But when I select the USB mic the sound stutters, like it's adding silence between the buffers. By the way, if I use a program like Audacity to record the USB microphone, everything works fine.

Upvotes: 2

Views: 213

Answers (1)

Zac
Zac

Reputation: 11

I would recommend trying to use the Microphone.setSilenceLevel() method. It allows you to set a level of microphone activity necessary for flash to read the audio input. Then, when no input is recorded, it won't write in silence when no information is received.

For more info: http://help.adobe.com/en_US/ActionScript/3.0_ProgrammingAS3/WS5b3ccc516d4fbf351e63e3d118a9b90204-7d0c.html

Upvotes: 1

Related Questions