added ui elements and profile loading for oscillator pitch parameters

This commit is contained in:
2026-01-31 20:10:49 -06:00
parent 0c1c71da49
commit cffd06c0e1
11 changed files with 749 additions and 37 deletions

View File

@@ -11,11 +11,11 @@ Osc1Freq: [100, 20, 600]
# wavetable selections # wavetable selections
OscWaveSelector1: 2 OscWaveSelector1: 2
OscWaveSelector2: 1 OscWaveSelector2: 3
# Frequency parameters # Frequency parameters
MasterOctaveOffset: [1, -5, 5] MasterOctaveOffset: [0, -5, 5]
MasterSemitoneOffset: [1, -12, 12] MasterSemitoneOffset: [0, -12, 12]
MasterPitchOffset: [0, -100, 100] MasterPitchOffset: [0, -100, 100]
Osc1OctaveOffset: [0, -5, 5] Osc1OctaveOffset: [0, -5, 5]
Osc1SemitoneOffset: [0, -12, 12] Osc1SemitoneOffset: [0, -12, 12]

View File

@@ -47,7 +47,7 @@ int ConfigInterface::getValue(ConfigFile file, std::string key, int defaultVal)
} }
// ugly but if it works it works // ugly but if it works it works
void ConfigInterface::loadProfile(std::string filename) { YAML::Node ConfigInterface::loadProfile(std::string filename) {
// load file // load file
std::string filepath = "config/profiles/" + filename + ".yaml"; std::string filepath = "config/profiles/" + filename + ".yaml";
@@ -57,14 +57,14 @@ void ConfigInterface::loadProfile(std::string filename) {
config = YAML::LoadFile(filepath); config = YAML::LoadFile(filepath);
} catch(const std::exception& e) { } catch(const std::exception& e) {
std::cerr << e.what() << std::endl; std::cerr << e.what() << std::endl;
return; return config;
} }
// check version // check version
int version = config["version"].as<int>(); // yaml-cpp parses unquoted hex as integers int version = config["version"].as<int>(); // yaml-cpp parses unquoted hex as integers
if(version < CONFIG_VERSION) { if(version < CONFIG_VERSION) {
std::cout << "Parameter profile version " << version << "is outdated below the compatible version " << CONFIG_VERSION << std::endl; std::cout << "Parameter profile version " << version << "is outdated below the compatible version " << CONFIG_VERSION << std::endl;
return; return config;
} else { } else {
std::cout << "Parameter profile version " << version << std::endl; std::cout << "Parameter profile version " << version << std::endl;
} }
@@ -120,6 +120,8 @@ void ConfigInterface::loadProfile(std::string filename) {
// load wavetable settings // load wavetable settings
// load oscillator pitch settings // load oscillator pitch settings
return config;
} }
std::array<ParamDefault, 5> ConfigInterface::loadEnvProfile(YAML::Node* node, std::string profile) { std::array<ParamDefault, 5> ConfigInterface::loadEnvProfile(YAML::Node* node, std::string profile) {

View File

@@ -32,7 +32,7 @@ public:
int getValue(ConfigFile file, std::string key, int defaultVal); int getValue(ConfigFile file, std::string key, int defaultVal);
void loadProfile(std::string filename); YAML::Node loadProfile(std::string filename);
std::array<ParamDefault, 5> loadEnvProfile(YAML::Node* node, std::string profile); std::array<ParamDefault, 5> loadEnvProfile(YAML::Node* node, std::string profile);
std::array<ParamDefault, 5> loadEnvProfile(std::string filename, std::string profile); std::array<ParamDefault, 5> loadEnvProfile(std::string filename, std::string profile);

View File

@@ -28,8 +28,6 @@ KeyboardController::KeyboardController(NoteQueue& queue, ConfigInterface* config
std::string keyString = entry.first.as<std::string>(); std::string keyString = entry.first.as<std::string>();
std::string noteString = entry.second.as<std::string>(); std::string noteString = entry.second.as<std::string>();
std::cout << keyString << ": " << noteString << std::endl;
// match the strings to ints // match the strings to ints
uint8_t noteValue = notesNode[noteString].as<uint8_t>(); uint8_t noteValue = notesNode[noteString].as<uint8_t>();
uint32_t keyValue = keysNode[keyString].as<uint32_t>(); uint32_t keyValue = keysNode[keyString].as<uint32_t>();

View File

@@ -49,6 +49,67 @@ MainWindow::MainWindow(QWidget *parent) :
audio_->parameters()->set(ParamId::Osc1WaveSelector2, index); audio_->parameters()->set(ParamId::Osc1WaveSelector2, index);
}); });
// rogue sliders, TODO: clean these up in a package
connect(ui_->sliderMasterOctave, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::MasterOctaveOffset, value);
ui_->sliderMasterOctave->setResolution();
});
connect(ui_->sliderMasterSemitone, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::MasterSemitoneOffset, value);
ui_->sliderMasterSemitone->setResolution();
});
connect(ui_->sliderMasterPitch, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::MasterPitchOffset, value);
});
connect(ui_->sliderOsc1Octave, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc1OctaveOffset, value);
ui_->sliderOsc1Octave->setResolution();
});
connect(ui_->sliderOsc1Semitone, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc1SemitoneOffset, value);
ui_->sliderOsc1Semitone->setResolution();
});
connect(ui_->sliderOsc1Pitch, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc1PitchOffset, value);
});
connect(ui_->sliderOsc2Octave, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc2OctaveOffset, value);
ui_->sliderOsc2Octave->setResolution();
});
connect(ui_->sliderOsc2Semitone, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc2SemitoneOffset, value);
ui_->sliderOsc2Semitone->setResolution();
});
connect(ui_->sliderOsc2Pitch, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc2PitchOffset, value);
});
connect(ui_->sliderOsc3Octave, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc3OctaveOffset, value);
ui_->sliderOsc3Octave->setResolution();
});
connect(ui_->sliderOsc3Semitone, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc3SemitoneOffset, value);
ui_->sliderOsc3Semitone->setResolution();
});
connect(ui_->sliderOsc3Pitch, &SmartSlider::valueChanged,
this, [this](float value) {
audio_->parameters()->set(ParamId::Osc3PitchOffset, value);
});
// synth business // synth business
audio_->start(); audio_->start();
@@ -75,14 +136,59 @@ void MainWindow::onResetClicked() {
// initialize to defaults // initialize to defaults
config_.loadProfile("default"); YAML::Node configRoot = config_.loadProfile("default");
// update ui from the paramstore // update ui from the paramstore
ui_->envelopeOsc1Volume->init(EnvelopeId::Osc1Volume, config_.loadEnvProfile("default", "Osc1Volume")); ui_->envelopeOsc1Volume->init(EnvelopeId::Osc1Volume, config_.loadEnvProfile("default", "Osc1Volume"));
ui_->envelopeFilterCutoff->init(EnvelopeId::FilterCutoff, config_.loadEnvProfile("default", "FilterCutoff")); ui_->envelopeFilterCutoff->init(EnvelopeId::FilterCutoff, config_.loadEnvProfile("default", "FilterCutoff"));
ui_->envelopeFilterResonance->init(EnvelopeId::FilterResonance, config_.loadEnvProfile("default", "FilterResonance")); ui_->envelopeFilterResonance->init(EnvelopeId::FilterResonance, config_.loadEnvProfile("default", "FilterResonance"));
ui_->comboOsc1WaveSelector1->setCurrentIndex(static_cast<int>(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1WaveSelector1)].def)); // TODO: clean these up, maybe put them in a package like the envelope generators (it'll help encapsulate the int-snapping business)
ui_->comboOsc1WaveSelector2->setCurrentIndex(static_cast<int>(PARAM_DEFS[static_cast<size_t>(ParamId::Osc1WaveSelector2)].def)); ui_->sliderMasterOctave->setResolution(configRoot["MasterOctaveOffset"][2].as<int>() - configRoot["MasterOctaveOffset"][1].as<int>());
ui_->sliderMasterOctave->setRange(configRoot["MasterOctaveOffset"][1].as<int>(), configRoot["MasterOctaveOffset"][2].as<int>());
ui_->sliderMasterOctave->setValue(configRoot["MasterOctaveOffset"][0].as<int>());
ui_->sliderMasterSemitone->setResolution(configRoot["MasterSemitoneOffset"][2].as<int>() - configRoot["MasterSemitoneOffset"][1].as<int>());
ui_->sliderMasterSemitone->setRange(configRoot["MasterSemitoneOffset"][1].as<int>(), configRoot["MasterSemitoneOffset"][2].as<int>());
ui_->sliderMasterSemitone->setValue(configRoot["MasterSemitoneOffset"][0].as<int>());
ui_->sliderMasterPitch->setRange(configRoot["MasterPitchOffset"][1].as<float>(), configRoot["MasterPitchOffset"][2].as<float>());
ui_->sliderMasterPitch->setValue(configRoot["MasterPitchOffset"][0].as<float>());
ui_->sliderOsc1Octave->setResolution(configRoot["Osc1OctaveOffset"][2].as<int>() - configRoot["Osc1OctaveOffset"][1].as<int>());
ui_->sliderOsc1Octave->setRange(configRoot["Osc1OctaveOffset"][1].as<int>(), configRoot["Osc1OctaveOffset"][2].as<int>());
ui_->sliderOsc1Octave->setValue(configRoot["Osc1OctaveOffset"][0].as<int>());
ui_->sliderOsc1Semitone->setResolution(configRoot["Osc1SemitoneOffset"][2].as<int>() - configRoot["Osc1SemitoneOffset"][1].as<int>());
ui_->sliderOsc1Semitone->setRange(configRoot["Osc1SemitoneOffset"][1].as<int>(), configRoot["Osc1SemitoneOffset"][2].as<int>());
ui_->sliderOsc1Semitone->setValue(configRoot["Osc1SemitoneOffset"][0].as<int>());
ui_->sliderOsc1Pitch->setRange(configRoot["Osc1PitchOffset"][1].as<float>(), configRoot["Osc1PitchOffset"][2].as<float>());
ui_->sliderOsc1Pitch->setValue(configRoot["Osc1PitchOffset"][0].as<float>());
ui_->sliderOsc2Octave->setResolution(configRoot["Osc2OctaveOffset"][2].as<int>() - configRoot["Osc2OctaveOffset"][1].as<int>());
ui_->sliderOsc2Octave->setRange(configRoot["Osc2OctaveOffset"][1].as<int>(), configRoot["Osc2OctaveOffset"][2].as<int>());
ui_->sliderOsc2Octave->setValue(configRoot["Osc2OctaveOffset"][0].as<int>());
ui_->sliderOsc2Semitone->setResolution(configRoot["Osc2SemitoneOffset"][2].as<int>() - configRoot["Osc2SemitoneOffset"][1].as<int>());
ui_->sliderOsc2Semitone->setRange(configRoot["Osc2SemitoneOffset"][1].as<int>(), configRoot["Osc2SemitoneOffset"][2].as<int>());
ui_->sliderOsc2Semitone->setValue(configRoot["Osc2SemitoneOffset"][0].as<int>());
ui_->sliderOsc2Pitch->setRange(configRoot["Osc2PitchOffset"][1].as<float>(), configRoot["Osc2PitchOffset"][2].as<float>());
ui_->sliderOsc2Pitch->setValue(configRoot["Osc2PitchOffset"][0].as<float>());
ui_->sliderOsc3Octave->setResolution(configRoot["Osc3OctaveOffset"][2].as<int>() - configRoot["Osc3OctaveOffset"][1].as<int>());
ui_->sliderOsc3Octave->setRange(configRoot["Osc3OctaveOffset"][1].as<int>(), configRoot["Osc3OctaveOffset"][2].as<int>());
ui_->sliderOsc3Octave->setValue(configRoot["Osc3OctaveOffset"][0].as<int>());
ui_->sliderOsc3Semitone->setResolution(configRoot["Osc3SemitoneOffset"][2].as<int>() - configRoot["Osc3SemitoneOffset"][1].as<int>());
ui_->sliderOsc3Semitone->setRange(configRoot["Osc3SemitoneOffset"][1].as<int>(), configRoot["Osc3SemitoneOffset"][2].as<int>());
ui_->sliderOsc3Semitone->setValue(configRoot["Osc3SemitoneOffset"][0].as<int>());
ui_->sliderOsc3Pitch->setRange(configRoot["Osc3PitchOffset"][1].as<float>(), configRoot["Osc3PitchOffset"][2].as<float>());
ui_->sliderOsc3Pitch->setValue(configRoot["Osc3PitchOffset"][0].as<float>());
ui_->comboOsc1WaveSelector1->setCurrentIndex(configRoot["OscWaveSelector1"].as<int>());
ui_->comboOsc1WaveSelector2->setCurrentIndex(configRoot["OscWaveSelector2"].as<int>());
} }

