ar1st0crat/NWaves

Butterworth filter constructor have no parameter for sample rate

FounderSG opened this issue · 2 comments

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

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');

Thanks for the clear explanation.