diff options
Diffstat (limited to 'src/tests/test_tracker.cc')
| -rw-r--r-- | src/tests/test_tracker.cc | 47 |
1 files changed, 32 insertions, 15 deletions
diff --git a/src/tests/test_tracker.cc b/src/tests/test_tracker.cc index ea1debd..7ef7172 100644 --- a/src/tests/test_tracker.cc +++ b/src/tests/test_tracker.cc @@ -24,25 +24,42 @@ void test_tracker_pattern_triggering() { synth_init(); tracker_init(); - // Test 1: Trigger patterns at 0.0f + // At time 0.0f, 4 patterns are triggered: + // - crash (1 event at beat 0.0) + // - kick_basic (events at beat 0.0, 2.0, 2.5) + // - snare_basic (events at beat 1.0, 3.0) + // - hihat_stressed (events at beat 0.0, 0.5, 1.0, 1.5, 2.0, 2.5, 3.0, 3.5) + // With the new event-based triggering, only events at beat 0.0 trigger immediately. + + // Test 1: At music_time = 0.0f, events at beat 0.0 trigger tracker_update(0.0f); - printf("Actual active voice count: %d\n", synth_get_active_voice_count()); - // Expect 4 voices (one for each pattern triggered at 0.0f: - // crash, kick_basic, snare_basic, hihat_stressed) - assert(synth_get_active_voice_count() == 4); + printf("Actual active voice count at 0.0f: %d\n", + synth_get_active_voice_count()); + // Expect 3 voices: crash (beat 0.0), kick_basic (beat 0.0), hihat_stressed + // (beat 0.0) + assert(synth_get_active_voice_count() == 3); - // Test 2: Advance time slightly - tracker_update(0.1f); + // Test 2: At music_time = 0.25f (beat 0.5 @ 120 BPM), hihat event triggers + // beat_duration = 60.0f / 120.0f = 0.5s per beat + // beat 0.5 = 0.25s + tracker_update(0.25f); + printf("Actual active voice count at 0.25f: %d\n", + synth_get_active_voice_count()); + // Expect 4 voices (3 previous + 1 new hihat) assert(synth_get_active_voice_count() == 4); - // Test 3: Advance further, no new triggers until 4.0f - tracker_update(3.0f); - // Voices from 0.0f triggers might have ended, but new ones haven't started. - // synth_get_active_voice_count might drop if previous voices ended. - // For this test, we assume voices triggered at 0.0f are still active for a - // short duration. A more robust test would check for specific spectrograms or - // mock synth. For now, we expect voices to still be somewhat active or new - // ones to be triggered if there's overlap + // Test 3: At music_time = 0.5f (beat 1.0), snare event triggers + tracker_update(0.5f); + printf("Actual active voice count at 0.5f: %d\n", + synth_get_active_voice_count()); + // Expect 6 voices (4 previous + snare + hihat at beat 1.0) + assert(synth_get_active_voice_count() == 6); + + // Test 4: Advance further to 2.0f (beat 4.0), new pattern triggers at 2.0f + tracker_update(2.0f); + printf("Actual active voice count at 2.0f: %d\n", + synth_get_active_voice_count()); + // Multiple events have triggered by now assert(synth_get_active_voice_count() > 0); printf("Tracker pattern triggering test PASSED\n"); |
