X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;ds=sidebyside;f=libs%2Fsurfaces%2Fmackie%2Fmackie_control_protocol.cc;h=be1144e6ac57b3d9bb078ca22c44c8ace821769f;hb=f8912b8b57cebf2e63eca34b596d76e00ed35923;hp=68c47effca72817cc5728ff521d16a1164412177;hpb=d3e2de8b4e006ac652b004cb44b66afa9f6584f6;p=ardour.git diff --git a/libs/surfaces/mackie/mackie_control_protocol.cc b/libs/surfaces/mackie/mackie_control_protocol.cc index 68c47effca..be1144e6ac 100644 --- a/libs/surfaces/mackie/mackie_control_protocol.cc +++ b/libs/surfaces/mackie/mackie_control_protocol.cc @@ -71,9 +71,10 @@ using namespace ARDOUR; using namespace std; -using namespace Mackie; using namespace PBD; using namespace Glib; +using namespace ArdourSurface; +using namespace Mackie; #include "i18n.h" @@ -109,6 +110,7 @@ MackieControlProtocol::MackieControlProtocol (Session& session) , _initialized (false) , _surfaces_state (0) , _surfaces_version (0) + , _session_load (true) { DEBUG_TRACE (DEBUG::MackieControl, "MackieControlProtocol::MackieControlProtocol\n"); @@ -270,7 +272,10 @@ MackieControlProtocol::get_sorted_routes() if (route_is_locked_to_strip(route)) { continue; } - + /* This next section which is not used yet, looks wrong to me + The first four belong here but the bottom five are not a selection + of routes and belong elsewhere as they are v-pot modes. + */ switch (_view_mode) { case Mixer: break; @@ -489,8 +494,8 @@ MackieControlProtocol::update_global_button (int id, LedState ls) if (!_device_info.has_global_controls()) { return; } - - boost::shared_ptr surface = surfaces.front(); + // surface needs to be master surface + boost::shared_ptr surface = _master_surface; map::iterator x = surface->controls_by_device_independent_id.find (id); if (x != surface->controls_by_device_independent_id.end()) { @@ -509,8 +514,7 @@ MackieControlProtocol::update_global_led (int id, LedState ls) if (!_device_info.has_global_controls()) { return; } - - boost::shared_ptr surface = surfaces.front(); + boost::shared_ptr surface = _master_surface; map::iterator x = surface->controls_by_device_independent_id.find (id); @@ -561,13 +565,13 @@ MackieControlProtocol::initialize() return; } - if (!surfaces.front()->active ()) { + if (!_master_surface->active ()) { return; } // sometimes the jog wheel is a pot if (_device_info.has_jog_wheel()) { - surfaces.front()->blank_jog_ring (); + _master_surface->blank_jog_ring (); } } @@ -657,9 +661,9 @@ MackieControlProtocol::set_device (const string& device_name) } gboolean -ipmidi_input_handler (GIOChannel*, GIOCondition condition, void *data) +ArdourSurface::ipmidi_input_handler (GIOChannel*, GIOCondition condition, void *data) { - MackieControlProtocol::ipMIDIHandler* ipm = static_cast(data); + ArdourSurface::MackieControlProtocol::ipMIDIHandler* ipm = static_cast(data); return ipm->mcp->midi_input_handler (Glib::IOCondition (condition), ipm->port); } @@ -667,7 +671,7 @@ int MackieControlProtocol::create_surfaces () { string device_name; - surface_type_t stype = mcu; + surface_type_t stype = mcu; // type not yet determined char buf[128]; if (_device_info.extenders() == 0) { @@ -682,12 +686,21 @@ MackieControlProtocol::create_surfaces () boost::shared_ptr surface; + if (n == _device_info.master_position()) { + stype = mcu; + } else { + stype = ext; + } try { surface.reset (new Surface (*this, device_name, n, stype)); } catch (...) { return -1; } + if (n == _device_info.master_position()) { + _master_surface = surface; + } + if (_surfaces_state) { surface->set_state (*_surfaces_state, _surfaces_version); } @@ -696,8 +709,6 @@ MackieControlProtocol::create_surfaces () Glib::Threads::Mutex::Lock lm (surfaces_lock); surfaces.push_back (surface); } - - /* next device will be an extender */ if (_device_info.extenders() < 2) { device_name = X_("mackie control #2"); @@ -705,7 +716,6 @@ MackieControlProtocol::create_surfaces () snprintf (buf, sizeof (buf), X_("mackie control #%d"), n+2); device_name = buf; } - stype = ext; if (!_device_info.uses_ipmidi()) { @@ -724,15 +734,13 @@ MackieControlProtocol::create_surfaces () session->engine().make_port_name_non_relative (surface->port().output_port().name()) ); - session->BundleAdded (_input_bundle); - session->BundleAdded (_output_bundle); + session->BundleAddedOrRemoved (); } else { _input_bundle.reset ((ARDOUR::Bundle*) 0); _output_bundle.reset ((ARDOUR::Bundle*) 0); - session->BundleRemoved (_input_bundle); - session->BundleRemoved (_output_bundle); + session->BundleAddedOrRemoved (); } MIDI::Port& input_port (surface->port().input_port()); @@ -828,6 +836,10 @@ MackieControlProtocol::set_state (const XMLNode & node, int version) const XMLProperty* prop; uint32_t bank = 0; + if (ControlProtocol::set_state (node, version)) { + return -1; + } + if ((prop = node.property (X_("ipmidi-base"))) != 0) { set_ipmidi_base (atoi (prop->value())); } @@ -918,7 +930,7 @@ MackieControlProtocol::update_timecode_display() return; } - boost::shared_ptr surface = surfaces.front(); + boost::shared_ptr surface = _master_surface; if (surface->type() != mcu || !_device_info.has_timecode_display() || !surface->active ()) { return; @@ -954,9 +966,11 @@ MackieControlProtocol::update_timecode_display() void MackieControlProtocol::notify_parameter_changed (std::string const & p) { if (p == "punch-in") { - update_global_button (Button::PunchIn, session->config.get_punch_in()); + // no such button right now + // update_global_button (Button::PunchIn, session->config.get_punch_in()); } else if (p == "punch-out") { - update_global_button (Button::PunchOut, session->config.get_punch_out()); + // no such button right now + // update_global_button (Button::PunchOut, session->config.get_punch_out()); } else if (p == "clicking") { // update_global_button (Button::RelayClick, Config->get_clicking()); } else { @@ -990,7 +1004,7 @@ MackieControlProtocol::notify_solo_active_changed (bool active) { Glib::Threads::Mutex::Lock lm (surfaces_lock); - surface = surfaces.front (); + surface = _master_surface; } map::iterator x = surface->controls_by_device_independent_id.find (Led::RudeSolo); @@ -1068,7 +1082,7 @@ MackieControlProtocol::notify_record_state_changed () { Glib::Threads::Mutex::Lock lm (surfaces_lock); - surface = surfaces.front(); + surface = _master_surface; } /* rec is a tristate */ @@ -1149,8 +1163,8 @@ MackieControlProtocol::build_button_map () #define DEFINE_BUTTON_HANDLER(b,p,r) button_map.insert (pair ((b), ButtonHandlers ((p),(r)))); - DEFINE_BUTTON_HANDLER (Button::IO, &MackieControlProtocol::io_press, &MackieControlProtocol::io_release); - DEFINE_BUTTON_HANDLER (Button::Sends, &MackieControlProtocol::sends_press, &MackieControlProtocol::sends_release); + DEFINE_BUTTON_HANDLER (Button::Track, &MackieControlProtocol::track_press, &MackieControlProtocol::track_release); + DEFINE_BUTTON_HANDLER (Button::Send, &MackieControlProtocol::send_press, &MackieControlProtocol::send_release); DEFINE_BUTTON_HANDLER (Button::Pan, &MackieControlProtocol::pan_press, &MackieControlProtocol::pan_release); DEFINE_BUTTON_HANDLER (Button::Plugin, &MackieControlProtocol::plugin_press, &MackieControlProtocol::plugin_release); DEFINE_BUTTON_HANDLER (Button::Eq, &MackieControlProtocol::eq_press, &MackieControlProtocol::eq_release); @@ -1160,7 +1174,7 @@ MackieControlProtocol::build_button_map () DEFINE_BUTTON_HANDLER (Button::ChannelLeft, &MackieControlProtocol::channel_left_press, &MackieControlProtocol::channel_left_release); DEFINE_BUTTON_HANDLER (Button::ChannelRight, &MackieControlProtocol::channel_right_press, &MackieControlProtocol::channel_right_release); DEFINE_BUTTON_HANDLER (Button::Flip, &MackieControlProtocol::flip_press, &MackieControlProtocol::flip_release); - DEFINE_BUTTON_HANDLER (Button::Edit, &MackieControlProtocol::edit_press, &MackieControlProtocol::edit_release); + DEFINE_BUTTON_HANDLER (Button::View, &MackieControlProtocol::view_press, &MackieControlProtocol::view_release); DEFINE_BUTTON_HANDLER (Button::NameValue, &MackieControlProtocol::name_value_press, &MackieControlProtocol::name_value_release); DEFINE_BUTTON_HANDLER (Button::TimecodeBeats, &MackieControlProtocol::timecode_beats_press, &MackieControlProtocol::timecode_beats_release); DEFINE_BUTTON_HANDLER (Button::F1, &MackieControlProtocol::F1_press, &MackieControlProtocol::F1_release); @@ -1171,35 +1185,35 @@ MackieControlProtocol::build_button_map () DEFINE_BUTTON_HANDLER (Button::F6, &MackieControlProtocol::F6_press, &MackieControlProtocol::F6_release); DEFINE_BUTTON_HANDLER (Button::F7, &MackieControlProtocol::F7_press, &MackieControlProtocol::F7_release); DEFINE_BUTTON_HANDLER (Button::F8, &MackieControlProtocol::F8_press, &MackieControlProtocol::F8_release); - DEFINE_BUTTON_HANDLER (Button::F9, &MackieControlProtocol::F9_press, &MackieControlProtocol::F9_release); - DEFINE_BUTTON_HANDLER (Button::F10, &MackieControlProtocol::F10_press, &MackieControlProtocol::F10_release); - DEFINE_BUTTON_HANDLER (Button::F11, &MackieControlProtocol::F11_press, &MackieControlProtocol::F11_release); - DEFINE_BUTTON_HANDLER (Button::F12, &MackieControlProtocol::F12_press, &MackieControlProtocol::F12_release); - DEFINE_BUTTON_HANDLER (Button::F13, &MackieControlProtocol::F13_press, &MackieControlProtocol::F13_release); - DEFINE_BUTTON_HANDLER (Button::F14, &MackieControlProtocol::F14_press, &MackieControlProtocol::F14_release); - DEFINE_BUTTON_HANDLER (Button::F15, &MackieControlProtocol::F15_press, &MackieControlProtocol::F15_release); - DEFINE_BUTTON_HANDLER (Button::F16, &MackieControlProtocol::F16_press, &MackieControlProtocol::F16_release); + DEFINE_BUTTON_HANDLER (Button::MidiTracks, &MackieControlProtocol::miditracks_press, &MackieControlProtocol::miditracks_release); + DEFINE_BUTTON_HANDLER (Button::Inputs, &MackieControlProtocol::inputs_press, &MackieControlProtocol::inputs_release); + DEFINE_BUTTON_HANDLER (Button::AudioTracks, &MackieControlProtocol::audiotracks_press, &MackieControlProtocol::audiotracks_release); + DEFINE_BUTTON_HANDLER (Button::AudioInstruments, &MackieControlProtocol::audioinstruments_press, &MackieControlProtocol::audioinstruments_release); + DEFINE_BUTTON_HANDLER (Button::Aux, &MackieControlProtocol::aux_press, &MackieControlProtocol::aux_release); + DEFINE_BUTTON_HANDLER (Button::Busses, &MackieControlProtocol::busses_press, &MackieControlProtocol::busses_release); + DEFINE_BUTTON_HANDLER (Button::Outputs, &MackieControlProtocol::outputs_press, &MackieControlProtocol::outputs_release); + DEFINE_BUTTON_HANDLER (Button::User, &MackieControlProtocol::user_press, &MackieControlProtocol::user_release); DEFINE_BUTTON_HANDLER (Button::Shift, &MackieControlProtocol::shift_press, &MackieControlProtocol::shift_release); DEFINE_BUTTON_HANDLER (Button::Option, &MackieControlProtocol::option_press, &MackieControlProtocol::option_release); DEFINE_BUTTON_HANDLER (Button::Ctrl, &MackieControlProtocol::control_press, &MackieControlProtocol::control_release); DEFINE_BUTTON_HANDLER (Button::CmdAlt, &MackieControlProtocol::cmd_alt_press, &MackieControlProtocol::cmd_alt_release); - DEFINE_BUTTON_HANDLER (Button::On, &MackieControlProtocol::on_press, &MackieControlProtocol::on_release); - DEFINE_BUTTON_HANDLER (Button::RecReady, &MackieControlProtocol::rec_ready_press, &MackieControlProtocol::rec_ready_release); - DEFINE_BUTTON_HANDLER (Button::Undo, &MackieControlProtocol::undo_press, &MackieControlProtocol::undo_release); - DEFINE_BUTTON_HANDLER (Button::Save, &MackieControlProtocol::save_press, &MackieControlProtocol::save_release); + DEFINE_BUTTON_HANDLER (Button::Read, &MackieControlProtocol::read_press, &MackieControlProtocol::read_release); + DEFINE_BUTTON_HANDLER (Button::Write, &MackieControlProtocol::write_press, &MackieControlProtocol::write_release); + DEFINE_BUTTON_HANDLER (Button::Trim, &MackieControlProtocol::trim_press, &MackieControlProtocol::trim_release); DEFINE_BUTTON_HANDLER (Button::Touch, &MackieControlProtocol::touch_press, &MackieControlProtocol::touch_release); - DEFINE_BUTTON_HANDLER (Button::Redo, &MackieControlProtocol::redo_press, &MackieControlProtocol::redo_release); - DEFINE_BUTTON_HANDLER (Button::Marker, &MackieControlProtocol::marker_press, &MackieControlProtocol::marker_release); - DEFINE_BUTTON_HANDLER (Button::Enter, &MackieControlProtocol::enter_press, &MackieControlProtocol::enter_release); + DEFINE_BUTTON_HANDLER (Button::Latch, &MackieControlProtocol::latch_press, &MackieControlProtocol::latch_release); + DEFINE_BUTTON_HANDLER (Button::Grp, &MackieControlProtocol::grp_press, &MackieControlProtocol::grp_release); + DEFINE_BUTTON_HANDLER (Button::Save, &MackieControlProtocol::save_press, &MackieControlProtocol::save_release); + DEFINE_BUTTON_HANDLER (Button::Undo, &MackieControlProtocol::undo_press, &MackieControlProtocol::undo_release); DEFINE_BUTTON_HANDLER (Button::Cancel, &MackieControlProtocol::cancel_press, &MackieControlProtocol::cancel_release); - DEFINE_BUTTON_HANDLER (Button::Mixer, &MackieControlProtocol::mixer_press, &MackieControlProtocol::mixer_release); - DEFINE_BUTTON_HANDLER (Button::FrmLeft, &MackieControlProtocol::frm_left_press, &MackieControlProtocol::frm_left_release); - DEFINE_BUTTON_HANDLER (Button::FrmRight, &MackieControlProtocol::frm_right_press, &MackieControlProtocol::frm_right_release); + DEFINE_BUTTON_HANDLER (Button::Enter, &MackieControlProtocol::enter_press, &MackieControlProtocol::enter_release); + DEFINE_BUTTON_HANDLER (Button::Marker, &MackieControlProtocol::marker_press, &MackieControlProtocol::marker_release); + DEFINE_BUTTON_HANDLER (Button::Nudge, &MackieControlProtocol::nudge_press, &MackieControlProtocol::nudge_release); DEFINE_BUTTON_HANDLER (Button::Loop, &MackieControlProtocol::loop_press, &MackieControlProtocol::loop_release); - DEFINE_BUTTON_HANDLER (Button::PunchIn, &MackieControlProtocol::punch_in_press, &MackieControlProtocol::punch_in_release); - DEFINE_BUTTON_HANDLER (Button::PunchOut, &MackieControlProtocol::punch_out_press, &MackieControlProtocol::punch_out_release); - DEFINE_BUTTON_HANDLER (Button::Home, &MackieControlProtocol::home_press, &MackieControlProtocol::home_release); - DEFINE_BUTTON_HANDLER (Button::End, &MackieControlProtocol::end_press, &MackieControlProtocol::end_release); + DEFINE_BUTTON_HANDLER (Button::Drop, &MackieControlProtocol::drop_press, &MackieControlProtocol::drop_release); + DEFINE_BUTTON_HANDLER (Button::Replace, &MackieControlProtocol::replace_press, &MackieControlProtocol::replace_release); + DEFINE_BUTTON_HANDLER (Button::Click, &MackieControlProtocol::click_press, &MackieControlProtocol::click_release); + DEFINE_BUTTON_HANDLER (Button::ClearSolo, &MackieControlProtocol::clearsolo_press, &MackieControlProtocol::clearsolo_release); DEFINE_BUTTON_HANDLER (Button::Rewind, &MackieControlProtocol::rewind_press, &MackieControlProtocol::rewind_release); DEFINE_BUTTON_HANDLER (Button::Ffwd, &MackieControlProtocol::ffwd_press, &MackieControlProtocol::ffwd_release); DEFINE_BUTTON_HANDLER (Button::Stop, &MackieControlProtocol::stop_press, &MackieControlProtocol::stop_release); @@ -1215,29 +1229,6 @@ MackieControlProtocol::build_button_map () DEFINE_BUTTON_HANDLER (Button::UserB, &MackieControlProtocol::user_b_press, &MackieControlProtocol::user_b_release); DEFINE_BUTTON_HANDLER (Button::MasterFaderTouch, &MackieControlProtocol::master_fader_touch_press, &MackieControlProtocol::master_fader_touch_release); - DEFINE_BUTTON_HANDLER (Button::Snapshot, &MackieControlProtocol::snapshot_press, &MackieControlProtocol::snapshot_release); - DEFINE_BUTTON_HANDLER (Button::Read, &MackieControlProtocol::read_press, &MackieControlProtocol::read_release); - DEFINE_BUTTON_HANDLER (Button::Write, &MackieControlProtocol::write_press, &MackieControlProtocol::write_release); - DEFINE_BUTTON_HANDLER (Button::FdrGroup, &MackieControlProtocol::fdrgroup_press, &MackieControlProtocol::fdrgroup_release); - DEFINE_BUTTON_HANDLER (Button::ClearSolo, &MackieControlProtocol::clearsolo_press, &MackieControlProtocol::clearsolo_release); - DEFINE_BUTTON_HANDLER (Button::Track, &MackieControlProtocol::track_press, &MackieControlProtocol::track_release); - DEFINE_BUTTON_HANDLER (Button::Send, &MackieControlProtocol::send_press, &MackieControlProtocol::send_release); - DEFINE_BUTTON_HANDLER (Button::MidiTracks, &MackieControlProtocol::miditracks_press, &MackieControlProtocol::miditracks_release); - DEFINE_BUTTON_HANDLER (Button::Inputs, &MackieControlProtocol::inputs_press, &MackieControlProtocol::inputs_release); - DEFINE_BUTTON_HANDLER (Button::AudioTracks, &MackieControlProtocol::audiotracks_press, &MackieControlProtocol::audiotracks_release); - DEFINE_BUTTON_HANDLER (Button::AudioInstruments, &MackieControlProtocol::audioinstruments_press, &MackieControlProtocol::audioinstruments_release); - DEFINE_BUTTON_HANDLER (Button::Aux, &MackieControlProtocol::aux_press, &MackieControlProtocol::aux_release); - DEFINE_BUTTON_HANDLER (Button::Busses, &MackieControlProtocol::busses_press, &MackieControlProtocol::busses_release); - DEFINE_BUTTON_HANDLER (Button::Outputs, &MackieControlProtocol::outputs_press, &MackieControlProtocol::outputs_release); - DEFINE_BUTTON_HANDLER (Button::User, &MackieControlProtocol::user_press, &MackieControlProtocol::user_release); - DEFINE_BUTTON_HANDLER (Button::Trim, &MackieControlProtocol::trim_press, &MackieControlProtocol::trim_release); - DEFINE_BUTTON_HANDLER (Button::Latch, &MackieControlProtocol::latch_press, &MackieControlProtocol::latch_release); - DEFINE_BUTTON_HANDLER (Button::Grp, &MackieControlProtocol::grp_press, &MackieControlProtocol::grp_release); - DEFINE_BUTTON_HANDLER (Button::Nudge, &MackieControlProtocol::nudge_press, &MackieControlProtocol::nudge_release); - DEFINE_BUTTON_HANDLER (Button::Drop, &MackieControlProtocol::drop_press, &MackieControlProtocol::drop_release); - DEFINE_BUTTON_HANDLER (Button::Replace, &MackieControlProtocol::replace_press, &MackieControlProtocol::replace_release); - DEFINE_BUTTON_HANDLER (Button::Click, &MackieControlProtocol::click_press, &MackieControlProtocol::click_release); - DEFINE_BUTTON_HANDLER (Button::View, &MackieControlProtocol::view_press, &MackieControlProtocol::view_release); } void