summaryrefslogtreecommitdiff
path: root/src/audio/tracker.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/tracker.cc')
-rw-r--r--src/audio/tracker.cc10
1 files changed, 6 insertions, 4 deletions
diff --git a/src/audio/tracker.cc b/src/audio/tracker.cc
index 93a1c49..1cccc57 100644
--- a/src/audio/tracker.cc
+++ b/src/audio/tracker.cc
@@ -239,8 +239,9 @@ void tracker_update(float music_time_sec) {
}
// Step 2: Update all active patterns and trigger individual events
- // Get current audio playback position for sample-accurate timing
- const float current_playback_time = audio_get_playback_time();
+ // Get current audio RENDER position (write position) for sample-accurate timing
+ // This is where we're currently writing to the ring buffer (~400ms ahead of playback)
+ const float current_render_time = audio_get_render_time();
const float SAMPLE_RATE = 32000.0f; // Audio sample rate
for (int i = 0; i < MAX_SPECTROGRAMS; ++i) {
@@ -265,8 +266,9 @@ void tracker_update(float music_time_sec) {
const float event_trigger_time = active.start_music_time +
(event.unit_time * unit_duration_sec);
- // Calculate sample-accurate offset from current playback position
- const float time_delta = event_trigger_time - current_playback_time;
+ // Calculate sample-accurate offset from current RENDER position (write pos)
+ // This is where we're currently writing to the buffer, not where playback is
+ const float time_delta = event_trigger_time - current_render_time;
int sample_offset = (int)(time_delta * SAMPLE_RATE);
// Clamp to 0 if negative (event is late, play immediately)