Fix KnobEventHandler motion drag with log scale#531
Open
nabsei wants to merge 1 commit into
Open
Conversation
motionEvent() added the linear mouse delta directly to valueTmp and then applied logscale() once, but valueTmp is stored in log-scaled space when usingLog is set. This double-transforms the value instead of converting it back to linear space first, so dragging a log-scale knob stayed stuck near the minimum. Convert valueTmp through invlogscale() before adding the delta, same as the already-correct scrollEvent() a few lines below. Fixes DISTRHO#388
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #388.
motionEvent()added the linear mouse delta directly tovalueTmpand then appliedlogscale()once. ButvalueTmpis stored in log-scaled space whenusingLogis set (that's whatlogscale()at the end of each call produces), so adding a linear delta to it and then log-scaling again double-transforms the value — which is why dragging a log-scale knob stayed stuck near the minimum.The fix converts
valueTmpback to linear space viainvlogscale()before adding the delta, exactly like the already-correctscrollEvent()a few lines below in the same file (mouse wheel already worked correctly per the original report, and this makesmotionEvent()consistent with it).Verification:
logscale/invlogscaleformulas and both the old and newmotionEventcomputations. Simulating 5 drag steps of +1 linear unit each on a log-scale knob (range 1–100, starting at linear value 10): the old code converges to ~2.05 (confirming the reported bug — stuck near the minimum), the new code correctly reaches ~15.0 and matchesscrollEvent's math bit-for-bit.dglwith the Cairo backend (make -C dgl cairo) — compiles cleanly.CairoUIexample plugin across all formats (CLAP, DSSI, JACK standalone, LV2, VST2, VST3, AU) — all succeed.Small part of this fix (working through the log-scale round-trip math above) was done with the help of Claude Code.