From c45d12db1d474eb128b79e0049a8634aa42ef713 Mon Sep 17 00:00:00 2001 From: Armin Date: Wed, 15 Jul 2026 23:53:34 +0200 Subject: [PATCH] Make pitch bend wheel drag start at center (0) --- Source/PluginEditor.cpp | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/Source/PluginEditor.cpp b/Source/PluginEditor.cpp index dc126bd..b26109f 100644 --- a/Source/PluginEditor.cpp +++ b/Source/PluginEditor.cpp @@ -1332,9 +1332,14 @@ void PianoRollComponent::paint(juce::Graphics& g) { void PianoRollComponent::mouseDown(const juce::MouseEvent& e) { auto pos = e.getPosition(); - // Pitch bend strip: ignore plain clicks — require a vertical drag (see mouseDrag) + // Pitch bend strip: begin a drag that starts from center (0 bend) if (pos.x < pitchBendWidth) { - pitchBendDragging = false; + pitchBendDragging = true; + pitchBendGliding = false; + pitchBendStartY = pos.y; + currentPitchBend = 64; + processor.pitchBendValue.store(0.0f); + repaint(); return; } @@ -1387,11 +1392,11 @@ void PianoRollComponent::timerCallback() { void PianoRollComponent::mouseDrag(const juce::MouseEvent& e) { auto pos = e.getPosition(); - // Pitch bend drag — only while touching the strip + // Pitch bend drag — relative to where the drag started (starts at 0) if (pos.x < pitchBendWidth) { pitchBendDragging = true; pitchBendGliding = false; - float pbNorm = 1.0f - 2.0f * static_cast(pos.y) / static_cast(whiteKeyHeight); + float pbNorm = 2.0f * static_cast(pitchBendStartY - pos.y) / static_cast(whiteKeyHeight); pbNorm = std::clamp(pbNorm, -1.0f, 1.0f); currentPitchBend = 64 + static_cast(pbNorm * 64.0f); processor.pitchBendValue.store(pbNorm);