diff options
| author | skal <pascal.massimino@gmail.com> | 2026-02-08 17:30:49 +0100 |
|---|---|---|
| committer | skal <pascal.massimino@gmail.com> | 2026-02-08 17:30:49 +0100 |
| commit | b85635ea92ace57e4d94288031a3a61a96fcbd2a (patch) | |
| tree | 15d2243d8c1a3226d10eaea7e2d94bc74f2c9e4b /src/test_demo.cc | |
| parent | 41b64071beba9dd62a2a8f4e915ea104605a4964 (diff) | |
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
Diffstat (limited to 'src/test_demo.cc')
| -rw-r--r-- | src/test_demo.cc | 23 |
1 files changed, 11 insertions, 12 deletions
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 |
