Hello good people. I have tried to implement basic FIR filtering into my audio plugin. I have generated some coefficients with matlab,tried filtering a signal in matlab with those coeffs and everything was fine. Then I’ve tried the same thing in C++ but the results was not same nor close enough. Here are my coefficients,filter is order of 8 so i have 9 of them:

double filterCoefs[9] = { 0.0180524263969752, 0.0486396239380447, 0.122649723887587,

0.196847395914674, 0.227621659725439, 0.196847395914674,

0.122649723887587, 0.0486396239380447, 0.0180524263969752 };

Filter is basic low pass filter designed with fir1 function,cutoff frequency of 800Hz,where sample frequency is 44100Hz.

C++ code is next:

AudioBuffer output = buffer;

```
const int N = 8; //filter order
for (int channel = 0; channel < getTotalNumInputChannels(); ++channel)
{
output.setSample(channel, 0, filterCoefs[0] * buffer.getSample(channel, 0));
for (int n = 1; n < numSamples; n++)
{
if ((n - N) <= 0) {
double tempSample = 0;
for (int k = 0; k <= n; k++)
tempSample = tempSample + filterCoefs[k] * buffer.getSample(channel, n - k);
output.setSample(channel, n, tempSample);
}
else {
double tempSample = 0;
for (int k = 0; k <= N; k++)
tempSample = tempSample + filterCoefs[k] * buffer.getSample(channel, n - k);
output.setSample(channel, n, tempSample);
}
}
}
buffer = output;
```

Where buffer is the audio buffer I have in processBlock method of my processor class.

Is there something wrong with that C++ implementation or this whole way of realizing FIR filtering in C++ is wrong way to do that.

Best regards,Cila.

P.S. I have tried with more different coefficients and signals,I never get good results.