13
0

Fix LADSPA default values for log-scale controls

This commit is contained in:
Robin Gareus 2023-02-23 15:05:14 +01:00
parent 52cfa9ff19
commit e1ef2c7e0d
Signed by: rgareus
GPG Key ID: A090BCE02CF57F04

View File

@ -188,6 +188,7 @@ LadspaPlugin::_default_value (uint32_t port) const
bool bounds_given = false;
bool sr_scaling = false;
bool earlier_hint = false;
bool logarithmic = LADSPA_IS_HINT_LOGARITHMIC (prh[port].HintDescriptor);
/* defaults - case 1 */
@ -199,17 +200,29 @@ LadspaPlugin::_default_value (uint32_t port) const
}
else if (LADSPA_IS_HINT_DEFAULT_LOW(prh[port].HintDescriptor)) {
ret = prh[port].LowerBound * 0.75f + prh[port].UpperBound * 0.25f;
if (logarithmic && prh[port].LowerBound * prh[port].UpperBound > 0) {
ret = exp (log(prh[port].LowerBound)) * 0.75f + log (prh[port].UpperBound) * 0.25f;
} else {
ret = prh[port].LowerBound * 0.75f + prh[port].UpperBound * 0.25f;
}
bounds_given = true;
sr_scaling = true;
}
else if (LADSPA_IS_HINT_DEFAULT_MIDDLE(prh[port].HintDescriptor)) {
ret = prh[port].LowerBound * 0.5f + prh[port].UpperBound * 0.5f;
if (logarithmic && prh[port].LowerBound * prh[port].UpperBound > 0) {
ret = exp (log(prh[port].LowerBound)) * 0.5f + log (prh[port].UpperBound) * 0.5f;
} else {
ret = prh[port].LowerBound * 0.5f + prh[port].UpperBound * 0.5f;
}
bounds_given = true;
sr_scaling = true;
}
else if (LADSPA_IS_HINT_DEFAULT_HIGH(prh[port].HintDescriptor)) {
ret = prh[port].LowerBound * 0.25f + prh[port].UpperBound * 0.75f;
if (logarithmic && prh[port].LowerBound * prh[port].UpperBound > 0) {
ret = exp (log(prh[port].LowerBound)) * 0.25f + log (prh[port].UpperBound) * 0.75f;
} else {
ret = prh[port].LowerBound * 0.25f + prh[port].UpperBound * 0.75f;
}
bounds_given = true;
sr_scaling = true;
}