View File

@@ -6,8 +6,8 @@
<rect> <rect>
<x>0</x> <x>0</x>
<y>0</y> <y>0</y>
<width>1102</width> <width>1100</width>
<height>564</height> <height>900</height>
</rect> </rect>
</property> </property>
<property name="windowTitle"> <property name="windowTitle">
@@ -261,6 +261,602 @@
<set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set> <set>Qt::AlignmentFlag::AlignRight|Qt::AlignmentFlag::AlignTrailing|Qt::AlignmentFlag::AlignVCenter</set>
</property> </property>
</widget> </widget>
<widget class="Line" name="line_3">
<property name="geometry">
<rect>
<x>340</x>
<y>880</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc1Semitone" native="true">
<property name="geometry">
<rect>
<x>410</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_8">
<property name="geometry">
<rect>
<x>490</x>
<y>580</y>
<width>41</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Pitch</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc1Octave" native="true">
<property name="geometry">
<rect>
<x>340</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_9">
<property name="geometry">
<rect>
<x>410</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Semitone</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line_4">
<property name="geometry">
<rect>
<x>340</x>
<y>600</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc1Pitch" native="true">
<property name="geometry">
<rect>
<x>480</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_6">
<property name="geometry">
<rect>
<x>340</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Octave</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_10">
<property name="geometry">
<rect>
<x>630</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Semitone</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line_5">
<property name="geometry">
<rect>
<x>560</x>
<y>600</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_7">
<property name="geometry">
<rect>
<x>560</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Octave</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line_6">
<property name="geometry">
<rect>
<x>560</x>
<y>880</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc2Semitone" native="true">
<property name="geometry">
<rect>
<x>630</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_11">
<property name="geometry">
<rect>
<x>710</x>
<y>580</y>
<width>41</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Pitch</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc2Octave" native="true">
<property name="geometry">
<rect>
<x>560</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc2Pitch" native="true">
<property name="geometry">
<rect>
<x>700</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc3Semitone" native="true">
<property name="geometry">
<rect>
<x>850</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc3Pitch" native="true">
<property name="geometry">
<rect>
<x>920</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_12">
<property name="geometry">
<rect>
<x>780</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Octave</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="SmartSlider" name="sliderOsc3Octave" native="true">
<property name="geometry">
<rect>
<x>780</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_13">
<property name="geometry">
<rect>
<x>930</x>
<y>580</y>
<width>41</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Pitch</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line_7">
<property name="geometry">
<rect>
<x>780</x>
<y>600</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="Line" name="line_8">
<property name="geometry">
<rect>
<x>780</x>
<y>880</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_14">
<property name="geometry">
<rect>
<x>850</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Semitone</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_15">
<property name="geometry">
<rect>
<x>390</x>
<y>567</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Oscillator 1</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_16">
<property name="geometry">
<rect>
<x>611</x>
<y>567</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Oscillator 2</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_17">
<property name="geometry">
<rect>
<x>830</x>
<y>569</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Oscillator 3</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="Line" name="line_9">
<property name="geometry">
<rect>
<x>120</x>
<y>880</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_18">
<property name="geometry">
<rect>
<x>170</x>
<y>567</y>
<width>111</width>
<height>20</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Master</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="QLabel" name="label_19">
<property name="geometry">
<rect>
<x>270</x>
<y>580</y>
<width>41</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Pitch</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="SmartSlider" name="sliderMasterOctave" native="true">
<property name="geometry">
<rect>
<x>120</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="SmartSlider" name="sliderMasterPitch" native="true">
<property name="geometry">
<rect>
<x>260</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="Line" name="line_10">
<property name="geometry">
<rect>
<x>120</x>
<y>600</y>
<width>211</width>
<height>20</height>
</rect>
</property>
<property name="orientation">
<enum>Qt::Orientation::Horizontal</enum>
</property>
</widget>
<widget class="QLabel" name="label_20">
<property name="geometry">
<rect>
<x>190</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Semitone</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
<widget class="SmartSlider" name="sliderMasterSemitone" native="true">
<property name="geometry">
<rect>
<x>190</x>
<y>610</y>
<width>65</width>
<height>280</height>
</rect>
</property>
<property name="autoFillBackground">
<bool>true</bool>
</property>
</widget>
<widget class="QLabel" name="label_21">
<property name="geometry">
<rect>
<x>120</x>
<y>580</y>
<width>71</width>
<height>31</height>
</rect>
</property>
<property name="font">
<font>
<pointsize>12</pointsize>
</font>
</property>
<property name="text">
<string>Octave</string>
</property>
<property name="alignment">
<set>Qt::AlignmentFlag::AlignCenter</set>
</property>
</widget>
</widget> </widget>
</widget> </widget>
<customwidgets> <customwidgets>
@@ -276,6 +872,12 @@
<header>Scope/Scope.h</header> <header>Scope/Scope.h</header>
<container>1</container> <container>1</container>
</customwidget> </customwidget>
<customwidget>
<class>SmartSlider</class>
<extends>QWidget</extends>
<header>SmartSlider/SmartSlider.h</header>
<container>1</container>
</customwidget>
</customwidgets> </customwidgets>
<resources/> <resources/>
<connections/> <connections/>

