From af4b27dfb0862bc4a76d716dacd24acf73ee059a Mon Sep 17 00:00:00 2001 From: skal Date: Wed, 4 Feb 2026 14:38:04 +0100 Subject: feat(audio): Trigger pattern events individually for tempo scaling Refactored tracker system to trigger individual events as separate voices instead of compositing patterns into single spectrograms. This enables notes within patterns to respect tempo scaling dynamically. Key Changes: - Added ActivePattern tracking with start_music_time and next_event_idx - Individual events trigger when their beat time is reached - Elapsed beats calculated dynamically: (music_time - start_time) / beat_duration - Removed pattern compositing logic (paste_spectrogram) - Each note now triggers as separate voice with volume/pan parameters Behavior: - Tempo scaling (via music_time) now affects note spacing within patterns - At 2.0x tempo: patterns trigger 2x faster AND notes within play 2x faster - At 0.5x tempo: patterns trigger 2x slower AND notes within play 2x slower Testing: - Updated test_tracker to verify event-based triggering at specific beat times - All 17 tests pass (100%) - WAV dump confirms tempo scaling works correctly: * 0-10s: steady 1.00x tempo * 10-15s: acceleration to 2.00x tempo * 15-20s: reset to 1.00x tempo * 20-25s: deceleration to 0.50x tempo * 25s+: return to normal Result: Music time advances at variable rates (61.24s in 60s physical time), and notes within patterns correctly accelerate/decelerate with tempo changes. handoff(Claude): Tempo scaling now affects notes within patterns Co-Authored-By: Claude Sonnet 4.5 --- src/audio/tracker.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) (limited to 'src/audio/tracker.h') diff --git a/src/audio/tracker.h b/src/audio/tracker.h index 49fcd3c..e6d479a 100644 --- a/src/audio/tracker.h +++ b/src/audio/tracker.h @@ -41,4 +41,5 @@ extern const uint32_t g_tracker_patterns_count; extern const TrackerScore g_tracker_score; void tracker_init(); -void tracker_update(float time_sec); +void tracker_update(float music_time_sec); +void tracker_reset(); // Reset tracker state (for tests/seeking) -- cgit v1.2.3