ar1st0crat / NWaves

.NET DSP library with a lot of audio processing functions
MIT License
453 stars 71 forks source link

How to use the SOS transfer functions as a filter? #38

Closed ToGoOrNotToGo closed 3 years ago

ToGoOrNotToGo commented 3 years ago

How to use the transfer functions from DesignFilter.TfToSos and apply the filter direct? Is it possible with NWaves?

ar1st0crat commented 3 years ago

You can use FilterChain class:


// specify TF explicitly (numerator and denominator)
var tf = new TransferFunction(num, den);
var sos = DesignFilter.TfToSos(tf);

// or get TF from filter designed by NWaves:
// var order = 10;
// var filter = new Butterworth.BandPassFilter(4f/250, 8f/250, order);
// var sos = DesignFilter.TfToSos(filter.Tf);

var sosFilter = new FilterChain(sos);
var y = sosFilter.ApplyTo(x);

NWaves DSP cheatsheet

More about SOS (with C# code in the end)

ToGoOrNotToGo commented 3 years ago

Oh, sorry, I didn't find this page on your wiki. Cool stuff! Thanks a lot!