From 0dc37b0efa4fa45939ab5e65b2d5dd8ad8f79b4e Mon Sep 17 00:00:00 2001 From: Blitblank Date: Tue, 23 Dec 2025 23:24:05 -0600 Subject: [PATCH] comments --- src/ParameterStore.h | 2 +- src/synth/AudioEngine.h | 11 ++++++++++- src/synth/Synth.h | 8 +++++++- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/src/ParameterStore.h b/src/ParameterStore.h index e4d55c6..b55f0d0 100644 --- a/src/ParameterStore.h +++ b/src/ParameterStore.h @@ -32,7 +32,7 @@ struct ParamDef { }; // TODO: make these configurable via yml file too -// TODO: and then when I have full on profile saving there will be a default profile to load from +// later TODO: and then when I have full on profile saving there will be a default profile to load from constexpr std::array(ParamId::Count)> PARAM_DEFS {{ { 100.0f, 20.0f, 600.0f}, // Osc1Freq { 0.8f, 0.0f, 1.0f}, // Osc1Gain diff --git a/src/synth/AudioEngine.h b/src/synth/AudioEngine.h index 0229e93..c39f18a 100644 --- a/src/synth/AudioEngine.h +++ b/src/synth/AudioEngine.h @@ -13,12 +13,21 @@ public: AudioEngine(); ~AudioEngine(); + // starts the audio stream. returns true on success and false on failure bool start(); + + // stops the audio stream. void stop(); + + // params getter ParameterStore* parameters() { return ¶ms_; } -private: +private: + + // RtAudio binding for passing samples static int32_t audioCallback(void* outputBuffer, void* inputBuffer, uint32_t nFrames, double streamTime, RtAudioStreamStatus status, void* userData); + + // calls the synth.process to generate a buffer audio samples int32_t process(float* out, uint32_t nFrames); ParameterStore params_; diff --git a/src/synth/Synth.h b/src/synth/Synth.h index c2a8f55..2c77054 100644 --- a/src/synth/Synth.h +++ b/src/synth/Synth.h @@ -21,12 +21,18 @@ public: Synth(const ParameterStore& params); ~Synth() = default; + // generates a buffer of audio samples nFrames long void process(float* out, uint32_t nFrames, uint32_t sampleRate); + + // sample rate setter void setSampleRate(uint32_t sampleRate) { sampleRate_ = sampleRate; } private: - void updateParams(); + // update internal params to the paramStore. not an immediate sync, its buffered for smoothing + void updateParams(); // (might remove the smoothing later) + + // small getter that abstracts all the static casts and such inline float getParam(ParamId); const ParameterStore& paramStore_;