From 5bc3a5d7ff7de04cf1d97bd8fa8df02b2b8a1d42 Mon Sep 17 00:00:00 2001 From: Bliblank Date: Sat, 24 Jan 2026 18:53:48 -0600 Subject: [PATCH] profile loading checkpoint --- config/profiles/default.yaml | 45 ++++++++++++++++++++++++++++++++++++ src/ConfigInterface.cpp | 2 +- src/ConfigInterface.h | 1 + src/ParameterStore.cpp | 13 ++++++++++- src/ParameterStore.h | 6 ++++- src/synth/AudioEngine.cpp | 2 +- src/synth/AudioEngine.h | 2 +- src/ui/MainWindow.h | 2 +- 8 files changed, 67 insertions(+), 6 deletions(-) diff --git a/config/profiles/default.yaml b/config/profiles/default.yaml index e69de29..19fe404 100644 --- a/config/profiles/default.yaml +++ b/config/profiles/default.yaml @@ -0,0 +1,45 @@ + +# default.yaml +# Default voice profile + +# sequences in the form [x, x, x] denote [setValue, sliderMinimum, sliderMaximum] + +version: 00001 + +# deprecated, useless +Osc1Freq: [100, 20, 600] + +# wavetable selections +OscWaveSelector1: 2 +OscWaveSelector2: 1 + +# Oscillator frequency parameters +Osc1OctaveOffset: [0, -5, 5] +Osc1SemitoneOffset: [0, -12, 12] +Osc1PitchOffset: [0, -100, 100] +Osc2OctaveOffset: [1, -5, 5] +Osc2SemitoneOffset: [0, -12, 12] +Osc2PitchOffset: [0, -100, 100] +Osc3OctaveOffset: [1, -5, 5] +Osc3SemitoneOffset: [7, -12, 12] +Osc3PitchOffset: [1.96, -100, 100] + +# Envelope generator parameters +Osc1Volume: + - [1, 0, 2] # Depth + - [0.05, 0, 2] # Attack + - [0.2, 0, 2] # Decay + - [0.7, 0, 1] # Sustain + - [0.2, 0, 2] # Release +FilterCutoff: + - [4, 0, 8] # Depth + - [0.05, 0, 2] # Attack + - [0.2, 0, 2] # Decay + - [0.2, 0, 1] # Sustain + - [0.25, 0, 2] # Release +FilterResonance: + - [3, 0, 8] # Depth + - [0.05, 0, 2] # Attack + - [0.2, 0, 2] # Decay + - [0.5, 0, 1] # Sustain + - [0.3, 0, 2] # Release diff --git a/src/ConfigInterface.cpp b/src/ConfigInterface.cpp index 4c209ef..733bdd6 100644 --- a/src/ConfigInterface.cpp +++ b/src/ConfigInterface.cpp @@ -3,7 +3,6 @@ #include "yaml-cpp/yaml.h" -#include #include #include @@ -24,6 +23,7 @@ int ConfigInterface::getValue(ConfigFile file, std::string key, int defaultVal) // attempt to open file YAML::Node config; try { + YAML::Node config = YAML::LoadFile(filepath); // read key if it exists diff --git a/src/ConfigInterface.h b/src/ConfigInterface.h index 6bd15bd..faea952 100644 --- a/src/ConfigInterface.h +++ b/src/ConfigInterface.h @@ -3,6 +3,7 @@ #include #include +#include enum class ConfigFile { Audio = 0 diff --git a/src/ParameterStore.cpp b/src/ParameterStore.cpp index 49f1d94..0262b20 100644 --- a/src/ParameterStore.cpp +++ b/src/ParameterStore.cpp @@ -1,7 +1,9 @@ #include "ParameterStore.h" -ParameterStore::ParameterStore() { +#include + +ParameterStore::ParameterStore(ConfigInterface* config) : config_(config) { resetToDefaults(); } @@ -30,6 +32,15 @@ void ParameterStore::resetToDefaults() { for(size_t i = 0; i < PARAM_COUNT; i++) { values_[i].store(PARAM_DEFS[i].def, std::memory_order_relaxed); } + + if(config_) { + int x = config_->getValue(ConfigFile::Audio, "sampleRate", 0); + std::cout << "test: " << x << std::endl; + } else { + std::cout << "pointer null" << std::endl; + } + + } // TODO: applying parameter profiles will work similarly to above function diff --git a/src/ParameterStore.h b/src/ParameterStore.h index 70fdef1..9b2493a 100644 --- a/src/ParameterStore.h +++ b/src/ParameterStore.h @@ -1,6 +1,8 @@ #pragma once +#include "ConfigInterface.h" + #include #include #include @@ -107,7 +109,7 @@ class ParameterStore { public: - ParameterStore(); + ParameterStore(ConfigInterface* config); ~ParameterStore() = default; void set(ParamId id, float value); @@ -121,4 +123,6 @@ private: std::array, PARAM_COUNT> values_; + ConfigInterface* config_; + }; diff --git a/src/synth/AudioEngine.cpp b/src/synth/AudioEngine.cpp index 4b29f7d..56772a9 100644 --- a/src/synth/AudioEngine.cpp +++ b/src/synth/AudioEngine.cpp @@ -3,7 +3,7 @@ #include -AudioEngine::AudioEngine(ConfigInterface* config) : synth_(params_), config_(config) { +AudioEngine::AudioEngine(ConfigInterface* config) : params_(ParameterStore(config)), synth_(params_), config_(config) { if(audio_.getDeviceCount() < 1) { throw std::runtime_error("No audio devices found"); } diff --git a/src/synth/AudioEngine.h b/src/synth/AudioEngine.h index ae673fc..9c1f128 100644 --- a/src/synth/AudioEngine.h +++ b/src/synth/AudioEngine.h @@ -40,11 +40,11 @@ private: // calls the synth.process to generate a buffer of audio samples int32_t process(float* out, uint32_t nFrames); + ConfigInterface* config_; // access to config files ParameterStore params_; // stores the control parameters NoteQueue noteQueue_; // stores note events for passing between threads Synth synth_; // generates audio ScopeBuffer scope_ { 1024 }; // stores audio samples for visualization - ConfigInterface* config_; // access to config files RtAudio audio_{AUDIO_API}; // audio device // TODO: id like a yml config file or something for these diff --git a/src/ui/MainWindow.h b/src/ui/MainWindow.h index ff71068..73b00ad 100644 --- a/src/ui/MainWindow.h +++ b/src/ui/MainWindow.h @@ -30,9 +30,9 @@ private slots: private: Ui::MainWindow *ui_; + ConfigInterface config_; AudioEngine* audio_ = nullptr; KeyboardController keyboard_; MidiController midi_; - ConfigInterface config_; };