如何实现该方程给出的带通滤波器?
我正在摆弄一些音频内容和我试图实现的算法,该算法需要由等式给出的带通二阶 FIR 滤波器
H(z) = z - z^(-1)
如何在 C 中实现这样的带通滤波器?
我有原始音频数据以及对该音频数据的 FFT,但我仍然不确定如何实现这个滤波器,我也不确定这个方程的确切含义。
在下图中,我尝试实现 HF3:
I'm messing around with some audio stuff and the algorithm I'm trying to implement calls for a band-pass second-order FIR filter given by the equation
H(z) = z - z^(-1)
How do I implement such a bandpass filter in C?
I have raw audio data as well as an FFT on that audio data available to me, but I'm still not sure how to implement this filter, neither am I sure exactly what the equation means.
In the image below, I am trying to implement HF3:
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
z^-1
是一个单位(一个样本)延迟,z
是未来的一个样本。因此,样本i
处的过滤器输出取决于i-1
和i+1
处的输入样本。 (一般来说,您可以认为z^-n
是 n 个样本延迟。)如果输入缓冲区
x[]
中有时域样本,并且您想要将这些样本过滤到输出缓冲区y[]
,然后您将像这样实现给定的传递函数:例如,在 C 中,您可以像这样处理 N 个样本的缓冲区:
这是一个非常简单的第一个-阶非递归高通滤波器 - 它的零点为 +1和 -1,因此幅度响应在 DC (0) 和奈奎斯特 (Fs / 2) 处为零,并且在 Fs / 4 处达到峰值。因此,它是一个非常宽的带通滤波器。
z^-1
is a unit (one sample) delay,z
is one sample into the future. So your filter output at samplei
depends on input samples ati-1
andi+1
. (In general you can think ofz^-n
is an n sample delay.)If you have time domain samples in an input buffer
x[]
, and you want to filter these samples to an an output buffery[]
, then you would implement the given transfer function like this:E.g. in C you might process a buffer of N samples like this:
This is a very simple first-order non-recursive high pass filter - it has zeroes at +1 and -1, so the magnitude response is zero at DC (0) and at Nyquist (Fs / 2), and it peaks at Fs / 4. So it's a very broad bandpass filter.
FIR 滤波器乘以系数并为每个输出数据样本累加一堆相邻的输入数据样本。系数的数量将与 Z 变换正确大小的 z 项的数量相同。
请注意,带通 FIR 滤波器通常需要更多的项或系数,大致与所需带通转换的陡度成比例,因此对于任何有用的带通滤波来说,2 个抽头可能太短。
A FIR filter multiplies by coefficients and accumulates a bunch of adjacent input data samples for every output data sample. The number of coefficients will be the same as the number of z terms on the right size of your Z transform.
Note that a bandpass FIR filter usually requires a lot more terms or coefficients, roughly proportional to the steepness of the bandpass transitions desired, so 2 taps is probably too short for any useful bandpass filtering.