From 9ef6b3cf96e3ac652b60f1b18c29413184891ff9 Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 17 Dec 2024 22:05:24 +0800 Subject: [PATCH 01/27] well it compiles. does't work but its a start --- src/surge-fx/SurgeFXEditor.cpp | 63 +++++++++++++++++----------------- src/surge-fx/SurgeFXEditor.h | 4 +-- 2 files changed, 34 insertions(+), 33 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index cab1172de30..b8b88e89e5f 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -134,27 +134,28 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { - fxParamSliders[i].setRange(0.0, 1.0, 0.0001); - fxParamSliders[i].setValue(processor.getFXStorageValue01(i), - juce::NotificationType::dontSendNotification); - fxParamSliders[i].setSliderStyle(juce::Slider::SliderStyle::RotaryHorizontalVerticalDrag); - fxParamSliders[i].setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, - 0); - fxParamSliders[i].setChangeNotificationOnlyOnRelease(false); - fxParamSliders[i].setEnabled(processor.getParamEnabled(i)); - fxParamSliders[i].onValueChange = [i, this]() { - this->processor.prepareParametersAbsentAudio(); - this->processor.setFXParamValue01(i, this->fxParamSliders[i].getValue()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); - fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); - }; - fxParamSliders[i].onDragStart = [i, this]() { - this->processor.setUserEditingFXParam(i, true); - }; - fxParamSliders[i].onDragEnd = [i, this]() { - this->processor.setUserEditingFXParam(i, false); - }; + // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); + // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), + // juce::NotificationType::dontSendNotification); + // + // fxParamSliders[i].setSliderStyle(juce::Slider::SliderStyle::RotaryHorizontalVerticalDrag); + // fxParamSliders[i].setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, + // 0); + // fxParamSliders[i].setChangeNotificationOnlyOnRelease(false); + // fxParamSliders[i].setEnabled(processor.getParamEnabled(i)); + // fxParamSliders[i].onValueChange = [i, this]() { + // this->processor.prepareParametersAbsentAudio(); + // this->processor.setFXParamValue01(i, this->fxParamSliders[i].getValue()); + // fxParamDisplay[i].setDisplay( + // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); + // }; + // fxParamSliders[i].onDragStart = [i, this]() { + // this->processor.setUserEditingFXParam(i, true); + // }; + // fxParamSliders[i].onDragEnd = [i, this]() { + // this->processor.setUserEditingFXParam(i, false); + // }; fxParamSliders[i].setTitle("Parameter " + std::to_string(i) + " Knob"); addAndMakeVisibleRecordOrder(&(fxParamSliders[i])); @@ -167,8 +168,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamTempoSync(i, this->fxTempoSync[i].getToggleState()); this->processor.setFXStorageTempoSync(i, this->fxTempoSync[i].getToggleState()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + // fxParamDisplay[i].setDisplay( + // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); this->processor.setUserEditingParamFeature(i, false); }; @@ -200,8 +201,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamExtended(i, this->fxExtended[i].getToggleState()); this->processor.setFXStorageExtended(i, this->fxExtended[i].getToggleState()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + // fxParamDisplay[i].setDisplay( + // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); @@ -216,8 +217,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamAbsolute(i, this->fxAbsoluted[i].getToggleState()); this->processor.setFXStorageAbsolute(i, this->fxAbsoluted[i].getToggleState()); - fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + // fxParamDisplay[i].setDisplay( + // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); this->processor.setUserEditingParamFeature(i, false); }; @@ -285,8 +286,8 @@ void SurgefxAudioProcessorEditor::resetLabels() for (int i = 0; i < n_fx_params; ++i) { auto nm = processor.getParamName(i) + " " + processor.getParamGroup(i); - fxParamSliders[i].setValue(processor.getFXStorageValue01(i), - juce::NotificationType::dontSendNotification); + // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), + // juce::NotificationType::dontSendNotification); fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); fxParamDisplay[i].setName(processor.getParamName(i).c_str()); @@ -297,7 +298,7 @@ void SurgefxAudioProcessorEditor::resetLabels() fxParamSliders[i].setEnabled(processor.getParamEnabled(i) && !processor.getFXStorageAppearsDeactivated(i)); st(fxParamSliders[i], nm + " Knob"); - fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); + // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); fxTempoSync[i].setEnabled(processor.canTempoSync(i)); fxTempoSync[i].setAccessible(processor.canTempoSync(i)); @@ -353,7 +354,7 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { - fxParamSliders[i].setValue(fv[i], juce::NotificationType::dontSendNotification); + // fxParamSliders[i].setValue(fv[i], juce::NotificationType::dontSendNotification); fxParamDisplay[i].setDisplay(processor.getParamValueFor(i, fv[i])); } else diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 65e033e6b2d..9760057eeb2 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -27,7 +27,7 @@ #include "SurgeLookAndFeel.h" #include "juce_gui_basics/juce_gui_basics.h" - +#include "sst/jucegui/components/Knob.h" //============================================================================== /** */ @@ -159,7 +159,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, return false; } }; - AccSlider fxParamSliders[n_fx_params]; + sst::jucegui::components::Knob fxParamSliders[n_fx_params]; SurgeFXParamDisplay fxParamDisplay[n_fx_params]; SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; SurgeTempoSyncSwitch fxDeactivated[n_fx_params]; From 1a1b04f07aa7721e8e34e52efe6120c9a87d55b0 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 27 Dec 2024 12:30:24 +0800 Subject: [PATCH 02/27] added the contModParam and added another array --- src/surge-fx/SurgeFXContModParam.h | 42 ++++++++++++++++++++++++++++++ src/surge-fx/SurgeFXEditor.cpp | 12 +++++++++ src/surge-fx/SurgeFXEditor.h | 3 +++ 3 files changed, 57 insertions(+) create mode 100644 src/surge-fx/SurgeFXContModParam.h diff --git a/src/surge-fx/SurgeFXContModParam.h b/src/surge-fx/SurgeFXContModParam.h new file mode 100644 index 00000000000..f36a903d33e --- /dev/null +++ b/src/surge-fx/SurgeFXContModParam.h @@ -0,0 +1,42 @@ +#pragma once // this doesn't seem like the norm in this repo but still a wip + +#include +#include +#include +#include + +struct SurgeFXContModParam : sst::jucegui::data::ContinuousModulatable +{ + SurgeFXContModParam(std::string label = "leo") { label = label; }; + + std::string label{"default"}; + std::string getLabel() const override { return label; } + + float value{0}; + float min{0}, max{1}; + float mv{0.2}; + + float getValue() const override { return value; } + float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; } + void setValueFromGUI(const float &f) override + { + value = f; + for (auto *l : guilisteners) + l->dataChanged(); + for (auto *l : modellisteners) + l->dataChanged(); + } + void setValueFromModel(const float &f) override + { + value = f; + for (auto *l : guilisteners) + l->dataChanged(); + } + + float getMin() const override { return min; } + float getMax() const override { return max; } + + float getModulationValuePM1() const override { return mv; } + void setModulationValuePM1(const float &f) override { mv = f; } + bool isModulationBipolar() const override { return isBipolar(); } // sure why not +}; \ No newline at end of file diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index b8b88e89e5f..81b4ae144cc 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -134,6 +134,18 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { + + // auto k = std::make_unique(); + // auto d = std::make_unique(); + // k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); + // k->setEditingModulation(true); + + fxParamSliders[i].setModulationDisplay( + sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); + fxParamSliders[i].setEditingModulation(true); + + fxParamSources[i].setValueFromGUI(0.5f); + fxParamSliders[i].setSource(&fxParamSources[i]); // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), // juce::NotificationType::dontSendNotification); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 9760057eeb2..a48bb803778 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -25,6 +25,7 @@ #include "SurgeFXProcessor.h" #include "SurgeLookAndFeel.h" +#include "SurgeFXContModParam.h" #include "juce_gui_basics/juce_gui_basics.h" #include "sst/jucegui/components/Knob.h" @@ -160,6 +161,8 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, } }; sst::jucegui::components::Knob fxParamSliders[n_fx_params]; + SurgeFXContModParam fxParamSources[n_fx_params]; + SurgeFXParamDisplay fxParamDisplay[n_fx_params]; SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; SurgeTempoSyncSwitch fxDeactivated[n_fx_params]; From 3c8fc328122e5c168d41a33a6264a4aa83648a21 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 27 Dec 2024 23:24:34 +0800 Subject: [PATCH 03/27] temp commit --- src/surge-fx/SurgeFXContModParam.h | 13 +++++------- src/surge-fx/SurgeFXEditor.cpp | 33 ++++++++++++++++++++---------- src/surge-fx/SurgeFXEditor.h | 2 +- 3 files changed, 28 insertions(+), 20 deletions(-) diff --git a/src/surge-fx/SurgeFXContModParam.h b/src/surge-fx/SurgeFXContModParam.h index f36a903d33e..3167b2eba53 100644 --- a/src/surge-fx/SurgeFXContModParam.h +++ b/src/surge-fx/SurgeFXContModParam.h @@ -5,17 +5,12 @@ #include #include -struct SurgeFXContModParam : sst::jucegui::data::ContinuousModulatable +struct ConcreteCM : sst::jucegui::data::ContinuousModulatable { - SurgeFXContModParam(std::string label = "leo") { label = label; }; - - std::string label{"default"}; + ConcreteCM() {}; + std::string label{"A Knob"}; std::string getLabel() const override { return label; } - float value{0}; - float min{0}, max{1}; - float mv{0.2}; - float getValue() const override { return value; } float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; } void setValueFromGUI(const float &f) override @@ -33,9 +28,11 @@ struct SurgeFXContModParam : sst::jucegui::data::ContinuousModulatable l->dataChanged(); } + float min{0}, max{1}; float getMin() const override { return min; } float getMax() const override { return max; } + float mv{0.2}; float getModulationValuePM1() const override { return mv; } void setModulationValuePM1(const float &f) override { mv = f; } bool isModulationBipolar() const override { return isBipolar(); } // sure why not diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 81b4ae144cc..27364a56748 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -139,13 +139,16 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & // auto d = std::make_unique(); // k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); // k->setEditingModulation(true); - + // fxParamSliders[i] = sst::jucegui::components::Knob(); fxParamSliders[i].setModulationDisplay( - sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); - fxParamSliders[i].setEditingModulation(true); + sst::jucegui::components::Knob::Modulatable::FROM_OTHER); + // fxParamSliders[i].setEditingModulation(true); - fxParamSources[i].setValueFromGUI(0.5f); + // fxParamSources[i] = SurgeFXContModParam(); + // fxParamSources[i].setValueFromGUI(0.5f); fxParamSliders[i].setSource(&fxParamSources[i]); + + std::cout << fxParamSources[i].getLabel() << std::endl; // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), // juce::NotificationType::dontSendNotification); @@ -169,7 +172,11 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & // this->processor.setUserEditingFXParam(i, false); // }; fxParamSliders[i].setTitle("Parameter " + std::to_string(i) + " Knob"); - addAndMakeVisibleRecordOrder(&(fxParamSliders[i])); + + fxParamSliders[i].onBeginEdit = [this, i]() { std::cout << "startEdit" << std::endl; }; + fxParamSliders[i].onEndEdit = []() { DBGOUT("endEdit"); }; + // addAndMakeVisibleRecordOrder(&(fxParamSliders[i])); + addAndMakeVisible(&(fxParamSliders[i])); fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); @@ -186,7 +193,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & }; fxTempoSync[i].setTitle("Parameter " + std::to_string(i) + " TempoSync"); - addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); + // addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); fxDeactivated[i].setOnOffImage(BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize, BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize); @@ -202,7 +209,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, false); }; fxDeactivated[i].setTitle("Parameter " + std::to_string(i) + " Deactivate"); - addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); + // addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); fxExtended[i].setOnOffImage(BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize, BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize); @@ -218,7 +225,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); - addAndMakeVisibleRecordOrder(&(fxExtended[i])); + // addAndMakeVisibleRecordOrder(&(fxExtended[i])); fxAbsoluted[i].setOnOffImage(BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize, BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize); @@ -229,13 +236,14 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamAbsolute(i, this->fxAbsoluted[i].getToggleState()); this->processor.setFXStorageAbsolute(i, this->fxAbsoluted[i].getToggleState()); + // fxParamDisplay[i].setDisplay( // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); this->processor.setUserEditingParamFeature(i, false); }; fxAbsoluted[i].setTitle("Parameter " + std::to_string(i) + " Absoluted"); - addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); + // addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); processor.prepareParametersAbsentAudio(); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); @@ -246,14 +254,14 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & processor.setParameterByString(i, s); }; - addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); + // addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); } fxNameLabel = std::make_unique("fxlabel", "Surge XT Effects"); fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setColour(juce::Label::textColourId, juce::Colours::black); fxNameLabel->setJustificationType(juce::Justification::centredLeft); - addAndMakeVisibleRecordOrder(fxNameLabel.get()); + // addAndMakeVisibleRecordOrder(fxNameLabel.get()); this->processor.setParameterChangeListener([this]() { this->triggerAsyncUpdate(); }); @@ -366,6 +374,9 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { + + // fxParamSources[i].setValueFromGUI(fv[i]); + // fxParamSliders[i].setValue(fv[i], juce::NotificationType::dontSendNotification); fxParamDisplay[i].setDisplay(processor.getParamValueFor(i, fv[i])); } diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index a48bb803778..5c819abbebe 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -161,7 +161,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, } }; sst::jucegui::components::Knob fxParamSliders[n_fx_params]; - SurgeFXContModParam fxParamSources[n_fx_params]; + ConcreteCM fxParamSources[n_fx_params]; SurgeFXParamDisplay fxParamDisplay[n_fx_params]; SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; From 6743c694f264effd938ab838f819fdb551924691 Mon Sep 17 00:00:00 2001 From: yoshih Date: Fri, 27 Dec 2024 23:37:32 +0800 Subject: [PATCH 04/27] switch to std::vector --- src/surge-fx/SurgeFXEditor.cpp | 59 ++++++++++++++++++++++------------ src/surge-fx/SurgeFXEditor.h | 3 ++ 2 files changed, 41 insertions(+), 21 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 27364a56748..626921b0797 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -138,18 +138,18 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & // auto k = std::make_unique(); // auto d = std::make_unique(); // k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); - // k->setEditingModulation(true); - // fxParamSliders[i] = sst::jucegui::components::Knob(); - fxParamSliders[i].setModulationDisplay( - sst::jucegui::components::Knob::Modulatable::FROM_OTHER); - // fxParamSliders[i].setEditingModulation(true); - - // fxParamSources[i] = SurgeFXContModParam(); - // fxParamSources[i].setValueFromGUI(0.5f); - fxParamSliders[i].setSource(&fxParamSources[i]); - - std::cout << fxParamSources[i].getLabel() << std::endl; - // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); + // // k->setEditingModulation(true); + // // fxParamSliders[i] = sst::jucegui::components::Knob(); + // fxParamSliders[i].setModulationDisplay( + // sst::jucegui::components::Knob::Modulatable::FROM_OTHER); + // // fxParamSliders[i].setEditingModulation(true); + + // // fxParamSources[i] = SurgeFXContModParam(); + // // fxParamSources[i].setValueFromGUI(0.5f); + // fxParamSliders[i].setSource(&fxParamSources[i]); + + // std::cout << fxParamSources[i].getLabel() << std::endl; + // // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), // juce::NotificationType::dontSendNotification); // @@ -170,13 +170,29 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & // }; // fxParamSliders[i].onDragEnd = [i, this]() { // this->processor.setUserEditingFXParam(i, false); - // }; - fxParamSliders[i].setTitle("Parameter " + std::to_string(i) + " Knob"); + // // }; + // fxParamSliders[i].setTitle("Parameter " + std::to_string(i) + " Knob"); - fxParamSliders[i].onBeginEdit = [this, i]() { std::cout << "startEdit" << std::endl; }; - fxParamSliders[i].onEndEdit = []() { DBGOUT("endEdit"); }; + // fxParamSliders[i].onBeginEdit = [this, i]() { std::cout << "startEdit" << std::endl; }; + // fxParamSliders[i].onEndEdit = []() { DBGOUT("endEdit"); }; // addAndMakeVisibleRecordOrder(&(fxParamSliders[i])); - addAndMakeVisible(&(fxParamSliders[i])); + + auto k = std::make_unique(); + auto d = std::make_unique(); + + k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); + k->setEditingModulation(true); + + d->setValueFromGUI(1.0 * (rand() % 18502) / 18502.f); + k->setSource(d.get()); + k->onBeginEdit = []() { DBGOUT("beginEdit"); }; + k->onEndEdit = []() { DBGOUT("endEdit"); }; + k->onPopupMenu = [](const auto &m) { DBGOUT("popupMenu"); }; + addAndMakeVisible(*k); + knobs.push_back(std::move(k)); + sources.push_back(std::move(d)); + + // addAndMakeVisible(&(fxParamSliders[i])); fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); @@ -315,8 +331,8 @@ void SurgefxAudioProcessorEditor::resetLabels() fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); - fxParamSliders[i].setEnabled(processor.getParamEnabled(i) && - !processor.getFXStorageAppearsDeactivated(i)); + // fxParamSliders[i].setEnabled(processor.getParamEnabled(i) && + // !processor.getFXStorageAppearsDeactivated(i)); st(fxParamSliders[i], nm + " Knob"); // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); @@ -413,8 +429,9 @@ void SurgefxAudioProcessorEditor::resized() juce::Rectangle position{(i / 6) * getWidth() / 2 + sliderOff, (i % 6) * rowHeight + ypos0, rowHeight - sliderOff, rowHeight - sliderOff}; - fxParamSliders[i].setBounds(position); - + // fxParamSliders[i].setBounds(position); + knobs.at(i).get()->setBounds(position); + // knobs.at(i).get()->setOpaque(true); int buttonSize = 19; if (getWidth() < baseWidth) buttonSize = 17; diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 5c819abbebe..6396e2b55de 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -106,6 +106,9 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, static constexpr int baseWidth = 600, baseHeight = 55 * 6 + 80 + topSection; + std::vector> knobs; + std::vector> sources; + private: struct AccSlider : public juce::Slider { From fc01f28ebf436ee96b620db9b4d79f4ba7a7ddca Mon Sep 17 00:00:00 2001 From: yoshih Date: Sat, 28 Dec 2024 00:14:29 +0800 Subject: [PATCH 05/27] cleanup --- src/surge-fx/SurgeFXContModParam.h | 39 -------------------- src/surge-fx/SurgeFXEditor.cpp | 59 ++++-------------------------- src/surge-fx/SurgeFXEditor.h | 6 +-- 3 files changed, 10 insertions(+), 94 deletions(-) delete mode 100644 src/surge-fx/SurgeFXContModParam.h diff --git a/src/surge-fx/SurgeFXContModParam.h b/src/surge-fx/SurgeFXContModParam.h deleted file mode 100644 index 3167b2eba53..00000000000 --- a/src/surge-fx/SurgeFXContModParam.h +++ /dev/null @@ -1,39 +0,0 @@ -#pragma once // this doesn't seem like the norm in this repo but still a wip - -#include -#include -#include -#include - -struct ConcreteCM : sst::jucegui::data::ContinuousModulatable -{ - ConcreteCM() {}; - std::string label{"A Knob"}; - std::string getLabel() const override { return label; } - float value{0}; - float getValue() const override { return value; } - float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; } - void setValueFromGUI(const float &f) override - { - value = f; - for (auto *l : guilisteners) - l->dataChanged(); - for (auto *l : modellisteners) - l->dataChanged(); - } - void setValueFromModel(const float &f) override - { - value = f; - for (auto *l : guilisteners) - l->dataChanged(); - } - - float min{0}, max{1}; - float getMin() const override { return min; } - float getMax() const override { return max; } - - float mv{0.2}; - float getModulationValuePM1() const override { return mv; } - void setModulationValuePM1(const float &f) override { mv = f; } - bool isModulationBipolar() const override { return isBipolar(); } // sure why not -}; \ No newline at end of file diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 626921b0797..955c83da293 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -134,49 +134,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { - - // auto k = std::make_unique(); - // auto d = std::make_unique(); - // k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); - // // k->setEditingModulation(true); - // // fxParamSliders[i] = sst::jucegui::components::Knob(); - // fxParamSliders[i].setModulationDisplay( - // sst::jucegui::components::Knob::Modulatable::FROM_OTHER); - // // fxParamSliders[i].setEditingModulation(true); - - // // fxParamSources[i] = SurgeFXContModParam(); - // // fxParamSources[i].setValueFromGUI(0.5f); - // fxParamSliders[i].setSource(&fxParamSources[i]); - - // std::cout << fxParamSources[i].getLabel() << std::endl; - // // fxParamSliders[i].setRange(0.0, 1.0, 0.0001); - // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), - // juce::NotificationType::dontSendNotification); - // - // fxParamSliders[i].setSliderStyle(juce::Slider::SliderStyle::RotaryHorizontalVerticalDrag); - // fxParamSliders[i].setTextBoxStyle(juce::Slider::TextEntryBoxPosition::NoTextBox, true, 0, - // 0); - // fxParamSliders[i].setChangeNotificationOnlyOnRelease(false); - // fxParamSliders[i].setEnabled(processor.getParamEnabled(i)); - // fxParamSliders[i].onValueChange = [i, this]() { - // this->processor.prepareParametersAbsentAudio(); - // this->processor.setFXParamValue01(i, this->fxParamSliders[i].getValue()); - // fxParamDisplay[i].setDisplay( - // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); - // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); - // }; - // fxParamSliders[i].onDragStart = [i, this]() { - // this->processor.setUserEditingFXParam(i, true); - // }; - // fxParamSliders[i].onDragEnd = [i, this]() { - // this->processor.setUserEditingFXParam(i, false); - // // }; - // fxParamSliders[i].setTitle("Parameter " + std::to_string(i) + " Knob"); - - // fxParamSliders[i].onBeginEdit = [this, i]() { std::cout << "startEdit" << std::endl; }; - // fxParamSliders[i].onEndEdit = []() { DBGOUT("endEdit"); }; - // addAndMakeVisibleRecordOrder(&(fxParamSliders[i])); - auto k = std::make_unique(); auto d = std::make_unique(); @@ -192,8 +149,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & knobs.push_back(std::move(k)); sources.push_back(std::move(d)); - // addAndMakeVisible(&(fxParamSliders[i])); - fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); fxTempoSync[i].setEnabled(processor.canTempoSync(i)); @@ -209,7 +164,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & }; fxTempoSync[i].setTitle("Parameter " + std::to_string(i) + " TempoSync"); - // addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); + addAndMakeVisibleRecordOrder(&(fxTempoSync[i])); fxDeactivated[i].setOnOffImage(BinaryData::DE_Act_svg, BinaryData::DE_Act_svgSize, BinaryData::DE_Deact_svg, BinaryData::DE_Deact_svgSize); @@ -225,7 +180,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, false); }; fxDeactivated[i].setTitle("Parameter " + std::to_string(i) + " Deactivate"); - // addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); + addAndMakeVisibleRecordOrder(&(fxDeactivated[i])); fxExtended[i].setOnOffImage(BinaryData::EX_Act_svg, BinaryData::EX_Act_svgSize, BinaryData::EX_Deact_svg, BinaryData::EX_Deact_svgSize); @@ -241,7 +196,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); - // addAndMakeVisibleRecordOrder(&(fxExtended[i])); + addAndMakeVisibleRecordOrder(&(fxExtended[i])); fxAbsoluted[i].setOnOffImage(BinaryData::AB_Act_svg, BinaryData::AB_Act_svgSize, BinaryData::AB_Deact_svg, BinaryData::AB_Deact_svgSize); @@ -259,7 +214,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & }; fxAbsoluted[i].setTitle("Parameter " + std::to_string(i) + " Absoluted"); - // addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); + addAndMakeVisibleRecordOrder(&(fxAbsoluted[i])); processor.prepareParametersAbsentAudio(); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); @@ -270,14 +225,14 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & processor.setParameterByString(i, s); }; - // addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); + addAndMakeVisibleRecordOrder(&(fxParamDisplay[i])); } fxNameLabel = std::make_unique("fxlabel", "Surge XT Effects"); fxNameLabel->setFont(juce::FontOptions(28)); fxNameLabel->setColour(juce::Label::textColourId, juce::Colours::black); fxNameLabel->setJustificationType(juce::Justification::centredLeft); - // addAndMakeVisibleRecordOrder(fxNameLabel.get()); + addAndMakeVisibleRecordOrder(fxNameLabel.get()); this->processor.setParameterChangeListener([this]() { this->triggerAsyncUpdate(); }); @@ -333,7 +288,7 @@ void SurgefxAudioProcessorEditor::resetLabels() fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); // fxParamSliders[i].setEnabled(processor.getParamEnabled(i) && // !processor.getFXStorageAppearsDeactivated(i)); - st(fxParamSliders[i], nm + " Knob"); + // st(fxParamSliders[i], nm + " Knob"); // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); fxTempoSync[i].setEnabled(processor.canTempoSync(i)); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 6396e2b55de..e2124dbedb8 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -25,7 +25,7 @@ #include "SurgeFXProcessor.h" #include "SurgeLookAndFeel.h" -#include "SurgeFXContModParam.h" +#include "KnobSource.h" #include "juce_gui_basics/juce_gui_basics.h" #include "sst/jucegui/components/Knob.h" @@ -163,8 +163,8 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, return false; } }; - sst::jucegui::components::Knob fxParamSliders[n_fx_params]; - ConcreteCM fxParamSources[n_fx_params]; + // sst::jucegui::components::Knob fxParamSliders[n_fx_params]; + // ConcreteCM fxParamSources[n_fx_params]; SurgeFXParamDisplay fxParamDisplay[n_fx_params]; SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; From 54ce67cde2746252c5e14cb2ce4e3a94ac244221 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sat, 28 Dec 2024 00:14:36 +0800 Subject: [PATCH 06/27] cleanup --- src/surge-fx/KnobSource.h | 39 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) create mode 100644 src/surge-fx/KnobSource.h diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h new file mode 100644 index 00000000000..3167b2eba53 --- /dev/null +++ b/src/surge-fx/KnobSource.h @@ -0,0 +1,39 @@ +#pragma once // this doesn't seem like the norm in this repo but still a wip + +#include +#include +#include +#include + +struct ConcreteCM : sst::jucegui::data::ContinuousModulatable +{ + ConcreteCM() {}; + std::string label{"A Knob"}; + std::string getLabel() const override { return label; } + float value{0}; + float getValue() const override { return value; } + float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; } + void setValueFromGUI(const float &f) override + { + value = f; + for (auto *l : guilisteners) + l->dataChanged(); + for (auto *l : modellisteners) + l->dataChanged(); + } + void setValueFromModel(const float &f) override + { + value = f; + for (auto *l : guilisteners) + l->dataChanged(); + } + + float min{0}, max{1}; + float getMin() const override { return min; } + float getMax() const override { return max; } + + float mv{0.2}; + float getModulationValuePM1() const override { return mv; } + void setModulationValuePM1(const float &f) override { mv = f; } + bool isModulationBipolar() const override { return isBipolar(); } // sure why not +}; \ No newline at end of file From 0ce80dc9dc550d33fe16accd68d474ddf4f03775 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 00:07:13 +0800 Subject: [PATCH 07/27] more copy pasta --- src/surge-fx/KnobSource.h | 300 ++++++++++++++++++++++++++++++++- src/surge-fx/SurgeFXEditor.cpp | 10 +- 2 files changed, 308 insertions(+), 2 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 3167b2eba53..7e46fa741fe 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -2,9 +2,13 @@ #include #include -#include +// #include #include +#include +#include +#include + struct ConcreteCM : sst::jucegui::data::ContinuousModulatable { ConcreteCM() {}; @@ -36,4 +40,298 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable float getModulationValuePM1() const override { return mv; } void setModulationValuePM1(const float &f) override { mv = f; } bool isModulationBipolar() const override { return isBipolar(); } // sure why not +}; + +struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet +{ + StyleSheetBuiltInImpl() {} + ~StyleSheetBuiltInImpl() {} + + std::unordered_map> colours; + std::unordered_map> fonts; + void setColour(const StyleSheet::Class &c, const StyleSheet::Property &p, + const juce::Colour &col) override + { + jassert(isValidPair(c, p)); + colours[c.cname][p.pname] = col; + } + void setFont(const StyleSheet::Class &c, const StyleSheet::Property &p, + const juce::Font &f) override + { + jassert(isValidPair(c, p)); + +#if defined(_MSC_VER) +#pragma warning(push) +#pragma warning(disable : 4996) +#endif + + fonts[c.cname][p.pname] = f; + +#if defined(_MSC_VER) +#pragma warning(pop) +#endif + } + + void replaceFontsWithTypeface(const juce::Typeface::Ptr &p) override + { + for (auto &[cn, propFonts] : fonts) + { + for (auto &[pn, f] : propFonts) + { + auto nf = SST_JUCE_FONT_CTOR(p); + nf.setHeight(f.getHeight()); + f = nf; + } + } + } + void replaceFontsWithFamily(const juce::String familyName) override { assert(false); } + + bool hasColour(const Class &c, const Property &p) const override + { + assert(p.type == Property::COLOUR); + auto byC = colours.find(c.cname); + if (byC != colours.end()) + { + auto byP = byC->second.find(p.pname); + if (byP != byC->second.end()) + return true; + } + return false; + } + + juce::Colour getColour(const Class &c, const Property &p) const override + { + auto r = getColourOptional(c, p); + if (r.has_value()) + return *r; + + std::cout << __FILE__ << ":" << __LINE__ << " COLOUR Missing : " << c.cname + << "::" << p.pname << std::endl; + return juce::Colours::red; + } + + std::optional getColourOptional(const Class &c, const Property &p) const override + { + assert(p.type == Property::COLOUR); + auto byC = colours.find(c.cname); + if (byC != colours.end()) + { + auto byP = byC->second.find(p.pname); + if (byP != byC->second.end()) + { + jassert(isValidPair(c, p)); + + return byP->second; + } + } + + auto parC = inheritFromTo.find(c.cname); + if (parC != inheritFromTo.end()) + { + for (const auto &k : parC->second) + { + auto sub = getColourOptional({k.c_str()}, p); + if (sub.has_value()) + return sub; + } + } + return std::nullopt; + } + + bool hasFont(const Class &c, const Property &p) const override + { + assert(p.type == Property::FONT); + auto byC = fonts.find(c.cname); + if (byC != fonts.end()) + { + auto byP = byC->second.find(p.pname); + if (byP != byC->second.end()) + return true; + } + return false; + } + + juce::Font getFont(const Class &c, const Property &p) const override + { + auto r = getFontOptional(c, p); + if (r.has_value()) + return *r; + + std::cout << __FILE__ << ":" << __LINE__ << " FONT Missing : " << c.cname << "::" << p.pname + << std::endl; + return SST_JUCE_FONT_CTOR(36, juce::Font::italic); + } + std::optional getFontOptional(const Class &c, const Property &p) const override + { + assert(p.type == Property::FONT); + auto byC = fonts.find(c.cname); + if (byC != fonts.end()) + { + auto byP = byC->second.find(p.pname); + if (byP != byC->second.end()) + { + jassert(isValidPair(c, p)); + return byP->second; + } + } + + auto parC = inheritFromTo.find(c.cname); + if (parC != inheritFromTo.end()) + { + for (const auto &k : parC->second) + { + auto q = getFontOptional({k.c_str()}, p); + if (q.has_value()) + return *q; + } + } + + return std::nullopt; + } +}; + +struct KnobStyleSheet : public StyleSheetBuiltInImpl +{ + bool initialized{false}; + KnobStyleSheet() {} + void initialize() + { + if (initialized) + return; + + initialized = true; + + { + using n = sst::jucegui::components::base_styles::Base; + setColour(n::styleClass, n::background, juce::Colour(0x25, 0x25, 0x28)); + } + + { + using n = sst::jucegui::components::base_styles::SelectableRegion; + setColour(n::styleClass, n::backgroundSelected, juce::Colour(0x45, 0x45, 0x48)); + } + + { + using n = sst::jucegui::components::base_styles::Outlined; + setColour(n::styleClass, n::outline, juce::Colour(0x50, 0x50, 0x50)); + setColour(n::styleClass, n::brightoutline, juce::Colour(0x70, 0x70, 0x70)); + } + + { + using n = sst::jucegui::components::base_styles::BaseLabel; + setColour(n::styleClass, n::labelcolor, juce::Colour(220, 220, 220)); + setColour(n::styleClass, n::labelcolor_hover, juce::Colour(240, 240, 235)); + setFont(n::styleClass, n::labelfont, SST_JUCE_FONT_CTOR(13)); + } + + // { + // using n = sst::jucegui::components::NamedPanel::Styles; + // setColour(n::styleClass, n::labelrule, juce::Colour(0x70, 0x70, 0x70)); + // setColour(n::styleClass, n::selectedtab, juce::Colour(0xFF, 0x90, 00)); + // setColour(n::styleClass, n::accentedPanel, juce::Colour(0xFF, 0x90, 00)); + // } + + // { + // using w = sst::jucegui::components::WindowPanel::Styles; + // setColour(w::styleClass, w::bgstart, juce::Colour(0x3B, 0x3D, 0x40)); + // setColour(w::styleClass, w::bgend, juce::Colour(0x1B, 0x1D, 0x20)); + // } + + // { + // using n = sst::jucegui::components::base_styles::PushButton; + // setColour(n::styleClass, n::fill, juce::Colour(0x60, 0x60, 0x60)); + // setColour(n::styleClass, n::fill_hover, juce::Colour(0x90, 0x85, 0x83)); + // setColour(n::styleClass, n::fill_pressed, juce::Colour(0x80, 0x80, 0x80)); + // } + + // { + // using n = sst::jucegui::components::MenuButton::Styles; + // setColour(n::styleClass, n::menuarrow_hover, juce::Colour(0xFF, 0x90, 0x00)); + // } + + // { + // using n = sst::jucegui::components::JogUpDownButton::Styles; + // setColour(n::styleClass, n::jogbutton_hover, juce::Colour(0xFF, 0x90, 0x00)); + // } + + // { + // using n = sst::jucegui::components::base_styles::ValueBearing; + // setColour(n::styleClass, n::value, juce::Colour(0xFF, 0x90, 0x00)); + // setColour(n::styleClass, n::value_hover, juce::Colour(0xFF, 0xA0, 0x30)); + // setColour(n::styleClass, n::valuelabel, juce::Colour(0x20, 0x10, 0x20)); + // setColour(n::styleClass, n::valuelabel_hover, juce::Colour(0x30, 0x20, 0x10)); + // } + + // { + // using n = sst::jucegui::components::MultiSwitch::Styles; + // setColour(n::styleClass, n::unselected_hover, juce::Colour(0x50, 0x50, 0x50)); + // setColour(n::styleClass, n::valuebg, juce::Colour(0x30, 0x20, 0x00)); + // } + + { + using n = sst::jucegui::components::base_styles::ValueGutter; + setColour(n::styleClass, n::gutter, juce::Colour(0x05, 0x05, 0x00)); + setColour(n::styleClass, n::gutter_hover, juce::Colour(0x40, 0x25, 0x00)); + } + + { + using n = sst::jucegui::components::base_styles::GraphicalHandle; + setColour(n::styleClass, n::handle, juce::Colour(0xD0, 0xD0, 0xD0)); + setColour(n::styleClass, n::handle_outline, juce::Colour(0x0F, 0x09, 0x00)); + setColour(n::styleClass, n::handle_hover, juce::Colour(0xFF, 0xE0, 0xC0)); + + setColour(n::styleClass, n::modulation_handle, juce::Colour(0xA0, 0xF0, 0xA0)); + setColour(n::styleClass, n::modulation_handle_hover, juce::Colour(0xB0, 0xFF, 0xB0)); + } + + { + using n = sst::jucegui::components::base_styles::ModulationValueBearing; + setColour(n::styleClass, n::modulated_by_other, juce::Colour(0x20, 0x40, 0x20)); + setColour(n::styleClass, n::modulated_by_selected, juce::Colour(0x30, 0x50, 0x30)); + setColour(n::styleClass, n::modulation_value, juce::Colour(0x20, 0xA0, 0x20)); + setColour(n::styleClass, n::modulation_opposite_value, juce::Colour(0x20, 0x80, 0x20)); + setColour(n::styleClass, n::modulation_value_hover, juce::Colour(0x40, 0xA0, 0x40)); + setColour(n::styleClass, n::modulation_opposite_value_hover, + juce::Colour(0x40, 0x80, 0x40)); + } + + { + using n = sst::jucegui::components::Knob::Styles; + setColour(n::styleClass, n::knobbase, juce::Colour(82, 82, 82)); + } + + // { + // using n = sst::jucegui::components::VUMeter::Styles; + // setColour(n::styleClass, n::vu_gutter, juce::Colour(0, 0, 0)); + // setColour(n::styleClass, n::vu_gradstart, juce::Colour(200, 200, 100)); + // setColour(n::styleClass, n::vu_gradend, juce::Colour(100, 100, 220)); + // setColour(n::styleClass, n::vu_overload, juce::Colour(200, 50, 50)); + // } + + // { + // using n = sst::jucegui::components::TabbedComponent::Styles; + // setColour(n::styleClass, n::tabSelectedLabelColor, juce::Colour(0xFF, 0x90, 0x00)); + // setColour(n::styleClass, n::tabUnselectedLabelColor, juce::Colour(0xAF, 0xA0, 0xA0)); + // setColour(n::styleClass, n::tabSelectedFillColor, juce::Colour(0x0A, 0x0A, 0x0A)); + // setColour(n::styleClass, n::tabUnselectedOutlineColor, juce::Colour(0xA0, 0xA0, + // 0xA0)); + // } + + // { + // using n = sst::jucegui::components::TabularizedTreeViewer::Styles; + + // setColour(n::styleClass, n::toggleboxcol, juce::Colour(190, 190, 190)); + // setColour(n::styleClass, n::toggleglyphcol, juce::Colours::white); + // setColour(n::styleClass, n::toggleglyphhovercol, juce::Colour(0xFF, 90, 80)); + + // setColour(n::styleClass, n::connectorcol, juce::Colour(160, 160, 160)); + // } + + // { + // using n = sst::jucegui::components::ToolTip::Styles; + // setFont(n::styleClass, n::datafont, + // getFont(components::base_styles::BaseLabel::styleClass, + // components::base_styles::BaseLabel::labelfont)); + // } + } }; \ No newline at end of file diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 955c83da293..92e69ad893a 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -131,11 +131,19 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); - for (int i = 0; i < n_fx_params; ++i) { auto k = std::make_unique(); auto d = std::make_unique(); + k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + sst::jucegui::style::StyleSheet::DARK)); + + k->setTransform(juce::AffineTransform().scaled(1.0)); + auto ss = sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + sst::jucegui::style::StyleSheet::LIGHT); + ss->dumpStyleSheetTo(std::cout); + k->setSettings(std::make_shared()); + // w->setContentOwned(newt, false); k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); k->setEditingModulation(true); From 2e9c8d80f53f54e465bace627d135963bd100995 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 02:11:06 +0800 Subject: [PATCH 08/27] omg omg omg i think i get it now --- src/surge-fx/KnobSource.h | 28 ++++++++++++++-------------- src/surge-fx/SurgeFXEditor.cpp | 20 +++++++++++++------- 2 files changed, 27 insertions(+), 21 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 7e46fa741fe..944fdec0926 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -42,10 +42,10 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable bool isModulationBipolar() const override { return isBipolar(); } // sure why not }; -struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet +struct StyleSheetBuiltInImp : public sst::jucegui::style::StyleSheet { - StyleSheetBuiltInImpl() {} - ~StyleSheetBuiltInImpl() {} + StyleSheetBuiltInImp() {} + ~StyleSheetBuiltInImp() {} std::unordered_map> colours; std::unordered_map> fonts; @@ -55,6 +55,7 @@ struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet jassert(isValidPair(c, p)); colours[c.cname][p.pname] = col; } + void setFont(const StyleSheet::Class &c, const StyleSheet::Property &p, const juce::Font &f) override { @@ -105,14 +106,14 @@ struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet if (r.has_value()) return *r; - std::cout << __FILE__ << ":" << __LINE__ << " COLOUR Missing : " << c.cname + std::cout << __FILE__ << ":" << __LINE__ << " VALUE Missing : " << c.cname << "::" << p.pname << std::endl; return juce::Colours::red; } std::optional getColourOptional(const Class &c, const Property &p) const override { - assert(p.type == Property::COLOUR); + auto byC = colours.find(c.cname); if (byC != colours.end()) { @@ -120,7 +121,6 @@ struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet if (byP != byC->second.end()) { jassert(isValidPair(c, p)); - return byP->second; } } @@ -190,7 +190,7 @@ struct StyleSheetBuiltInImpl : public sst::jucegui::style::StyleSheet } }; -struct KnobStyleSheet : public StyleSheetBuiltInImpl +struct KnobStyleSheet : public StyleSheetBuiltInImp { bool initialized{false}; KnobStyleSheet() {} @@ -254,13 +254,13 @@ struct KnobStyleSheet : public StyleSheetBuiltInImpl // setColour(n::styleClass, n::jogbutton_hover, juce::Colour(0xFF, 0x90, 0x00)); // } - // { - // using n = sst::jucegui::components::base_styles::ValueBearing; - // setColour(n::styleClass, n::value, juce::Colour(0xFF, 0x90, 0x00)); - // setColour(n::styleClass, n::value_hover, juce::Colour(0xFF, 0xA0, 0x30)); - // setColour(n::styleClass, n::valuelabel, juce::Colour(0x20, 0x10, 0x20)); - // setColour(n::styleClass, n::valuelabel_hover, juce::Colour(0x30, 0x20, 0x10)); - // } + { + using n = sst::jucegui::components::base_styles::ValueBearing; + setColour(n::styleClass, n::value, juce::Colour(0xFF, 0x90, 0x00)); + setColour(n::styleClass, n::value_hover, juce::Colour(0xFF, 0xA0, 0x30)); + setColour(n::styleClass, n::valuelabel, juce::Colour(0x20, 0x10, 0x20)); + setColour(n::styleClass, n::valuelabel_hover, juce::Colour(0x30, 0x20, 0x10)); + } // { // using n = sst::jucegui::components::MultiSwitch::Styles; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 92e69ad893a..1842ce90584 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -121,6 +121,8 @@ struct Picker : public juce::Component SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor &p) : AudioProcessorEditor(&p), processor(p) { + sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); + processor.storage->addErrorListener(this); setAccessible(true); setFocusContainerType(juce::Component::FocusContainerType::keyboardFocusContainer); @@ -135,17 +137,21 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & { auto k = std::make_unique(); auto d = std::make_unique(); - k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet::DARK)); + // k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + // sst::jucegui::style::StyleSheet::DARK)); + auto style = std::make_shared(); + style->initialize(); + k->setStyle(style); + + // k->setTransform(juce::AffineTransform().scaled(1.0)); - k->setTransform(juce::AffineTransform().scaled(1.0)); - auto ss = sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet::LIGHT); - ss->dumpStyleSheetTo(std::cout); + // auto ss = sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + // sst::jucegui::style::StyleSheet::LIGHT); + // ss->dumpStyleSheetTo(std::cout); k->setSettings(std::make_shared()); // w->setContentOwned(newt, false); - k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::FROM_ACTIVE); + k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); k->setEditingModulation(true); d->setValueFromGUI(1.0 * (rand() % 18502) / 18502.f); From 8e5b737c8043674d1d7af55fd79c9464296dc4d8 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 16:28:09 +0800 Subject: [PATCH 09/27] method change --- src/surge-fx/KnobSource.h | 294 --------------------------------- src/surge-fx/SurgeFXEditor.cpp | 18 +- src/surge-fx/SurgeFXEditor.h | 3 +- 3 files changed, 16 insertions(+), 299 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 944fdec0926..0e37f28ef89 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -41,297 +41,3 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable void setModulationValuePM1(const float &f) override { mv = f; } bool isModulationBipolar() const override { return isBipolar(); } // sure why not }; - -struct StyleSheetBuiltInImp : public sst::jucegui::style::StyleSheet -{ - StyleSheetBuiltInImp() {} - ~StyleSheetBuiltInImp() {} - - std::unordered_map> colours; - std::unordered_map> fonts; - void setColour(const StyleSheet::Class &c, const StyleSheet::Property &p, - const juce::Colour &col) override - { - jassert(isValidPair(c, p)); - colours[c.cname][p.pname] = col; - } - - void setFont(const StyleSheet::Class &c, const StyleSheet::Property &p, - const juce::Font &f) override - { - jassert(isValidPair(c, p)); - -#if defined(_MSC_VER) -#pragma warning(push) -#pragma warning(disable : 4996) -#endif - - fonts[c.cname][p.pname] = f; - -#if defined(_MSC_VER) -#pragma warning(pop) -#endif - } - - void replaceFontsWithTypeface(const juce::Typeface::Ptr &p) override - { - for (auto &[cn, propFonts] : fonts) - { - for (auto &[pn, f] : propFonts) - { - auto nf = SST_JUCE_FONT_CTOR(p); - nf.setHeight(f.getHeight()); - f = nf; - } - } - } - void replaceFontsWithFamily(const juce::String familyName) override { assert(false); } - - bool hasColour(const Class &c, const Property &p) const override - { - assert(p.type == Property::COLOUR); - auto byC = colours.find(c.cname); - if (byC != colours.end()) - { - auto byP = byC->second.find(p.pname); - if (byP != byC->second.end()) - return true; - } - return false; - } - - juce::Colour getColour(const Class &c, const Property &p) const override - { - auto r = getColourOptional(c, p); - if (r.has_value()) - return *r; - - std::cout << __FILE__ << ":" << __LINE__ << " VALUE Missing : " << c.cname - << "::" << p.pname << std::endl; - return juce::Colours::red; - } - - std::optional getColourOptional(const Class &c, const Property &p) const override - { - - auto byC = colours.find(c.cname); - if (byC != colours.end()) - { - auto byP = byC->second.find(p.pname); - if (byP != byC->second.end()) - { - jassert(isValidPair(c, p)); - return byP->second; - } - } - - auto parC = inheritFromTo.find(c.cname); - if (parC != inheritFromTo.end()) - { - for (const auto &k : parC->second) - { - auto sub = getColourOptional({k.c_str()}, p); - if (sub.has_value()) - return sub; - } - } - return std::nullopt; - } - - bool hasFont(const Class &c, const Property &p) const override - { - assert(p.type == Property::FONT); - auto byC = fonts.find(c.cname); - if (byC != fonts.end()) - { - auto byP = byC->second.find(p.pname); - if (byP != byC->second.end()) - return true; - } - return false; - } - - juce::Font getFont(const Class &c, const Property &p) const override - { - auto r = getFontOptional(c, p); - if (r.has_value()) - return *r; - - std::cout << __FILE__ << ":" << __LINE__ << " FONT Missing : " << c.cname << "::" << p.pname - << std::endl; - return SST_JUCE_FONT_CTOR(36, juce::Font::italic); - } - std::optional getFontOptional(const Class &c, const Property &p) const override - { - assert(p.type == Property::FONT); - auto byC = fonts.find(c.cname); - if (byC != fonts.end()) - { - auto byP = byC->second.find(p.pname); - if (byP != byC->second.end()) - { - jassert(isValidPair(c, p)); - return byP->second; - } - } - - auto parC = inheritFromTo.find(c.cname); - if (parC != inheritFromTo.end()) - { - for (const auto &k : parC->second) - { - auto q = getFontOptional({k.c_str()}, p); - if (q.has_value()) - return *q; - } - } - - return std::nullopt; - } -}; - -struct KnobStyleSheet : public StyleSheetBuiltInImp -{ - bool initialized{false}; - KnobStyleSheet() {} - void initialize() - { - if (initialized) - return; - - initialized = true; - - { - using n = sst::jucegui::components::base_styles::Base; - setColour(n::styleClass, n::background, juce::Colour(0x25, 0x25, 0x28)); - } - - { - using n = sst::jucegui::components::base_styles::SelectableRegion; - setColour(n::styleClass, n::backgroundSelected, juce::Colour(0x45, 0x45, 0x48)); - } - - { - using n = sst::jucegui::components::base_styles::Outlined; - setColour(n::styleClass, n::outline, juce::Colour(0x50, 0x50, 0x50)); - setColour(n::styleClass, n::brightoutline, juce::Colour(0x70, 0x70, 0x70)); - } - - { - using n = sst::jucegui::components::base_styles::BaseLabel; - setColour(n::styleClass, n::labelcolor, juce::Colour(220, 220, 220)); - setColour(n::styleClass, n::labelcolor_hover, juce::Colour(240, 240, 235)); - setFont(n::styleClass, n::labelfont, SST_JUCE_FONT_CTOR(13)); - } - - // { - // using n = sst::jucegui::components::NamedPanel::Styles; - // setColour(n::styleClass, n::labelrule, juce::Colour(0x70, 0x70, 0x70)); - // setColour(n::styleClass, n::selectedtab, juce::Colour(0xFF, 0x90, 00)); - // setColour(n::styleClass, n::accentedPanel, juce::Colour(0xFF, 0x90, 00)); - // } - - // { - // using w = sst::jucegui::components::WindowPanel::Styles; - // setColour(w::styleClass, w::bgstart, juce::Colour(0x3B, 0x3D, 0x40)); - // setColour(w::styleClass, w::bgend, juce::Colour(0x1B, 0x1D, 0x20)); - // } - - // { - // using n = sst::jucegui::components::base_styles::PushButton; - // setColour(n::styleClass, n::fill, juce::Colour(0x60, 0x60, 0x60)); - // setColour(n::styleClass, n::fill_hover, juce::Colour(0x90, 0x85, 0x83)); - // setColour(n::styleClass, n::fill_pressed, juce::Colour(0x80, 0x80, 0x80)); - // } - - // { - // using n = sst::jucegui::components::MenuButton::Styles; - // setColour(n::styleClass, n::menuarrow_hover, juce::Colour(0xFF, 0x90, 0x00)); - // } - - // { - // using n = sst::jucegui::components::JogUpDownButton::Styles; - // setColour(n::styleClass, n::jogbutton_hover, juce::Colour(0xFF, 0x90, 0x00)); - // } - - { - using n = sst::jucegui::components::base_styles::ValueBearing; - setColour(n::styleClass, n::value, juce::Colour(0xFF, 0x90, 0x00)); - setColour(n::styleClass, n::value_hover, juce::Colour(0xFF, 0xA0, 0x30)); - setColour(n::styleClass, n::valuelabel, juce::Colour(0x20, 0x10, 0x20)); - setColour(n::styleClass, n::valuelabel_hover, juce::Colour(0x30, 0x20, 0x10)); - } - - // { - // using n = sst::jucegui::components::MultiSwitch::Styles; - // setColour(n::styleClass, n::unselected_hover, juce::Colour(0x50, 0x50, 0x50)); - // setColour(n::styleClass, n::valuebg, juce::Colour(0x30, 0x20, 0x00)); - // } - - { - using n = sst::jucegui::components::base_styles::ValueGutter; - setColour(n::styleClass, n::gutter, juce::Colour(0x05, 0x05, 0x00)); - setColour(n::styleClass, n::gutter_hover, juce::Colour(0x40, 0x25, 0x00)); - } - - { - using n = sst::jucegui::components::base_styles::GraphicalHandle; - setColour(n::styleClass, n::handle, juce::Colour(0xD0, 0xD0, 0xD0)); - setColour(n::styleClass, n::handle_outline, juce::Colour(0x0F, 0x09, 0x00)); - setColour(n::styleClass, n::handle_hover, juce::Colour(0xFF, 0xE0, 0xC0)); - - setColour(n::styleClass, n::modulation_handle, juce::Colour(0xA0, 0xF0, 0xA0)); - setColour(n::styleClass, n::modulation_handle_hover, juce::Colour(0xB0, 0xFF, 0xB0)); - } - - { - using n = sst::jucegui::components::base_styles::ModulationValueBearing; - setColour(n::styleClass, n::modulated_by_other, juce::Colour(0x20, 0x40, 0x20)); - setColour(n::styleClass, n::modulated_by_selected, juce::Colour(0x30, 0x50, 0x30)); - setColour(n::styleClass, n::modulation_value, juce::Colour(0x20, 0xA0, 0x20)); - setColour(n::styleClass, n::modulation_opposite_value, juce::Colour(0x20, 0x80, 0x20)); - setColour(n::styleClass, n::modulation_value_hover, juce::Colour(0x40, 0xA0, 0x40)); - setColour(n::styleClass, n::modulation_opposite_value_hover, - juce::Colour(0x40, 0x80, 0x40)); - } - - { - using n = sst::jucegui::components::Knob::Styles; - setColour(n::styleClass, n::knobbase, juce::Colour(82, 82, 82)); - } - - // { - // using n = sst::jucegui::components::VUMeter::Styles; - // setColour(n::styleClass, n::vu_gutter, juce::Colour(0, 0, 0)); - // setColour(n::styleClass, n::vu_gradstart, juce::Colour(200, 200, 100)); - // setColour(n::styleClass, n::vu_gradend, juce::Colour(100, 100, 220)); - // setColour(n::styleClass, n::vu_overload, juce::Colour(200, 50, 50)); - // } - - // { - // using n = sst::jucegui::components::TabbedComponent::Styles; - // setColour(n::styleClass, n::tabSelectedLabelColor, juce::Colour(0xFF, 0x90, 0x00)); - // setColour(n::styleClass, n::tabUnselectedLabelColor, juce::Colour(0xAF, 0xA0, 0xA0)); - // setColour(n::styleClass, n::tabSelectedFillColor, juce::Colour(0x0A, 0x0A, 0x0A)); - // setColour(n::styleClass, n::tabUnselectedOutlineColor, juce::Colour(0xA0, 0xA0, - // 0xA0)); - // } - - // { - // using n = sst::jucegui::components::TabularizedTreeViewer::Styles; - - // setColour(n::styleClass, n::toggleboxcol, juce::Colour(190, 190, 190)); - // setColour(n::styleClass, n::toggleglyphcol, juce::Colours::white); - // setColour(n::styleClass, n::toggleglyphhovercol, juce::Colour(0xFF, 90, 80)); - - // setColour(n::styleClass, n::connectorcol, juce::Colour(160, 160, 160)); - // } - - // { - // using n = sst::jucegui::components::ToolTip::Styles; - // setFont(n::styleClass, n::datafont, - // getFont(components::base_styles::BaseLabel::styleClass, - // components::base_styles::BaseLabel::labelfont)); - // } - } -}; \ No newline at end of file diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 1842ce90584..139a2652086 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -119,10 +119,17 @@ struct Picker : public juce::Component //============================================================================== SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor &p) - : AudioProcessorEditor(&p), processor(p) + : AudioProcessorEditor(&p), + sst::jucegui::style::StyleConsumer(sst::jucegui::components::Knob::Styles::styleClass), + processor(p) { sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); + setTransform(juce::AffineTransform().scaled(1.0)); + + // setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + // sst::jucegui::style::StyleSheet::DARK)); + processor.storage->addErrorListener(this); setAccessible(true); setFocusContainerType(juce::Component::FocusContainerType::keyboardFocusContainer); @@ -137,11 +144,14 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & { auto k = std::make_unique(); auto d = std::make_unique(); + k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + sst::jucegui::style::StyleSheet::DARK)); + // k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( // sst::jucegui::style::StyleSheet::DARK)); - auto style = std::make_shared(); - style->initialize(); - k->setStyle(style); + // auto style = std::make_shared(); + // style->initialize(); + // k->setStyle(style); // k->setTransform(juce::AffineTransform().scaled(1.0)); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index e2124dbedb8..b14aac8c42c 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -34,7 +34,8 @@ */ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, juce::AsyncUpdater, - SurgeStorage::ErrorListener + SurgeStorage::ErrorListener, + sst::jucegui::style::StyleConsumer { public: SurgefxAudioProcessorEditor(SurgefxAudioProcessor &); From 84b420861bb5836d099d063f1b77bd2cdf25b077 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 16:37:19 +0800 Subject: [PATCH 10/27] update method --- src/surge-fx/SurgeFXEditor.cpp | 20 ++++++-------------- src/surge-fx/SurgeFXEditor.h | 1 + 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 139a2652086..d57efff47f5 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -121,12 +121,15 @@ struct Picker : public juce::Component SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor &p) : AudioProcessorEditor(&p), sst::jucegui::style::StyleConsumer(sst::jucegui::components::Knob::Styles::styleClass), + styleSheet(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( + sst::jucegui::style::StyleSheet::DARK)), processor(p) { sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); setTransform(juce::AffineTransform().scaled(1.0)); + // @ BP this compiles but causes a segfault on launc // setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( // sst::jucegui::style::StyleSheet::DARK)); @@ -144,23 +147,12 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & { auto k = std::make_unique(); auto d = std::make_unique(); - k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - sst::jucegui::style::StyleSheet::DARK)); + styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, + sst::jucegui::components::Knob::Styles::value, juce::Colours::pink); - // k->setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - // sst::jucegui::style::StyleSheet::DARK)); - // auto style = std::make_shared(); - // style->initialize(); - // k->setStyle(style); + k->setStyle(styleSheet); - // k->setTransform(juce::AffineTransform().scaled(1.0)); - - // auto ss = sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - // sst::jucegui::style::StyleSheet::LIGHT); - // ss->dumpStyleSheetTo(std::cout); k->setSettings(std::make_shared()); - // w->setContentOwned(newt, false); - k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); k->setEditingModulation(true); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index b14aac8c42c..7097c5f33be 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -203,6 +203,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, public: std::vector accessibleOrderWeakRefs; + std::shared_ptr styleSheet; public: std::unique_ptr createFocusTraverser() override; From 500881068aa8b3685c3c8cd52de209ba18ebdbba Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 23:30:14 +0800 Subject: [PATCH 11/27] properly update knob parameters --- src/surge-fx/KnobSource.h | 10 +++++++++- src/surge-fx/SurgeFXEditor.cpp | 12 ++++-------- src/surge-fx/SurgeFXEditor.h | 2 ++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 0e37f28ef89..d34fce366e4 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -11,7 +11,8 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable { - ConcreteCM() {}; + ConcreteCM(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} + std::string label{"A Knob"}; std::string getLabel() const override { return label; } float value{0}; @@ -24,7 +25,11 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable l->dataChanged(); for (auto *l : modellisteners) l->dataChanged(); + + this->processor.prepareParametersAbsentAudio(); + this->processor.setFXParamValue01(id, value); } + void setValueFromModel(const float &f) override { value = f; @@ -32,6 +37,9 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable l->dataChanged(); } + SurgefxAudioProcessor &processor; + int id; + float min{0}, max{1}; float getMin() const override { return min; } float getMax() const override { return max; } diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index d57efff47f5..3ca4f8c6cab 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -127,12 +127,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & { sst::jucegui::style::StyleSheet::initializeStyleSheets([]() {}); - setTransform(juce::AffineTransform().scaled(1.0)); - - // @ BP this compiles but causes a segfault on launc - // setStyle(sst::jucegui::style::StyleSheet::getBuiltInStyleSheet( - // sst::jucegui::style::StyleSheet::DARK)); - processor.storage->addErrorListener(this); setAccessible(true); setFocusContainerType(juce::Component::FocusContainerType::keyboardFocusContainer); @@ -146,13 +140,13 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { auto k = std::make_unique(); - auto d = std::make_unique(); + auto d = std::make_unique(processor, i); styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, sst::jucegui::components::Knob::Styles::value, juce::Colours::pink); k->setStyle(styleSheet); - k->setSettings(std::make_shared()); + k->setSettings(settingsSheet); k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); k->setEditingModulation(true); @@ -161,6 +155,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & k->onBeginEdit = []() { DBGOUT("beginEdit"); }; k->onEndEdit = []() { DBGOUT("endEdit"); }; k->onPopupMenu = [](const auto &m) { DBGOUT("popupMenu"); }; + k->pathDrawMode = sst::jucegui::components::Knob::PathDrawMode::ALWAYS_FROM_MIN; + addAndMakeVisible(*k); knobs.push_back(std::move(k)); sources.push_back(std::move(d)); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 7097c5f33be..febab378f25 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -29,6 +29,7 @@ #include "juce_gui_basics/juce_gui_basics.h" #include "sst/jucegui/components/Knob.h" +#include "sst/jucegui/components/WindowPanel.h" //============================================================================== /** */ @@ -204,6 +205,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, public: std::vector accessibleOrderWeakRefs; std::shared_ptr styleSheet; + std::shared_ptr settingsSheet; public: std::unique_ptr createFocusTraverser() override; From 09d8f1b134ea39feaa26ff5bbbee67291a2af8d2 Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 23:31:53 +0800 Subject: [PATCH 12/27] some todos in preparation for review --- src/surge-fx/KnobSource.h | 7 +++++-- src/surge-fx/SurgeFXEditor.cpp | 4 +++- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index d34fce366e4..8a4b23f67a6 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -13,11 +13,14 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable { ConcreteCM(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} - std::string label{"A Knob"}; + std::string label{"A Knob"}; // todo better name std::string getLabel() const override { return label; } float value{0}; float getValue() const override { return value; } - float getDefaultValue() const override { return (getMax() - getMin()) / 2.0; } + float getDefaultValue() const override + { + return (getMax() - getMin()) / 2.0; + } // todo:: look into processor and grab deafult value void setValueFromGUI(const float &f) override { value = f; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 3ca4f8c6cab..9f7351415d2 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -150,7 +150,9 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); k->setEditingModulation(true); - d->setValueFromGUI(1.0 * (rand() % 18502) / 18502.f); + d->setValueFromGUI(1.0 * (rand() % 18502) / + 18502.f); // todo - this should use the param defaults from processor + k->setSource(d.get()); k->onBeginEdit = []() { DBGOUT("beginEdit"); }; k->onEndEdit = []() { DBGOUT("endEdit"); }; From 0162a4dac8d9ff586b34d1e52dcaa1fcac791c0a Mon Sep 17 00:00:00 2001 From: yoshih Date: Sun, 29 Dec 2024 23:53:23 +0800 Subject: [PATCH 13/27] maybe it needs settingsConsumer --- src/surge-fx/KnobSource.h | 1 + src/surge-fx/SurgeFXEditor.cpp | 4 ++-- src/surge-fx/SurgeFXEditor.h | 3 ++- 3 files changed, 5 insertions(+), 3 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 8a4b23f67a6..2cb1fd28a36 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -21,6 +21,7 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable { return (getMax() - getMin()) / 2.0; } // todo:: look into processor and grab deafult value + void setValueFromGUI(const float &f) override { value = f; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 9f7351415d2..52d2ced29c1 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -146,9 +146,9 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & k->setStyle(styleSheet); - k->setSettings(settingsSheet); k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - k->setEditingModulation(true); + + k->setSettings(settingsSheet); // todo might be unneeded d->setValueFromGUI(1.0 * (rand() % 18502) / 18502.f); // todo - this should use the param defaults from processor diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index febab378f25..0775d4f67cd 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -36,7 +36,8 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, juce::AsyncUpdater, SurgeStorage::ErrorListener, - sst::jucegui::style::StyleConsumer + sst::jucegui::style::StyleConsumer, + sst::jucegui::style::SettingsConsumer { public: SurgefxAudioProcessorEditor(SurgefxAudioProcessor &); From 306a7e59975291008de4801d1b84bb6fadc3045c Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 01:55:45 +0800 Subject: [PATCH 14/27] bp said no settings consumer --- src/surge-fx/SurgeFXEditor.cpp | 2 -- src/surge-fx/SurgeFXEditor.h | 1 - 2 files changed, 3 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 52d2ced29c1..9ca5d46a5b1 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -148,8 +148,6 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - k->setSettings(settingsSheet); // todo might be unneeded - d->setValueFromGUI(1.0 * (rand() % 18502) / 18502.f); // todo - this should use the param defaults from processor diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 0775d4f67cd..0e7fc959d4c 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -206,7 +206,6 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, public: std::vector accessibleOrderWeakRefs; std::shared_ptr styleSheet; - std::shared_ptr settingsSheet; public: std::unique_ptr createFocusTraverser() override; From 7d368211ffb0ed8e1ab0b342d93f7982dbce5eab Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 02:21:04 +0800 Subject: [PATCH 15/27] set colours correctly --- src/surge-fx/SurgeFXEditor.cpp | 19 +++++++++++++++++-- 1 file changed, 17 insertions(+), 2 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 9ca5d46a5b1..27fd15f2ab3 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -137,12 +137,27 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & picker = std::make_unique(this); addAndMakeVisibleRecordOrder(picker.get()); + + auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); + auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); + + styleSheet->setColour(sst::jucegui::components::base_styles::GraphicalHandle::styleClass, + sst::jucegui::components::base_styles::GraphicalHandle::handle, + backgroundColour); + + styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, + sst::jucegui::components::Knob::Styles::knobbase, backgroundColour); + + styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, + sst::jucegui::components::Knob::Styles::value, surgeOrange); + + styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, + sst::jucegui::components::Knob::Styles::value_hover, surgeOrange); + for (int i = 0; i < n_fx_params; ++i) { auto k = std::make_unique(); auto d = std::make_unique(processor, i); - styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, - sst::jucegui::components::Knob::Styles::value, juce::Colours::pink); k->setStyle(styleSheet); From d7230b6460a94a9445c63a183adc0f698957d65f Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 02:39:47 +0800 Subject: [PATCH 16/27] Fixing my todos --- src/surge-fx/KnobSource.h | 12 ++++-------- src/surge-fx/SurgeFXEditor.cpp | 5 ++--- src/surge-fx/SurgeFXEditor.h | 2 -- src/surge-fx/SurgeFXProcessor.h | 4 ++++ 4 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 2cb1fd28a36..0efdcc7e143 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -9,18 +9,15 @@ #include #include -struct ConcreteCM : sst::jucegui::data::ContinuousModulatable +struct KnobSource : sst::jucegui::data::ContinuousModulatable { - ConcreteCM(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} + KnobSource(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} - std::string label{"A Knob"}; // todo better name + std::string label{"KnobSource"}; std::string getLabel() const override { return label; } float value{0}; float getValue() const override { return value; } - float getDefaultValue() const override - { - return (getMax() - getMin()) / 2.0; - } // todo:: look into processor and grab deafult value + float getDefaultValue() const override { return processor.getFXStorageDefaultValue01(id); } void setValueFromGUI(const float &f) override { @@ -30,7 +27,6 @@ struct ConcreteCM : sst::jucegui::data::ContinuousModulatable for (auto *l : modellisteners) l->dataChanged(); - this->processor.prepareParametersAbsentAudio(); this->processor.setFXParamValue01(id, value); } diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 27fd15f2ab3..fc19633ef21 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -157,14 +157,13 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { auto k = std::make_unique(); - auto d = std::make_unique(processor, i); + auto d = std::make_unique(processor, i); k->setStyle(styleSheet); k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - d->setValueFromGUI(1.0 * (rand() % 18502) / - 18502.f); // todo - this should use the param defaults from processor + d->setValueFromGUI(d->getDefaultValue()); k->setSource(d.get()); k->onBeginEdit = []() { DBGOUT("beginEdit"); }; diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 0e7fc959d4c..da22bffccec 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -166,8 +166,6 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, return false; } }; - // sst::jucegui::components::Knob fxParamSliders[n_fx_params]; - // ConcreteCM fxParamSources[n_fx_params]; SurgeFXParamDisplay fxParamDisplay[n_fx_params]; SurgeTempoSyncSwitch fxTempoSync[n_fx_params]; diff --git a/src/surge-fx/SurgeFXProcessor.h b/src/surge-fx/SurgeFXProcessor.h index 79bb7bb36b4..12109d2906f 100644 --- a/src/surge-fx/SurgeFXProcessor.h +++ b/src/surge-fx/SurgeFXProcessor.h @@ -121,6 +121,10 @@ class SurgefxAudioProcessor : public juce::AudioProcessor, int getEffectType() { return effectNum; } float getFXStorageValue01(int i) { return fxstorage->p[fx_param_remap[i]].get_value_f01(); } + float getFXStorageDefaultValue01(int i) + { + return fxstorage->p[fx_param_remap[i]].get_default_value_f01(); + } float getFXParamValue01(int i) { return *(fxParams[i]); } void setFXParamValue01(int i, float f) { *(fxParams[i]) = f; } From 2bb2febe1414c42045d1c5f0a8af2c7cbbe36440 Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 02:48:43 +0800 Subject: [PATCH 17/27] improve readability --- src/surge-fx/KnobSource.h | 9 +++------ src/surge-fx/SurgeFXEditor.cpp | 17 +++++------------ src/surge-fx/SurgeFXEditor.h | 6 ++++-- 3 files changed, 12 insertions(+), 20 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 0efdcc7e143..b94347234ac 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -1,14 +1,10 @@ -#pragma once // this doesn't seem like the norm in this repo but still a wip +#ifndef SURGE_SRC_SURGE_FX_KNOBSOURCE_H +#define SURGE_SRC_SURGE_FX_KNOBSOURCE_H #include #include -// #include #include -#include -#include -#include - struct KnobSource : sst::jucegui::data::ContinuousModulatable { KnobSource(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} @@ -49,3 +45,4 @@ struct KnobSource : sst::jucegui::data::ContinuousModulatable void setModulationValuePM1(const float &f) override { mv = f; } bool isModulationBipolar() const override { return isBipolar(); } // sure why not }; +#endif // SURGE_SRC_SURGE_FX_KNOBSOURCE_H diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index fc19633ef21..36356e633a2 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -141,18 +141,11 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & auto backgroundColour = findColour(SurgeLookAndFeel::SurgeColourIds::componentBgStart); auto surgeOrange = findColour(SurgeLookAndFeel::SurgeColourIds::orange); - styleSheet->setColour(sst::jucegui::components::base_styles::GraphicalHandle::styleClass, - sst::jucegui::components::base_styles::GraphicalHandle::handle, - backgroundColour); - - styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, - sst::jucegui::components::Knob::Styles::knobbase, backgroundColour); - - styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, - sst::jucegui::components::Knob::Styles::value, surgeOrange); - - styleSheet->setColour(sst::jucegui::components::Knob::Styles::styleClass, - sst::jucegui::components::Knob::Styles::value_hover, surgeOrange); + using knobStyle = sst::jucegui::components::Knob::Styles; + styleSheet->setColour(knobStyle::styleClass, knobStyle::handle, backgroundColour); + styleSheet->setColour(knobStyle::styleClass, knobStyle::knobbase, backgroundColour); + styleSheet->setColour(knobStyle::styleClass, knobStyle::value, surgeOrange); + styleSheet->setColour(knobStyle::styleClass, knobStyle::value_hover, surgeOrange); for (int i = 0; i < n_fx_params; ++i) { diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index da22bffccec..aab85430083 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -28,8 +28,10 @@ #include "KnobSource.h" #include "juce_gui_basics/juce_gui_basics.h" -#include "sst/jucegui/components/Knob.h" -#include "sst/jucegui/components/WindowPanel.h" + +#include +#include + //============================================================================== /** */ From 37739d1d8bf0013980b5e88184523d67cbc28497 Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 02:59:48 +0800 Subject: [PATCH 18/27] more cleanup --- src/surge-fx/KnobSource.h | 11 +---------- src/surge-fx/SurgeFXEditor.cpp | 22 ++++++++++------------ src/surge-fx/SurgeFXEditor.h | 2 +- 3 files changed, 12 insertions(+), 23 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index b94347234ac..41492e5d777 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -5,7 +5,7 @@ #include #include -struct KnobSource : sst::jucegui::data::ContinuousModulatable +struct KnobSource : sst::jucegui::data::Continuous { KnobSource(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} @@ -35,14 +35,5 @@ struct KnobSource : sst::jucegui::data::ContinuousModulatable SurgefxAudioProcessor &processor; int id; - - float min{0}, max{1}; - float getMin() const override { return min; } - float getMax() const override { return max; } - - float mv{0.2}; - float getModulationValuePM1() const override { return mv; } - void setModulationValuePM1(const float &f) override { mv = f; } - bool isModulationBipolar() const override { return isBipolar(); } // sure why not }; #endif // SURGE_SRC_SURGE_FX_KNOBSOURCE_H diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 36356e633a2..af81c74b39b 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -153,16 +153,13 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & auto d = std::make_unique(processor, i); k->setStyle(styleSheet); - k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); d->setValueFromGUI(d->getDefaultValue()); k->setSource(d.get()); - k->onBeginEdit = []() { DBGOUT("beginEdit"); }; - k->onEndEdit = []() { DBGOUT("endEdit"); }; - k->onPopupMenu = [](const auto &m) { DBGOUT("popupMenu"); }; - k->pathDrawMode = sst::jucegui::components::Knob::PathDrawMode::ALWAYS_FROM_MIN; + + // k->pathDrawMode = sst::jucegui::components::Knob::PathDrawMode::ALWAYS_FROM_MIN; addAndMakeVisible(*k); knobs.push_back(std::move(k)); @@ -177,8 +174,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamTempoSync(i, this->fxTempoSync[i].getToggleState()); this->processor.setFXStorageTempoSync(i, this->fxTempoSync[i].getToggleState()); - // fxParamDisplay[i].setDisplay( - // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); this->processor.setUserEditingParamFeature(i, false); }; @@ -210,8 +207,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setUserEditingParamFeature(i, true); this->processor.setFXParamExtended(i, this->fxExtended[i].getToggleState()); this->processor.setFXStorageExtended(i, this->fxExtended[i].getToggleState()); - // fxParamDisplay[i].setDisplay( - // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageDefaultValue01(i))); this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); @@ -227,8 +224,8 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setFXParamAbsolute(i, this->fxAbsoluted[i].getToggleState()); this->processor.setFXStorageAbsolute(i, this->fxAbsoluted[i].getToggleState()); - // fxParamDisplay[i].setDisplay( - // processor.getParamValueFromFloat(i, this->fxParamSliders[i].getValue())); + fxParamDisplay[i].setDisplay( + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); this->processor.setUserEditingParamFeature(i, false); }; @@ -296,7 +293,8 @@ void SurgefxAudioProcessorEditor::resetLabels() for (int i = 0; i < n_fx_params; ++i) { auto nm = processor.getParamName(i) + " " + processor.getParamGroup(i); - // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), + + // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), // juce::NotificationType::dontSendNotification); fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index aab85430083..942b0863cab 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -112,7 +112,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, static constexpr int baseWidth = 600, baseHeight = 55 * 6 + 80 + topSection; std::vector> knobs; - std::vector> sources; + std::vector> sources; private: struct AccSlider : public juce::Slider From b16164f8bf1aa5f9d32eb61baef70393a0cb344a Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 03:03:50 +0800 Subject: [PATCH 19/27] readability --- src/surge-fx/SurgeFXEditor.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index af81c74b39b..371b1a1579e 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -149,21 +149,19 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { - auto k = std::make_unique(); - auto d = std::make_unique(processor, i); + auto knob = std::make_unique(); + auto knobSource = std::make_unique(processor, i); - k->setStyle(styleSheet); - k->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); + knob->setStyle(styleSheet); + knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); - d->setValueFromGUI(d->getDefaultValue()); + knobSource->setValueFromGUI(knobSource->getDefaultValue()); - k->setSource(d.get()); + knob->setSource(knobSource.get()); - // k->pathDrawMode = sst::jucegui::components::Knob::PathDrawMode::ALWAYS_FROM_MIN; - - addAndMakeVisible(*k); - knobs.push_back(std::move(k)); - sources.push_back(std::move(d)); + addAndMakeVisible(*knob); + knobs.push_back(std::move(knob)); + sources.push_back(std::move(knobSource)); fxTempoSync[i].setOnOffImage(BinaryData::TS_Act_svg, BinaryData::TS_Act_svgSize, BinaryData::TS_Deact_svg, BinaryData::TS_Deact_svgSize); @@ -208,7 +206,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & this->processor.setFXParamExtended(i, this->fxExtended[i].getToggleState()); this->processor.setFXStorageExtended(i, this->fxExtended[i].getToggleState()); fxParamDisplay[i].setDisplay( - processor.getParamValueFromFloat(i, processor.getFXStorageDefaultValue01(i))); + processor.getParamValueFromFloat(i, processor.getFXStorageValue01(i))); this->processor.setUserEditingParamFeature(i, false); }; fxExtended[i].setTitle("Parameter " + std::to_string(i) + " Extended"); @@ -294,7 +292,7 @@ void SurgefxAudioProcessorEditor::resetLabels() { auto nm = processor.getParamName(i) + " " + processor.getParamGroup(i); - // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), + // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), // juce::NotificationType::dontSendNotification); fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); From a0ca399b254a9ea26c73af894385082919b5e711 Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 16:15:04 +0800 Subject: [PATCH 20/27] accessibility changes --- libs/sst/sst-jucegui | 2 +- src/surge-fx/KnobSource.h | 1 + src/surge-fx/SurgeFXEditor.cpp | 21 ++++++++++----------- src/surge-fx/SurgeFXEditor.h | 2 +- 4 files changed, 13 insertions(+), 13 deletions(-) diff --git a/libs/sst/sst-jucegui b/libs/sst/sst-jucegui index 96985a5d10c..2c363f3965c 160000 --- a/libs/sst/sst-jucegui +++ b/libs/sst/sst-jucegui @@ -1 +1 @@ -Subproject commit 96985a5d10cae91c1a008b50f74510ab39624c6d +Subproject commit 2c363f3965c52b6258dbf3ad049167bdc2110ad7 diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 41492e5d777..9361bb97735 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -11,6 +11,7 @@ struct KnobSource : sst::jucegui::data::Continuous std::string label{"KnobSource"}; std::string getLabel() const override { return label; } + void setLabel(std::string input) { label = input; } float value{0}; float getValue() const override { return value; } float getDefaultValue() const override { return processor.getFXStorageDefaultValue01(id); } diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 371b1a1579e..24d194eb9d2 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -155,7 +155,9 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & knob->setStyle(styleSheet); knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); + auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); knobSource->setValueFromGUI(knobSource->getDefaultValue()); + knobSource->setLabel(paramName + " Knob"); knob->setSource(knobSource.get()); @@ -292,8 +294,8 @@ void SurgefxAudioProcessorEditor::resetLabels() { auto nm = processor.getParamName(i) + " " + processor.getParamGroup(i); - // fxParamSliders[i].setValue(processor.getFXStorageValue01(i), - // juce::NotificationType::dontSendNotification); + sources.at(i)->setValueFromGUI(sources.at(i)->getDefaultValue()); + fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); fxParamDisplay[i].setName(processor.getParamName(i).c_str()); @@ -301,10 +303,8 @@ void SurgefxAudioProcessorEditor::resetLabels() fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); - // fxParamSliders[i].setEnabled(processor.getParamEnabled(i) && - // !processor.getFXStorageAppearsDeactivated(i)); - // st(fxParamSliders[i], nm + " Knob"); - // fxParamSliders[i].setTextValue(processor.getParamValue(i).c_str()); + + sources.at(i)->setLabel(nm + "Knob"); fxTempoSync[i].setEnabled(processor.canTempoSync(i)); fxTempoSync[i].setAccessible(processor.canTempoSync(i)); @@ -360,10 +360,7 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { - - // fxParamSources[i].setValueFromGUI(fv[i]); - - // fxParamSliders[i].setValue(fv[i], juce::NotificationType::dontSendNotification); + sources.at(i)->setValueFromGUI(fv[i]); fxParamDisplay[i].setDisplay(processor.getParamValueFor(i, fv[i])); } else @@ -399,7 +396,9 @@ void SurgefxAudioProcessorEditor::resized() juce::Rectangle position{(i / 6) * getWidth() / 2 + sliderOff, (i % 6) * rowHeight + ypos0, rowHeight - sliderOff, rowHeight - sliderOff}; - // fxParamSliders[i].setBounds(position); + + position = position.reduced(position.getWidth() * 0.10, position.getHeight() * 0.10); + knobs.at(i).get()->setBounds(position); // knobs.at(i).get()->setOpaque(true); int buttonSize = 19; diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 942b0863cab..7f0c89d1c5e 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -112,7 +112,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, static constexpr int baseWidth = 600, baseHeight = 55 * 6 + 80 + topSection; std::vector> knobs; - std::vector> sources; + std::vector> sources; private: struct AccSlider : public juce::Slider From cca9564fe6c5bc093951c07dcd81e8c3f89042e1 Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 16:18:10 +0800 Subject: [PATCH 21/27] misc cleanup --- src/surge-fx/SurgeFXEditor.cpp | 2 +- src/surge-fx/SurgeFXEditor.h | 3 +-- 2 files changed, 2 insertions(+), 3 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 24d194eb9d2..cbb6cc6ee47 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -400,7 +400,7 @@ void SurgefxAudioProcessorEditor::resized() position = position.reduced(position.getWidth() * 0.10, position.getHeight() * 0.10); knobs.at(i).get()->setBounds(position); - // knobs.at(i).get()->setOpaque(true); + int buttonSize = 19; if (getWidth() < baseWidth) buttonSize = 17; diff --git a/src/surge-fx/SurgeFXEditor.h b/src/surge-fx/SurgeFXEditor.h index 7f0c89d1c5e..ff9d31735d6 100644 --- a/src/surge-fx/SurgeFXEditor.h +++ b/src/surge-fx/SurgeFXEditor.h @@ -38,8 +38,7 @@ class SurgefxAudioProcessorEditor : public juce::AudioProcessorEditor, juce::AsyncUpdater, SurgeStorage::ErrorListener, - sst::jucegui::style::StyleConsumer, - sst::jucegui::style::SettingsConsumer + sst::jucegui::style::StyleConsumer { public: SurgefxAudioProcessorEditor(SurgefxAudioProcessor &); From e5d5ae3b66dafd2c371bcacc1de129891e63645f Mon Sep 17 00:00:00 2001 From: yoshih Date: Tue, 31 Dec 2024 16:50:15 +0800 Subject: [PATCH 22/27] reset labels works now, needed to resize --- src/surge-fx/SurgeFXEditor.cpp | 33 +++++++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 8 deletions(-) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index cbb6cc6ee47..7474ff28e25 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -269,6 +269,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & idleTimer = std::make_unique(this); idleTimer->startTimer(1000 / 5); + resized(); } SurgefxAudioProcessorEditor::~SurgefxAudioProcessorEditor() @@ -290,11 +291,28 @@ void SurgefxAudioProcessorEditor::resetLabels() handler->notifyAccessibilityEvent(juce::AccessibilityEvent::valueChanged); } }; + + knobs.clear(); + sources.clear(); + for (int i = 0; i < n_fx_params; ++i) { - auto nm = processor.getParamName(i) + " " + processor.getParamGroup(i); + auto knob = std::make_unique(); + auto knobSource = std::make_unique(processor, i); + + knob->setStyle(styleSheet); + knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); + + auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); + knobSource->setValueFromGUI(knobSource->getDefaultValue()); + auto name = paramName + " Knob"; + knobSource->setLabel(name); + + knob->setSource(knobSource.get()); - sources.at(i)->setValueFromGUI(sources.at(i)->getDefaultValue()); + addAndMakeVisible(*knob); + knobs.push_back(std::move(knob)); + sources.push_back(std::move(knobSource)); fxParamDisplay[i].setDisplay(processor.getParamValue(i).c_str()); fxParamDisplay[i].setGroup(processor.getParamGroup(i).c_str()); @@ -304,30 +322,28 @@ void SurgefxAudioProcessorEditor::resetLabels() fxParamDisplay[i].setEnabled(processor.getParamEnabled(i)); fxParamDisplay[i].setAppearsDeactivated(processor.getFXStorageAppearsDeactivated(i)); - sources.at(i)->setLabel(nm + "Knob"); - fxTempoSync[i].setEnabled(processor.canTempoSync(i)); fxTempoSync[i].setAccessible(processor.canTempoSync(i)); fxTempoSync[i].setToggleState(processor.getFXStorageTempoSync(i), juce::NotificationType::dontSendNotification); - st(fxTempoSync[i], nm + " Tempo Synced"); + st(fxTempoSync[i], name + " Tempo Synced"); fxDeactivated[i].setEnabled(false); fxExtended[i].setEnabled(processor.canExtend(i)); fxExtended[i].setToggleState(processor.getFXStorageExtended(i), juce::NotificationType::dontSendNotification); fxExtended[i].setAccessible(processor.canExtend(i)); - st(fxExtended[i], nm + " Extended"); + st(fxExtended[i], name + " Extended"); fxAbsoluted[i].setEnabled(processor.canAbsolute(i)); fxAbsoluted[i].setToggleState(processor.getFXStorageAbsolute(i), juce::NotificationType::dontSendNotification); fxAbsoluted[i].setAccessible(processor.canAbsolute(i)); - st(fxAbsoluted[i], nm + " Absolute"); + st(fxAbsoluted[i], name + " Absolute"); fxDeactivated[i].setEnabled(processor.canDeactitvate(i)); fxDeactivated[i].setToggleState(processor.getFXStorageDeactivated(i), juce::NotificationType::dontSendNotification); fxDeactivated[i].setAccessible(processor.canDeactitvate(i)); - st(fxDeactivated[i], nm + " Deactivated"); + st(fxDeactivated[i], name + " Deactivated"); } picker->repaint(); @@ -338,6 +354,7 @@ void SurgefxAudioProcessorEditor::resetLabels() { h->notifyAccessibilityEvent(juce::AccessibilityEvent::structureChanged); } + resized(); } void SurgefxAudioProcessorEditor::setEffectType(int i) From 82a74c65d49f841a246cd76f807d511f39b65a1e Mon Sep 17 00:00:00 2001 From: yoshih Date: Wed, 1 Jan 2025 02:50:30 +0800 Subject: [PATCH 23/27] add display changes to KnobSource - doesn't fully work yet --- src/surge-fx/KnobSource.h | 7 ++++++- src/surge-fx/SurgeFXEditor.cpp | 4 ++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 9361bb97735..b9e54c44f43 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -7,7 +7,10 @@ struct KnobSource : sst::jucegui::data::Continuous { - KnobSource(SurgefxAudioProcessor &p, int i) : processor(p), id(i) {} + KnobSource(SurgefxAudioProcessor &p, SurgeFXParamDisplay &d, int i) + : processor(p), display(d), id(i) + { + } std::string label{"KnobSource"}; std::string getLabel() const override { return label; } @@ -25,6 +28,7 @@ struct KnobSource : sst::jucegui::data::Continuous l->dataChanged(); this->processor.setFXParamValue01(id, value); + display.setDisplay(std::to_string(value)); } void setValueFromModel(const float &f) override @@ -35,6 +39,7 @@ struct KnobSource : sst::jucegui::data::Continuous } SurgefxAudioProcessor &processor; + SurgeFXParamDisplay &display; int id; }; #endif // SURGE_SRC_SURGE_FX_KNOBSOURCE_H diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 7474ff28e25..2bac0e0a4bf 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -150,7 +150,7 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & for (int i = 0; i < n_fx_params; ++i) { auto knob = std::make_unique(); - auto knobSource = std::make_unique(processor, i); + auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); knob->setStyle(styleSheet); knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); @@ -298,7 +298,7 @@ void SurgefxAudioProcessorEditor::resetLabels() for (int i = 0; i < n_fx_params; ++i) { auto knob = std::make_unique(); - auto knobSource = std::make_unique(processor, i); + auto knobSource = std::make_unique(processor, fxParamDisplay[i], i); knob->setStyle(styleSheet); knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); From e892eb278bae6c5dddd627ca127c471d907f6b9c Mon Sep 17 00:00:00 2001 From: yoshih Date: Wed, 1 Jan 2025 20:28:24 +0800 Subject: [PATCH 24/27] update the display callback --- src/surge-fx/KnobSource.h | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index b9e54c44f43..8c4f0b9b967 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -28,7 +28,12 @@ struct KnobSource : sst::jucegui::data::Continuous l->dataChanged(); this->processor.setFXParamValue01(id, value); - display.setDisplay(std::to_string(value)); + display.setDisplay(getValueAsStringFor(value)); + } + + std::string getValueAsStringFor(float f) const override + { + return processor.getParamValue(id).c_str(); } void setValueFromModel(const float &f) override From 5a3437010ddaf63e66e598ac088b33ef538f97fc Mon Sep 17 00:00:00 2001 From: yoshih Date: Wed, 1 Jan 2025 21:28:01 +0800 Subject: [PATCH 25/27] set enabled --- src/surge-fx/SurgeFXEditor.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 2bac0e0a4bf..5da9adfa8ad 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -309,6 +309,7 @@ void SurgefxAudioProcessorEditor::resetLabels() knobSource->setLabel(name); knob->setSource(knobSource.get()); + knob->setEnabled(processor.getParamEnabled(i)); addAndMakeVisible(*knob); knobs.push_back(std::move(knob)); From 93c273c0dc2f9fe43ca19254706ac29ca340b0df Mon Sep 17 00:00:00 2001 From: yoshih Date: Wed, 1 Jan 2025 23:54:00 +0800 Subject: [PATCH 26/27] bp changes --- src/surge-fx/KnobSource.h | 2 ++ src/surge-fx/SurgeFXEditor.cpp | 2 +- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 8c4f0b9b967..1a831705e33 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -41,6 +41,8 @@ struct KnobSource : sst::jucegui::data::Continuous value = f; for (auto *l : guilisteners) l->dataChanged(); + this->processor.setFXParamValue01(id, value); + display.setDisplay(getValueAsStringFor(value)); } SurgefxAudioProcessor &processor; diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index 5da9adfa8ad..ee68e89bdd0 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -378,7 +378,7 @@ void SurgefxAudioProcessorEditor::paramsChangedCallback() { if (i < n_fx_params) { - sources.at(i)->setValueFromGUI(fv[i]); + sources.at(i)->setValueFromModel(fv[i]); fxParamDisplay[i].setDisplay(processor.getParamValueFor(i, fv[i])); } else From 5940664e302cacab1b4ac735bdb0673ca117d8ef Mon Sep 17 00:00:00 2001 From: yoshih Date: Thu, 2 Jan 2025 00:27:42 +0800 Subject: [PATCH 27/27] don't set processor param from knob source --- src/surge-fx/KnobSource.h | 1 - src/surge-fx/SurgeFXEditor.cpp | 6 +++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/surge-fx/KnobSource.h b/src/surge-fx/KnobSource.h index 1a831705e33..69be148e2b5 100644 --- a/src/surge-fx/KnobSource.h +++ b/src/surge-fx/KnobSource.h @@ -41,7 +41,6 @@ struct KnobSource : sst::jucegui::data::Continuous value = f; for (auto *l : guilisteners) l->dataChanged(); - this->processor.setFXParamValue01(id, value); display.setDisplay(getValueAsStringFor(value)); } diff --git a/src/surge-fx/SurgeFXEditor.cpp b/src/surge-fx/SurgeFXEditor.cpp index ee68e89bdd0..ffac9682e77 100644 --- a/src/surge-fx/SurgeFXEditor.cpp +++ b/src/surge-fx/SurgeFXEditor.cpp @@ -156,12 +156,12 @@ SurgefxAudioProcessorEditor::SurgefxAudioProcessorEditor(SurgefxAudioProcessor & knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); - knobSource->setValueFromGUI(knobSource->getDefaultValue()); + knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); knobSource->setLabel(paramName + " Knob"); knob->setSource(knobSource.get()); - addAndMakeVisible(*knob); + addAndMakeVisible(knob.get()); knobs.push_back(std::move(knob)); sources.push_back(std::move(knobSource)); @@ -304,7 +304,7 @@ void SurgefxAudioProcessorEditor::resetLabels() knob->setModulationDisplay(sst::jucegui::components::Knob::Modulatable::NONE); auto paramName = processor.getParamName(i) + " " + processor.getParamGroup(i); - knobSource->setValueFromGUI(knobSource->getDefaultValue()); + knobSource->setValueFromGUI(processor.getFXStorageValue01(i)); auto name = paramName + " Knob"; knobSource->setLabel(name);