summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/main.cc b/src/main.cc
index 89e21f1..4922d69 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -125,12 +125,13 @@ int main(int argc, char** argv) {
}
#endif
- // Calculate delta time and advance music time at scaled rate
+ // Calculate delta time
const float dt = (float)(t - g_last_physical_time);
g_last_physical_time = t;
- g_music_time += dt * g_tempo_scale;
- // Pass music_time (not physical time) to tracker
+ // CRITICAL: Update tracker BEFORE advancing music_time
+ // This ensures events trigger in the correct frame, not one frame early
+ // Pass current music_time (not future time) to tracker
g_audio_engine.update(g_music_time);
// Fill ring buffer with upcoming audio (look-ahead rendering)
@@ -138,6 +139,10 @@ int main(int argc, char** argv) {
// acceleration/deceleration At 2.0x tempo, we consume 2x audio per physical
// second, so we must render 2x per frame
audio_render_ahead(g_music_time, dt * g_tempo_scale);
+
+ // Advance music time AFTER rendering audio for this frame
+ // This prevents events from triggering one frame early
+ g_music_time += dt * g_tempo_scale;
};
#if !defined(STRIP_ALL)