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

Butterworth filter constructor have no parameter for sample rate #25

Closed
FounderSG opened this issue Feb 26, 2020 · 2 comments
Closed

Butterworth filter constructor have no parameter for sample rate #25

FounderSG opened this issue Feb 26, 2020 · 2 comments

Comments

@FounderSG
Copy link

All other filter design tool take sample rate as a parameter, why NWaves not care about sample rate?

@ar1st0crat
Copy link
Owner

Similar to MATLAB/sciPy, this library expects normalized frequencies for input. You don't specify sample rate explicitly, but it's there:

double freq_in_Hz = 500;
double sample_rate = 8000;

double freq = freq_in_Hz / sample_rate;

var filter = new Filters.Butterworth.LowPassFilter(freq, order);

// i.e.:
// var filter = new Filters.Butterworth.LowPassFilter(500.0 / 8000, order);

In MATLAB, though, normalized frequencies are mapped onto range [0, 1] (in NWaves it's [0, 0.5]). Hence, the code above would be written as:

[b, a] = butter(order, 2*500/8000, 'low');

@FounderSG
Copy link
Author

Thanks for the clear explanation.

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

No branches or pull requests

2 participants