Saturday, October 20, 2018

Which filter for an audio equalizer



I’m new to DSP and I have to do an audio equalizer in c++.
I did a lot of research about it and tried some stuff in the last month, but I’m a little overwhelmed with all those informations and it’s not working yet.


I decided to start over and for now, all I got is a function which fills the audio buffer with a sin wave (1kHz). And I’m trying to apply a filter with those values to it.






































So here are my questions :




  1. In which domain should I apply the filter ? I started in the frequency domain, but this blog (here and here) shows me that it’s not the best and only solution.





  2. Which kind of filter should I use ? I’m lost with all those high pass, low pass, peaking, shelving filters; and I don’t know which one to choose.




  3. I only found “tutorial” to create a filter which modify only one frequency / band. Is it possible to create a filter that is a sum of multiples filters ? Or applying multiples filters in series to the signal ?




Feel free to ask if I forgot something that might help to understand my problem.
Thanks for your time.



PS : Sorry if this post is not very specific, but I want to clear that out before posting specifics problems or code.



Answer



Simply put, you need a bank of passband filters. You feed your signal through each of the filters, and sum up the outputs from the filters.


Designing the filters is where the fun comes in.


First off, assuming this is just audio (music or the like) then there's no need of special filters. You can use the simplest and fastest and not worry too much about phase and ripple.
You will want to use IIR filters, as they require the least amount of calculation - since you have 28 bands and presumably are working in stereo, you will want to reduce the load on the CPU else the computer won't be able to do much else. IIR uses less CPU time than FIR filters.


There are online tools that you can use to create the needed coefficients for the filters. Matlab or Gnu Octave can also be used. You will need to look up algorithms for implementing IIR Filters, and how to make use of the calculated coefficients.


Specifying the bands is the next fun step. When a filter passes audio, it doesn't simply remove everything out side of its passband. It just isn't possible to do so. Frequencies outside of the passband of a filter sort of slope off down towards zero amplitude.
At some frequency outside of its passband, the audio amplitude will drop by one half. This is the -3dB point, and is used in specifying filters.
What you want to do is to arrange your passbands such that the -3dB points of adjacant filters are at the same frequency. Say you have two filters. One should pass frequencies from 500 to 1000Hz and the next from 1000 to 2000Hz. You would want to make the high cutoff of the lower filter to be 1000Hz, and the low cutoff of the high filter also be 1000Hz. Design the filters such that 1000Hz is down by half in each filter (usually, just specifying it as the cutoff is enough.) When you now sum the outputs of the two, they add up to just the audio from 500 to 200Hz, with everything in that range at (more or less) the same amplitude as before.



Now, with your audio split into banks, you can multiply the output of each filter with some constant to dampen or emphasize that band. This image demonstrates what I mean about the way the bands have to be layed out. equalizer


No comments:

Post a Comment

periodic trends - Comparing radii in lithium, beryllium, magnesium, aluminium and sodium ions

Apparently the of last four, $\ce{Mg^2+}$ is closest in radius to $\ce{Li+}$. Is this true, and if so, why would a whole larger shell ($\ce{...