diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/main.cc | 31 | ||||
| -rw-r--r-- | src/tests/test_tracker.cc | 8 |
2 files changed, 35 insertions, 4 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; diff --git a/src/tests/test_tracker.cc b/src/tests/test_tracker.cc index 2a9239c..ea1debd 100644 --- a/src/tests/test_tracker.cc +++ b/src/tests/test_tracker.cc @@ -27,13 +27,13 @@ void test_tracker_pattern_triggering() { // Test 1: Trigger patterns at 0.0f tracker_update(0.0f); printf("Actual active voice count: %d\n", synth_get_active_voice_count()); - // Expect 3 voices (one for each pattern triggered at 0.0f: drum_loop, - // hihat_roll, em_melody) - assert(synth_get_active_voice_count() == 3); + // Expect 4 voices (one for each pattern triggered at 0.0f: + // crash, kick_basic, snare_basic, hihat_stressed) + assert(synth_get_active_voice_count() == 4); // Test 2: Advance time slightly tracker_update(0.1f); - assert(synth_get_active_voice_count() == 3); + assert(synth_get_active_voice_count() == 4); // Test 3: Advance further, no new triggers until 4.0f tracker_update(3.0f); |
