# Filtering reject two bands (multiband bandstop FIR filter)

I know the existence of Remez Parks-McClellan, but I want to exploring results with Math....

I have five frequencies on input (check blue plot):

233.08Hz, 246.94Hz, 261.63Hz, 277.18Hz, 293.66Hz

I want to desing a filter that stops two separates bands. I want to remove the second frequency (with bandstop) and remove the fourth frequency (with the same bandstop filter)

But, I want a single pass (apply convolution only one time) to the input!

This is a similar question, but is for bandpass filters:

Using Typical Hamming Window. I have this:

• Sampling Rate = $8000\textrm{ Hz}$

• Low bands (for 2nd Frequency)

• $f_{{Lo}_{c}} = 239.912\textrm{ Hz}$: Frequency $1^{\rm st}$ band cut
• $f_{{Lo}_{p}} = 254.178\textrm{ Hz}$: Frequency $1^{\rm st}$ band pass
• HighBand (for 4th Frequency)

• $f_{{Hi}_{c}} = 269.292\textrm{ Hz}$: Frequency $2^{\rm nd}$ band cut
• $f_{{Hi}_{p}} = 285.305\textrm{ Hz}$: Frequency $2^{\rm nd}$ band pass
• The calculated size was $N=1961$ (more restrictive size).

I calculate the Coefficients (Java), getBandStopCoefficients is working perfectly (I'm not providing the source code)!!!

http://www.labbookpages.co.uk/audio/firWindowing.html#high

double[] dBSC_B1 = getBandStopCoefficients(N, "Hamming", 239.912, 254.178);  // Band One for Second Frequency
double[] dBSC_B2 = getBandStopCoefficients(N, "Hamming", 269.292, 285.305);  // Band Two for Fourth Frequency


The Response for Second Frequency (Red Plot)

The Response for Fourth Frequency (Green Plot)

I don't want to do something like (but I want the same result):

double[] x;// : input
...
double[] y = convolution(x, dBSC_B1);
y = convolution(y, dBSC_B2);


I was testing something...

when is needed to perform FFT to multiply the data by window

double[] dBSC_Both = new double[N];
for (int i = 0; i < SizeTest; i++) {
dBSC_Both[i] = dBSC_B1[i]*dBSC_B2[i];
}


//Other manner... Get two BandPass (adding the output, and is subtracted from the input)

double[] dBPC_B1 = getBandPassCoefficients(N, "Hamming", 239.912, 254.178);  // Band One
double[] dBPC_B2 = getBandPassCoefficients(N, "Hamming", 269.292, 285.305);  // Band Two

double[] dBSC_Both = new double[N];
for (int i = 0; i < N; i++) {
dBSC_Both[i] = 1.0 - (dBPC_B1[i] + dBPC_B2[i]);
}
double[] y = convolution(x, dBSC_Both);
// the BandPass work fairly well, but like double BandStop so bad!


I was trying this ("preconvolution" Check Purple Plot)

double[] dBSC_Both = convolution(dBSC_B2, dBSC_B1);  //
double[] y = convolution(x, dBSC_Both);
// the result was similar poorly than expected (filter effectively attenuated in the bands,
//but not enough, and amplitude permitted in the bands was attenuated)


I was thinking the theory of calculating the coefficients for windows (changing the formula of the sine)

Some clue on how to do this?

• I am completely unsure what you are trying to do! Can you explain in words a little more what you're after? Please edit your question and add this explanation. – Peter K. Jul 8 '16 at 16:59
• My english is not good! – QA_Col Jul 8 '16 at 17:02
• @PeterK. Give feedback if is clear for you... – QA_Col Jul 8 '16 at 17:12
• That's much clearer. Once I've had lunch, I may edit. Reopening now. – Peter K. Jul 8 '16 at 18:08