Skip to content

Commit

Permalink
lichen-community-systemsgh-66: Fixes ClockDetector tests.
Browse files Browse the repository at this point in the history
  • Loading branch information
colinbdclark committed Nov 25, 2023
1 parent b00e4a0 commit a3960d4
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion libsignaletic/tests/test-libsignaletic.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down Expand Up @@ -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);
Expand Down

0 comments on commit a3960d4

Please sign in to comment.