summaryrefslogtreecommitdiff
path: root/src/audio/audio.cc
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-31 15:44:30 +0100
committerskal <pascal.massimino@gmail.com>2026-01-31 15:44:30 +0100
commit0bb7fa35cc340a65c944e546231632379bcfa30c (patch)
tree23913b4d5d26686b45acee5648b147a44877e3a0 /src/audio/audio.cc
parent72c0cbcb38732b698d33d52459fed67af56ee2ec (diff)
feat: Add --seek command line option for fast-forward debugging
This feature allows developers to jump to a specific time in the demo sequence (e.g., './demo64k --seek 10.5'). It simulates the game logic, audio state (rendering silent buffers), and visual physics (compute shaders) from t=0 up to the target time before starting real-time playback. Audio initialization is refactored to separate device init and start.
Diffstat (limited to 'src/audio/audio.cc')
-rw-r--r--src/audio/audio.cc15
1 files changed, 15 insertions, 0 deletions
diff --git a/src/audio/audio.cc b/src/audio/audio.cc
index 6249479..517e376 100644
--- a/src/audio/audio.cc
+++ b/src/audio/audio.cc
@@ -38,7 +38,9 @@ void audio_init() {
printf("Failed to open playback device.\n");
return;
}
+}
+void audio_start() {
if (ma_device_start(&g_device) != MA_SUCCESS) {
printf("Failed to start playback device.\n");
ma_device_uninit(&g_device);
@@ -46,6 +48,19 @@ void audio_init() {
}
}
+void audio_render_silent(float duration_sec) {
+ const int sample_rate = 32000;
+ const int chunk_size = 512;
+ int total_frames = (int)(duration_sec * sample_rate);
+ float buffer[chunk_size * 2]; // Stereo
+
+ while (total_frames > 0) {
+ int frames_to_render = (total_frames > chunk_size) ? chunk_size : total_frames;
+ synth_render(buffer, frames_to_render);
+ total_frames -= frames_to_render;
+ }
+}
+
void audio_update() {
}