I am willing to implement a basic FIR filter using C++ and JUCE.
I wrote this simple algorithm using the information I found in the DSPGuide, but I only seem to get a variation in volume for all the frequencies, instead of a frequency filtering.
How can I correct it to effectively apply frequency filtering ?
if (channel == 0) {
float result = 0; // initialisation to 0 of the result
for (int sample = 0; sample < buffer.getNumSamples(); sample++) { // for each sample
// moving the samples in the delay line
for (int i = 0; i < 8; i++) { // delayLine being 9 values long
delayLine[i + 1] = delayLine[i];
}
delayLine[0] = reader[sample];
result = 0;
for (int i = 0; i < 9; i++) { // for each tap
result = result + delayLine[i] * filterTaps[i]; // multiply
}
writeback[sample] = result; // output
}
}
Here are the coefficients used, which are supposed to produce a Low-Pass Filter in the audible range :
filterTaps[0] = 0.002385;
filterTaps[1] = 0.011910;
filterTaps[2] = 0.026352;
filterTaps[3] = 0.039825;
filterTaps[4] = 0.045351;
filterTaps[5] = 0.039825;
filterTaps[6] = 0.026352;
filterTaps[7] = 0.011910;
filterTaps[8] = 0.002385;
I have generated them using this website http://www.arc.id.au/FilterDesign.html Can't remember the cut-off I chose, but it was between 1000 and 5000 kHz with a 44100 Hz sampling rate. These coefficients are just an example, as my initial goal was to make an anti-aliasing filter. Since the filter was not working properly, probably because of the algorithm, I chose another set of coefficients in the audible range to ease the debug process).
Thank you.