[music-dsp] bandpass cutoff frequencies
James Chandler Jr
jchandjr at bellsouth.net
Mon Apr 6 18:03:28 EDT 2009
Robert's cookbook is very well-behaved.
Regardless of your chosen filtering and coefficient selection method,
it is advisable to do all coefficients and filter processing math in
double or Int64 fixed point math if possible.
I usually use double math because all my programming is done on
desktop puters. Strangely enough, if you are forced by hardware
limitations to use 32 bit float or small-sized-int fixed point math,
it is said that long term math error accumulation is most likely to
affect low-FC filters.
The strategy of adding or subtracting filtered output to the original
sound, is similar to the parallel-bank design in analog equalizers.
What makes this 'tricky' in digital, is that analog equalizers usually
incorporate a global feedback loop to enforce boost/cut.
In analog, once you set the Q of a filter, that boost/cut feedback
loop 'magically' allows the width of the boost to be the same as the
width of an equivalent cut. IE, a 6 dB boost hump is the mirror image
of a 6 dB cut dip. The 'constant Q design'.
The different filters in the analog bank will fight each other at band
boundaries somewhat, because of reverse-direction phase shifting where
the bands overlap, but the global feedback can hide some of the
unpredictable inter-band ugliness in a good analog EQ design.
In digital you typically cannot do successful global feedback (ala
opamps), except at outlandish high sample rates. Digitally adding or
subtracting a filter output against the 'straight wire' doesn't have
exactly the same effect as an analog filter bank with boost/cut global
In digital without the feedback to 'linearize' the boost/cut
bandwidth, if you select a certain Filter Q and add it to the
'straight wire', then the more gain you add, the wider is the boost.
But if you keep the same selected Filter Q and subtract it from the
'straight wire', then the more cut you impose, the cut band gets
narrower. So you don't get the expected analog 'constant Q' behavior.
Given a certain Filter Q, a 6 dB boost would have a much wider 'hump'
than a 6 dB cut's 'dip'. That is because of how the phase shift
cancellations interact with the original signal with simple addition
You could do an add/subtract parallel filter bank in digital (without
feedback), but to accomplish constant Q output behavior, you would
need to calculate a different Q for a filter, every time the user
changes that band's gain.
Robert worked out most of those nasty details in his Peaking Filter.
He incorporates the 'constant Q' feature into his coefficient
calculations. Every time the user twists a gain knob in the GUI and
you recalc an RBJ peaking filter for a different gain (but same Q)--
Robert's coefficient calculations adapt the 'actual' width of the
filtering so that cuts have the same bandwidth as equivalent boosts.
If a digital EQ is implemented as peaking filters in series, it also
eliminates adjacent bands fighting each other with phase
cancellations. This does not eliminate the phase shifts, but it
eliminates unexpected inter-band amplitude wiggles from phase
cancellation or reinforcement.
The output of filter 1 is 'carved in stone' amplitude-wise and phase-
wise when it arrives at filter 2. And so filter 2 can mess with the
amplitude and phase, but filter 2 can't do anything to the phase that
would unexpectedly cancel or reinforce amplitude with whatever filter
1 did to the phase.
So if filter 2 is wider than filter 1, then filter 2 might affect what
filter 1 did to the amplitude response, but the phase shifts of the
two filters cannot unpredictably cancel or reinforce and cause
unexpected inter-band behavior.
If you use high-resolution calculations and high-resolution
intermediate data in-between the filters, to minimize accumulated math
errors, a series filter EQ is generally well-behaved. For top and
bottom bands, you might want shelving filters rather than peaking
filters, but a bass shelving filter given a lot of boost can
occasionally be 'sonically' problematic.
I don't know much about this field compared to the experts here, but
believe the above to be 'generally accurate'.
James Chandler Jr.
On Apr 6, 2009, at 4:40 PM, Thomas Rehaag wrote:
> Hi James,
> my problem was that I didn't know enough about the frequency warping
> digital filters. That's why I feared big errors in my 'analog
> calculation'. I don't need a perfect EQ.
> Your words about "RBJ peaking filters" sound very interesting. Don't
> know them. I'll have a look at them tomorow.
> My first plan was to add or subtract LP/BP/HP filtered sound to/from
> original sound in order to keep the untreated parts clean. Especialy
> clean of phase distortion.
More information about the music-dsp