#ifdef WITH_TESTS #include #include "../../Tests.h" #include "../../../math/dsp/fir/Complex.h" #include TEST(FIRComplex, filter1) { const float sRate = 200; const float freq = 10; FIRComplex f(sRate); f.lowPass(5, 50); f.dumpKernel("/tmp/k1.m", "k1"); f.shiftBy(freq); f.dumpKernel("/tmp/k2.m", "k2"); std::minstd_rand gen; std::normal_distribution noise(0.0, 0.3); std::vector> out; std::ofstream fileO("/tmp/orig.dat"); std::ofstream fileF("/tmp/filtered.dat"); for (int i = 0; i < 1000; ++i) { const float t = i / sRate; const float n = noise(gen); const float s = std::sin(2*M_PI*freq*t); const float v = s+n; std::vector values; values.push_back(s+n); fileO << v << "\n"; std::vector> res = f.append(values); out.insert(out.end(), res.begin(), res.end()); } for (const std::complex c : out) { fileF << c.real() << "\n"; } } #endif