View File

@@ -75,24 +75,6 @@ void EnvelopeGenerator::emitEnvelope() {
); );
} }
void EnvelopeGenerator::init(EnvelopeId id) {
EnvelopeParam params = ENV_PARAMS[static_cast<size_t>(id)];
ui_->sliderDepth->setRange(PARAM_DEFS[static_cast<size_t>(params.depth)].min, PARAM_DEFS[static_cast<size_t>(params.depth)].max);
ui_->sliderAttack->setRange(PARAM_DEFS[static_cast<size_t>(params.a)].min, PARAM_DEFS[static_cast<size_t>(params.a)].max);
ui_->sliderDecay->setRange(PARAM_DEFS[static_cast<size_t>(params.d)].min, PARAM_DEFS[static_cast<size_t>(params.d)].max);
ui_->sliderSustain->setRange(PARAM_DEFS[static_cast<size_t>(params.s)].min, PARAM_DEFS[static_cast<size_t>(params.s)].max);
ui_->sliderRelease->setRange(PARAM_DEFS[static_cast<size_t>(params.r)].min, PARAM_DEFS[static_cast<size_t>(params.r)].max);
setDepth(PARAM_DEFS[static_cast<size_t>(params.depth)].def);
setAttack(PARAM_DEFS[static_cast<size_t>(params.a)].def);
setDecay(PARAM_DEFS[static_cast<size_t>(params.d)].def);
setSustain(PARAM_DEFS[static_cast<size_t>(params.s)].def);
setRelease(PARAM_DEFS[static_cast<size_t>(params.r)].def);
}
void EnvelopeGenerator::init(EnvelopeId id, std::array<ParamDefault, 5> profile) { void EnvelopeGenerator::init(EnvelopeId id, std::array<ParamDefault, 5> profile) {
EnvelopeParam params = ENV_PARAMS[static_cast<size_t>(id)]; EnvelopeParam params = ENV_PARAMS[static_cast<size_t>(id)];

View File

@@ -16,8 +16,7 @@ public:
explicit EnvelopeGenerator(QWidget* parent = nullptr); explicit EnvelopeGenerator(QWidget* parent = nullptr);
~EnvelopeGenerator(); ~EnvelopeGenerator();
// connects signals, sets parameters to the defaults defined in paramStore // connects signals, sets parameters to a provided profile
void init(EnvelopeId id);
void init(EnvelopeId id, std::array<ParamDefault, 5> profile); void init(EnvelopeId id, std::array<ParamDefault, 5> profile);
// setters // setters

View File

@@ -42,6 +42,7 @@ void SmartSlider::setRange(float min, float max) {
ui_->slider->setValue(sliderValue); ui_->slider->setValue(sliderValue);
ui_->spinValue->setValue(value); ui_->spinValue->setValue(value);
} }
// sets value of the slider and the spinBox, called by other classes // sets value of the slider and the spinBox, called by other classes
@@ -57,6 +58,10 @@ void SmartSlider::setValue(float value) {
emit valueChanged(value); emit valueChanged(value);
} }
void SmartSlider::setResolution(int resolution) {
sliderResolution_ = resolution;
}
float SmartSlider::value() { float SmartSlider::value() {
return ui_->spinValue->value(); return ui_->spinValue->value();
} }

