BandPass and StopBand FIR filters (Hamming) is not working

I have two groups of 3 frequencies of tone (music), First Group

Tones: 39 (77.7817 Hz), 40 (82.4069 Hz) and 41 (87.3070 Hz).


Second Group

Tones: 83 (987.7666 Hz), 84 (1046.5022 Hz) and 85 (1108.7305 Hz).


These groups work independently (the frequencies aren't mixed between them)

ToneB: Tone Back  39 or 83
ToneH: Tone Half  40 or 84
ToneF: Tone Fore  41 or 85


ToneB < ToneM < ToneF

I made two WAV files combining these 3 frequencies (one for the first group, and one for the second group). I want to filter them:

Low Pass (Allowing ToneB, Denying ToneB and ToneF)
High Pass (Allowing ToneF, Denying ToneB and ToneB)
Band Pass (Allowing ToneB, Denying ToneB and ToneF)
Band Stop (Denying ToneB, Allowing ToneB and ToneF)


The Tones are separates by Math.Pow(2,1/12) // or 2^(1/12)

ToneF = ToneH*Math.Pow(2,1/12)
ToneB = ToneH*Math.Pow(2,-1/12)


Now I decided that the Cut Frequencies are established by Math.Pow(2,1/24)

First Group

Then CutFreq between Tone39 and Tone40 is 80.060925 Hz
Then CutFreq between Tone40 and Tone41 is 84.821595 Hz


Second Group

Then CutFreq between Tone83 and Tone84 is 1016.710373 Hz
Then CutFreq between Tone84 and Tone85 is 1077.167118 Hz


If N is Order (or lenght) of Hdn(): Impulse Response But making subtraction, the N Between (ToneB and ToneH) would be different to the N Between (ToneH and ToneF).

                   |------------- dDelta ------------|
|                                 |
Fa                |               Fc                |               Fb
|----------------|----------------|----------------|----------------|

|                |                |                |                |
0               1/48             1/24             3/48             1/12
|                |                |                |                |
-1/12            -3/48            -1/24            -1/48              0


According to this:

Fc = Fa*Math.Pow(2,1/24)    or    Fc = Fb*Math.Pow(2,-1/24)


Now to calculate N, I will use Hamming Windows:

int SampleRate = 32000;
double dHammingFact = (double)3.3*SampleRate;
double dDeltaFore = Math.pow(2.0, 3.0/48.0) - Math.pow(2.0, 1.0/48.0);
double dDeltaBack = Math.pow(2.0, -1.0/48.0) - Math.pow(2.0,-3.0/48.0);


dDelta can be dDeltaFore or dDeltaBack

Simulating this:

N = RoundUpEven(dHammingFact/(Fc*dDelta))  //Rounding to Ceil Even number


So we have:

First Group

FcLP = ToneB(39)*Math.Pow(2,1/24)   //Low Pass
FcHP = ToneB(41)*Math.Pow(2,-1/24)  //High Pass
FcBPb = ToneB(39)*Math.Pow(2,1/24)   //Band Pass Back
FcBPf = ToneB(41)*Math.Pow(2,-1/24)  //Band Pass Fore
FcBSf = ToneB(39)*Math.Pow(2,1/24)   //Band Stop Back
FcBSf = ToneB(41)*Math.Pow(2,-1/24)  //Band Stop Fore

N(Tone39 and Tone40) = 45669
N(Tone40 and Tone41) = 43107


Second Group

FcLP = ToneB(83)*Math.Pow(2,1/24)   //Low Pass
FcHP = ToneB(85)*Math.Pow(2,-1/24)  //High Pass
FcBPb = ToneB(83)*Math.Pow(2,1/24)   //Band Pass Back
FcBPf = ToneB(85)*Math.Pow(2,-1/24)  //Band Pass Fore
FcBSf = ToneB(83)*Math.Pow(2,1/24)   //Band Stop Back
FcBSf = ToneB(85)*Math.Pow(2,-1/24)  //Band Stop Fore

N(Tone83 and Tone84) = 3597
N(Tone84 and Tone85) = 3395


Obviously, highest N will be used.

my filters works fine for Low Pass Filter, High Pass Filter (First and Second Groups) But, checking with Pass Band and Stop Band (First and Second Groups) fails...

Now let's go to see the result of FIRST Group:

spectrum wav file with only the three frequencies of the First group

LowPass Filter first group

HighPass Filter first group

BandPass Filter first group

BandStop Filter first group

Now let's go to see the result of SECOND Group:

spectrum wav file with only the three frequencies of the Second group

LowPass Filter second group

HighPass Filter second group

BandPass Filter second group

BandStop Filter second group

How Can I to solve this? Are very narrow my bands in relation with SamplingFrequency?

• First of all, you should use a much lower sampling frequency or downsample the signal, otherwise your frequency bands are indeed much too narrow. Second, it's a bit hard for me to understand all the details of your question, e.g. the figure 'Lowpass filter first group' is not really a lowpass filter (if the bottom plot is supposed to be the frequency response). What are the filter lengths that you get? They should be very long. – Matt L. Dec 17 '14 at 8:17
• Thank you... I'm implementig this in Java... I want to plot Hn(f). If you have a code to evaluate the response of Hn(f) or Hn(w), please tell me; or if you have another applicagtion to do it. Thank you. . With the figure 'Lowpass filter first group' is really a lowpass filter, but the WaveSpectra higher order number is needed; like 128K. – chepe lucho Dec 17 '14 at 16:41
• i agree with @MattL that it is hard to decode the detail of the question. (it seems like a frequency selectivity problem.) i am not sure i agree with him that reducing the sample rate helps. if computational costs are not an issue, i think leaving it at whatever the .wav sample rate is best. (i can't tell from the screen shots, what is it? 44.1 kHz? 48? 96? 22.05?) you can make your bands as narrow as you like as long as the FIR is long enough. you might also want to consider doing this using IIR (in lieu of FIR) and/or heterodyning the BPF to LPF. – robert bristow-johnson Dec 17 '14 at 20:44