mirror of
https://codeberg.org/armin/chromaflock.git
synced 2026-09-01 12:20:47 +02:00
Make pitch bend wheel drag start at center (0)
This commit is contained in:
parent
27cb9d3a85
commit
c45d12db1d
1 changed files with 9 additions and 4 deletions
|
|
@ -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<float>(pos.y) / static_cast<float>(whiteKeyHeight);
|
||||
float pbNorm = 2.0f * static_cast<float>(pitchBendStartY - pos.y) / static_cast<float>(whiteKeyHeight);
|
||||
pbNorm = std::clamp(pbNorm, -1.0f, 1.0f);
|
||||
currentPitchBend = 64 + static_cast<int>(pbNorm * 64.0f);
|
||||
processor.pitchBendValue.store(pbNorm);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue