Bandpass FIR Filter

I need to make a simple bandpass sound filter. Now I used this simple C ++ class: http://www.cardinalpeak.com/blog/ac-class-to-implement-low-pass-high-pass-and-band-pass-filters

It works well and cuts off the necessary groups. But when I try to change the upper or lower limit with small steps, at some values ​​of the limit I hear the wrong result - a sound weakened or shifted in frequency (not corresponding to the current limits).

Function for calculating impulse response:

void Filter::designBPF()
{
    int n;
    float mm;

    for(n = 0; n < m_num_taps; n++){
        mm = n - (m_num_taps - 1.0) / 2.0;
        if( mm == 0.0 ) m_taps[n] = (m_phi - m_lambda) / M_PI;
        else m_taps[n] = (   sin( mm * m_phi ) -
                             sin( mm * m_lambda )   ) / (mm * M_PI);
    }

    return;
}

Where

m_lambda = M_PI * Fl / (Fs/2);
m_phi = M_PI * Fu / (Fs/2);

Fs - sampling frequency (44.100) Fl - lower limit Fu - upper limit

And a simple filtering function:

float Filter::do_sample(float data_sample)
{
    int i;
    float result;

    if( m_error_flag != 0 ) return(0);

    for(i = m_num_taps - 1; i >= 1; i--){
        m_sr[i] = m_sr[i-1];
    }   
    m_sr[0] = data_sample;

    result = 0;
    for(i = 0; i < m_num_taps; i++) result += m_sr[i] * m_taps[i];

    return result;
}

Do I need to use any window function (Blackman, etc.)? If so, how do I do this? I tried to multiply my impulse response by the Blackman window:

m_taps[n] *= 0.42 - 0.5 * cos(2.0 * M_PI * n / double(N - 1)) +
                0.08 * cos(4.0 * M_PI * n / double(N - 1));

. ?

+4
2

FIR-: http://www.iowahills.com/A7ExampleCodePage.html

... CIR CIR : - ( , , ). (, , ..) . ...

+1

y [i] = [i] Γ— (0.42659071 - 0.49656062cos (w) + 0.07684867cos (2w))

w = (2) i/n n -

, : http://zone.ni.com/reference/en-XX/help/370592P-01/digitizers/blackman_window/

, .

0

Source: https://habr.com/ru/post/1570277/


All Articles