减少不必要的噪音

发布于 2024-10-12 02:55:32 字数 1544 浏览 2 评论 0原文

在下面的代码中,有时当麦克风未连接时会产生一些噪音,并且系统会继续发出相同的声音。下面的代码有什么问题以及如何减少不需要的噪音。我应该在下面的代码中设置 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>

In the below code sometimes when microphone is not connected some noise is generated and the system just keeps on buzzing the same sound.Whats wrong with the code below and how to reduce the unwanted noise. Should i set myMic.setLoopBack(false) in the below code

<?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>

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

深海蓝天 2024-10-19 02:55:32

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

Try making myMic.silenceLevel(20) or some higher integer and check.
This should resolve the issue.

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文