Skip to content

Instantly share code, notes, and snippets.

@Xenakios
Created February 7, 2023 16:10
Show Gist options
  • Select an option

  • Save Xenakios/6d4917bc11e0c7075a64ac44668b485c to your computer and use it in GitHub Desktop.

Select an option

Save Xenakios/6d4917bc11e0c7075a64ac44668b485c to your computer and use it in GitHub Desktop.
struct ConcreteCM : sst::jucegui::data::ContinunousModulatable, juce::AudioParameterFloat::Listener,
juce::AsyncUpdater
{
juce::AudioParameterFloat* parToControl = nullptr;
void parameterValueChanged (int parameterIndex, float newValue) override
{
value = newValue;
triggerAsyncUpdate();
}
void handleAsyncUpdate() override
{
setValueFromModel(value);
}
void parameterGestureChanged (int parameterIndex, bool gestureIsStarting) override
{
}
~ConcreteCM()
{
parToControl->removeListener(this);
}
ConcreteCM(juce::AudioParameterFloat* p)
{
parToControl = p;
label = parToControl->getName(100).toStdString();
parToControl->addListener(this);
}
std::string label{"A Knob"};
std::string getLabel() const override { return label; }
float value{0};
float getValue() const override
{
return *parToControl;
}
void setValueFromGUI(const float &f) override
{
value = f;
*parToControl = 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
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment