summaryrefslogtreecommitdiff
path: root/src/audio/synth.h
diff options
context:
space:
mode:
authorskal <pascal.massimino@gmail.com>2026-01-27 22:16:23 +0100
committerskal <pascal.massimino@gmail.com>2026-01-27 22:16:23 +0100
commitad4f87e0ebfd361c69c7ba9adc29292305f21f7c (patch)
tree7e3d4feffce3cac26139df1ace2f879e62bfc00c /src/audio/synth.h
parent2f68b86ba403fdae97c00569b6bb9b58ad1f33a6 (diff)
feat(audio): Implement real-time spectrogram synthesizer
Adds a multi-voice, real-time audio synthesis engine that generates sound from spectrogram data using an Inverse Discrete Cosine Transform (IDCT). Key features: - A thread-safe, double-buffered system for dynamically updating spectrograms in real-time without interrupting audio playback. - Core DSP components: FDCT, IDCT, and Hamming window functions. - A simple sequencer in the main loop to demonstrate scripted audio events and dynamic updates. - Unit tests for the new synth engine and Hamming window, integrated with CTest. - A file documenting the build process, features, and how to run tests.
Diffstat (limited to 'src/audio/synth.h')
-rw-r--r--src/audio/synth.h24
1 files changed, 24 insertions, 0 deletions
diff --git a/src/audio/synth.h b/src/audio/synth.h
new file mode 100644
index 0000000..ce9825d
--- /dev/null
+++ b/src/audio/synth.h
@@ -0,0 +1,24 @@
+#pragma once
+
+#include "dct.h"
+
+#define MAX_SPECTROGRAMS 16
+#define MAX_VOICES 16
+
+struct Spectrogram {
+ float* spectral_data_a;
+ float* spectral_data_b;
+ int num_frames;
+};
+
+void synth_init();
+void synth_shutdown();
+
+int synth_register_spectrogram(const Spectrogram* spec);
+void synth_unregister_spectrogram(int spectrogram_id);
+
+float* synth_begin_update(int spectrogram_id);
+void synth_commit_update(int spectrogram_id);
+
+void synth_trigger_voice(int spectrogram_id, float volume, float pan);
+void synth_render(float* output_buffer, int num_frames);