How do I configure a bandpass filter?

拜拜、爱过 提交于 2019-12-19 08:05:15

问题


I'm trying to use the Web Audio API's bandpass filter functionality, but I believe my question is more general. I don't understand the "Q" value of the bandpass filter. I would like to be able to configure the filter to pass frequencies that are within Y hertz of a middle frequency X hertz.

I'm very new to audio programming, so are there other variables I need to consider to compute Q?


回答1:


Let's say you have a filter at 1000Hz, and you want it to start at 500Hz and end at 2000Hz.

First off, you'll notice it doesn't extend the same number of hertz in each direction. That's because filter bandwidth is based on octaves, not frequencies. So in this case, it extends one octave down and one octave up. Put another way, the frequency was divided by 2 on the low end and multiplied by 2 on the high end - which gives it a bandwidth of 2 octaves.

Anyway, here's how you can calculate it, assuming you know the frequencies:

Q = center_frequency / (top_frequency - bottom_frequency)

Which in this case would be 1000 / ( 2000 - 500 ), or 0.667.

You can also calculate it without knowing the top and bottom frequencies as long as you have a target bandwidth (in octaves) in mind:

function getQ( bandwidth ){
  return Math.sqrt( Math.pow(2, bandwidth) ) / ( Math.pow(2, bandwidth) - 1 )
}

Again, if you pass 2 as the bandwidth argument, you'll get the same result: Q = 0.667.

Hope that helps.



来源:https://stackoverflow.com/questions/15627013/how-do-i-configure-a-bandpass-filter

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!