Skip to content

Commit

Permalink
Expand drop->span caluclation (#1485)
Browse files Browse the repository at this point in the history
the drop->span calculation gets a sqrt and so on to make it feel
sensitive and natural but that skims too much of the end of the range
so add a bit of range management.

Closes #1477
  • Loading branch information
baconpaul authored Jan 24, 2025
1 parent b662ddf commit 3a9f958
Showing 1 changed file with 3 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -1019,6 +1019,9 @@ std::array<int16_t, 3> ZoneLayoutDisplay::rootAndRangeForPosition(const juce::Po
(float)ZoneLayoutKeyboard::firstMidiNote, (float)ZoneLayoutKeyboard::lastMidiNote);

auto fromTop = std::clamp((p.getY() - bip.getY()), 0, getHeight()) * 1.f / getHeight();
// have the top 10% cover the entire zone since the sqrt is a bit sensitive
static constexpr float zoneTrim{0.15f};
fromTop = std::clamp((fromTop - zoneTrim) / (1.f - zoneTrim), 0.f, 1.f);
auto span = (1.0f - sqrt(fromTop)) * 80;
auto low = std::clamp(rootKey - span, 0.f, 127.f);
auto high = std::clamp(rootKey + span, 0.f, 127.f);
Expand Down

0 comments on commit 3a9f958

Please sign in to comment.