From: Paul Davis Date: Fri, 13 Apr 2012 00:35:42 +0000 (+0000) Subject: convert rec-enable control for a Track from PBD::COntrollable to ARDOUR::AutomatioNCo... X-Git-Tag: 3.0~1722 X-Git-Url: https://main.carlh.net/gitweb/?p=ardour.git;a=commitdiff_plain;h=13699251d95d4d1732c05e37038a675f64e2f63f convert rec-enable control for a Track from PBD::COntrollable to ARDOUR::AutomatioNControl, and use in MCP git-svn-id: svn://localhost/ardour2/branches/3.0@11956 d708f5d6-7413-0410-9779-e7cbd77b26cf --- diff --git a/libs/ardour/amp.cc b/libs/ardour/amp.cc index b74a57dbce..24b2066ed5 100644 --- a/libs/ardour/amp.cc +++ b/libs/ardour/amp.cc @@ -47,6 +47,8 @@ Amp::Amp (Session& s) p.set_range (0, 1.99526231f, 1, false); boost::shared_ptr gl (new AutomationList (p)); _gain_control = boost::shared_ptr (new GainControl (X_("gaincontrol"), s, this, p, gl)); + _gain_control->set_flags (Controllable::GainLike); + add_control(_gain_control); } diff --git a/libs/ardour/ardour/automation_control.h b/libs/ardour/ardour/automation_control.h index 9ad46c9090..2c15a1b1b0 100644 --- a/libs/ardour/ardour/automation_control.h +++ b/libs/ardour/ardour/automation_control.h @@ -38,9 +38,9 @@ class AutomationControl : public PBD::Controllable, public Evoral::Control { public: AutomationControl(ARDOUR::Session&, - const Evoral::Parameter& parameter, - boost::shared_ptr l=boost::shared_ptr(), - const std::string& name=""); + const Evoral::Parameter& parameter, + boost::shared_ptr l=boost::shared_ptr(), + const std::string& name=""); boost::shared_ptr alist() const { return boost::dynamic_pointer_cast(_list); diff --git a/libs/ardour/ardour/track.h b/libs/ardour/ardour/track.h index 587a8dcd1b..2ec1ed4fdd 100644 --- a/libs/ardour/ardour/track.h +++ b/libs/ardour/ardour/track.h @@ -102,7 +102,7 @@ class Track : public Route, public PublicDiskstream virtual int set_state (const XMLNode&, int version); static void zero_diskstream_id_in_xml (XMLNode&); - boost::shared_ptr rec_enable_control() { return _rec_enable_control; } + boost::shared_ptr rec_enable_control() { return _rec_enable_control; } bool record_enabled() const; void set_record_enabled (bool yn, void *src); @@ -201,13 +201,13 @@ class Track : public Route, public PublicDiskstream FreezeState state; }; - struct RecEnableControllable : public PBD::Controllable { - RecEnableControllable (Track&); + struct RecEnableControl : public AutomationControl { + RecEnableControl (boost::shared_ptr t); void set_value (double); double get_value (void) const; - Track& track; + boost::shared_ptr track; }; virtual void set_state_part_two () = 0; @@ -218,7 +218,7 @@ class Track : public Route, public PublicDiskstream void maybe_declick (BufferSet&, framecnt_t, int); - boost::shared_ptr _rec_enable_control; + boost::shared_ptr _rec_enable_control; framecnt_t check_initial_delay (framecnt_t nframes, framecnt_t&); diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index b6ab07c743..3ebf5478e6 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -145,7 +145,8 @@ namespace ARDOUR { MidiSystemExclusiveAutomation, FadeInAutomation, FadeOutAutomation, - EnvelopeAutomation + EnvelopeAutomation, + RecEnableAutomation }; enum AutoState { diff --git a/libs/ardour/event_type_map.cc b/libs/ardour/event_type_map.cc index 4b21d32e58..7cf6045d86 100644 --- a/libs/ardour/event_type_map.cc +++ b/libs/ardour/event_type_map.cc @@ -159,6 +159,9 @@ EventTypeMap::new_parameter(uint32_t type, uint8_t channel, uint32_t id) const case PanFrontBackAutomation: case PanLFEAutomation: break; + case RecEnableAutomation: + /* default 0.0 - 1.0 is fine */ + break; case PluginAutomation: case SoloAutomation: case MuteAutomation: diff --git a/libs/ardour/track.cc b/libs/ardour/track.cc index 2ef3c85b4a..f7f0e6fdbe 100644 --- a/libs/ardour/track.cc +++ b/libs/ardour/track.cc @@ -44,7 +44,6 @@ Track::Track (Session& sess, string name, Route::Flag flag, TrackMode mode, Data , _saved_meter_point (_meter_point) , _mode (mode) , _monitoring (MonitorAuto) - , _rec_enable_control (new RecEnableControllable(*this)) { _freeze_record.state = NoFreeze; _declickable = true; @@ -64,6 +63,15 @@ Track::init () return -1; } + boost::shared_ptr rp (shared_from_this()); + boost::shared_ptr rt = boost::dynamic_pointer_cast (rp); + _rec_enable_control = boost::shared_ptr (new RecEnableControl(rt)); + _rec_enable_control->set_flags (Controllable::Toggle); + + /* don't add rec_enable_control to controls because we don't want it to + * appear as an automatable parameter + */ + return 0; } @@ -195,23 +203,24 @@ Track::freeze_state() const return _freeze_record.state; } -Track::RecEnableControllable::RecEnableControllable (Track& s) - : Controllable (X_("recenable"), Controllable::Toggle), track (s) +Track::RecEnableControl::RecEnableControl (boost::shared_ptr t) + : AutomationControl (t->session(), RecEnableAutomation, boost::shared_ptr(), X_("recenable")) + , track (t) { + boost::shared_ptr gl(new AutomationList(Evoral::Parameter(RecEnableAutomation))); + set_list (gl); } void -Track::RecEnableControllable::set_value (double val) +Track::RecEnableControl::set_value (double val) { - bool bval = ((val >= 0.5) ? true: false); - track.set_record_enabled (bval, this); + track->set_record_enabled (val >= 0.5 ? true : false, this); } double -Track::RecEnableControllable::get_value (void) const +Track::RecEnableControl::get_value (void) const { - if (track.record_enabled()) { return 1.0; } - return 0.0; + return (track->record_enabled() ? 1.0 : 0.0); } bool diff --git a/libs/surfaces/mackie/strip.cc b/libs/surfaces/mackie/strip.cc index bce306d139..88de3f1afc 100644 --- a/libs/surfaces/mackie/strip.cc +++ b/libs/surfaces/mackie/strip.cc @@ -164,11 +164,13 @@ Strip::set_route (boost::shared_ptr r) if (_solo) { _solo->set_normal_control (_route->solo_control()); + _solo->set_modified_control (boost::shared_ptr()); _route->solo_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_solo_changed, this), ui_context()); } if (_mute) { _mute->set_normal_control (_route->mute_control()); + _mute->set_modified_control (boost::shared_ptr()); _route->mute_control()->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_mute_changed, this), ui_context()); } @@ -181,13 +183,15 @@ Strip::set_route (boost::shared_ptr r) _route->pannable()->pan_width_control->Changed.connect(route_connections, invalidator(), ui_bind (&Strip::notify_panner_changed, this, false), ui_context()); } + /* bind fader & pan pot, as appropriate for current flip mode */ + flip_mode_changed (false); boost::shared_ptr trk = boost::dynamic_pointer_cast(_route); if (trk) { - // XXX FIX ME WHEN rec-enable IS-A AutomationControl - // _recenable->set_normal_control (trk->rec_enable_control()); + _recenable->set_normal_control (trk->rec_enable_control()); + _recenable->set_modified_control (boost::shared_ptr()); trk->rec_enable_control()->Changed .connect(route_connections, invalidator(), ui_bind (&Strip::notify_record_enable_changed, this), ui_context()); } @@ -376,6 +380,9 @@ Strip::handle_button (Button& button, ButtonState bs) if (button.id() >= Button::select_base_id && button.id() < Button::select_base_id + 8) { + + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("select touch, lock ? %1\n", ((ms & lock_mod) == lock_mod) ? 1 : 0)); + if ((ms & lock_mod) == lock_mod) { _controls_locked = !_controls_locked; return; @@ -405,14 +412,19 @@ Strip::handle_button (Button& button, ButtonState bs) return; } - if (ms & MackieControlProtocol::MODIFIER_OPTION) { - /* reset to default/normal value */ - - boost::shared_ptr control = button.control (modified); - - if (control) { - control->set_value (!control->get_value()); + boost::shared_ptr control = button.control (modified); + + if (control) { + if (ms & MackieControlProtocol::MODIFIER_OPTION) { + /* reset to default/normal value */ + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("reset %1 to default of %2\n", control->name(), control->normal())); + control->set_value (control->normal()); + } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("toggle %1 to default of %2\n", control->name(), control->get_value() ? 0.0 : 1.0)); + control->set_value (control->get_value() ? 0.0 : 1.0); } + } else { + DEBUG_TRACE (DEBUG::MackieControl, string_compose ("button has no control at present (modified ? %1)\n", modified)); } }