Expand my Community achievements bar.

Enhance your AEM Assets & Boost Your Development: [AEM Gems | June 19, 2024] Improving the Developer Experience with New APIs and Events

Microphone Sampling rate limited to 16?

Avatar

Level 2

Hi,

i am setting microphone rate property to 44, but it is switched to 16, is there any specific way to set rate in afcs.

Thanks

Atul

5 Replies

Avatar

Former Community Member

Hi ,

This is according to Player Microphone docs :

IF YOU ARE USING THE SPEEX CODEC (MICROPHONE.CODEC = SOUNDCODEC.SPEEX) FOR FLASH PLAYER 10 AND AIR 1.5 OR LATER, THE DEFAULT RATE VALUE IS 16KHZ. IF YOU USE THE SPEEX CODEC AND THEN CHANGE THE CODEC VALUE TO NELLYMOSER (MICROPHONE.CODEC = SOUNDCODEC.NELLYMOSER), THE RATE CONTINUES TO BE SET TO 16KHZ UNTIL YOU EXPLICITLY SET THE RATE TO A NEW VALUE. TO RECEIVE AUDIO USING FLASH PLAYER RELEASES BEFORE FLASH PLAYER 10 AND AIR RELEASES BEFORE AIR 1.5, CHANGE BOTH THE CODEC AND THE RATE VALUES WHEN YOU PUBLISH THE AUDIO.

We(LCCS) set the default when you create the Mic the first time to 11 kHz and that’s what player 9 can support maximum. But if you are using player 10 or later and set explicitly , it shouldn't be problem unless you are switching from one codec to another which then resets to 16.

So, check if you are switching codecs and if that’s the case, after switch , set it back again explicitly to 44.

You can look for reference at the MicrophoneManager.as code in player 9 source for any details. It’s similar to player 10.

Hope this helps

Thanks

Hironmay Basu

Avatar

Level 2

Hi,

Thanks for the quick reply.

I am setting codec and rate explicitly,

m=Microphone.getMicrophone();

m.codec=SoundCodec.SPEEX;

m.rate=44;

i am running flash player 10.1 beta3 debugger version.

but still rate is showing 16 on trace.

Thanks

Atul

Avatar

Former Community Member

That's strange since we don’t modify the rate. Can you send me a small test code of urs ? I will take a look tomorrow.

Thanks

Hironmay Basu

Avatar

Level 2

Hi Hironmay,

I think there is no relation to afcs code regarding rate set to 16, i have tried same code without using afcs container, just a simple code,but trace is showing 16 even after explicitly setting rate to 44.

I am running flash player 10.1 beta3

<?xml version="1.0" encoding="utf-8"?>
<s:Application xmlns:fx="http://ns.adobe.com/mxml/2009"
   xmlns:s="library://ns.adobe.com/flex/spark"
   xmlns:mx="library://ns.adobe.com/flex/mx" minWidth="955" minHeight="600" xmlns:rtc="AfcsNameSpace"
  applicationComplete="load()">
<fx:Declarations>
<!-- Place non-visual elements (e.g., services, value objects) here -->
</fx:Declarations>
<fx:Script>
<![CDATA[
  private var mySound:Sound;
    private var byt:ByteArray;
private var m:Microphone;
private var sound:Sound;
private function load():void{
sound=new Sound();
byt=new ByteArray();
}
private function listen(event:SampleDataEvent):void
{
while(event.data.bytesAvailable>0){
byt.writeFloat(event.data.readFloat());
}
}
protected function stop_handler(event:MouseEvent):void
{
m.removeEventListener(SampleDataEvent.SAMPLE_DATA,listen);
sound.removeEventListener(SampleDataEvent.SAMPLE_DATA,playMe);
}
protected function record_handler(event:MouseEvent):void
{
m=Microphone.getMicrophone();
m.codec=SoundCodec.SPEEX;
m.rate=44;
m.addEventListener(SampleDataEvent.SAMPLE_DATA,listen);
trace(m.rate);
}
protected function play_handler(event:MouseEvent):void
{
sound.addEventListener(SampleDataEvent.SAMPLE_DATA,playMe);
byt.position=0;
sound.play();
}
protected function playMe(event:SampleDataEvent):void{
for(var i:int=0;i<2048;i++){
if(byt.bytesAvailable>0){
var value:Number=byt.readFloat();
event.data.writeFloat(value);
event.data.writeFloat(value);
}
}
}
]]>
</fx:Script>
<s:Button x="270" y="10" label="Stop" id="stop" click="stop_handler(event)"/>
<s:Button x="192" y="10" label="Record" id="record" click="record_handler(event)"/>
<s:Button x="350" y="10" label="Play" id="play" click="play_handler(event)"/>
</s:Application>
Thanks
-Atul

Avatar

Former Community Member

Hi ,

I would say mail to the player forum and see their reply regarding this explicit setting. They might need to update their docs. I will talk to them too.

Thanks

Hironmay Basu