Skip to content

Snap LADSPA Parameter Step Sizes to Powers of 10#8429

Open
extern-stat wants to merge 1 commit into
LMMS:masterfrom
extern-stat:model-step
Open

Snap LADSPA Parameter Step Sizes to Powers of 10#8429
extern-stat wants to merge 1 commit into
LMMS:masterfrom
extern-stat:model-step

Conversation

@extern-stat

Copy link
Copy Markdown
Contributor

Currently, LADSPA parameter step sizes are calculated by the code below:

( 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 ) ) )

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.00248007 would be rounded down to 0.001.

@JohannesLorenz

Copy link
Copy Markdown
Contributor

Sorry, I wanted to self-request a review, but accidentally clicked on Copilot. I will review anyways 😉

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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 LadspaControl to use an intermediate step variable before calling setRange().

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +83 to +88
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);

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@extern-stat Do you want to do changes according to this comment, or discard it?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants