// This file is part of the 64k demo project. // It tests the core functionality of the audio tracker engine. #include "audio/tracker.h" #include "audio/synth.h" #include "audio/gen.h" // #include "generated/music_data.h" // Will be generated by tracker_compiler #include #include // Forward declaration for generated data to avoid compilation issues before generation // extern const NoteParams g_tracker_samples[]; // extern const uint32_t g_tracker_samples_count; // extern const TrackerPattern g_tracker_patterns[]; // extern const uint32_t g_tracker_patterns_count; // extern const TrackerScore g_tracker_score; void test_tracker_init() { synth_init(); tracker_init(); printf("Tracker init test PASSED\n"); } void test_tracker_pattern_triggering() { synth_init(); tracker_init(); // Test 1: Trigger patterns at 0.0f tracker_update(0.0f); printf("Actual active voice count: %d\n", synth_get_active_voice_count()); // Expect 3 voices (one for each pattern triggered at 0.0f: drum_loop, hihat_roll, em_melody) assert(synth_get_active_voice_count() == 3); // Test 2: Advance time slightly tracker_update(0.1f); assert(synth_get_active_voice_count() == 3); // 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 assert(synth_get_active_voice_count() > 0); printf("Tracker pattern triggering test PASSED\n"); } int main() { printf("Running Tracker tests...\n"); test_tracker_init(); test_tracker_pattern_triggering(); printf("Tracker tests PASSED\n"); return 0; }