Implementing an FIR filter

umans

New member
I have assembled a Teensy 4.1 system which accepts audio input from a PCM1808 ADC and outputs audio through a PCM5102 DAC. When I connect them direct as

AudioConnection patchCord1(input, 0, output, 0);
AudioConnection patchCord2(input, 1, output, 1);

and input the same sinusoidal signal on both inputs of the 1808 I get, as expected, the same signal on both outputs of the PCM5102. However, when I run the second input signal through an FIR filter as

AudioConnection patchCord1(input, 0, output, 0);
AudioConnection patchCord2(input, 1, fir1, 0);
AudioConnection patchCord3(fir1, 0 output, 1);

I see zero output from the second output of the PCM1502. Clearly I am doing something wrong but I am stuck at this point and would like some help. I've attached a sample of my code, with the FIR filter defined by a simple set of 5 taps, replacing a FIR filter defined by a large number of taps which I was trying to get working. I've tried many variations of the code and searched the internet. I suspect that there is a solution somewhere on this forum but I couldn't find it.

Many thanks,
Steve Umans
 

Attachments

  • Simple_FIR_Filter_Example.ino.ino
    1.5 KB · Views: 21
The FIR filter requires an even number of coefficients. If you want a 5-tap filter, you need to set num_taps to 6, and append a zero value to intTaps[].
 
Thank you!! Just goes to show that one must carefully read the fine print (which I obviously didn't) ... and also not put too much faith in the examples (AI created?) one finds on the web.
 
Back
Top