diff --git a/libs/ardour/ardour/route.h b/libs/ardour/ardour/route.h index e25e744a28..c4a1b8cd7c 100644 --- a/libs/ardour/ardour/route.h +++ b/libs/ardour/ardour/route.h @@ -550,6 +550,9 @@ public: uint32_t eq_band_cnt () const; std::string eq_band_name (uint32_t) const; + std::shared_ptr mapped_control (enum WellKnownCtrl, uint32_t band = 0) const; + std::shared_ptr mapped_output (enum WellKnownData) const; + std::shared_ptr eq_enable_controllable () const; std::shared_ptr eq_gain_controllable (uint32_t band) const; std::shared_ptr eq_freq_controllable (uint32_t band) const; @@ -840,6 +843,11 @@ private: bool _in_sidechain_setup; gain_t _monitor_gain; + void add_well_known_ctrl (WellKnownCtrl, std::shared_ptr, int param); + void add_well_known_ctrl (WellKnownCtrl); + + std::map>> _well_known_map; + /** true if we've made a note of a custom meter position in these variables */ bool _custom_meter_position_noted; /** the processor that came after the meter when it was last set to a custom position, diff --git a/libs/ardour/ardour/stripable.h b/libs/ardour/ardour/stripable.h index 5d46d34929..2af114af41 100644 --- a/libs/ardour/ardour/stripable.h +++ b/libs/ardour/ardour/stripable.h @@ -53,6 +53,9 @@ class MonitorProcessor; class RecordEnableControl; class RecordSafeControl; +enum WellKnownCtrl : int; +enum WellKnownData : int; + /* This is a virtual base class for any object that needs to be potentially * represented by a control-centric user interface using the general model of a * mixing console "strip" - a collection of controls that determine the state @@ -138,13 +141,19 @@ class LIBARDOUR_API Stripable : public SessionObject, virtual std::shared_ptr pan_frontback_control() const = 0; virtual std::shared_ptr pan_lfe_control() const = 0; - /* "well-known" controls for an EQ in this route. Any or all may - * be null. eq_band_cnt() must return 0 if there is no EQ present. - * Passing an @p band value >= eq_band_cnt() will guarantee the - * return of a null ptr (or an empty string for eq_band_name()). - */ + /* "well-known" controls. Any or all may NULL. */ virtual uint32_t eq_band_cnt () const = 0; virtual std::string eq_band_name (uint32_t) const = 0; + + + virtual std::shared_ptr mapped_control (enum WellKnownCtrl, uint32_t band = 0) const = 0; + virtual std::shared_ptr mapped_output (enum WellKnownData) const = 0; + + /* ACs mapped to any control have changed. API user is to drop references, + * and query mapped ctrl again + */ + PBD::Signal0 MappedControlsChanged; + virtual std::shared_ptr eq_enable_controllable () const = 0; virtual std::shared_ptr eq_gain_controllable (uint32_t band) const = 0; virtual std::shared_ptr eq_freq_controllable (uint32_t band) const = 0; diff --git a/libs/ardour/ardour/vca.h b/libs/ardour/ardour/vca.h index ae4b0c052f..7756a2eaa5 100644 --- a/libs/ardour/ardour/vca.h +++ b/libs/ardour/ardour/vca.h @@ -110,6 +110,13 @@ class LIBARDOUR_API VCA : public Stripable, /* null Stripable API, because VCAs don't have any of this */ + std::shared_ptr mapped_control (enum WellKnownCtrl, uint32_t band = 0) const { + return std::shared_ptr(); + } + std::shared_ptr mapped_output (enum WellKnownData) const { + return std::shared_ptr(); + } + std::shared_ptr solo_isolate_control() const { return std::shared_ptr(); } std::shared_ptr solo_safe_control() const { return std::shared_ptr(); } std::shared_ptr peak_meter() { return std::shared_ptr(); } diff --git a/libs/ardour/luabindings.cc b/libs/ardour/luabindings.cc index 5265d17837..31bbd490fc 100644 --- a/libs/ardour/luabindings.cc +++ b/libs/ardour/luabindings.cc @@ -104,6 +104,7 @@ #include "ardour/user_bundle.h" #include "ardour/vca.h" #include "ardour/vca_manager.h" +#include "ardour/well_known_enum.h" #include "LuaBridge/LuaBridge.h" @@ -1392,6 +1393,8 @@ LuaBindings::common (lua_State* L) .addFunction ("trim_control", &Stripable::trim_control) .addFunction ("rec_enable_control", &Stripable::rec_enable_control) .addFunction ("rec_safe_control", &Stripable::rec_safe_control) + .addFunction ("mapped_control", &Stripable::mapped_control) + .addFunction ("mapped_output", &Stripable::mapped_output) .addFunction ("pan_azimuth_control", &Stripable::pan_azimuth_control) .addFunction ("pan_elevation_control", &Stripable::pan_elevation_control) .addFunction ("pan_width_control", &Stripable::pan_width_control) @@ -2535,6 +2538,56 @@ LuaBindings::common (lua_State* L) .addConst ("ImplicitlyIgnoreCues", ARDOUR::CueBehavior(ImplicitlyIgnoreCues)) .endNamespace () + .beginNamespace ("WellKnownCtrl") + .addConst ("EQ_Enable", ARDOUR::WellKnownCtrl(EQ_Enable)) + .addConst ("EQ_Gain", ARDOUR::WellKnownCtrl(EQ_Gain)) + .addConst ("EQ_Freq", ARDOUR::WellKnownCtrl(EQ_Freq)) + .addConst ("EQ_Q", ARDOUR::WellKnownCtrl(EQ_Q)) + .addConst ("EQ_Shape", ARDOUR::WellKnownCtrl(EQ_Shape)) + .addConst ("HPF_Enable", ARDOUR::WellKnownCtrl(HPF_Enable)) + .addConst ("HPF_Freq", ARDOUR::WellKnownCtrl(HPF_Freq)) + .addConst ("HPF_Slope", ARDOUR::WellKnownCtrl(HPF_Slope)) + .addConst ("LPF_Enable", ARDOUR::WellKnownCtrl(LPF_Enable)) + .addConst ("LPF_Freq", ARDOUR::WellKnownCtrl(LPF_Freq)) + .addConst ("LPF_Slope", ARDOUR::WellKnownCtrl(LPF_Slope)) + .addConst ("TapeDrive_Drive", ARDOUR::WellKnownCtrl(TapeDrive_Drive)) + .addConst ("TapeDrive_Mode", ARDOUR::WellKnownCtrl(TapeDrive_Mode)) + .addConst ("Comp_Enable", ARDOUR::WellKnownCtrl(Comp_Enable)) + .addConst ("Comp_Mode", ARDOUR::WellKnownCtrl(Comp_Mode)) + .addConst ("Comp_Threshold", ARDOUR::WellKnownCtrl(Comp_Threshold)) + .addConst ("Comp_Makeup", ARDOUR::WellKnownCtrl(Comp_Makeup)) + .addConst ("Comp_Ratio", ARDOUR::WellKnownCtrl(Comp_Ratio)) + .addConst ("Comp_Attack", ARDOUR::WellKnownCtrl(Comp_Attack)) + .addConst ("Comp_Release", ARDOUR::WellKnownCtrl(Comp_Release)) + .addConst ("Comp_KeyFilterFreq", ARDOUR::WellKnownCtrl(Comp_KeyFilterFreq)) + .addConst ("Gate_Enable", ARDOUR::WellKnownCtrl(Gate_Enable)) + .addConst ("Gate_Mode", ARDOUR::WellKnownCtrl(Gate_Mode)) + .addConst ("Gate_Threshold", ARDOUR::WellKnownCtrl(Gate_Threshold)) + .addConst ("Gate_Ratio", ARDOUR::WellKnownCtrl(Gate_Ratio)) + .addConst ("Gate_Knee", ARDOUR::WellKnownCtrl(Gate_Knee)) + .addConst ("Gate_Depth", ARDOUR::WellKnownCtrl(Gate_Depth)) + .addConst ("Gate_Hysteresis", ARDOUR::WellKnownCtrl(Gate_Hysteresis)) + .addConst ("Gate_Hold", ARDOUR::WellKnownCtrl(Gate_Hold)) + .addConst ("Gate_Attack", ARDOUR::WellKnownCtrl(Gate_Attack)) + .addConst ("Gate_Release", ARDOUR::WellKnownCtrl(Gate_Release)) + .addConst ("Gate_KeyListen", ARDOUR::WellKnownCtrl(Gate_KeyListen)) + .addConst ("Gate_KeyFilterEnable", ARDOUR::WellKnownCtrl(Gate_KeyFilterEnable)) + .addConst ("Gate_KeyFilterFreq", ARDOUR::WellKnownCtrl(Gate_KeyFilterFreq)) + .addConst ("Master_Limiter_Enable", ARDOUR::WellKnownCtrl(Master_Limiter_Enable)) + .endNamespace () + + .beginNamespace ("WellKnownData") + .addConst ("TapeDrive_Saturation", ARDOUR::WellKnownData(TapeDrive_Saturation)) + .addConst ("Master_PhaseCorrelationMin", ARDOUR::WellKnownData(Master_PhaseCorrelationMin)) + .addConst ("Master_PhaseCorrelationMax", ARDOUR::WellKnownData(Master_PhaseCorrelationMax)) + .addConst ("Master_KMeter", ARDOUR::WellKnownData(Master_KMeter)) + .addConst ("Master_LimiterRedux", ARDOUR::WellKnownData(Master_LimiterRedux)) + .addConst ("Comp_Meter", ARDOUR::WellKnownData(Comp_Meter)) + .addConst ("Comp_Redux", ARDOUR::WellKnownData(Comp_Redux)) + .addConst ("Gate_Meter", ARDOUR::WellKnownData(Gate_Meter)) + .addConst ("Gate_Redux", ARDOUR::WellKnownData(Gate_Redux)) + .endNamespace () + .beginNamespace ("SampleFormat") .addConst ("Float", ARDOUR::SampleFormat(FormatFloat)) .addConst ("Int24", ARDOUR::SampleFormat(FormatInt24)) diff --git a/libs/ardour/route.cc b/libs/ardour/route.cc index ba29fa1762..8042f07ade 100644 --- a/libs/ardour/route.cc +++ b/libs/ardour/route.cc @@ -101,6 +101,7 @@ #include "ardour/types_convert.h" #include "ardour/unknown_processor.h" #include "ardour/utils.h" +#include "ardour/well_known_enum.h" #include "ardour/vca.h" #include "pbd/i18n.h" @@ -5860,6 +5861,34 @@ Route::eq_band_cnt () const return 0; } +void +Route::add_well_known_ctrl (WellKnownCtrl which) +{ + _well_known_map[which].push_back (std::weak_ptr ()); +} + +void +Route::add_well_known_ctrl (WellKnownCtrl which, std::shared_ptr pi, int param) +{ + _well_known_map[which].push_back (std::dynamic_pointer_cast (pi->control (Evoral::Parameter (ARDOUR::PluginAutomation, 0, param)))); +} + +std::shared_ptr +Route::mapped_control (enum WellKnownCtrl which, uint32_t band) const +{ + auto it = _well_known_map.find (which); + if (it == _well_known_map.end () || it->second.size () <= band) { + return std::shared_ptr (); + } + return it->second[band].lock(); +} + +std::shared_ptr +Route::mapped_output (enum WellKnownData which) const +{ + return std::shared_ptr(); +} + std::shared_ptr Route::eq_enable_controllable () const {