Skip to content

FIR - buffer window: too small / order mixed up #15

@MaKe81

Description

@MaKe81

Hi, Thank for the really nice filter implementation.

But I see two issues on the convolution in firFilter.js:

  • the buffer is initialized in line 36. The length is one too short.
    For this reason the convolution in line 41-43 doesn't loop over the entire filter length, but one element less
    This creates for filters with low order a gain which is significant smaller than 1.
    SUGGEST: z = initZero(f.length)
  • Compliment for the logic how the index in line 42 is calculated. Very nice piece of code.
    But instead of "+ cnt" the calculation should call the previous index, so "- cnt"
    •this makes a different at the beginning, when the buffer is not completely filled yet.
    •to avoid negative index at the beginning there is the need to add d.buf.length in the calculation.
    SUGGEST: out += (f[cnt] * d.buf[(d.buf.length + d.pointer - cnt) % d.buf.length])

Can you please double-check?
Thanks

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions