MCP: Patch from Rodrigo that:
authorPaul Davis <paul@linuxaudiosystems.com>
Fri, 1 Jun 2012 12:56:20 +0000 (12:56 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Fri, 1 Jun 2012 12:56:20 +0000 (12:56 +0000)
    * implements Metering on/off through Button::Read as per Seablade's suggestion. I choose this button as it's the "Show meters" button in Traktion;
    * removes redundant code from Meter::update_transport_rolling();
    * renames Meter::update_transport_rolling() to Meter::notify_metering_state_changed();
    * renamed Surface::notify_transport_state_changed() to Surface::notify_metering_state_changed();
    * renamed Strip::notify_transport_state_changed() to Strip::notify_metering_state_changed();
    * created MackieControlProtocol::notify_metering_state_changed() and made MackieControlProtocol::notify_transport_state_changed() use it;
    * implemented turning off of timecode display and two char display in Surface::zero_all ();
    * implemented master fader zeroing in Surface::zero_all ();
    * calling Surfaces->zero_all() at MackieControlProtocol destructor;
    * implemented restore of 2nd LCD line content after metering being active.

git-svn-id: svn://localhost/ardour2/branches/3.0@12520 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/mackie_control_protocol.h
libs/surfaces/mackie/mcp_buttons.cc
libs/surfaces/mackie/meter.cc
libs/surfaces/mackie/meter.h
libs/surfaces/mackie/strip.cc
libs/surfaces/mackie/strip.h
libs/surfaces/mackie/surface.cc
libs/surfaces/mackie/surface.h

index 1efe904976d01a65f6accc9f29a024b043a03861..c291b91e92582648dd3ebaf658e3c6817e090a3f 100644 (file)
@@ -107,6 +107,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        , _modifier_state (0)
        , _ipmidi_base (MIDI::IPMIDIPort::lowest_ipmidi_port_default)
        , needs_ipmidi_restart (false)
+       , _metering_active (true)
 {
        DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n");
 
@@ -123,7 +124,11 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
 MackieControlProtocol::~MackieControlProtocol()
 {
        DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::~MackieControlProtocol\n");
-
+       
+       for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+               (*s)->zero_all ();
+       }
+       
        drop_connections ();
        tear_down_gui ();
 
@@ -880,14 +885,20 @@ MackieControlProtocol::notify_transport_state_changed()
        update_global_button (Button::Stop, !session->transport_rolling());
        update_global_button (Button::Rewind, session->transport_speed() < 0.0);
        update_global_button (Button::Ffwd, session->transport_speed() > 1.0);
-       
-       for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
-               (*s)->notify_transport_state_changed ();
-       }
+
+       notify_metering_state_changed ();
        
        _transport_previously_rolling = session->transport_rolling();
 }
 
+void 
+MackieControlProtocol::notify_metering_state_changed()
+{
+       for (Surfaces::iterator s = surfaces.begin(); s != surfaces.end(); ++s) {
+               (*s)->notify_metering_state_changed ();
+       }       
+}
+
 void
 MackieControlProtocol::notify_record_state_changed ()
 {
index 0fd5d8c8a26ef16cc32166e8b43567fc88f79e5a..eb3cc22b8cfe38cc519516f46744ca1578315a02 100644 (file)
@@ -128,6 +128,7 @@ class MackieControlProtocol
        bool     flip_mode () const { return _flip_mode; }
        ViewMode view_mode () const { return _view_mode; }
        bool zoom_mode () const { return _zoom_mode; }
+       bool     metering_active () const { return _metering_active; }
 
        void set_view_mode (ViewMode);
        void set_flip_mode (bool);
@@ -164,6 +165,7 @@ class MackieControlProtocol
        void notify_record_state_changed();
        void notify_transport_state_changed();
        void notify_loop_state_changed();
+       void notify_metering_state_changed();
        // mainly to pick up punch-in and punch-out
        void notify_parameter_changed(std::string const &);
        void notify_solo_active_changed(bool);
@@ -171,7 +173,7 @@ class MackieControlProtocol
        /// Turn timecode on and beats off, or vice versa, depending
        /// on state of _timecode_type
        void update_timecode_beats_led();
-  
+       
        /// this is called to generate the midi to send in response to a button press.
        void update_led(Mackie::Surface&, Mackie::Button & button, Mackie::LedState);
   
@@ -286,6 +288,7 @@ class MackieControlProtocol
        ButtonMap                 button_map;
        int16_t                  _ipmidi_base;
        bool                      needs_ipmidi_restart;
+       bool                     _metering_active;
 
        ARDOUR::RouteNotificationList _last_selected_routes;
 
index c864b5b87126ca2d6f19b80a03a1ba7b642fef79..be51f016512173e057e0e8543bc2845b77213d20 100644 (file)
@@ -1009,12 +1009,14 @@ MackieControlProtocol::snapshot_release (Mackie::Button&)
 Mackie::LedState 
 MackieControlProtocol::read_press (Mackie::Button&) 
 {
-       return none;
+       _metering_active = !_metering_active;
+       notify_metering_state_changed ();
+       return _metering_active;
 }
 Mackie::LedState 
 MackieControlProtocol::read_release (Mackie::Button&) 
 {
-       return none;
+       return _metering_active;
 }
 Mackie::LedState 
 MackieControlProtocol::write_press (Mackie::Button&) 
index d4842aa5caef36d4af22cda42f99a38f615b634d..fe11357d3a505751407996bea97116c65bd673d4 100644 (file)
@@ -22,7 +22,6 @@
 #include "pbd/compose.h"
 #include "ardour/debug.h"
 
-#include "mackie_control_protocol.h"
 #include "meter.h"
 #include "surface.h"
 #include "surface_port.h"
@@ -42,54 +41,26 @@ Meter::factory (Surface& surface, int id, const char* name, Group& group)
 }
 
 void 
-Meter::update_transport_rolling(Surface& surface)
-{
-       bool transport_is_rolling = (surface.mcp().get_transport_speed () != 0.0f);
-       
-       if (_transport_is_rolling == transport_is_rolling) {
-               return;
-       }
-       if (transport_is_rolling) {
-               MidiByteArray enable_msg;
-               
-               // sysex header
-               enable_msg << surface.sysex_hdr();
-               
-               // code for Channel Meter Enable Message
-               enable_msg << 0x20;
-               
-               // Channel identification
-               enable_msg << id();
-               
-               // Enabling level meter on LCD, peak hold display on horizontal meter and signal LED
-               enable_msg << 0x07;
-               
-               // sysex trailer
-               enable_msg << MIDI::eox;
-               
-               surface.write (enable_msg);
-               
-       } else {
-               MidiByteArray disable_msg;
+Meter::notify_metering_state_changed(Surface& surface, bool transport_is_rolling, bool metering_active)
+{      
+       MidiByteArray msg;
                
-               // sysex header
-               disable_msg << surface.sysex_hdr();
+       // sysex header
+       msg << surface.sysex_hdr();
                
-               // code for Channel Meter Enable Message
-               disable_msg << 0x20;
+       // code for Channel Meter Enable Message
+       msg << 0x20;
                
-               // Channel identification
-               disable_msg << id();
+       // Channel identification
+       msg << id();
                
-               // Disabling level meter on LCD, peak hold display on horizontal meter and signal LED
-               disable_msg << 0x00;
+       // Enable (0x07) / Disable (0x00) level meter on LCD, peak hold display on horizontal meter and signal LED
+       msg << ((transport_is_rolling && metering_active) ? 0x07 : 0x00);
                
-               // sysex trailer
-               disable_msg << MIDI::eox;
+       // sysex trailer
+       msg << MIDI::eox;
                
-               surface.write (disable_msg);            
-       }
-       _transport_is_rolling = transport_is_rolling;
+       surface.write (msg);
 }
 
 void
@@ -99,10 +70,6 @@ Meter::send_update (Surface& surface, float dB)
 
        // DEBUG_TRACE (DEBUG::MackieControl, string_compose ("Meter ID %1 dB %2\n", id(), dB));
        
-       if (!_transport_is_rolling) {
-               return;
-       }
-       
        if (dB < -70.0f) {
                def = 0.0f;
        } else if (dB < -60.0f) {
index fffba9599d174297b11e61684fc9b303d1fd6239..db3e8cffb3469ded6892aa08301d83ce25a20d3c 100644 (file)
@@ -40,11 +40,10 @@ public:
 
        static Control* factory (Surface&, int id, const char*, Group&);
   
-       void update_transport_rolling(Surface& surface);
+       void notify_metering_state_changed(Surface& surface, bool transport_is_rolling, bool metering_active);
 
   private:
        bool overload_on;
-       bool _transport_is_rolling;
 };
 
 }
index 64ea8785cd6b1326e9b919e349e1c9934f1f8857..84c32138a34ff1930a06942a3468eb5626f134ca 100644 (file)
@@ -73,6 +73,8 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::
        , _index (index)
        , _surface (&s)
        , _controls_locked (false)
+       , _transport_is_rolling (false)
+       , _metering_active (true)
        , _reset_display_at (0)
        , _last_gain_position_written (-1.0)
        , _last_pan_azi_position_written (-1.0)
