profile loading checkpoint

This commit is contained in:
2026-01-24 18:53:48 -06:00
parent 69a507d57b
commit 5bc3a5d7ff
8 changed files with 67 additions and 6 deletions

View File

@@ -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

View File

@@ -3,7 +3,6 @@
#include "yaml-cpp/yaml.h"
#include <iostream>
#include <fstream>
#include <filesystem>
@@ -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

View File

@@ -3,6 +3,7 @@
#include <string>
#include <vector>
#include <iostream>
enum class ConfigFile {
Audio = 0

View File

@@ -1,7 +1,9 @@
#include "ParameterStore.h"
ParameterStore::ParameterStore() {
#include <iostream>
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

View File

@@ -1,6 +1,8 @@
#pragma once
#include "ConfigInterface.h"
#include <cstdint>
#include <array>
#include <atomic>
@@ -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<std::atomic<float>, PARAM_COUNT> values_;
ConfigInterface* config_;
};

View File

@@ -3,7 +3,7 @@
#include <iostream>
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");
}

View File

@@ -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

View File

@@ -30,9 +30,9 @@ private slots:
private:
Ui::MainWindow *ui_;
ConfigInterface config_;
AudioEngine* audio_ = nullptr;
KeyboardController keyboard_;
MidiController midi_;
ConfigInterface config_;
};