# filtering by convolution

Started by May 5, 2009
```Hi all,

I have some newbie questions for someone much more experienced than I.  I
am implementing a 6 band equalizer on the AVR32 processor, which has built
in functions that do filtering by convolution of the input signal with the
impulse response of filter.

I have a couple of questions based on the AVR32 implementation of FIR
filtering.  In matlab I generated 6 bandpass filters and a highpass filter.
The avr function has an input buffer, an output buffer, and the
coefficients.

My issue is the size discrepancy and how to deal with it.  The input
buffer size is 100; the coefficient size is 52, and the output buffer size
they specify is 100 - 52 + 1.  I'm assuming that the effect of this smaller
buffer is that the sampling rate is decreased.  I don't know, I'm asking.
What do I do to restore the 44.1kHz sampling rate?

I am implenting this EQ by taking the input, IN, and filtering the input
for each band, and then running the highpass filter.  It looks like this:

0ut = Filter(Filter(IN, Band1) + Filter(IN, Band2) +
Filter(IN, Band3) + Filter(IN, Band4) + Filter(IN, Band5) +
Filter(IN, Band6)), Highpass).  I also assume that I will need to scale,
because each of the filters was designed as a unity gain filter.  My guess
is that I would need to divide each part by 6 to prevent overflow, even
though I have 32/64 bits of width.

Obviously I don't know much about DSP, but I had an introductory course in
college, 15+ years ago.

Any help and suggestions in simple language would be greatly appreciated.

Rob

```
```RMcPherson wrote:
> Hi all,
>
> I have some newbie questions for someone much more experienced than I.  I
> am implementing a 6 band equalizer on the AVR32 processor, which has built
> in functions that do filtering by convolution of the input signal with the
> impulse response of filter.
>
> I have a couple of questions based on the AVR32 implementation of FIR
> filtering.  In matlab I generated 6 bandpass filters and a highpass filter.
>  The avr function has an input buffer, an output buffer, and the
> coefficients.
>
> My issue is the size discrepancy and how to deal with it.  The input
> buffer size is 100; the coefficient size is 52, and the output buffer size
> they specify is 100 - 52 + 1.  I'm assuming that the effect of this smaller
> buffer is that the sampling rate is decreased.  I don't know, I'm asking.
> What do I do to restore the 44.1kHz sampling rate?
>
> I am implenting this EQ by taking the input, IN, and filtering the input
> for each band, and then running the highpass filter.  It looks like this:
>
> 0ut = Filter(Filter(IN, Band1) + Filter(IN, Band2) +
> Filter(IN, Band3) + Filter(IN, Band4) + Filter(IN, Band5) +
> Filter(IN, Band6)), Highpass).  I also assume that I will need to scale,
> because each of the filters was designed as a unity gain filter.  My guess
> is that I would need to divide each part by 6 to prevent overflow, even
> though I have 32/64 bits of width.
>
> Obviously I don't know much about DSP, but I had an introductory course in
> college, 15+ years ago.
>
> Any help and suggestions in simple language would be greatly appreciated.

They are not reducing your sampling rate.  They are trimming out the
output samples that can't be fully calculated from the input vector.
Since you need the current sample plus 51 prior ones to convolve with
the 52-tap filter, if you want to capture only fully-specified output
samples you need 51 more samples on the input than you get on the output.

I hope this helps.

--

Tim Wescott
Wescott Design Services
http://www.wescottdesign.com

Do you need to implement control loops in software?
"Applied Control Theory for Embedded Systems" was written for you.
See details at http://www.wescottdesign.com/actfes/actfes.html
```