1
$\begingroup$

Before I begin, I have read these already:

I am processing audio using Csound in a high performance real time environment. One part of my code uses 10 butterworth bandpass filters in parallel, each with a different centre frequency and bandwidth. However, the centre frequencies and bandwidths are all relative to each other. The centre frequency of each filter are set whole number multiples or divisions of the main filter's centre frequency (ie, if main filter has cf of 100Hz, the other filters cfs would be 200, 300, 400, 500, 600, 50, 33.333, 25, and 20). The bandwidths of each filter are all a specific division of the associated centre frequency (ie, cf 100 = bw 10, cf 200 = bw 20, etc).

The main centre frequency is not fixed, but seeing as the filter centre frequencies and bandwidths are all relative to the main filters centre frequency and bandwidth, could I design a filter that combines all these filters into one? And most importantly, if I could, would it make any major difference to performance?

My best guess as to how to achieve this would be to combine the filter equations into one. I don't know if this would actually work, but if it did, I don't feel like it would improve the performance by much.

EDIT:

The sample being filtered is rich in harmonic and in-harmonic frequencies. It is borderline noisy, so the sum of the outputs of the BP filters is quite interesting, and the harmonies aren't always perfectly related. This quality I would like to keep.

$\endgroup$
  • $\begingroup$ what's the order of the individual BPFs? and what are you trying to do? filterbank? graphic EQ? $\endgroup$ – robert bristow-johnson Feb 8 '16 at 6:14
  • $\begingroup$ 2nd order. What I'm doing is feeding in a rich, borderline noisy sample signal, and filtering out a range of signals that are pretty much harmonically related, hence the integer multiples and divisions of the fundamental. I guess that would be considered a filterbank. $\endgroup$ – Iron Attorney Feb 9 '16 at 10:19
  • $\begingroup$ okay, since a 2nd-order BPF is a mapping of a 1st-order LPF prototype to 2nd-order by this mapping: $$ Q \left( \frac{\omega_0}{s} + \frac{s}{\omega_0} \right) \rightarrow s $$ and all 1st-order LPFs are Butterworth, the qualifier "butterworth" does not have meaning. but Q still is an issue. is this a filterbank (with separate outputs for each 2nd-order BPF) or is it a graphic EQ where the outputs are mixed? since Q of a BPF is 1-to-1 related to bandwidth in octaves, i would suggest having the same Q for all BPFs and then spacing the center frequencies equally in the log-frequency scale. $\endgroup$ – robert bristow-johnson Feb 9 '16 at 20:09
  • $\begingroup$ so if we forget about the filters bellow 100Hz, then my example fits the bill. So how do I use this idea to optimise the filters? $\endgroup$ – Iron Attorney Feb 12 '16 at 19:39
  • $\begingroup$ so you want a filterbank? what are you trying to do with it? i presume you will be summing each filter output to your overall output, but i also presume that you are doing some processing to each of those filter outputs before summing. but i don't understand what the processing is or is intended to be. $\endgroup$ – robert bristow-johnson Feb 12 '16 at 21:51
1
$\begingroup$

So, what I took away from my multirate lectures is:

You don't use IIRs in that case, because the recursive part isn't shareable among multiple filter implementations (being specific to the output of each filter), and hence, you end up with a lot more multipliers than you'd have if you went for a FIR system and removed redundancies. This is especially true for hardware/FPGA implementation, where placing a wire to use a result twice is cheap. You're doing software, so saving a few registers worth of filter taps really won't pay -- you're breaking the linear nature of memory access that way, and that will impose a performance hit that is much, much worse.

In fact, I'd challenge you to look at how you can understand your filter bank as an array of filterbanks with identical filters.

For example, assume that all your BPFs have equally spaced center frequencies $\frac{f_\text{sample}}{N}$. Also, they might have different bandwidths, but since you say they are related to each other, let's assume there's one "maximum bandwidth" that is a multiple of all smaller bandwidths.

Now, implementing a polyphase filterbank ("channelizer") with a BPF of that maximum bandwidth and the constant frequency spacing is very efficient. Basically, it's like taking a single very BPF at full rate, add one FFT, and you get the complexity of the system for up to $N$ channels (note: this is $N-1$ free channels!). Then, take the channels whose bandwidth you'd need to be reduced further. Now, assume these $m<N$ channels all need to be reduced in bandwidth by a factor of $4$, for example. So that's $m$ identical quarterband lowpass filters! Implementing identical filters in hardware is pretty efficient, usually, especially because after the first filterbank, sampling rate might already be reduced (so you can multiplex multipliers); now, you're seemingly doing audio on a PC:

Take these $m$ channels, and just implement individual filters. There's nothing much you can or need to optimize here; assuming this is on something that has a PC-like CPU, caching will keep your filter taps close to CPU registers, and and only the actual samples will need to go through memory buses. Also, not that things like $\frac{1}{M}$ low pass filters are relatively relaxed in transition width requirements, and hence, FIR implementations are short in taps, and thus fast.

As usual in signal processing, decimate whenever possible! The polyphase filterbank might already decimate, but also your $m$ channel low pass filters should do that, too, and in a clever manner (a polyphase lowpass decimator runs at the output, not the input sampling rate!). Not processing samples you don't need is probably reason Nr. 1 that modern DSP is so capable.

$\endgroup$
  • $\begingroup$ Thanks for your detailed response! I have to admit my DSP isn't up to scratch enough to keep up with everything you've said from the example onwards, so I'm gonna have to give it a good few reads through :D I haven't actually tried any other filters except the butterworth yet, so I can't rule out the possibility of using an FIR instead, you never know, the results might sound better! I will definitely try some other filters... $\endgroup$ – Iron Attorney Feb 9 '16 at 10:33
  • $\begingroup$ ... So I can glean from what you say that the equally spaced filter CFs will help my ability to optimize, as well as the relative bandwidths. It occurs to me that, because the bandwidths increase identically to the CFs, then my BPFs at 100, 200, 300 Hz CFs can be thought of as HPFs at 95, 190, 285 Hz and LPFs at 105, 210, 315 Hz, which means each of the HP and LP elements also have equally spaced cuttoff frequencies. $\endgroup$ – Iron Attorney Feb 9 '16 at 10:45
  • $\begingroup$ @IronAttorney hm, this is all getting a bit too confusing for a comments section; can't you make a new question about "Efficient implementation of non-uniform filterbank", detailing the center frequencies and bandwidths of those, in a table or so? $\endgroup$ – Marcus Müller Feb 9 '16 at 14:00
  • $\begingroup$ I thought I was still talking about a uniform filterbank. Let's simplify this. In my current filters, the bandwidths increase at the same rate as the centre freqs. For example, the bandwidth is always 10 times smaller than the centre frequency. A re-read of this "Then, take the channels whose bandwidth you'd need to be reduced further. Now, assume these m<Nm<N channels all need to be reduced in bandwidth by a factor of 44, for example." now makes me think that would end up with as many calculations as if they were separate filters. Is that right? $\endgroup$ – Iron Attorney Feb 10 '16 at 11:39
  • $\begingroup$ @IronAttorney the trick is that after your channelizer filterbank, you would have simple, pretty relaxed low-pass filters, that reduce on a $\frac 1N f_\text{sample}$ further to a $\frac {1}{Nm} f_\text{sample}$ rate. Your original filters would be very narrowband relative to the full sample rate, and hence very long and hence very CPU-intense... $\endgroup$ – Marcus Müller Feb 10 '16 at 13:39

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.