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.cc18
1 files changed, 18 insertions, 0 deletions
diff --git a/src/audio/tracker.cc b/src/audio/tracker.cc
index 1c0a9b2..00c31e9 100644
--- a/src/audio/tracker.cc
+++ b/src/audio/tracker.cc
@@ -234,6 +234,16 @@ static void trigger_note_event(const TrackerEvent& event,
}
void tracker_update(float music_time_sec, float dt_music_sec) {
+ // TODO(timing): CRITICAL BUG - Events trigger ~180ms early over 63 beats @ BPM=90
+ // Observed: Beat 63 snare at 41.82s in WAV, should be at 42.00s (180ms drift)
+ // NOTE: This is NOT a float vs double precision issue - floats handle <500s times fine
+ // Root cause unknown - suspects:
+ // 1. Systematic bias in time calculation (not random accumulation)
+ // 2. Truncation in audio.cc:103 chunk_frames = (int)(dt * sample_rate)
+ // 3. BPM calculation precision below (unit_duration_sec)
+ // 4. Mismatch between tracker time and actual sample rendering
+ // See also: audio.cc sample rendering truncation
+
// Unit-less timing: 1 unit = 4 beats (by convention)
const float BEATS_PER_UNIT = 4.0f;
const float unit_duration_sec =
@@ -314,6 +324,14 @@ void tracker_update(float music_time_sec, float dt_music_sec) {
}
}
+ // DEBUG: Track kick/snare timing for drift investigation
+ if (event.sample_id == 0 || event.sample_id == 1) { // Assuming kick=0, snare=1
+ const char* name = (event.sample_id == 0) ? "KICK " : "SNARE";
+ const float delta_ms = (event_music_time - music_time_sec) * 1000.0f;
+ printf("[DRIFT] %s: music=%.4f expect=%.4f delta=%.2fms offset=%d\n",
+ name, music_time_sec, event_music_time, delta_ms, sample_offset);
+ }
+
trigger_note_event(event, sample_offset, volume_mult);
active.next_event_idx++;
}