Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix start values of FIIR and Biquad filter to second sample #52

Closed
wants to merge 2 commits into from

Conversation

theHenks
Copy link
Contributor

In the current implementation of the FIIR and Biquad filters, the first sample is off since the algorithms starts with an initial state of zero(T). This creates unwanted behavior e.g. for the DifferentiatorFilter:
image
The fix sets the first sample to the value of the second sample to avoid this behavior:
image

@oschulz
Copy link
Member

oschulz commented Dec 16, 2024

I don't think this fix will work for all Biquad filters, it works for the differentiation filter because that has a finite-length response. I think we need to initialize s1, s2 and s3 correctly, instead of fixing the first output values after filtering.

@fhagemann
Copy link
Contributor

fhagemann commented Dec 16, 2024

I don't think this fix will work for all Biquad filters, it works for the differentiation filter because that has a finite-length response. I think we need to initialize s1, s2 and s3 correctly, instead of fixing the first output values after filtering.

@oschulz could you have a look into this? Or recommend how EXACTLY it should be done or how we can be sure it is done the correct way? This filter is kind of critical..

I think the issue here is that the differentiation would usually result in shorter length vectors, but we still force the length of the filtered array to be the same

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants