麦克风录制的声音与口吃

时间:2014-09-03 12:59:53

标签: actionscript-3 air

我的Android设备代码有问题。

我正在使用麦克风录制语音,但在录制后我播放录制的音频时会出现口吃。请帮帮我。

这是我的代码:

_mic.setSilenceLevel(0);
_mic.gain = 100;
_mic.rate = 44;

// function called when start Record button is clicked
public function startRecording():void
{
    _mic.addEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
}

// function called when stop Record button is clicked
public  function stopRecording():void
{
    _mic.removeEventListener(SampleDataEvent.SAMPLE_DATA, onSampleData);
    soundBytes.position = 0;
    soundO.length       = 0;
    soundO.writeBytes(soundBytes);
    soundO.position     = 0;
    soundBytes.length   = 0; 

    if(CALLBAC != null) 
        CALLBAC(soundO);
}

private function onSampleData(eve:SampleDataEvent):void
{
    while(eve.data.bytesAvailable)
    {
        var sample:Number = eve.data.readFloat();
        soundBytes.writeFloat(sample);
    }
}

// function when i click on play button
private function playbackSampleHandler(event:SampleDataEvent):void
{
    for (var i:int = 0; i < 8192; i++)
    {   
        var sample:Number = soundBytArr.readFloat();
        event.data.writeFloat(sample);
        event.data.writeFloat(sample);
    }
}

0 个答案:

没有答案