Add API to compute parameter delta, depending on AutomationType
This commit is contained in:
parent
37905d82a6
commit
16624f3139
|
@ -73,6 +73,10 @@ struct LIBARDOUR_API ParameterDescriptor : public Evoral::ParameterDescriptor
|
||||||
*/
|
*/
|
||||||
float from_interface (float) const;
|
float from_interface (float) const;
|
||||||
|
|
||||||
|
bool is_linear () const;
|
||||||
|
float compute_delta (float from, float to) const;
|
||||||
|
float apply_delta (float value, float delta) const;
|
||||||
|
|
||||||
/** Set step, smallstep, and largestep, based on current description. */
|
/** Set step, smallstep, and largestep, based on current description. */
|
||||||
void update_steps();
|
void update_steps();
|
||||||
|
|
||||||
|
|
|
@ -354,4 +354,43 @@ ParameterDescriptor::from_interface (float val) const
|
||||||
return val;
|
return val;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool
|
||||||
|
ParameterDescriptor::is_linear () const
|
||||||
|
{
|
||||||
|
if (logarithmic) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
switch(type) {
|
||||||
|
case GainAutomation:
|
||||||
|
case EnvelopeAutomation:
|
||||||
|
case BusSendLevel:
|
||||||
|
return false;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
ParameterDescriptor::compute_delta (float from, float to) const
|
||||||
|
{
|
||||||
|
if (is_linear ()) {
|
||||||
|
return to - from;
|
||||||
|
}
|
||||||
|
if (from == 0) {
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
return to / from;
|
||||||
|
}
|
||||||
|
|
||||||
|
float
|
||||||
|
ParameterDescriptor::apply_delta (float val, float delta) const
|
||||||
|
{
|
||||||
|
if (is_linear ()) {
|
||||||
|
return val + delta;
|
||||||
|
} else {
|
||||||
|
return val * delta;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
} // namespace ARDOUR
|
} // namespace ARDOUR
|
||||||
|
|
Loading…
Reference in New Issue
Block a user