summaryrefslogtreecommitdiff
path: root/src/test_demo.cc
diff options
context:
space:
mode:
Diffstat (limited to 'src/test_demo.cc')
-rw-r--r--src/test_demo.cc41
1 files changed, 21 insertions, 20 deletions
diff --git a/src/test_demo.cc b/src/test_demo.cc
index 87cdd1e..4ec8d70 100644
--- a/src/test_demo.cc
+++ b/src/test_demo.cc
@@ -8,6 +8,7 @@
#include "gpu/demo_effects.h"
#include "gpu/gpu.h"
#include "platform/platform.h"
+#include "util/check_return.h"
#include <cmath>
#include <cstdio>
#include <cstdlib>
@@ -181,19 +182,20 @@ int main(int argc, char** argv) {
return 1;
}
} else if (strcmp(argv[i], "--log-peaks") == 0) {
- if (i + 1 < argc) {
- log_peaks_file = argv[++i];
- } else {
- fprintf(stderr, "Error: --log-peaks requires a filename argument\n\n");
- print_usage(argv[0]);
- return 1;
- }
+ CHECK_RETURN_BEGIN(i + 1 >= argc, 1)
+ print_usage(argv[0]);
+ ERROR_MSG("--log-peaks requires a filename argument\n");
+ return 1;
+ CHECK_RETURN_END
+ log_peaks_file = argv[++i];
} else if (strcmp(argv[i], "--log-peaks-fine") == 0) {
log_peaks_fine = true;
} else {
- fprintf(stderr, "Error: Unknown option '%s'\n\n", argv[i]);
+ CHECK_RETURN_BEGIN(true, 1)
print_usage(argv[0]);
+ ERROR_MSG("Unknown option '%s'\n", argv[i]);
return 1;
+ CHECK_RETURN_END
}
}
#else
@@ -227,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