减少不必要的噪音

时间:2011-01-17 12:51:19

标签: flex flash actionscript-3 mxml mxmlc

在下面的代码中,有时当麦克风没有连接时会产生一些噪音,系统只会继续嗡嗡声相同的声音。下面的代码有什么问题,以及如何减少不必要的噪音。我应该在下面的代码中设置myMic.setLoopBack(false)

<?xml version="1.0" encoding="utf-8"?>
<mx:Application
xmlns:mx="http://www.adobe.com/2006/mxml"
layout="absolute"
width="300"
height="100"
creationComplete="init()">

<mx:Script>
  <![CDATA[
     import mx.controls.Alert;
     import flash.net.NetStream;

     private var myMic:Microphone;
     private var recordingState:String = "idle";

     private function init():void {

        myMic = Microphone.getMicrophone();
        myMic.setSilenceLevel(0);
        myMic.rate = 44;
        myMic.gain = 100;
        myMic.setUseEchoSuppression(true);
        micLevel.visible = true;
        //Security.showSettings(SecurityPanel.MICROPHONE);
        myMic.setLoopBack(true);
        if (myMic != null)
        {
           myMic.setUseEchoSuppression(true);
           micLevel.setProgress(myMic.activityLevel, 100);
           addEventListener(Event.ENTER_FRAME, showMicLevel);
           //micLevel.setProgress(myMic.activityLevel, 100);
        }

     }

     private function showMicLevel(event:Event):void{
        switch (recordingState){
           case "idle" :
              micLevel.setProgress(myMic.activityLevel, 100);
              break;
        }

       }







  ]]>
  </mx:Script>

    <mx:ProgressBar x="0" y="36" mode="manual" id="micLevel" label="" labelPlacement="bottom" width="100" fontSize="10" fontWeight="normal"/>


  </mx:Application>

1 个答案:

答案 0 :(得分:0)

尝试制作myMic.silenceLevel(20)或更高的整数并检查。 这应该可以解决问题。