From a3960d4724020e6f7e6dacd636127e98d3cf2365 Mon Sep 17 00:00:00 2001 From: Colin Clark Date: Sat, 25 Nov 2023 13:41:47 -0500 Subject: [PATCH] gh-66: Fixes ClockDetector tests. --- libsignaletic/tests/test-libsignaletic.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/libsignaletic/tests/test-libsignaletic.c b/libsignaletic/tests/test-libsignaletic.c index a30052c..2e73c38 100644 --- a/libsignaletic/tests/test-libsignaletic.c +++ b/libsignaletic/tests/test-libsignaletic.c @@ -726,6 +726,13 @@ void testClockDetector(struct sig_test_BufferPlayer* clockPlayer, FLOAT_ARRAY(det->outputs.main)[0], "The clock's frequency should have been detected correctly."); + float expectedBPM = expectedFreq * 60.0f; + + TEST_ASSERT_FLOAT_WITHIN_MESSAGE(0.05, + expectedBPM, + FLOAT_ARRAY(det->outputs.bpm)[0], + "The clock's bpm tempo should have been detected correctly."); + sig_dsp_ClockDetector_destroy(&allocator, det); } @@ -803,7 +810,9 @@ void test_sig_dsp_ClockDetector_stop() { struct sig_test_BufferPlayer* clockPlayer = sig_test_BufferPlayer_new( &allocator, context, waveformBuffer); - testClockDetector(clockPlayer, bufferDuration, 0.0f); + // When it no longer receives clock pulses, the detector + // should hold on to whatever tempo it last calculated. + testClockDetector(clockPlayer, bufferDuration, clockFreq); sig_BufferView_destroy(&allocator, silentSection); sig_BufferView_destroy(&allocator, clockSection);