diff --git a/Source/Gui/Knob.h b/Source/Gui/Knob.h index d0cf5ba..f9c4835 100644 --- a/Source/Gui/Knob.h +++ b/Source/Gui/Knob.h @@ -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 shiftDragCallback; + std::function shiftDragCallback, altDragCallback, alternativeValueMapCallback; private: Image kni; int fh, numFr; diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index 0f92e97..9db7c3d 100755 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -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(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);