现在我使用了这个简单的C类: http://www.cardinalpeak.com/blog/a-c-class-to-implement-low-pass-high-pass-and-band-pass-filters
它运作良好并切断了所需的乐队.但是当我尝试用小步骤改变上限或下限时,在某些极限值上我听到错误的结果 – 衰减或频率偏移(不对应电流限制)声音.
计算脉冲响应的函数:
voID Filter::designBPF(){ int n; float mm; for(n = 0; n < m_num_taps; n++){ mm = n - (m_num_taps - 1.0) / 2.0; if( mm == 0.0 ) m_taps[n] = (m_phi - m_lambda) / M_PI; else m_taps[n] = ( sin( mm * m_phi ) - sin( mm * m_lambda ) ) / (mm * M_PI); } return;}
哪里
m_lambda = M_PI * Fl / (Fs/2);m_phi = M_PI * Fu / (Fs/2);
Fs – 采样率(44.100)
F1 – 下限
福 – 上限
简单的过滤功能:
float Filter::do_sample(float data_sample){ int i; float result; if( m_error_flag != 0 ) return(0); for(i = m_num_taps - 1; i >= 1; i--){ m_sr[i] = m_sr[i-1]; } m_sr[0] = data_sample; result = 0; for(i = 0; i < m_num_taps; i++) result += m_sr[i] * m_taps[i]; return result;}
我需要使用任何窗口功能(布莱克曼等)吗?如果是,我该怎么做?
我试图将我的冲动响应乘以布莱克曼窗口:
m_taps[n] *= 0.42 - 0.5 * cos(2.0 * M_PI * n / double(N - 1)) + 0.08 * cos(4.0 * M_PI * n / double(N - 1));
但结果是错误的.
我需要标准化水龙头吗?
http://www.iowahills.com/A7ExampleCodePage.html
总结…This Windowed FIR Filter C Code has two parts,the first is the calculation of the impulse response for a rectangular window (low pass,high pass,band pass,or notch). Then a window (Kaiser,Hanning,etc) is applIEd to the impulse response. There are several windows to choose from…
以上是内存溢出为你收集整理的c – 带通FIR滤波器全部内容,希望文章能够帮你解决c – 带通FIR滤波器所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)