1
我有這個代碼使用NAudio來查找筆記本電腦上連接的所有麥克風,並且當我選擇一個時,它會在進度條中顯示一米的聲音。 當我收集所有設備,我收集他們在一個dropdwon列表中,我的問題是,當我從列表中選擇一個麥克風它將不會被激活,並在儀表上顯示聲音,除非我啓動WINDOWS SOUND RECORDER似乎啓動麥克風。 如何在無需啓動WINDOWS SOUND RECORDER的情況下啓用或激活代碼中的麥克風?啓用使用NAudio麥克風c#
這裏是代碼:
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
using NAudio;
using NAudio.CoreAudioApi;
using System.Threading;
using NAudio.Wave;
using NAudio.Mixer;
namespace NaudioVisualizer
{
public partial class Form1 : Form
{
public int a = 1;
public Form1()
{
InitializeComponent();
MMDeviceEnumerator de = new MMDeviceEnumerator();
var device = de.EnumerateAudioEndPoints(DataFlow.All, DeviceState.Active);
comboBox1.Items.AddRange(device.ToArray());
}
private void timer1_Tick(object sender, EventArgs e)
{
if (comboBox1.SelectedItem != null)
{
var device = (MMDevice)comboBox1.SelectedItem;
progressBar1.Value = (int)Math.Round(device.AudioMeterInformation.MasterPeakValue * 100);
}
}
}
}
一般來說,答案是更有益的,如果它們包含的解釋是什麼 代碼的目的是爲了解決問題而不介紹其他問題。 – Peter