@@ -690,7 +692,7 @@ Strip::update_automation ()
 void
 Strip::update_meter ()
 {
-       if (_meter) {
+       if (_meter && _transport_is_rolling && _metering_active) {
                float dB = const_cast<PeakMeter&> (_route->peak_meter()).peak_power (0);
                _meter->send_update (*_surface, dB);
        }
@@ -1068,9 +1070,26 @@ Strip::reset_saved_values ()
 }
 
 void 
-Strip::notify_transport_state_changed()
+Strip::notify_metering_state_changed()
 {
-       if (_meter) {
-               _meter->update_transport_rolling (*_surface);
+       if (!_route || !_meter) {
+               return;
+       }
+       
+       bool transport_is_rolling = (_surface->mcp().get_transport_speed () != 0.0f);
+       bool metering_active = _surface->mcp().metering_active ();
+       
+       if ((_transport_is_rolling == transport_is_rolling) && (_metering_active == metering_active)) {
+               return;
        }
+       
+       _meter->notify_metering_state_changed (*_surface, transport_is_rolling, metering_active);
+       
+       if (!transport_is_rolling || !metering_active) {
+               notify_property_changed (PBD::PropertyChange (ARDOUR::Properties::name));
+               notify_panner_azi_changed (true);
+       }
+       
+       _transport_is_rolling = transport_is_rolling;
+       _metering_active = metering_active;
 }
index 0e58b9ec2f9526e5f80d48a7c4c6c076edd830df..d5fdc6c17c5917b82f0f8fb3cf4be23d9588eb22 100644 (file)
@@ -84,7 +84,7 @@ public:
 
        void gui_selection_changed (const ARDOUR::StrongRouteNotificationList&);
   
-       void notify_transport_state_changed();
+       void notify_metering_state_changed();
 
 private:
        Button*  _solo;
@@ -99,6 +99,8 @@ private:
        int      _index;
        Surface* _surface;
        bool     _controls_locked;
+       bool     _transport_is_rolling;
+       bool     _metering_active;
        uint64_t _reset_display_at;
        boost::shared_ptr<ARDOUR::Route> _route;
        PBD::ScopedConnectionList route_connections;
index ca8d3904e8e305a58ca7e458bda0c4e68cfd2a3e..6fb94cba93549a9678e5655e8fa9150ad73ed8c3 100644 (file)
@@ -573,8 +573,18 @@ Surface::nth_strip (uint32_t n) const
 void
 Surface::zero_all ()
 {
-       // TODO turn off Timecode displays
+       if (_mcp.device_info().has_timecode_display ()) {
+               display_timecode (string (10, '0'), string (10, ' '));
+       }
+       
+       if (_mcp.device_info().has_two_character_display()) {
+               show_two_char_display (string (2, ' '), string (2, '.'));
+       }
 
+       if (_mcp.device_info().has_master_fader ()) {
+               _port->write (_master_fader->zero ());
+       }
+       
        // zero all strips
        for (Strips::iterator it = strips.begin(); it != strips.end(); ++it) {
                (*it)->zero();
@@ -591,7 +601,7 @@ Surface::zero_controls ()
        }
 
        // turn off global buttons and leds
-        // global buttons are only ever on mcu_port, so we don't have
+       // global buttons are only ever on mcu_port, so we don't have
        // to figure out which port.
 
        for (Controls::iterator it = controls.begin(); it != controls.end(); ++it) {
@@ -601,12 +611,6 @@ Surface::zero_controls ()
                }
        }
 
-       if (_number == 0 && _mcp.device_info().has_two_character_display()) {
-               // any hardware-specific stuff
-               // clear 2-char display
-               show_two_char_display (" ");
-       }
-
        // and the led ring for the master strip
        blank_jog_ring ();
 }
@@ -847,9 +851,9 @@ Surface::route_is_locked_to_strip (boost::shared_ptr<Route> r) const
 }
 
 void 
-Surface::notify_transport_state_changed()
+Surface::notify_metering_state_changed()
 {
        for (Strips::const_iterator s = strips.begin(); s != strips.end(); ++s) {
-               (*s)->notify_transport_state_changed ();
+               (*s)->notify_metering_state_changed ();
        }
 }
index b3b931f2be69b45531242fab012fe3baa20c9160..1e33d117a580ca5ea84ebb4e6e022004dbcd5168 100644 (file)
@@ -146,7 +146,7 @@ public:
        void next_jog_mode ();
        void set_jog_mode (Mackie::JogWheel::Mode);
   
-  void notify_transport_state_changed();
+  void notify_metering_state_changed();
 
   protected: