MCP: various fixes, plus removal of ui_bind() (just for mackie code)
authorPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Apr 2012 04:42:01 +0000 (04:42 +0000)
committerPaul Davis <paul@linuxaudiosystems.com>
Wed, 25 Apr 2012 04:42:01 +0000 (04:42 +0000)
git-svn-id: svn://localhost/ardour2/branches/3.0@12086 d708f5d6-7413-0410-9779-e7cbd77b26cf

libs/surfaces/mackie/device_info.cc
libs/surfaces/mackie/device_info.h
libs/surfaces/mackie/gui.cc
libs/surfaces/mackie/gui.h
libs/surfaces/mackie/mackie_control_protocol.cc
libs/surfaces/mackie/strip.cc
libs/surfaces/mackie/surface.cc
libs/surfaces/mackie/surface_port.cc

index 93800aa43b942f0a0d787ce7308ac6540448b73b..ba14d9f8fdc94b582fb70e7b3e0dbac5b28841f8 100644 (file)
@@ -44,7 +44,6 @@ DeviceInfo::DeviceInfo()
        , _extenders (0)
        , _has_two_character_display (true)
        , _has_master_fader (true)
-       , _has_segmented_display (false)
        , _has_timecode_display (true)
        , _has_global_controls (true)
        , _has_jog_wheel (true)
@@ -238,40 +237,44 @@ DeviceInfo::set_state (const XMLNode& node, int /* version */)
                }
        }
 
-       if ((child = node.child ("DisplaySegments")) != 0) {
-               if ((prop = child->property ("value")) != 0) {
-                       _has_segmented_display = string_is_affirmative (prop->value());
-               }
-       }
-
        if ((child = node.child ("TimecodeDisplay")) != 0) {
                if ((prop = child->property ("value")) != 0) {
                        _has_timecode_display = string_is_affirmative (prop->value());
                }
+       } else {
+               _has_timecode_display = false;
        }
 
        if ((child = node.child ("GlobalControls")) != 0) {
                if ((prop = child->property ("value")) != 0) {
                        _has_global_controls = string_is_affirmative (prop->value());
                }
+       } else {
+               _has_global_controls = false;
        }
 
        if ((child = node.child ("JogWheel")) != 0) {
                if ((prop = child->property ("value")) != 0) {
                        _has_jog_wheel = string_is_affirmative (prop->value());
                }
+       } else {
+               _has_jog_wheel = false;
        }
 
        if ((child = node.child ("TouchSenseFaders")) != 0) {
                if ((prop = child->property ("value")) != 0) {
                        _has_touch_sense_faders = string_is_affirmative (prop->value());
                }
+       } else {
+               _has_touch_sense_faders = false;
        }
 
        if ((child = node.child ("UsesIPMIDI")) != 0) {
                if ((prop = child->property ("value")) != 0) {
                        _uses_ipmidi = string_is_affirmative (prop->value());
                }
+       } else {
+               _uses_ipmidi = false;
        }
 
        if ((child = node.child ("LogicControlButtons")) != 0) {
@@ -364,12 +367,6 @@ DeviceInfo::has_two_character_display() const
        return _has_two_character_display;
 }
 
-bool
-DeviceInfo::has_segmented_display() const
-{
-       return _has_segmented_display;
-}
-
 bool
 DeviceInfo::has_timecode_display () const
 {
index 4071fcffc72cadfde0a9c1c1dad73dea56bda511..4366cd09b1c7c5474ea88eed8ae4d8501bfe26cf 100644 (file)
@@ -62,7 +62,6 @@ class DeviceInfo
        uint32_t extenders() const;
        bool has_two_character_display() const; 
        bool has_master_fader () const;
-       bool has_segmented_display() const;
        bool has_timecode_display() const;
        bool has_global_controls() const;
        bool has_jog_wheel () const;
@@ -81,7 +80,6 @@ class DeviceInfo
     uint32_t _extenders;
     bool     _has_two_character_display;
     bool     _has_master_fader;
-    bool     _has_segmented_display;
     bool     _has_timecode_display;
     bool     _has_global_controls;
     bool     _has_jog_wheel;
index 2136a64d22621ef508a98ba6bf3a2c2631390991..409fd75831da5ad84c6ece00f5e7d5070f7afaef 100644 (file)
@@ -72,13 +72,15 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        , touch_sensitivity_adjustment (0, 0, 9, 1, 4)
        , touch_sensitivity_scale (touch_sensitivity_adjustment)
        , recalibrate_fader_button (_("Recalibrate Faders"))
+       , ipmidi_base_port_adjustment (MIDI::IPMIDIPort::lowest_ipmidi_port_default, 0, 32767, 1, 1000)
+       , ipmidi_base_port_spinner (ipmidi_base_port_adjustment)
 {
        Gtk::Label* l;
        Gtk::Alignment* align;
 
        set_border_width (12);
 
-       Gtk::Table* table = Gtk::manage (new Gtk::Table (2, 7));
+       Gtk::Table* table = Gtk::manage (new Gtk::Table (2, 8));
        table->set_row_spacings (4);
        table->set_col_spacings (6);
        l = manage (new Gtk::Label (_("Device Type:")));
@@ -133,6 +135,13 @@ MackieControlProtocolGUI::MackieControlProtocolGUI (MackieControlProtocol& p)
        table->attach (touch_sensitivity_scale, 1, 2, 5, 6, AttachOptions(FILL|EXPAND), AttachOptions (0));
        table->attach (recalibrate_fader_button, 1, 2, 6, 7, AttachOptions(FILL|EXPAND), AttachOptions (0));
 
+       l = manage (new Gtk::Label (_("ipMIDI Port (lowest)")));
+       l->set_alignment (1.0, 0.5);
+       table->attach (*l, 0, 1, 7, 8, AttachOptions(FILL|EXPAND), AttachOptions (0));
+       table->attach (ipmidi_base_port_spinner, 1, 2, 7, 8, AttachOptions(FILL|EXPAND), AttachOptions (0));
+
+       ipmidi_base_port_spinner.set_sensitive (_cp.device_info().uses_ipmidi());
+
        vector<string> profiles;
        
        profiles.push_back ("default");
@@ -474,6 +483,12 @@ void
 MackieControlProtocolGUI::surface_combo_changed ()
 {
        _cp.set_device (_surface_combo.get_active_text());
+
+       /* update ipMIDI field */
+
+       cerr << "New device called " << _cp.device_info().name() << " with ipMIDI ? " << _cp.device_info().uses_ipmidi() << endl;
+
+       ipmidi_base_port_spinner.set_sensitive (_cp.device_info().uses_ipmidi());
 }
 
 void
index 6255702e7b04fa734c4f966fc3b1857449d1182e..f8268b9e35d645c823f7e485f12e096ba7e39583 100644 (file)
@@ -102,5 +102,7 @@ class MackieControlProtocolGUI : public Gtk::Notebook
     Gtk::Adjustment  touch_sensitivity_adjustment;
     Gtk::HScale      touch_sensitivity_scale;
     Gtk::Button      recalibrate_fader_button;
+    Gtk::Adjustment  ipmidi_base_port_adjustment;
+    Gtk::SpinButton  ipmidi_base_port_spinner;
 };
 
index 6817564244c9c1d86099f90d1837ac381006458a..f93379f3e77f076df18c03b033b3b0c16b7278d9 100644 (file)
@@ -78,8 +78,6 @@ using namespace Glib;
 
 #include "pbd/abstract_ui.cc" // instantiate template
 
-#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
-
 const int MackieControlProtocol::MODIFIER_OPTION = 0x1;
 const int MackieControlProtocol::MODIFIER_CONTROL = 0x2;
 const int MackieControlProtocol::MODIFIER_SHIFT = 0x4;
@@ -115,7 +113,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session)
        set_device (Config->get_mackie_device_name());
        set_profile (Config->get_mackie_device_profile());
        
-       TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::gui_track_selection_changed, this, _1), this);
+       TrackSelectionChanged.connect (gui_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::gui_track_selection_changed, this, _1), this);
 
        _instance = this;
 
@@ -497,24 +495,24 @@ void
 MackieControlProtocol::connect_session_signals()
 {
        // receive routes added
-       session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_route_added, this, _1), this);
+       session->RouteAdded.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_route_added, this, _1), this);
        // receive record state toggled
-       session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_record_state_changed, this), this);
+       session->RecordStateChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_record_state_changed, this), this);
        // receive transport state changed
-       session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_transport_state_changed, this), this);
-       session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_loop_state_changed, this), this);
+       session->TransportStateChange.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_transport_state_changed, this), this);
+       session->TransportLooped.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_loop_state_changed, this), this);
        // receive punch-in and punch-out
-       Config->ParameterChanged.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
-       session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
+       Config->ParameterChanged.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
+       session->config.ParameterChanged.connect (session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_parameter_changed, this, _1), this);
        // receive rude solo changed
-       session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), this);
+       session->SoloActive.connect(session_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_solo_active_changed, this, _1), this);
 
        // make sure remote id changed signals reach here
        // see also notify_route_added
        Sorted sorted = get_sorted_routes();
 
        for (Sorted::iterator it = sorted.begin(); it != sorted.end(); ++it) {
-               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind(&MackieControlProtocol::notify_remote_id_changed, this), this);
+               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
        }
 }
 
@@ -544,6 +542,11 @@ MackieControlProtocol::set_device (const string& device_name)
                return;
        }
        
+       if (_active) {
+               clear_ports ();
+               surfaces.clear ();      
+       }
+
        _device_info = d->second;
 
        /* store it away in a global location */
@@ -551,8 +554,6 @@ MackieControlProtocol::set_device (const string& device_name)
        Config->set_mackie_device_name (device_name);
 
        if (_active) {
-               clear_ports ();
-               surfaces.clear ();
                create_surfaces ();
                switch_banks (0, true);
        }
@@ -794,7 +795,7 @@ MackieControlProtocol::notify_route_added (ARDOUR::RouteList & rl)
        typedef ARDOUR::RouteList ARS;
 
        for (ARS::iterator it = rl.begin(); it != rl.end(); ++it) {
-               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
+               (*it)->RemoteControlIDChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&MackieControlProtocol::notify_remote_id_changed, this), this);
        }
 }
 
index fc9e690c87644f588c914b27f9a3d65d81146b8b..6f3ed10bad3ea970eca2be1f782997bccfa4fe9f 100644 (file)
@@ -59,7 +59,6 @@ using namespace ARDOUR;
 using namespace PBD;
 
 #define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
-#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
 
 Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::ID,StripButtonInfo>& strip_buttons)
        : Group (name)
@@ -83,14 +82,12 @@ Strip::Strip (Surface& s, const std::string& name, int index, const map<Button::
        _vpot = dynamic_cast<Pot*> (Pot::factory (*_surface, Pot::ID + index, "vpot", *this));
        _meter = dynamic_cast<Meter*> (Meter::factory (*_surface, index, "meter", *this));
 
-#ifndef NDEBUG 
        for (map<Button::ID,StripButtonInfo>::const_iterator b = strip_buttons.begin(); b != strip_buttons.end(); ++b) {
                Button* bb = dynamic_cast<Button*> (Button::factory (*_surface, b->first, b->second.base_id + index, b->second.name, *this));
                DEBUG_TRACE (DEBUG::MackieControl, string_compose ("surface %1 strip %2 new button BID %3 id %4 from base %5\n",
                                                                   _surface->number(), index, Button::id_to_name (bb->bid()), 
                                                                   bb->id(), b->second.base_id));
        }
-#endif 
 }      
 
 Strip::~Strip ()
@@ -165,23 +162,23 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
 
        set_vpot_parameter (PanAzimuthAutomation);
        
-       _route->solo_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_solo_changed, this), ui_context());
-       _route->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_mute_changed, this), ui_context());
+       _route->solo_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_solo_changed, this), ui_context());
+       _route->mute_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_mute_changed, this), ui_context());
 
        boost::shared_ptr<Pannable> pannable = _route->pannable();
 
        if (pannable) {
-               pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
-               pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_panner_width_changed, this, false), ui_context());
+               pannable->pan_azimuth_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_azi_changed, this, false), ui_context());
+               pannable->pan_width_control->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_panner_width_changed, this, false), ui_context());
        }
-       _route->gain_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_gain_changed, this, false), ui_context());
-       _route->PropertyChanged.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_property_changed, this, _1), ui_context());
+       _route->gain_control()->Changed.connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_gain_changed, this, false), ui_context());
+       _route->PropertyChanged.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_property_changed, this, _1), ui_context());
        
        boost::shared_ptr<Track> trk = boost::dynamic_pointer_cast<ARDOUR::Track>(_route);
        
        if (trk) {
                _recenable->set_control (trk->rec_enable_control());
-               trk->rec_enable_control()->Changed .connect(route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_record_enable_changed, this), ui_context());
+               trk->rec_enable_control()->Changed .connect(route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_record_enable_changed, this), ui_context());
 
                
        }
@@ -189,8 +186,8 @@ Strip::set_route (boost::shared_ptr<Route> r, bool with_messages)
        // TODO this works when a currently-banked route is made inactive, but not
        // when a route is activated which should be currently banked.
        
-       _route->active_changed.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_active_changed, this), ui_context());
-       _route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, ui_bind (&Strip::notify_route_deleted, this), ui_context());
+       _route->active_changed.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_active_changed, this), ui_context());
+       _route->DropReferences.connect (route_connections, MISSING_INVALIDATOR, boost::bind (&Strip::notify_route_deleted, this), ui_context());
        
        /* Update */
        
index e2c364b5239ba382d1555f9778484c9ebf430d60..7c604138c389a9805448ce15ff1d08171c798783 100644 (file)
@@ -42,7 +42,6 @@ using ARDOUR::Pannable;
 using ARDOUR::AutomationControl;
 
 #define ui_context() MackieControlProtocol::instance() /* a UICallback-derived object that specifies the event loop for signal handling */
-#define ui_bind(f, ...) boost::protect (boost::bind (f, __VA_ARGS__))
 
 // The MCU sysex header.4th byte Will be overwritten
 // when we get an incoming sysex that identifies
@@ -205,7 +204,7 @@ Surface::setup_master ()
        }
        
        _master_fader->set_control (m->gain_control());
-       m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, ui_bind (&Surface::master_gain_changed, this), ui_context());
+       m->gain_control()->Changed.connect (*this, MISSING_INVALIDATOR, boost::bind (&Surface::master_gain_changed, this), ui_context());
 }
 
 void
index 645da67b431867cb36d946e1823a94702e3e793e..77d71b1a6add74e2cfc6d4121863d180eaf642be 100644 (file)
@@ -52,6 +52,8 @@ using namespace PBD;
  */
 SurfacePort::SurfacePort (Surface& s)
        : _surface (&s)
+       , _input_port (0)
+       , _output_port (0)
 {
        if (_surface->mcp().device_info().uses_ipmidi()) {
                _input_port = new MIDI::IPMIDIPort (MIDI::IPMIDIPort::lowest_ipmidi_port_default+_surface->number());