From 767c0238a34ef4acc4d345e88cd5ddb0c8a8e421 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 1 Dec 2014 14:28:03 -0500 Subject: Replace half-baked param metadata with descriptor. Among other things, this means that automation controls/lists have the actual min/max/normal/toggled of parameters, and not those inferred from the Parameter ID, which is not correct for things like plugin parameters. Pushing things down to the Evoral::ParmeterDescriptor may be useful in the future to have lists do smarter things based on parameter range, but currently I have just pushed down the above-mentioned currently used attributes. --- libs/ardour/ardour/parameter_descriptor.h | 76 +++---------------------------- 1 file changed, 7 insertions(+), 69 deletions(-) (limited to 'libs/ardour/ardour/parameter_descriptor.h') diff --git a/libs/ardour/ardour/parameter_descriptor.h b/libs/ardour/ardour/parameter_descriptor.h index 41b1f031d1..d4bef550f5 100644 --- a/libs/ardour/ardour/parameter_descriptor.h +++ b/libs/ardour/ardour/parameter_descriptor.h @@ -21,7 +21,9 @@ #define __ardour_parameter_descriptor_h__ #include "ardour/variant.h" + #include "evoral/Parameter.hpp" +#include "evoral/ParameterDescriptor.hpp" namespace ARDOUR { @@ -31,7 +33,7 @@ typedef std::map ScalePoints; * * Essentially a union of LADSPA, VST and LV2 info. */ -struct ParameterDescriptor +struct ParameterDescriptor : public Evoral::ParameterDescriptor { enum Unit { NONE, ///< No unit @@ -40,72 +42,12 @@ struct ParameterDescriptor HZ, ///< Frequency in Hertz }; - ParameterDescriptor(const Evoral::Parameter& parameter) - : key((uint32_t)-1) - , datatype(Variant::NOTHING) - , unit(NONE) - , normal(parameter.normal()) - , lower(parameter.min()) - , upper(parameter.max()) - , step(0) - , smallstep(0) - , largestep(0) - , integer_step(parameter.type() >= MidiCCAutomation && - parameter.type() <= MidiChannelPressureAutomation) - , toggled(parameter.toggled()) - , logarithmic(false) - , sr_dependent(false) - , min_unbound(0) - , max_unbound(0) - , enumeration(false) - { - if (parameter.type() == GainAutomation) { - unit = DB; - } - update_steps(); - } - - ParameterDescriptor() - : key((uint32_t)-1) - , datatype(Variant::NOTHING) - , unit(NONE) - , normal(0) - , lower(0) - , upper(0) - , step(0) - , smallstep(0) - , largestep(0) - , integer_step(false) - , toggled(false) - , logarithmic(false) - , sr_dependent(false) - , min_unbound(0) - , max_unbound(0) - , enumeration(false) - {} - - /* Set step, smallstep, and largestep, based on current description */ - void update_steps() { - if (unit == ParameterDescriptor::MIDI_NOTE) { - step = smallstep = 1; // semitone - largestep = 12; // octave - } else if (integer_step) { - const float delta = upper - lower; + ParameterDescriptor(const Evoral::Parameter& parameter); - smallstep = delta / 10000.0f; - step = delta / 1000.0f; - largestep = delta / 40.0f; + ParameterDescriptor(); - smallstep = std::max(1.0, rint(smallstep)); - step = std::max(1.0, rint(step)); - largestep = std::max(1.0, rint(largestep)); - } - /* else: leave all others as default '0' - * in that case the UI (eg. AutomationController::create) - * uses internal_to_interface() to map the value - * to an appropriate interface range - */ - } + /** Set step, smallstep, and largestep, based on current description. */ + void update_steps(); std::string label; std::string print_fmt; ///< format string for pretty printing @@ -113,14 +55,10 @@ struct ParameterDescriptor uint32_t key; ///< for properties Variant::Type datatype; ///< for properties Unit unit; - float normal; - float lower; ///< for frequencies, this is in Hz (not a fraction of the sample rate) - float upper; ///< for frequencies, this is in Hz (not a fraction of the sample rate) float step; float smallstep; float largestep; bool integer_step; - bool toggled; bool logarithmic; bool sr_dependent; bool min_unbound; -- cgit v1.2.3