convert rec-enable control for a Track from PBD::COntrollable to ARDOUR::AutomatioNCo...
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Apr 2012 00:35:42 +0000 (00:35 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 13 Apr 2012 00:35:42 +0000 (00:35 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@11956 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/ardour/amp.cc
libs/ardour/ardour/automation_control.h
libs/ardour/ardour/track.h
libs/ardour/ardour/types.h
libs/ardour/event_type_map.cc
libs/ardour/track.cc
libs/surfaces/mackie/strip.cc

index b74a57dbce8badfeede821a8973b3ed995ddf121..24b2066ed5a2d55f8bcc8617a7254104d33647ec 100644 (file)
@@ -47,6 +47,8 @@ Amp::Amp (Session& s)
        p.set_range (0, 1.99526231f, 1, false);
        boost::shared_ptr<AutomationList> gl (new AutomationList (p));
        _gain_control = boost::shared_ptr<GainControl> (new GainControl (X_("gaincontrol"), s, this, p, gl));
+       _gain_control->set_flags (Controllable::GainLike);
+
        add_control(_gain_control);
 }
 
index 9ad46c9090a0b8e06740a7feed3d5622ff0901a0..2c15a1b1b0ebeaac72d7017a07898c370de9df59 100644 (file)
@@ -38,9 +38,9 @@ class AutomationControl : public PBD::Controllable, public Evoral::Control
 {
 public:
        AutomationControl(ARDOUR::Session&,
-                       const Evoral::Parameter& parameter,
-                       boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
-                       const std::string& name="");
+                         const Evoral::Parameter& parameter,
+                         boost::shared_ptr<ARDOUR::AutomationList> l=boost::shared_ptr<ARDOUR::AutomationList>(),
+                         const std::string& name="");
 
        boost::shared_ptr<AutomationList> alist() const {
                return boost::dynamic_pointer_cast<AutomationList>(_list);
index 587a8dcd1b430a4564b20517241903f2398fa1d9..2ec1ed4fdd42bb378d5fb3c4da12d817a4c73943 100644 (file)
@@ -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<PBD::Controllable> rec_enable_control() { return _rec_enable_control; }
+       boost::shared_ptr<AutomationControl> 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<Track> t);
 
                void set_value (double);
                double get_value (void) const;
 
-               Track& track;
+               boost::shared_ptr<Track> 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<RecEnableControllable> _rec_enable_control;
+       boost::shared_ptr<RecEnableControl> _rec_enable_control;
        
        framecnt_t check_initial_delay (framecnt_t nframes, framecnt_t&);
 
index b6ab07c7432603aa1f56f80ef6178a4d666edf79..3ebf5478e6329796ac3bded4c4faf19d96d02aa9 100644 (file)
@@ -145,7 +145,8 @@ namespace ARDOUR {
                MidiSystemExclusiveAutomation,
                FadeInAutomation,
                FadeOutAutomation,
-               EnvelopeAutomation
+               EnvelopeAutomation,
+               RecEnableAutomation
        };
 
        enum AutoState {
index 4b21d32e583a34c5dc5a2a3b007b1d84a3cee787..7cf6045d86bc4fa85c875071e01480c9a9d42f0e 100644 (file)
@@ -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:
index 2ef3c85b4a7c4679462c950419e3040e3d44fcfd..f7f0e6fdbeb80cd5f0ef5b530f4cdab0447400e4 100644 (file)
@@ -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<Route> rp (shared_from_this());
+       boost::shared_ptr<Track> rt = boost::dynamic_pointer_cast<Track> (rp);
+       _rec_enable_control = boost::shared_ptr<RecEnableControl> (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<Track> t)
+       : AutomationControl (t->session(), RecEnableAutomation, boost::shared_ptr<AutomationList>(), X_("recenable"))
+       , track (t)
 {
+       boost::shared_ptr<AutomationList> 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
index bce306d139bd60c9e0c7598015a1098f3fe92050..88de3f1afc0a1b618e9b944a24119c00a0288b00 100644 (file)
@@ -164,11 +164,13 @@ Strip::set_route (boost::shared_ptr<Route> r)
 
                if (_solo) {
                        _solo->set_normal_control (_route->solo_control());
+                       _solo->set_modified_control (boost::shared_ptr<AutomationControl>());
                        _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<AutomationControl>());
                        _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<Route> 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<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_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<AutomationControl>());
                        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<AutomationControl> control = button.control (modified);
-
-               if (control) {
-                       control->set_value (!control->get_value());
+       boost::shared_ptr<AutomationControl> 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));
        }
 }