summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-02-04 13:48:44 +0100
committerskal <pascal.massimino@gmail.com>2026-02-04 13:48:44 +0100
commit6375468ea8d48a57f44e2d8bffd948e6a87ead89 (patch)
treedf300c446cc24648c02206778c0e0bb0418613b5 /src/main.cc
parent645b396ef9509257a896f0df5610e846f54b79a5 (diff)
feat(audio): Simplified demo track with tempo scaling tests
Created debuggable drum beat track that tests variable tempo system with clear acceleration and deceleration phases. Music Track Changes (assets/music.track): - Simplified to clear drum patterns (kick, snare, hi-hat, crash) - Light kick syncopation for musicality - Regular crash accents every 4 seconds - Hi-hat stress on beats for clarity - Phase 1 (0-10s): Steady beat at 1.0x tempo - Phase 2 (10-16s): Acceleration test (1.0x → 2.0x, then reset to 1.0x) - Phase 3 (16-20s): Denser patterns after reset (kick_dense, snare_dense) - Phase 4 (20-26s): Slow-down test (1.0x → 0.5x, then reset to 1.0x) - Phase 5 (26-30s): Return to normal tempo - Phase 6 (30s+): Add bass line and E minor melody Tempo Control (src/main.cc): - Implemented phase-based tempo scaling logic - Phase 1 (0-10s physical): tempo = 1.0 (steady) - Phase 2 (10-15s physical): tempo = 1.0 → 2.0 (acceleration) - Phase 3 (15-20s physical): tempo = 1.0 (reset trick) - Phase 4 (20-25s physical): tempo = 1.0 → 0.5 (deceleration) - Phase 5 (25s+ physical): tempo = 1.0 (reset trick) - Added debug output showing tempo changes (!STRIP_ALL) Test Updates (src/tests/test_tracker.cc): - Updated voice count assertions to match new track (3 → 4 voices) - New track triggers 4 patterns at t=0: crash, kick, snare, hi-hat Results: ✓ All 16 tests passing (100%) ✓ Clear, debuggable drum patterns ✓ Tests both acceleration and deceleration reset tricks ✓ Musical: E minor bass and melody after 30s ✓ Debug output shows tempo scaling in action handoff(Claude): Tempo scaling demo track ready for testing Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc31
1 files changed, 31 insertions, 0 deletions
diff --git a/src/main.cc b/src/main.cc
index 9f61f07..3d05822 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -101,6 +101,37 @@ int main(int argc, char** argv) {
int beat_count = 0;
auto update_game_logic = [&](double t) {
+ // Variable tempo test: Accelerate and decelerate based on physical time
+ // Phase 1 (0-10s): Steady at 1.0x
+ // Phase 2 (10-15s): Accelerate from 1.0x to 2.0x
+ // Phase 3 (15-20s): Reset to 1.0x (with denser patterns in track)
+ // Phase 4 (20-25s): Decelerate from 1.0x to 0.5x
+ // Phase 5 (25s+): Reset to 1.0x (back to normal)
+ const float prev_tempo = g_tempo_scale;
+ if (t < 10.0) {
+ g_tempo_scale = 1.0f; // Phase 1: Steady
+ } else if (t < 15.0) {
+ // Phase 2: Linear acceleration
+ const float progress = (float)(t - 10.0) / 5.0f;
+ g_tempo_scale = 1.0f + progress * 1.0f; // 1.0 → 2.0
+ } else if (t < 20.0) {
+ g_tempo_scale = 1.0f; // Phase 3: Reset to normal
+ } else if (t < 25.0) {
+ // Phase 4: Linear deceleration
+ const float progress = (float)(t - 20.0) / 5.0f;
+ g_tempo_scale = 1.0f - progress * 0.5f; // 1.0 → 0.5
+ } else {
+ g_tempo_scale = 1.0f; // Phase 5: Reset to normal
+ }
+
+#if !defined(STRIP_ALL)
+ // Debug output when tempo changes significantly
+ if (fabsf(g_tempo_scale - prev_tempo) > 0.05f) {
+ printf("[Tempo] t=%.2fs, tempo=%.3fx, music_time=%.3fs\n", (float)t,
+ g_tempo_scale, g_music_time);
+ }
+#endif
+
// Calculate delta time and advance music time at scaled rate
const float dt = (float)(t - g_last_physical_time);
g_last_physical_time = t;