2
0
Fork 0

Alt OSC1/2 semitone lock and Step fix

This commit is contained in:
George Reales 2022-03-11 18:22:24 +01:00
parent 95b1525c3f
commit 0ab0aaca0b
2 changed files with 45 additions and 2 deletions

View File

@ -62,6 +62,7 @@ public:
w2 = kni.getWidth();
numFr = kni.getHeight() / h2;
setLookAndFeel(&lookAndFeel);
setVelocityModeParameters(1.0, 1, 0.0, true, ModifierKeys::ctrlModifier);
}
~Knob() override
@ -104,6 +105,17 @@ public:
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
@ -160,7 +172,7 @@ public:
resetActionMessage = identifier;
}
std::function<double(double)> shiftDragCallback;
std::function<double(double)> shiftDragCallback, altDragCallback, alternativeValueMapCallback;
private:
Image kni;
int fh, numFr;

View File

@ -228,6 +228,11 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
if (value < 0.875) return 0.75;
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;
}
if (name == "pulseWidthKnob"){
@ -244,6 +249,11 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
if (value < 0.875) return 0.75;
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;
}
@ -384,6 +394,27 @@ void ObxdAudioProcessorEditor::loadSkin (ObxdAudioProcessor& ownerFilter)
if (name == "pitchQuantButton"){
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;
}
@ -739,7 +770,7 @@ Knob* ObxdAudioProcessorEditor::addKnob (int x, int y, int d, ObxdAudioProcessor
knob->setRange (0, 1);
knob->setBounds (x, y, d+(d/6), d+(d/6));
knob->setTextBoxIsEditable (false);
knob->setDoubleClickReturnValue (true, defval);
knob->setDoubleClickReturnValue (true, defval, ModifierKeys::noModifiers);
knob->setValue (filter.getPluginState().getParameter (filter.getEngineParameterId (parameter))->getValue());
addAndMakeVisible (knob);