From b85635ea92ace57e4d94288031a3a61a96fcbd2a Mon Sep 17 00:00:00 2001 From: skal Date: Sun, 8 Feb 2026 17:30:49 +0100 Subject: feat(audio): Add --tempo flag for variable tempo testing - test_demo: Accelerate [2s->4s], decelerate [6s->8s] - demo64k: Same tempo logic behind --tempo flag - Enhanced debug output to show tempo scale and music time --- src/test_demo.cc | 23 +++++++++++------------ 1 file changed, 11 insertions(+), 12 deletions(-) (limited to 'src/test_demo.cc') diff --git a/src/test_demo.cc b/src/test_demo.cc index 656d0ba..91c5427 100644 --- a/src/test_demo.cc +++ b/src/test_demo.cc @@ -229,19 +229,18 @@ int main(int argc, char** argv) { auto fill_audio_buffer = [&](float audio_dt, double physical_time) { // Calculate tempo scale if --tempo flag enabled if (tempo_test_enabled) { - // Each bar = 2 seconds at 120 BPM (4 beats) - const float bar_duration = 2.0f; - // Use physical_time for tempo modulation progression - const int bar_number = (int)(physical_time / bar_duration); - const float bar_progress = fmodf((float)physical_time, bar_duration) / - bar_duration; // 0.0-1.0 within bar - - if (bar_number % 2 == 0) { - // Even bars: Ramp from 1.0x → 1.5x - g_tempo_scale = 1.0f + (0.5f * bar_progress); + const float t = (float)physical_time; + if (t >= 2.0f && t < 4.0f) { + // [2s->4s]: Accelerate from 1.0x to 1.5x + const float progress = (t - 2.0f) / 2.0f; + g_tempo_scale = 1.0f + (0.5f * progress); + } else if (t >= 6.0f && t < 8.0f) { + // [6s->8s]: Decelerate from 1.0x to 0.66x + const float progress = (t - 6.0f) / 2.0f; + g_tempo_scale = 1.0f - (0.34f * progress); } else { - // Odd bars: Ramp from 1.0x → 0.66x - g_tempo_scale = 1.0f - (0.34f * bar_progress); + // All other times: Normal tempo + g_tempo_scale = 1.0f; } } else { g_tempo_scale = 1.0f; // No tempo variation -- cgit v1.2.3