Alt OSC1/2 semitone lock and Step fix
This commit is contained in:
parent
95b1525c3f
commit
0ab0aaca0b
2 changed files with 45 additions and 2 deletions
|
@ -62,6 +62,7 @@ public:
|
||||||
w2 = kni.getWidth();
|
w2 = kni.getWidth();
|
||||||
numFr = kni.getHeight() / h2;
|
numFr = kni.getHeight() / h2;
|
||||||
setLookAndFeel(&lookAndFeel);
|
setLookAndFeel(&lookAndFeel);
|
||||||
|
setVelocityModeParameters(1.0, 1, 0.0, true, ModifierKeys::ctrlModifier);
|
||||||
}
|
}
|
||||||
|
|
||||||
~Knob() override
|
~Knob() override
|
||||||
|
@ -104,6 +105,17 @@ public:
|
||||||
setValue(shiftDragCallback(getValue()), sendNotificationAsync);
|
setValue(shiftDragCallback(getValue()), sendNotificationAsync);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (event.mods.isAltDown())
|
||||||
|
{
|
||||||
|
if (altDragCallback)
|
||||||
|
{
|
||||||
|
setValue(altDragCallback(getValue()), sendNotificationAsync);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (alternativeValueMapCallback)
|
||||||
|
{
|
||||||
|
setValue(alternativeValueMapCallback(getValue()), sendNotificationAsync);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
|
// Source: https://git.iem.at/audioplugins/IEMPluginSuite/-/blob/master/resources/customComponents/ReverseSlider.h
|
||||||
|
@ -160,7 +172,7 @@ public:
|
||||||
resetActionMessage = identifier;
|
resetActionMessage = identifier;
|
||||||
}
|
}
|
||||||
|
|
||||||
std::function<double(double)> shiftDragCallback;
|
std::function<double(double)> shiftDragCallback, altDragCallback, alternativeValueMapCallback;
|
||||||
private:
|
private:
|
||||||
Image kni;
|
Image kni;
|
||||||
int fh, numFr;
|
int fh, numFr;
|
||||||
|
|
|
@ -228,6 +228,11 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
||||||
if (value < 0.875) return 0.75;
|
if (value < 0.875) return 0.75;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
};
|
};
|
||||||
|
osc1PitchKnob->altDragCallback = [](double value)
|
||||||
|
{
|
||||||
|
const auto semitoneValue = (int)jmap(value, -24.0, 24.0);
|
||||||
|
return jmap((double)semitoneValue, -24.0, 24.0, 0.0, 1.0);
|
||||||
|
};
|
||||||
mappingComps["osc1PitchKnob"] = osc1PitchKnob;
|
mappingComps["osc1PitchKnob"] = osc1PitchKnob;
|
||||||
}
|
}
|
||||||
if (name == "pulseWidthKnob"){
|
if (name == "pulseWidthKnob"){
|
||||||
|
@ -244,6 +249,11 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
||||||
if (value < 0.875) return 0.75;
|
if (value < 0.875) return 0.75;
|
||||||
return 1.0;
|
return 1.0;
|
||||||
};
|
};
|
||||||
|
osc2PitchKnob->altDragCallback = [](double value)
|
||||||
|
{
|
||||||
|
const auto semitoneValue = (int)jmap(value, -24.0, 24.0);
|
||||||
|
return jmap((double)semitoneValue, -24.0, 24.0, 0.0, 1.0);
|
||||||
|
};
|
||||||
mappingComps["osc2PitchKnob"] = osc2PitchKnob;
|
mappingComps["osc2PitchKnob"] = osc2PitchKnob;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -384,6 +394,27 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
|
||||||
|
|
||||||
if (name == "pitchQuantButton"){
|
if (name == "pitchQuantButton"){
|
||||||
pitchQuantButton = addButton (x, y, w, h, ownerFilter, OSCQuantize, "Step");
|
pitchQuantButton = addButton (x, y, w, h, ownerFilter, OSCQuantize, "Step");
|
||||||
|
pitchQuantButton->onStateChange = [&]
|
||||||
|
{
|
||||||
|
const auto isButtonOn = pitchQuantButton->getToggleState();
|
||||||
|
const auto configureOscKnob = [&](const String& parameter)
|
||||||
|
{
|
||||||
|
if (auto* knob = dynamic_cast<Knob*>(mappingComps[parameter]))
|
||||||
|
{
|
||||||
|
if (isButtonOn)
|
||||||
|
knob->alternativeValueMapCallback = [](double value)
|
||||||
|
{
|
||||||
|
const auto semitoneValue = (int)jmap(value, -24.0, 24.0);
|
||||||
|
return jmap((double)semitoneValue, -24.0, 24.0, 0.0, 1.0);
|
||||||
|
};
|
||||||
|
else
|
||||||
|
knob->alternativeValueMapCallback = nullptr;
|
||||||
|
}
|
||||||
|
};
|
||||||
|
configureOscKnob("osc1PitchKnob");
|
||||||
|
configureOscKnob("osc2PitchKnob");
|
||||||
|
|
||||||
|
};
|
||||||
mappingComps["pitchQuantButton"] = pitchQuantButton;
|
mappingComps["pitchQuantButton"] = pitchQuantButton;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -739,7 +770,7 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
|
||||||
knob->setRange (0, 1);
|
knob->setRange (0, 1);
|
||||||
knob->setBounds (x, y, d+(d/6), d+(d/6));
|
knob->setBounds (x, y, d+(d/6), d+(d/6));
|
||||||
knob->setTextBoxIsEditable (false);
|
knob->setTextBoxIsEditable (false);
|
||||||
knob->setDoubleClickReturnValue (true, defval);
|
knob->setDoubleClickReturnValue (true, defval, ModifierKeys::noModifiers);
|
||||||
knob->setValue (filter.getPluginState().getParameter (filter.getEngineParameterId (parameter))->getValue());
|
knob->setValue (filter.getPluginState().getParameter (filter.getEngineParameterId (parameter))->getValue());
|
||||||
addAndMakeVisible (knob);
|
addAndMakeVisible (knob);
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue