Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/wpf/12.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# NAudio测听信息仅在以下情况下有效;控制mmsys.cpl声音“;开放_C#_Wpf_Naudio - Fatal编程技术网

C# NAudio测听信息仅在以下情况下有效;控制mmsys.cpl声音“;开放

C# NAudio测听信息仅在以下情况下有效;控制mmsys.cpl声音“;开放,c#,wpf,naudio,C#,Wpf,Naudio,我正在尝试捕获麦克风的声音(DataFlow.capture),但AudioMeterInformation.peakValue仅在声音属性打开时才起作用(控制mmsys.cpl声音) 工作示例 但是当我关闭声音属性 我的代码 private void calculateChannels(Object source, ElapsedEventArgs e) { dev = devEnum.GetDefaultAudioEndpoint(DataFlow.Cap

我正在尝试捕获麦克风的声音(DataFlow.capture),但AudioMeterInformation.peakValue仅在声音属性打开时才起作用(控制mmsys.cpl声音)

工作示例

但是当我关闭声音属性

我的代码

    private void calculateChannels(Object source, ElapsedEventArgs e)
    {
        dev = devEnum.GetDefaultAudioEndpoint(DataFlow.Capture, Role.Multimedia);

        try
        {
            double currentLeftChannel = 100 - (dev.AudioMeterInformation.PeakValues[0] * 100);
            double currentRightChannel = 100 - (dev.AudioMeterInformation.PeakValues[1] * 100);

            // this function just "smooth" the progress bar
            this.leftChannel = round(this.leftChannel, currentLeftChannel);
            this.rightChannel = round(this.rightChannel, currentRightChannel);

        }
        catch (Exception ex)
        {
            Console.WriteLine(ex);
        }

    }
我在结果中使用(-100),因为我的进度条是反向的(黑色实际上是进度)

Render工作正常,即使没有打开属性


我怎样才能解决这个问题

我找到了解决办法。我必须在我的构造函数上设置WaveInEvent以启用该设备

waveInStream = new WaveInEvent();
waveInStream.WaveFormat = new WaveFormat(44100, 1);
waveInStream.StartRecording();
现在,它正在发挥作用