What exactly is stored in the buffer array in the FIR Filter code below? Is it the values of x[n-k] or something else?

float filter (float value){
    for (int i = ntaps-1; i>0; i--){
        buffer[i] = buffer[i-1];
    buffer[0] = value;
    for (int i = 0; i<ntaps; i++){
        output += buffer[i]*h[i];
    return ouput;
  • 1
    $\begingroup$ please edit and correct the missing code and put relevant information on the variables and the buffer data... $\endgroup$ – Fat32 Nov 6 '19 at 20:43

It stores the last $ntap$ samples of the input. So it's $x[n], x[n-1], ..., x[n-N+1]$

| improve this answer | |
  • $\begingroup$ But x[n], x[n-1],... x[n-N+1] are delayed versions of the signal x[n] whereas the buffer array stores numerical values, not signals. What exactly are the numerical values in the buffer array? $\endgroup$ – B. Han Nov 7 '19 at 15:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.