midi-controller, support log parameters - fixes #5890
This commit is contained in:
parent
c0845bed53
commit
af0c42ec4f
|
@ -1184,6 +1184,10 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, const Evoral::Param
|
|||
_logarithmic = desc.logarithmic;
|
||||
_sr_dependent = desc.sr_dependent;
|
||||
_toggled = desc.toggled;
|
||||
|
||||
if (desc.toggled) {
|
||||
set_flags(Controllable::Toggle);
|
||||
}
|
||||
}
|
||||
|
||||
/** @param val `user' value */
|
||||
|
|
|
@ -167,7 +167,7 @@ MIDIControllable::control_to_midi (float val)
|
|||
|
||||
float control_min = controllable->lower ();
|
||||
float control_max = controllable->upper ();
|
||||
const float control_range = control_max - control_min;
|
||||
float control_range = control_max - control_min;
|
||||
|
||||
if (controllable->is_toggle()) {
|
||||
if (val >= (control_min + (control_range/2.0f))) {
|
||||
|
@ -175,6 +175,14 @@ MIDIControllable::control_to_midi (float val)
|
|||
} else {
|
||||
return 0;
|
||||
}
|
||||
} else {
|
||||
AutomationControl *actl = dynamic_cast<AutomationControl*> (controllable);
|
||||
if (actl) {
|
||||
control_min = actl->internal_to_interface(control_min);
|
||||
control_max = actl->internal_to_interface(control_max);
|
||||
control_range = control_max - control_min;
|
||||
val = actl->internal_to_interface(val);
|
||||
}
|
||||
}
|
||||
|
||||
return (val - control_min) / control_range * max_value_for_type ();
|
||||
|
@ -196,8 +204,17 @@ MIDIControllable::midi_to_control (int val)
|
|||
|
||||
float control_min = controllable->lower ();
|
||||
float control_max = controllable->upper ();
|
||||
const float control_range = control_max - control_min;
|
||||
float control_range = control_max - control_min;
|
||||
|
||||
AutomationControl *actl = dynamic_cast<AutomationControl*> (controllable);
|
||||
if (actl) {
|
||||
if (fv == 0.f) return control_min;
|
||||
if (fv == 1.f) return control_max;
|
||||
control_min = actl->internal_to_interface(control_min);
|
||||
control_max = actl->internal_to_interface(control_max);
|
||||
control_range = control_max - control_min;
|
||||
return actl->interface_to_internal((fv * control_range) + control_min);
|
||||
}
|
||||
return (fv * control_range) + control_min;
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user