Skip to content

Commit

Permalink
WaveformHelper_tests.h:
Browse files Browse the repository at this point in the history
* Adding the first real unit tests (butterworth filter coeffs).
  • Loading branch information
razterizer committed Sep 29, 2024
1 parent 48f9e15 commit cc273f2
Showing 1 changed file with 18 additions and 0 deletions.
18 changes: 18 additions & 0 deletions Tests/WaveformHelper_tests.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,24 @@ namespace audio
std::cout << std::endl;

WaveformHelper::print_waveform_graph_idx(wave, GraphType::PLOT_THIN, N, 5);

auto butter = WaveformHelper::create_Butterworth_filter(1,
FilterOpType::LowPass,
wave.frequency*0.9f, {},
wave.sample_rate);
std::cout << "Filter Butterworth:" << std::endl;
std::cout << " a:" << std::endl;
for (auto a : butter.a)
std::cout << " " << a << std::endl;
std::cout << " b:" << std::endl;
for (auto b : butter.b)
std::cout << " " << b << std::endl;

assert(butter.a.size() == 2);
assert(butter.a[0] == 1.f);
assert(butter.a[1] - (-0.739251f) < 1e-6f);
assert(butter.b.size() == 1);
assert(butter.b[0] - (0.130375f) < 1e-6f);
}

}

0 comments on commit cc273f2

Please sign in to comment.