Snap LADSPA Parameter Step Sizes to Powers of 10#8429
Conversation
|
Sorry, I wanted to self-request a review, but accidentally clicked on Copilot. I will review anyways 😉 |
There was a problem hiding this comment.
Pull request overview
This PR improves LADSPA floating-point control resolution handling by snapping the computed parameter step size down to the nearest power of 10, aligning the knob-drag granularity with the “set value” dialog’s decimal precision expectations.
Changes:
- Computes a floating-point LADSPA control step size and snaps it down to a power-of-10 increment.
- Refactors the floating-point case in
LadspaControlto use an intermediatestepvariable before callingsetRange().
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| case BufferDataType::Floating: { | ||
| float step = (m_port->max - m_port->min) | ||
| / (m_port->name.toUpper() == "GAIN" | ||
| && m_port->max == 10.0f ? 4000.0f : (m_port->suggests_logscale ? 8000000.0f : 800000.0f)); | ||
| step = 1.0f / std::pow(10.0f, std::ceil(-std::log10(step))); | ||
| m_knobModel.setRange(m_port->min, m_port->max, step); |
There was a problem hiding this comment.
@extern-stat Do you want to do changes according to this comment, or discard it?
There was a problem hiding this comment.
I think we can discard it, since the code that was originally there would also break if the min was greater than the max. Also, the min and max values for LADSPA plugin parameters are set in .xml files, so if they are invalid, it should be fixed in the .xml file instead of in LadspaControl.cpp.
Currently, LADSPA parameter step sizes are calculated by the code below:
Which can result in step sizes that are not a power of 10. This can lead to issues with the set value dialog for those parameters having less decimal places than you can get by dragging. To fix this, this PR rounds the step size of floating-point LADSPA parameters down to the nearest power of 10. For example, a calculated step size of
0.00248007would be rounded down to0.001.