The following example shows how to apply FIR filter to audio data using KFR framework.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
#include <kfr/all.hpp> using namespace kfr; int main(int argc, char** argv) { // static array (like std::array) to hold the taps univector<double, 15> taps; // initialize window function // we pass tap count to window_hann function // window_hann does not calculate window functions // but creates object representing hann window expression_pointer<double> hann = to_pointer(window_hann(taps.size())); // FIR filter design using window method // frequency = 0.02 // true means that taps will be normalized fir_lowpass(taps, 960.0 / 48000.0, hann, true); // show filter frequency response using dspplot python library // dspplot must be installed before launching this example plot_show("fir_lowpass_hann", taps, "title='15-point lowpass FIR, Hann window'"); } |