From 36e32e564126e4587e3c2bee829c58876e65d285 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 21 Jun 2017 13:40:41 +0200 Subject: [PATCH] Remove separate ControlList min/max/default, use ParameterDescriptor. --- libs/ardour/automation_list.cc | 15 ------------ libs/ardour/gain_control.cc | 2 -- libs/ardour/plugin_insert.cc | 29 ----------------------- libs/evoral/evoral/ControlList.hpp | 16 ------------- libs/evoral/src/Control.cpp | 2 +- libs/evoral/src/ControlList.cpp | 37 ++++++++++-------------------- libs/evoral/src/Curve.cpp | 2 +- 7 files changed, 14 insertions(+), 89 deletions(-) diff --git a/libs/ardour/automation_list.cc b/libs/ardour/automation_list.cc index fbeb98fa26..f456ac210b 100644 --- a/libs/ardour/automation_list.cc +++ b/libs/ardour/automation_list.cc @@ -321,9 +321,6 @@ AutomationList::state (bool full) root->set_property ("automation-id", EventTypeMap::instance().to_symbol(_parameter)); root->set_property ("id", id()); - root->set_property ("default", _default_value); - root->set_property ("min-yval", _min_yval); - root->set_property ("max-yval", _max_yval); root->set_property ("interpolation-style", _interpolation); if (full) { @@ -495,10 +492,6 @@ AutomationList::set_state (const XMLNode& node, int version) _interpolation = Linear; } - if (!node.get_property (X_("default"), _default_value)) { - _default_value = 0.0; - } - if (node.get_property (X_("state"), _state)) { if (_state == Write) { _state = Off; @@ -508,14 +501,6 @@ AutomationList::set_state (const XMLNode& node, int version) _state = Off; } - if (!node.get_property (X_("min-yval"), _min_yval)) { - _min_yval = FLT_MIN; - } - - if (!node.get_property (X_("max-yval"), _max_yval)) { - _max_yval = FLT_MAX; - } - bool have_events = false; for (niter = nlist.begin(); niter != nlist.end(); ++niter) { diff --git a/libs/ardour/gain_control.cc b/libs/ardour/gain_control.cc index 35f666bdf1..36a161059c 100644 --- a/libs/ardour/gain_control.cc +++ b/libs/ardour/gain_control.cc @@ -40,8 +40,6 @@ GainControl::GainControl (Session& session, const Evoral::Parameter ¶m, boos param.type() == GainAutomation ? X_("gaincontrol") : X_("trimcontrol"), Controllable::GainLike) { - alist()->reset_default (1.0); - lower_db = accurate_coefficient_to_dB (_desc.lower); range_db = accurate_coefficient_to_dB (_desc.upper) - lower_db; } diff --git a/libs/ardour/plugin_insert.cc b/libs/ardour/plugin_insert.cc index ece0fbe40d..6dbfcc6a2b 100644 --- a/libs/ardour/plugin_insert.cc +++ b/libs/ardour/plugin_insert.cc @@ -2767,30 +2767,6 @@ PluginInsert::set_parameter_state_2X (const XMLNode& node, int version) if (c && c->alist()) { if (!child->children().empty()) { c->alist()->set_state (*child->children().front(), version); - - /* In some cases 2.X saves lists with min_yval and max_yval - being FLT_MIN and FLT_MAX respectively. This causes problems - in A3 because these min/max values are used to compute - where GUI control points should be drawn. If we see such - values, `correct' them to the min/max of the appropriate - parameter. - */ - - float min_y = c->alist()->get_min_y (); - float max_y = c->alist()->get_max_y (); - - ParameterDescriptor desc; - _plugins.front()->get_parameter_descriptor (port_id, desc); - - if (min_y == FLT_MIN) { - min_y = desc.lower; - } - - if (max_y == FLT_MAX) { - max_y = desc.upper; - } - - c->alist()->set_yrange (min_y, max_y); } } else { error << string_compose (_("PluginInsert: automatable control %1 not found - ignored"), port_id) << endmsg; @@ -2855,7 +2831,6 @@ PluginInsert::PluginControl::PluginControl (PluginInsert* p, , _plugin (p) { if (alist()) { - alist()->reset_default (desc.normal); if (desc.toggled) { list->set_interpolation(Evoral::ControlList::Discrete); } @@ -2922,10 +2897,6 @@ PluginInsert::PluginPropertyControl::PluginPropertyControl (PluginInsert* : AutomationControl (p->session(), param, desc, list) , _plugin (p) { - if (alist()) { - alist()->set_yrange (desc.lower, desc.upper); - alist()->reset_default (desc.normal); - } } void diff --git a/libs/evoral/evoral/ControlList.hpp b/libs/evoral/evoral/ControlList.hpp index 109124162b..99958d79fb 100644 --- a/libs/evoral/evoral/ControlList.hpp +++ b/libs/evoral/evoral/ControlList.hpp @@ -113,10 +113,6 @@ public: } bool empty() const { return _events.empty(); } - void reset_default (double val) { - _default_value = val; - } - void clear (); void x_scale (double factor); bool extend_to (double); @@ -177,14 +173,6 @@ public: bool paste (const ControlList&, double position); - void set_yrange (double min, double max) { - _min_yval = min; - _max_yval = max; - } - - double get_max_y() const { return _max_yval; } - double get_min_y() const { return _min_yval; } - /** truncate the event list after the given time * @param last_coordinate last event to include */ @@ -258,7 +246,6 @@ public: }; const EventList& events() const { return _events; } - double default_value() const { return _default_value; } // FIXME: const violations for Curve Glib::Threads::RWLock& lock() const { return _lock; } @@ -348,9 +335,6 @@ protected: EventList _events; int8_t _frozen; bool _changed_when_thawed; - double _min_yval; - double _max_yval; - double _default_value; bool _sort_pending; Curve* _curve; diff --git a/libs/evoral/src/Control.cpp b/libs/evoral/src/Control.cpp index 56f5f70f2c..8d53d3f276 100644 --- a/libs/evoral/src/Control.cpp +++ b/libs/evoral/src/Control.cpp @@ -29,7 +29,7 @@ Control::Control(const Parameter& parameter, const ParameterDescriptor& desc, boost::shared_ptr list) : _parameter(parameter) - , _user_value(list ? list->default_value() : desc.normal) + , _user_value(desc.normal) { set_list (list); } diff --git a/libs/evoral/src/ControlList.cpp b/libs/evoral/src/ControlList.cpp index 0ec9cad814..3a3737004b 100644 --- a/libs/evoral/src/ControlList.cpp +++ b/libs/evoral/src/ControlList.cpp @@ -59,9 +59,6 @@ ControlList::ControlList (const Parameter& id, const ParameterDescriptor& desc) _interpolation = desc.toggled ? Discrete : Linear; _frozen = 0; _changed_when_thawed = false; - _min_yval = desc.lower; - _max_yval = desc.upper; - _default_value = desc.normal; _lookup_cache.left = -1; _lookup_cache.range.first = _events.end(); _lookup_cache.range.second = _events.end(); @@ -83,9 +80,6 @@ ControlList::ControlList (const ControlList& other) { _frozen = 0; _changed_when_thawed = false; - _min_yval = other._min_yval; - _max_yval = other._max_yval; - _default_value = other._default_value; _lookup_cache.range.first = _events.end(); _lookup_cache.range.second = _events.end(); _search_cache.first = _events.end(); @@ -109,9 +103,6 @@ ControlList::ControlList (const ControlList& other, double start, double end) { _frozen = 0; _changed_when_thawed = false; - _min_yval = other._min_yval; - _max_yval = other._max_yval; - _default_value = other._default_value; _lookup_cache.range.first = _events.end(); _lookup_cache.range.second = _events.end(); _search_cache.first = _events.end(); @@ -161,12 +152,8 @@ ControlList::operator= (const ControlList& other) { if (this != &other) { - _min_yval = other._min_yval; - _max_yval = other._max_yval; - _interpolation = other._interpolation; - _default_value = other._default_value; copy_events (other); } @@ -553,8 +540,8 @@ ControlList::editor_add (double when, double value, bool with_guard) /* clamp new value to allowed range */ - value = max (_min_yval, value); - value = min (_max_yval, value); + value = max ((double)_desc.lower, value); + value = min ((double)_desc.upper, value); iterator result; DEBUG_TRACE (DEBUG::ControlList, string_compose ("editor_add: actually add when= %1 value= %2\n", when, value)); @@ -663,7 +650,7 @@ ControlList::add (double when, double value, bool with_guards, bool with_initial } else { _events.insert (_events.end(), new ControlEvent (0, value)); - DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _default_value)); + DEBUG_TRACE (DEBUG::ControlList, string_compose ("@%1 added default value %2 at zero\n", this, _desc.normal)); } } } @@ -1085,8 +1072,8 @@ ControlList::truncate_end (double last_coordinate) /* shortening end */ last_val = unlocked_eval (last_coordinate); - last_val = max ((double) _min_yval, last_val); - last_val = min ((double) _max_yval, last_val); + last_val = max ((double) _desc.lower, last_val); + last_val = min ((double) _desc.upper, last_val); i = _events.rbegin(); @@ -1187,8 +1174,8 @@ ControlList::truncate_start (double overall_length) first_legal_coordinate = _events.back()->when - overall_length; first_legal_value = unlocked_eval (first_legal_coordinate); - first_legal_value = max (_min_yval, first_legal_value); - first_legal_value = min (_max_yval, first_legal_value); + first_legal_value = max ((double)_desc.lower, first_legal_value); + first_legal_value = min ((double)_desc.upper, first_legal_value); /* remove all events earlier than the new "front" */ @@ -1248,7 +1235,7 @@ ControlList::unlocked_eval (double x) const switch (npoints) { case 0: - return _default_value; + return _desc.normal; case 1: return _events.front()->value; @@ -1284,7 +1271,7 @@ ControlList::unlocked_eval (double x) const } abort(); /*NOTREACHED*/ /* stupid gcc */ - return _default_value; + return _desc.normal; } double @@ -1869,9 +1856,9 @@ ControlList::operator!= (ControlList const & other) const return ( _parameter != other._parameter || _interpolation != other._interpolation || - _min_yval != other._min_yval || - _max_yval != other._max_yval || - _default_value != other._default_value + _desc.lower != other._desc.lower || + _desc.upper != other._desc.upper || + _desc.normal != other._desc.normal ); } diff --git a/libs/evoral/src/Curve.cpp b/libs/evoral/src/Curve.cpp index 83fd0756bd..07dd158079 100644 --- a/libs/evoral/src/Curve.cpp +++ b/libs/evoral/src/Curve.cpp @@ -203,7 +203,7 @@ Curve::_get_vector (double x0, double x1, float *vec, int32_t veclen) const if ((npoints = _list.events().size()) == 0) { /* no events in list, so just fill the entire array with the default value */ for (int32_t i = 0; i < veclen; ++i) { - vec[i] = _list.default_value(); + vec[i] = _list.descriptor().normal; } return; } -- 2.30.2