View File

@@ -9,6 +9,7 @@ QT_END_NAMESPACE
// SmartSlider is the widget including a slider, min/max settings, and a value setting parameter // SmartSlider is the widget including a slider, min/max settings, and a value setting parameter
class SmartSlider : public QWidget { class SmartSlider : public QWidget {
Q_OBJECT Q_OBJECT
public: public:
@@ -18,6 +19,8 @@ public:
// setters // setters
void setRange(float min, float max); void setRange(float min, float max);
void setValue(float value); void setValue(float value);
void setResolution(int resolution);
void setResolution() { setResolution(static_cast<int>(max_ - min_)); }
// getters // getters
float value(); float value();

View File

@@ -19,6 +19,9 @@
<property name="windowTitle"> <property name="windowTitle">
<string>Form</string> <string>Form</string>
</property> </property>
<property name="isInt" stdset="0">
<bool>false</bool>
</property>
<widget class="QSlider" name="slider"> <widget class="QSlider" name="slider">
<property name="geometry"> <property name="geometry">
<rect> <rect>
@@ -62,6 +65,12 @@
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property> </property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
<property name="maximum">
<double>100000.000000000000000</double>
</property>
</widget> </widget>
<widget class="QDoubleSpinBox" name="spinMax"> <widget class="QDoubleSpinBox" name="spinMax">
<property name="geometry"> <property name="geometry">
@@ -84,8 +93,11 @@
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property> </property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
<property name="maximum"> <property name="maximum">
<double>40000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="QDoubleSpinBox" name="spinValue"> <widget class="QDoubleSpinBox" name="spinValue">
@@ -117,8 +129,11 @@
<property name="buttonSymbols"> <property name="buttonSymbols">
<enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum> <enum>QAbstractSpinBox::ButtonSymbols::NoButtons</enum>
</property> </property>
<property name="minimum">
<double>-100000.000000000000000</double>
</property>
<property name="maximum"> <property name="maximum">
<double>80000.000000000000000</double> <double>100000.000000000000000</double>
</property> </property>
</widget> </widget>
<widget class="Line" name="line"> <widget class="Line" name="line">