loading default profile from yaml
This commit is contained in:
@@ -4,7 +4,7 @@
|
||||
|
||||
# sequences in the form [x, x, x] denote [setValue, sliderMinimum, sliderMaximum]
|
||||
|
||||
version: 00001
|
||||
version: 0x0002
|
||||
|
||||
# deprecated, useless
|
||||
Osc1Freq: [100, 20, 600]
|
||||
|
||||
@@ -2,6 +2,8 @@
|
||||
#include "ParameterStore.h"
|
||||
|
||||
#include <iostream>
|
||||
#include "yaml-cpp/yaml.h" // TODO: using yaml.h outside of ConfigInterface feels spaghetti to me
|
||||
#include <filesystem>
|
||||
|
||||
ParameterStore::ParameterStore(ConfigInterface* config) : config_(config) {
|
||||
resetToDefaults();
|
||||
@@ -33,14 +35,41 @@ void ParameterStore::resetToDefaults() {
|
||||
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;
|
||||
loadParameterProfile("config/profiles/default.yaml");
|
||||
|
||||
}
|
||||
|
||||
void ParameterStore::loadParameterProfile(std::string filepath) {
|
||||
|
||||
// TODO: abstract the actual yaml interfacing to the ConfigInterface instead of here
|
||||
// TODO: update ui based on changes that happen not in the ui
|
||||
// it will require some architecture rework :(
|
||||
|
||||
// load file
|
||||
filepath = std::filesystem::absolute(filepath).string();
|
||||
YAML::Node config;
|
||||
try {
|
||||
config = YAML::LoadFile(filepath);
|
||||
} catch(const std::exception& e) {
|
||||
std::cerr << e.what() << std::endl;
|
||||
return;
|
||||
}
|
||||
|
||||
// check version
|
||||
int version = config["version"].as<int>(); // yaml-cpp parses unquoted hex as integers
|
||||
if(version < CONFIG_VERSION) {
|
||||
std::cout << "Parameter profile version " << version << "is outdated below the compatible version " << CONFIG_VERSION << std::endl;
|
||||
return;
|
||||
} else {
|
||||
std::cout << "pointer null" << std::endl;
|
||||
//std::cout << version << std::endl;
|
||||
}
|
||||
|
||||
// start setting some values
|
||||
YAML::Node osc1Volume = config["Osc1Volume"];
|
||||
YAML::Node fCutoff = config["FilterCutoff"];
|
||||
YAML::Node fResonance = config["FilterResonance"];
|
||||
set(EnvelopeId::Osc1Volume, osc1Volume[0][0].as<float>(), osc1Volume[1][0].as<float>(), osc1Volume[2][0].as<float>(), osc1Volume[3][0].as<float>(), osc1Volume[4][0].as<float>());
|
||||
set(EnvelopeId::FilterCutoff, fCutoff[0][0].as<float>(), fCutoff[1][0].as<float>(), fCutoff[2][0].as<float>(), fCutoff[3][0].as<float>(), fCutoff[4][0].as<float>());
|
||||
set(EnvelopeId::FilterResonance, fResonance[0][0].as<float>(), fResonance[1][0].as<float>(), fResonance[2][0].as<float>(), fResonance[3][0].as<float>(), fResonance[4][0].as<float>());
|
||||
|
||||
}
|
||||
|
||||
// TODO: applying parameter profiles will work similarly to above function
|
||||
|
||||
@@ -7,6 +7,8 @@
|
||||
#include <array>
|
||||
#include <atomic>
|
||||
|
||||
#define CONFIG_VERSION 0x0001
|
||||
|
||||
enum class ParamId : uint16_t {
|
||||
Osc1Frequency,
|
||||
Osc1WaveSelector1,
|
||||
@@ -121,6 +123,8 @@ public:
|
||||
|
||||
private:
|
||||
|
||||
void loadParameterProfile(std::string filepath);
|
||||
|
||||
std::array<std::atomic<float>, PARAM_COUNT> values_;
|
||||
|
||||
ConfigInterface* config_;
|
||||
|
||||
Reference in New Issue
Block a user