summaryrefslogtreecommitdiff
path: root/src/main.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/main.cc')
-rw-r--r--src/main.cc57
1 files changed, 32 insertions, 25 deletions
diff --git a/src/main.cc b/src/main.cc
index 95582e8..b2b62a8 100644
--- a/src/main.cc
+++ b/src/main.cc
@@ -30,6 +30,7 @@ int main(int argc, char** argv) {
int width = 1280;
int height = 720;
bool dump_wav = false;
+ bool tempo_test_enabled = false;
const char* wav_output_file = "audio_dump.wav";
#if !defined(STRIP_ALL)
@@ -54,6 +55,8 @@ int main(int argc, char** argv) {
if (i + 1 < argc && argv[i + 1][0] != '-') {
wav_output_file = argv[++i];
}
+ } else if (strcmp(argv[i], "--tempo") == 0) {
+ tempo_test_enabled = true;
}
}
#else
@@ -92,30 +95,26 @@ int main(int argc, char** argv) {
static float g_last_audio_time = 0.0f;
auto fill_audio_buffer = [&](float audio_dt, double physical_time) {
- // Variable tempo system - acceleration phases for demo effect
- // Phase 1 (0-5s): Steady 1.0x
- // Phase 2 (5-10s): Steady 1.0x
- // Phase 3 (10-15s): Accelerate from 1.0x to 2.0x
- // Phase 4 (15-20s): Steady 1.0x (reset after acceleration)
- // Phase 5 (20-25s): Decelerate from 1.0x to 0.5x
- // Phase 6 (25s+): Steady 1.0x (reset after deceleration)
- const float prev_tempo = g_tempo_scale;
- if (physical_time < 10.0) {
- g_tempo_scale = 1.0f; // Steady at start
- } else if (physical_time < 15.0) {
- // Phase 3: Linear acceleration
- const float progress = (float)(physical_time - 10.0) / 5.0f;
- g_tempo_scale = 1.0f + progress * 1.0f; // 1.0 → 2.0
- } else if (physical_time < 20.0) {
- g_tempo_scale = 1.0f; // Reset to normal
- } else if (physical_time < 25.0) {
- // Phase 5: Linear deceleration
- const float progress = (float)(physical_time - 20.0) / 5.0f;
- g_tempo_scale = 1.0f - progress * 0.5f; // 1.0 → 0.5
+ // Calculate tempo scale if --tempo flag enabled
+ if (tempo_test_enabled) {
+ 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 {
+ // All other times: Normal tempo
+ g_tempo_scale = 1.0f;
+ }
} else {
- g_tempo_scale = 1.0f; // Reset to normal
+ g_tempo_scale = 1.0f; // No tempo variation
}
- g_tempo_scale = 1.0f;
+
+ const float prev_tempo = g_tempo_scale;
#if !defined(STRIP_ALL)
// Debug output when tempo changes significantly
@@ -276,9 +275,17 @@ int main(int argc, char** argv) {
static float last_graphics_print_time = -1.0f;
if (current_physical_time - last_graphics_print_time >=
0.5f) { // Print every 0.5 seconds
- printf("[GraphicsT=%.2f, AudioT=%.2f, Beat=%d, Frac=%.2f, Peak=%.2f]\n",
- current_physical_time, current_audio_time, beat_number, beat,
- visual_peak);
+ if (tempo_test_enabled) {
+ printf(
+ "[GraphicsT=%.2f, AudioT=%.2f, MusicT=%.2f, Beat=%d, Frac=%.2f, "
+ "Peak=%.2f, Tempo=%.2fx]\n",
+ current_physical_time, current_audio_time, g_music_time,
+ beat_number, beat, 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,
+ visual_peak);
+ }
last_graphics_print_time = current_physical_time;
}