From 3d26a29e8a2ed1286091fda2dd480bf5bbebe365 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Sun, 14 May 2017 00:16:02 +0200 Subject: [PATCH] Sanitize "well-known" ctrl API --- libs/ardour/ardour/route.h | 10 ++-- libs/ardour/ardour/stripable.h | 9 ++- libs/ardour/ardour/vca.h | 12 ++-- libs/ardour/luabindings.cc | 6 +- libs/ardour/route.cc | 74 ++++++++++++++---------- libs/surfaces/faderport8/faderport8.cc | 8 +-- libs/surfaces/mackie/strip.cc | 16 ++--- libs/surfaces/osc/osc.cc | 4 +- libs/surfaces/osc/osc_select_observer.cc | 9 +-- 9 files changed, 81 insertions(+), 67 deletions(-) diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index 038e750d01..0879071aca 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -504,16 +504,16 @@ public: */ uint32_t eq_band_cnt () const; std::string eq_band_name (uint32_t) const; + boost::shared_ptr eq_enable_controllable () const; boost::shared_ptr eq_gain_controllable (uint32_t band) const; boost::shared_ptr eq_freq_controllable (uint32_t band) const; boost::shared_ptr eq_q_controllable (uint32_t band) const; boost::shared_ptr eq_shape_controllable (uint32_t band) const; - boost::shared_ptr eq_enable_controllable () const; - boost::shared_ptr eq_hpf_controllable () const; - //additional filter params (currently 32C only ) - boost::shared_ptr eq_lpf_controllable () const; - boost::shared_ptr filter_enable_controllable () const; + //additional HP/LP filters + boost::shared_ptr filter_freq_controllable (bool hpf) const; + boost::shared_ptr filter_slope_controllable (bool) const; + boost::shared_ptr filter_enable_controllable (bool) const; /* "well-known" controls for a compressor in this route. Any or all may diff --git a/libs/ardour/ardour/stripable.h b/libs/ardour/ardour/stripable.h index dea2d55c89..b657ac6161 100644 --- a/libs/ardour/ardour/stripable.h +++ b/libs/ardour/ardour/stripable.h @@ -134,17 +134,16 @@ class LIBARDOUR_API Stripable : public SessionObject, * return of a null ptr (or an empty string for eq_band_name()). */ virtual uint32_t eq_band_cnt () const = 0; + virtual boost::shared_ptr eq_enable_controllable () const = 0; virtual std::string eq_band_name (uint32_t) const = 0; virtual boost::shared_ptr eq_gain_controllable (uint32_t band) const = 0; virtual boost::shared_ptr eq_freq_controllable (uint32_t band) const = 0; virtual boost::shared_ptr eq_q_controllable (uint32_t band) const = 0; virtual boost::shared_ptr eq_shape_controllable (uint32_t band) const = 0; - virtual boost::shared_ptr eq_enable_controllable () const = 0; - virtual boost::shared_ptr eq_hpf_controllable () const = 0; - //additional filter params (currently 32C only ) - virtual boost::shared_ptr eq_lpf_controllable () const = 0; - virtual boost::shared_ptr filter_enable_controllable () const = 0; + virtual boost::shared_ptr filter_freq_controllable (bool hp /* false for LPF*/) const = 0; + virtual boost::shared_ptr filter_slope_controllable (bool hp) const = 0; + virtual boost::shared_ptr filter_enable_controllable (bool hp) const = 0; /* "well-known" controls for a compressor in this route. Any or all may * be null. diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index 8ef0b9d241..fa0b08a2cf 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -119,12 +119,14 @@ class LIBARDOUR_API VCA : public Stripable, boost::shared_ptr pan_lfe_control() const { return boost::shared_ptr(); } uint32_t eq_band_cnt () const { return 0; } std::string eq_band_name (uint32_t) const { return std::string(); } - boost::shared_ptr eq_gain_controllable (uint32_t band) const { return boost::shared_ptr(); } - boost::shared_ptr eq_freq_controllable (uint32_t band) const { return boost::shared_ptr(); } - boost::shared_ptr eq_q_controllable (uint32_t band) const { return boost::shared_ptr(); } - boost::shared_ptr eq_shape_controllable (uint32_t band) const { return boost::shared_ptr(); } boost::shared_ptr eq_enable_controllable () const { return boost::shared_ptr(); } - boost::shared_ptr eq_hpf_controllable () const { return boost::shared_ptr(); } + boost::shared_ptr eq_gain_controllable (uint32_t) const { return boost::shared_ptr(); } + boost::shared_ptr eq_freq_controllable (uint32_t) const { return boost::shared_ptr(); } + boost::shared_ptr eq_q_controllable (uint32_t) const { return boost::shared_ptr(); } + boost::shared_ptr eq_shape_controllable (uint32_t) const { return boost::shared_ptr(); } + boost::shared_ptr filter_freq_controllable (bool) const { return boost::shared_ptr(); } + boost::shared_ptr filter_slope_controllable (bool) const { return boost::shared_ptr(); } + boost::shared_ptr filter_enable_controllable (bool) const { return boost::shared_ptr(); } boost::shared_ptr comp_enable_controllable () const { return boost::shared_ptr(); } boost::shared_ptr comp_threshold_controllable () const { return boost::shared_ptr(); } boost::shared_ptr comp_speed_controllable () const { return boost::shared_ptr(); } diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index bd7f8ada13..cfc5bb82d8 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -976,13 +976,15 @@ LuaBindings::common (lua_State* L) .addFunction ("comp_mode_name", &Stripable::comp_mode_name) .addFunction ("comp_speed_name", &Stripable::comp_speed_name) .addFunction ("eq_band_cnt ", &Stripable::eq_band_cnt) + .addFunction ("eq_enable_control ", &Stripable::eq_enable_controllable ) .addFunction ("eq_band_name", &Stripable::eq_band_name) .addFunction ("eq_gain_control", &Stripable::eq_gain_controllable) .addFunction ("eq_freq_control ", &Stripable::eq_freq_controllable ) .addFunction ("eq_q_control ", &Stripable::eq_q_controllable ) .addFunction ("eq_shape_control ", &Stripable::eq_shape_controllable ) - .addFunction ("eq_enable_control ", &Stripable::eq_enable_controllable ) - .addFunction ("eq_hpf_control ", &Stripable::eq_hpf_controllable ) + .addFunction ("filter_freq_controllable ", &Stripable::filter_freq_controllable ) + .addFunction ("filter_slope_controllable ", &Stripable::filter_slope_controllable ) + .addFunction ("filter_enable_controllable ", &Stripable::filter_enable_controllable ) .addFunction ("set_presentation_order", &Stripable::set_presentation_order) .addFunction ("presentation_info_ptr", &Stripable::presentation_info_ptr) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index 41d85bcda5..f3031aa15a 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -4968,7 +4968,7 @@ Route::eq_band_cnt () const if (is_master() || mixbus()) { return 3; } else { - return 6; + return 4; } #else return 3; @@ -5001,10 +5001,10 @@ Route::eq_gain_controllable (uint32_t band) const } else { #ifdef MIXBUS32C switch (band) { - case 2: port_number = 14; break; - case 3: port_number = 12; break; - case 4: port_number = 10; break; - case 5: port_number = 8; break; + case 0: port_number = 14; break; + case 1: port_number = 12; break; + case 2: port_number = 10; break; + case 3: port_number = 8; break; default: return boost::shared_ptr(); } @@ -5042,12 +5042,10 @@ Route::eq_freq_controllable (uint32_t band) const uint32_t port_number; #ifdef MIXBUS32C switch (band) { - case 0: port_number = 5; break; // HPF - case 1: port_number = 6; break; // LPF - case 2: port_number = 13; break; // lo - case 3: port_number = 11; break; // lo mid - case 4: port_number = 9; break; // hi mid - case 5: port_number = 7; break; // hi + case 0: port_number = 13; break; // lo + case 1: port_number = 11; break; // lo mid + case 2: port_number = 9; break; // hi mid + case 3: port_number = 7; break; // hi default: return boost::shared_ptr(); } @@ -5076,6 +5074,22 @@ Route::eq_q_controllable (uint32_t band) const boost::shared_ptr Route::eq_shape_controllable (uint32_t band) const { +#ifdef MIXBUS32C + boost::shared_ptr eq = ch_eq(); + if (is_master() || mixbus() || !eq) { + return boost::shared_ptr(); + } + switch (band) { + case 0: + return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4))); // lo bell + break; + case 3: + return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 3))); // hi bell + break; + default: + break; + } +#endif return boost::shared_ptr(); } @@ -5096,7 +5110,7 @@ Route::eq_enable_controllable () const } boost::shared_ptr -Route::eq_hpf_controllable () const +Route::filter_freq_controllable (bool hpf) const { #ifdef MIXBUS boost::shared_ptr eq = ch_eq(); @@ -5104,11 +5118,19 @@ Route::eq_hpf_controllable () const if (is_master() || mixbus() || !eq) { return boost::shared_ptr(); } + if (hpf) { #ifdef MIXBUS32C - return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5))); + return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 5))); // HPF freq #else - return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2))); + return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 2))); #endif + } else { +#ifdef MIXBUS32C + return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 6))); // LPF freq +#else + return boost::shared_ptr(); +#endif + } #else return boost::shared_ptr(); @@ -5116,23 +5138,13 @@ Route::eq_hpf_controllable () const } boost::shared_ptr -Route::eq_lpf_controllable () const +Route::filter_slope_controllable (bool) const { -#ifdef MIXBUS32C - boost::shared_ptr eq = ch_eq(); - - if (is_master() || mixbus() || !eq) { - return boost::shared_ptr(); - } - - return boost::dynamic_pointer_cast (eq->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, 4))); -#else return boost::shared_ptr(); -#endif } boost::shared_ptr -Route::filter_enable_controllable () const +Route::filter_enable_controllable (bool) const { #ifdef MIXBUS32C boost::shared_ptr eq = ch_eq(); @@ -5166,12 +5178,10 @@ Route::eq_band_name (uint32_t band) const #ifdef MIXBUS32C } else { switch (band) { - case 0: return _("HPF"); - case 1: return _("LPF"); - case 2: return _("lo"); - case 3: return _("lo mid"); - case 4: return _("hi mid"); - case 5: return _("hi"); + case 0: return _("lo"); + case 1: return _("lo mid"); + case 2: return _("hi mid"); + case 3: return _("hi"); default: return string(); } } diff --git a/libs/surfaces/faderport8/faderport8.cc b/libs/surfaces/faderport8/faderport8.cc index 7a2448e939..8d2898c2f2 100644 --- a/libs/surfaces/faderport8/faderport8.cc +++ b/libs/surfaces/faderport8/faderport8.cc @@ -1064,13 +1064,13 @@ FaderPort8::build_well_known_processor_ctrls (boost::shared_ptr s, bo int cnt = s->eq_band_cnt(); #ifdef MIXBUS32C - PUSH_BACK_NON_NULL ("Flt In", s->filter_enable_controllable ()); - PUSH_BACK_NON_NULL ("HP Freq", s->eq_hpf_controllable ()); - PUSH_BACK_NON_NULL ("LP Freq", s->eq_lpf_controllable ()); + PUSH_BACK_NON_NULL ("Flt In", s->filter_enable_controllable (true)); // both HP/LP + PUSH_BACK_NON_NULL ("HP Freq", s->filter_freq_controllable (true)); + PUSH_BACK_NON_NULL ("LP Freq", s->filter_freq_controllable (false)); PUSH_BACK_NON_NULL ("EQ In", s->eq_enable_controllable ()); #elif defined (MIXBUS) PUSH_BACK_NON_NULL ("EQ In", s->eq_enable_controllable ()); - PUSH_BACK_NON_NULL ("HP Freq", s->eq_hpf_controllable ()); + PUSH_BACK_NON_NULL ("HP Freq", s->filter_freq_controllable (true)); #endif for (int band = 0; band < cnt; ++band) { diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index 1ec72d501c..c42906bc18 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -529,7 +529,7 @@ Strip::notify_eq_change (AutomationType type, uint32_t band, bool force_update) break; #ifndef MIXBUS32C case EQHPF: - control = r->eq_hpf_controllable (); + control = r->filter_freq_controllable (true); break; #endif default: @@ -581,13 +581,13 @@ Strip::notify_dyn_change (AutomationType type, bool force_update, bool propagate break; #ifdef MIXBUS32C case EQHPF: - control = r->eq_hpf_controllable (); + control = r->filter_freq_controllable (true); break; case EQLPF: - control = r->eq_lpf_controllable (); + control = r->filter_freq_controllable (false); break; case EQFilterEnable: - control = r->filter_enable_controllable (); + control = r->filter_enable_controllable (true); // both HP/LP break; #endif default: @@ -1546,9 +1546,9 @@ Strip::setup_dyn_vpot (boost::shared_ptr r) boost::shared_ptr ec = r->comp_enable_controllable (); #ifdef MIXBUS32C //Mixbus32C needs to spill the filter controls into the comp section - boost::shared_ptr hpfc = r->eq_hpf_controllable (); - boost::shared_ptr lpfc = r->eq_lpf_controllable (); - boost::shared_ptr fec = r->filter_enable_controllable (); + boost::shared_ptr hpfc = r->filter_freq_controllable (true); + boost::shared_ptr lpfc = r->filter_freq_controllable (false); + boost::shared_ptr fec = r->filter_enable_controllable (true); // shared HP/LP #endif uint32_t pos = _surface->mcp().global_index (*this); @@ -1731,7 +1731,7 @@ Strip::setup_eq_vpot (boost::shared_ptr r) switch (parameter) { #ifndef MIXBUS32C case 0: /* first control after band parameters */ - pc = r->eq_hpf_controllable(); + pc = r->filter_freq_controllable(true); param = EQHPF; break; case 1: /* second control after band parameters */ diff --git a/libs/surfaces/osc/osc.cc b/libs/surfaces/osc/osc.cc index 634fcc674e..0a412ee7de 100644 --- a/libs/surfaces/osc/osc.cc +++ b/libs/surfaces/osc/osc.cc @@ -3706,8 +3706,8 @@ OSC::sel_eq_hpf (float val, lo_message msg) s = _select; } if (s) { - if (s->eq_hpf_controllable()) { - s->eq_hpf_controllable()->set_value (s->eq_hpf_controllable()->interface_to_internal (val), PBD::Controllable::NoGroup); + if (s->filter_freq_controllable(true)) { + s->filter_freq_controllable(true)->set_value (s->filter_freq_controllable(true)->interface_to_internal (val), PBD::Controllable::NoGroup); return 0; } } diff --git a/libs/surfaces/osc/osc_select_observer.cc b/libs/surfaces/osc/osc_select_observer.cc index 35d35841d9..151b00b6e0 100644 --- a/libs/surfaces/osc/osc_select_observer.cc +++ b/libs/surfaces/osc/osc_select_observer.cc @@ -624,10 +624,11 @@ void OSCSelectObserver::eq_init() { // HPF and enable are special case, rest are in bands - if (_strip->eq_hpf_controllable ()) { - _strip->eq_hpf_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf"), _strip->eq_hpf_controllable()), OSC::instance()); - change_message ("/select/eq_hpf", _strip->eq_hpf_controllable()); + if (_strip->filter_freq_controllable (true)) { + _strip->filter_freq_controllable (true)->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::change_message, this, X_("/select/eq_hpf"), _strip->filter_freq_controllable (true)), OSC::instance()); + change_message ("/select/eq_hpf", _strip->filter_freq_controllable(true)); } + // TODO LPF and LPF/HPF enable ctrls. if (_strip->eq_enable_controllable ()) { _strip->eq_enable_controllable ()->Changed.connect (eq_connections, MISSING_INVALIDATOR, boost::bind (&OSCSelectObserver::enable_message, this, X_("/select/eq_enable"), _strip->eq_enable_controllable()), OSC::instance()); enable_message ("/select/eq_enable", _strip->eq_enable_controllable()); @@ -666,7 +667,7 @@ OSCSelectObserver::eq_end () { //need to check feedback for [13] eq_connections.drop_connections (); - if (_strip->eq_hpf_controllable ()) { + if (_strip->filter_freq_controllable (true)) { send_float ("/select/eq_hpf", 0); } if (_strip->eq_enable_controllable ()) { -- 2.30.2