diff options
Diffstat (limited to 'src/main.cc')
| -rw-r--r-- | src/main.cc | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/main.cc b/src/main.cc index 6132841..41c881b 100644 --- a/src/main.cc +++ b/src/main.cc @@ -325,11 +325,10 @@ int main(int argc, char** argv) { const float raw_peak = audio_get_realtime_peak(); const float visual_peak = fminf(raw_peak * 8.0f, 1.0f); - // Beat calculation should use audio time to align with audio events. - // The graphics loop time (current_physical_time) is used for frame rate. - const float beat_time = current_audio_time * g_tracker_score.bpm / 60.0f; - const int beat_number = (int)beat_time; - const float beat = fmodf(beat_time, 1.0f); // Fractional part (0.0 to 1.0) + // Beat calculation: convert audio time to musical beats + const float absolute_beat_time = current_audio_time * g_tracker_score.bpm / 60.0f; + const int beat_number = (int)absolute_beat_time; + const float beat_phase = fmodf(absolute_beat_time, 1.0f); // Fractional part (0.0 to 1.0) // Print beat/time info periodically for identifying sync points // Use graphics time for the print interval to avoid excessive output if @@ -339,20 +338,21 @@ int main(int argc, char** argv) { 0.5f) { // Print every 0.5 seconds if (tempo_test_enabled) { printf( - "[GraphicsT=%.2f, AudioT=%.2f, MusicT=%.2f, Beat=%d, Frac=%.2f, " + "[GraphicsT=%.2f, AudioT=%.2f, MusicT=%.2f, Beat=%d, Phase=%.2f, " "Peak=%.2f, Tempo=%.2fx]\n", current_physical_time, current_audio_time, g_music_time, - beat_number, beat, visual_peak, g_tempo_scale); + beat_number, beat_phase, visual_peak, g_tempo_scale); } else { - printf("[GraphicsT=%.2f, AudioT=%.2f, Beat=%d, Frac=%.2f, Peak=%.2f]\n", - current_physical_time, current_audio_time, beat_number, beat, + printf("[GraphicsT=%.2f, AudioT=%.2f, Beat=%d, Phase=%.2f, Peak=%.2f]\n", + current_physical_time, current_audio_time, beat_number, beat_phase, visual_peak); } last_graphics_print_time = current_physical_time; } - // Draw graphics using the graphics frame time and synchronized audio events - gpu_draw(visual_peak, aspect_ratio, (float)current_physical_time, beat); + // Draw graphics using physical time and musical beat time + gpu_draw(visual_peak, aspect_ratio, (float)current_physical_time, + absolute_beat_time, beat_phase); last_frame_time = current_physical_time; // Update audio systems (tracker, synth, etc.) based on audio time |
