NAudio 低通滤波器
Posted
技术标签:
【中文标题】NAudio 低通滤波器【英文标题】:NAudio Low Pass Filter 【发布时间】:2017-03-08 22:59:41 【问题描述】:我编写了捕获麦克风音频的代码,然后通过扬声器播放音频。我想在 e.Buffer byte[] 上实现一个低通滤波器,以减少来自麦克风的噪音。
一些背景:我打算用这段代码来创建一个VOIP程序。客户端将过滤后的 e.Buffer 数组发送给另一个客户端,然后播放音频。
class Program
public static int inputdevicenumber;
public static WaveFormat waveformat = new WaveFormat(44100, 16, 1);
static BufferedWaveProvider bufferedWaveProvider = new BufferedWaveProvider(waveformat);
static WaveOutEvent waveOut = new WaveOutEvent();
static void Main(string[] args)
WaveInEvent waveIn = new WaveInEvent();
int waveInDevices = WaveIn.DeviceCount;
for (int waveInDevice = 0; waveInDevice < waveInDevices; waveInDevice++)
WaveInCapabilities deviceInfo = WaveIn.GetCapabilities(waveInDevice);
Console.WriteLine("Device 0: 1, 2 channels", waveInDevice, deviceInfo.ProductName, deviceInfo.Channels);
string Reply = Console.ReadLine();
inputdevicenumber = Convert.ToInt32(Reply);
NAUDIO_Capture();
NAudio_Play();
Console.ReadKey();
static void NAUDIO_Capture()
WaveInEvent waveIn = new WaveInEvent();
waveIn.BufferMilliseconds = 20;
waveIn.DeviceNumber = inputdevicenumber;
waveIn.WaveFormat = waveformat;
waveIn.DataAvailable += new EventHandler<WaveInEventArgs>(waveIn_DataAvailable);
waveIn.StartRecording();
static void NAudio_Play()
bufferedWaveProvider.DiscardOnBufferOverflow = true;
waveOut.Init(bufferedWaveProvider);
waveOut.Play();
static void waveIn_DataAvailable(object sender, WaveInEventArgs e)
bufferedWaveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
【问题讨论】:
【参考方案1】:查看 NAudio WPF 演示中的 Equalizer
类,了解如何使用 BiQuadFilter
类应用过滤器。
【讨论】:
以上是关于NAudio 低通滤波器的主要内容,如果未能解决你的问题,请参考以下文章