From d1123138a34543bc05685fa92e0397d21cbc6cb8 Mon Sep 17 00:00:00 2001 From: Blitblank Date: Fri, 30 Jan 2026 23:54:44 -0600 Subject: [PATCH] comments --- config/audio.yaml | 2 +- config/keymap.yaml | 35 +++++++++++++++++++++++++++++++++++ src/ParameterStore.h | 2 -- src/synth/AudioEngine.cpp | 14 +++++++++++--- src/synth/AudioEngine.h | 3 ++- src/synth/Voice.h | 2 +- 6 files changed, 50 insertions(+), 8 deletions(-) create mode 100644 config/keymap.yaml diff --git a/config/audio.yaml b/config/audio.yaml index 3e356bd..947f59f 100644 --- a/config/audio.yaml +++ b/config/audio.yaml @@ -3,7 +3,7 @@ # Configures properties for the RtAudio engine # Number of samples per second -sampleRate: 44100 +sampleRate: 96000 # unconfigurable: sampleFormat; [-1, 1] float # number of audio channels diff --git a/config/keymap.yaml b/config/keymap.yaml new file mode 100644 index 0000000..6b6d60d --- /dev/null +++ b/config/keymap.yaml @@ -0,0 +1,35 @@ + +# keymap.yaml +# Configures a computer keyboard mapping of keys to midi notes for when you don't have a midi device available +# (there's probably tools available that are able to make your keyboard act as a midi device but this was easier) + +# so Qt key enum => midi note id +# { Qt::Key_Shift, 47 }, // B 2 +# { Qt::Key_Z, 48 }, // C 3 +# { Qt::Key_S, 49 }, // C# +# { Qt::Key_X, 50 }, // D +# { Qt::Key_D, 51 }, // D# +# { Qt::Key_C, 52 }, // E +# { Qt::Key_V, 53 }, // F +# { Qt::Key_G, 54 }, // F# +# { Qt::Key_B, 55 }, // G +# { Qt::Key_H, 56 }, // G# +# { Qt::Key_N, 57 }, // A +# { Qt::Key_J, 58 }, // A# +# { Qt::Key_M, 59 }, // B 3 +# { Qt::Key_Q, 60 }, // C 4 +# { Qt::Key_2, 61 }, // C# +# { Qt::Key_W, 62 }, // D +# { Qt::Key_3, 63 }, // D# +# { Qt::Key_E, 64 }, // E +# { Qt::Key_R, 65 }, // F +# { Qt::Key_5, 66 }, // F# +# { Qt::Key_T, 67 }, // G +# { Qt::Key_6, 68 }, // G# +# { Qt::Key_Y, 69 }, // A +# { Qt::Key_7, 70 }, // A# +# { Qt::Key_U, 71 }, // B 4 +# { Qt::Key_I, 72 }, // C 5 + +# so we'll also need a mapping of the key strings to the qt::Key enum values +# and then a mapping of note strings to midi ids diff --git a/src/ParameterStore.h b/src/ParameterStore.h index 70fdef1..2bbdff9 100644 --- a/src/ParameterStore.h +++ b/src/ParameterStore.h @@ -69,8 +69,6 @@ struct ParamDefault { float max; }; -// TODO: make these configurable via yml file too -// 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 { 2.0f, 0.0f, 0.0f}, // OscWaveSelector1 diff --git a/src/synth/AudioEngine.cpp b/src/synth/AudioEngine.cpp index 6c80fdd..19f030c 100644 --- a/src/synth/AudioEngine.cpp +++ b/src/synth/AudioEngine.cpp @@ -35,9 +35,17 @@ bool AudioEngine::start() { RtAudio::StreamOptions options; options.flags = RTAUDIO_MINIMIZE_LATENCY; - // TODO: error check this please - audio_.openStream(¶ms, nullptr, RTAUDIO_FLOAT32, sampleRate_, &bufferFrames_, &AudioEngine::audioCallback, this, &options); - audio_.startStream(); + RtAudioErrorType status = audio_.openStream(¶ms, nullptr, RTAUDIO_FLOAT32, sampleRate_, &bufferFrames_, &AudioEngine::audioCallback, this, &options); + if(status != RTAUDIO_NO_ERROR) { + std::cout << "Error opening RtAudio stream" << std::endl; + return false; + } + + status = audio_.startStream(); + if(status != RTAUDIO_NO_ERROR) { + std::cout << "Error starting RtAudio stream" << std::endl; + return false; + } // sanity check std::cout << "sample rate: " << sampleRate_ << " buffer frames: " << bufferFrames_ << std::endl; diff --git a/src/synth/AudioEngine.h b/src/synth/AudioEngine.h index 7d00764..152fd40 100644 --- a/src/synth/AudioEngine.h +++ b/src/synth/AudioEngine.h @@ -49,7 +49,8 @@ private: ScopeBuffer scope_ { 1024 }; // stores audio samples for visualization RtAudio audio_{AUDIO_API}; // audio device - // TODO: id like a yml config file or something for these + + // Configurable in the audio.yaml file, assigned defaults if the file is not found uint32_t sampleRate_ = 44100; uint32_t bufferFrames_ = 512; // time per buffer = BF/SR (256/44100 = 5.8ms) uint32_t channels_ = 2; // stereo diff --git a/src/synth/Voice.h b/src/synth/Voice.h index 79f12e5..a440337 100644 --- a/src/synth/Voice.h +++ b/src/synth/Voice.h @@ -12,6 +12,7 @@ // TODO: make configurable #define SYNTH_OSCILLATOR_COUNT 3 +// if there's different oscillator amounts then we need to be able to dynamically create the ui for each of them struct SmoothedParam { float current = 0.0f; @@ -63,7 +64,6 @@ private: // filters Filter filter1_; Filter filter2_; - // TODO: I think the filter's state being uninitialized is what's causing popping when a voice starts for the first time // paramstore pointer SmoothedParam* params_;