C# 如何使用Naudio在ProgressBar中显示麦克风音量
我试图用Naudio捕捉ProgressBar中的麦克风/输入电平。我可以在组合框中获得设备列表,但ProgressBar中没有显示声级计级别(有点像VU/峰值计)。以下是代码:C# 如何使用Naudio在ProgressBar中显示麦克风音量,c#,naudio,C#,Naudio,我试图用Naudio捕捉ProgressBar中的麦克风/输入电平。我可以在组合框中获得设备列表,但ProgressBar中没有显示声级计级别(有点像VU/峰值计)。以下是代码: using System; using System.Linq; using System.Windows.Forms; using NAudio.CoreAudioApi; namespace WindowsFormsApp5 { public partial class Form1 : Form
using System;
using System.Linq;
using System.Windows.Forms;
using NAudio.CoreAudioApi;
namespace WindowsFormsApp5
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
var deviceEnumerator = new MMDeviceEnumerator();
var devices = deviceEnumerator.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
if (devices != null)
{
comboBox1.Items.AddRange(devices.ToArray());
}
}
void Mytimer_Tick(object sender, EventArgs e)
{
if (comboBox1.SelectedItem != null)
{
var device = (MMDevice)comboBox1.SelectedItem;
progressBar1.Value = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 100);
}
}
}
}
你开始录音了吗?通常,当您捕获音频时,您只能看到米级。您开始录制了吗?通常,当您捕获音频时,您只能看到米级。