From f75bbfd8ac52ea33692c3ee15953ceb2994117ab Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Sat, 13 Aug 2011 16:27:29 +0000 Subject: [PATCH] track changes to config parameters for MMC device id's correctly (from roy vegard) git-svn-id: svn://localhost/ardour2/branches/3.0@9985 d708f5d6-7413-0410-9779-e7cbd77b26cf --- gtk2_ardour/editor_ops.cc | 8 ++++++++ libs/ardour/session_state.cc | 4 ++-- .../control_protocol/control_protocol.cc | 1 + .../control_protocol/control_protocol.h | 1 + .../generic_midi_control_protocol.cc | 7 ++++++- libs/surfaces/generic_midi/midicontrollable.cc | 4 ++-- libs/surfaces/generic_midi/midifunction.cc | 16 +++++++++++++++- libs/surfaces/generic_midi/midifunction.h | 6 ++++-- libs/surfaces/generic_midi/midiinvokable.h | 2 +- 9 files changed, 40 insertions(+), 9 deletions(-) diff --git a/gtk2_ardour/editor_ops.cc b/gtk2_ardour/editor_ops.cc index 8ac44a8eff..a47fc95430 100644 --- a/gtk2_ardour/editor_ops.cc +++ b/gtk2_ardour/editor_ops.cc @@ -3273,6 +3273,14 @@ Editor::freeze_thread () void Editor::freeze_route () { + if (!_session) { + return; + } + + /* stop transport before we start. this is important */ + + _session->request_transport_speed (0.0); + if (clicked_routeview == 0 || !clicked_routeview->is_audio_track()) { return; } diff --git a/libs/ardour/session_state.cc b/libs/ardour/session_state.cc index 1b8c7c0ba0..074527dc33 100644 --- a/libs/ardour/session_state.cc +++ b/libs/ardour/session_state.cc @@ -3453,11 +3453,11 @@ Session::config_changed (std::string p, bool ours) //poke_midi_thread (); - } else if (p == "mmc-device-id" || p == "mmc-receive-id") { + } else if (p == "mmc-device-id" || p == "mmc-receive-id" || p == "mmc-receive-device-id") { MIDI::Manager::instance()->mmc()->set_receive_device_id (Config->get_mmc_receive_device_id()); - } else if (p == "mmc-send-id") { + } else if (p == "mmc-send-id" || p == "mmc-send-device-id") { MIDI::Manager::instance()->mmc()->set_send_device_id (Config->get_mmc_send_device_id()); diff --git a/libs/surfaces/control_protocol/control_protocol.cc b/libs/surfaces/control_protocol/control_protocol.cc index 3afd589ee7..983208343a 100644 --- a/libs/surfaces/control_protocol/control_protocol.cc +++ b/libs/surfaces/control_protocol/control_protocol.cc @@ -36,6 +36,7 @@ Signal0 ControlProtocol::ZoomOut; Signal0 ControlProtocol::ZoomIn; Signal0 ControlProtocol::Enter; Signal1 ControlProtocol::ScrollTimeline; +Signal1 ControlProtocol::SelectByRID; ControlProtocol::ControlProtocol (Session& s, string str, EventLoop* evloop) : BasicUI (s), diff --git a/libs/surfaces/control_protocol/control_protocol/control_protocol.h b/libs/surfaces/control_protocol/control_protocol/control_protocol.h index 479ffe30cc..c05e7e291a 100644 --- a/libs/surfaces/control_protocol/control_protocol/control_protocol.h +++ b/libs/surfaces/control_protocol/control_protocol/control_protocol.h @@ -61,6 +61,7 @@ class ControlProtocol : virtual public sigc::trackable, public PBD::Stateful, pu static PBD::Signal0 ZoomOut; static PBD::Signal0 Enter; static PBD::Signal1 ScrollTimeline; + static PBD::Signal1 SelectByRID; /* the model here is as follows: diff --git a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc index 23072cea37..1a615de424 100644 --- a/libs/surfaces/generic_midi/generic_midi_control_protocol.cc +++ b/libs/surfaces/generic_midi/generic_midi_control_protocol.cc @@ -772,6 +772,7 @@ GenericMidiControlProtocol::create_function (const XMLNode& node) MIDI::eventType ev; MIDI::byte* data = 0; uint32_t data_size = 0; + string argument; if ((prop = node.property (X_("ctl"))) != 0) { ev = MIDI::controller; @@ -843,11 +844,15 @@ GenericMidiControlProtocol::create_function (const XMLNode& node) } } + if ((prop = node.property (X_("arg"))) != 0) { + argument = prop->value (); + } + prop = node.property (X_("function")); MIDIFunction* mf = new MIDIFunction (*_input_port); - if (mf->init (*this, prop->value(), data, data_size)) { + if (mf->setup (*this, prop->value(), argument, data, data_size)) { delete mf; return 0; } diff --git a/libs/surfaces/generic_midi/midicontrollable.cc b/libs/surfaces/generic_midi/midicontrollable.cc index 9060f010a0..426d730743 100644 --- a/libs/surfaces/generic_midi/midicontrollable.cc +++ b/libs/surfaces/generic_midi/midicontrollable.cc @@ -351,7 +351,7 @@ MIDIControllable::send_feedback () { byte msg[3]; - if (!_learned || setting || !feedback || control_type == none) { + if (!_learned || setting || !feedback || control_type == none || !controllable) { return; } @@ -370,7 +370,7 @@ MIDIControllable::send_feedback () MIDI::byte* MIDIControllable::write_feedback (MIDI::byte* buf, int32_t& bufsize, bool /*force*/) { - if (control_type != none && feedback && bufsize > 2) { + if (controllable && control_type != none && feedback && bufsize > 2) { MIDI::byte gm; diff --git a/libs/surfaces/generic_midi/midifunction.cc b/libs/surfaces/generic_midi/midifunction.cc index 757c1aeffe..186858550f 100644 --- a/libs/surfaces/generic_midi/midifunction.cc +++ b/libs/surfaces/generic_midi/midifunction.cc @@ -35,10 +35,12 @@ MIDIFunction::~MIDIFunction () } int -MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable_name, MIDI::byte* msg_data, size_t data_sz) +MIDIFunction::setup (GenericMidiControlProtocol& ui, const std::string& invokable_name, const std::string& arg, MIDI::byte* msg_data, size_t data_sz) { MIDIInvokable::init (ui, invokable_name, msg_data, data_sz); + _argument = arg; + if (strcasecmp (_invokable_name.c_str(), "transport-stop") == 0) { _function = TransportStop; } else if (strcasecmp (_invokable_name.c_str(), "transport-roll") == 0) { @@ -59,6 +61,11 @@ MIDIFunction::init (GenericMidiControlProtocol& ui, const std::string& invokable _function = NextBank; } else if (strcasecmp (_invokable_name.c_str(), "prev-bank") == 0) { _function = PrevBank; + } else if (strcasecmp (_invokable_name.c_str(), "select") == 0) { + if (_argument.empty()) { + return -1; + } + _function = Select; } else { return -1; } @@ -109,6 +116,13 @@ MIDIFunction::execute () case TransportRecordDisable: _ui->set_record_enable (false); break; + + case Select: + if (!_argument.empty()) { + uint32_t rid; + sscanf (_argument.c_str(), "%d", &rid); + _ui->SelectByRID (rid); + } } } diff --git a/libs/surfaces/generic_midi/midifunction.h b/libs/surfaces/generic_midi/midifunction.h index 73ba21434e..aafa739f20 100644 --- a/libs/surfaces/generic_midi/midifunction.h +++ b/libs/surfaces/generic_midi/midifunction.h @@ -52,13 +52,14 @@ class MIDIFunction : public MIDIInvokable TransportEnd, TransportLoopToggle, TransportRecordEnable, - TransportRecordDisable + TransportRecordDisable, + Select, }; MIDIFunction (MIDI::Port&); virtual ~MIDIFunction (); - int init (GenericMidiControlProtocol&, const std::string& function_name, MIDI::byte* sysex = 0, size_t ssize = 0); + int setup (GenericMidiControlProtocol&, const std::string& function_name, const std::string& argument, MIDI::byte* sysex = 0, size_t ssize = 0); const std::string& function_name() const { return _invokable_name; } @@ -67,6 +68,7 @@ class MIDIFunction : public MIDIInvokable private: Function _function; + std::string _argument; void execute (); }; diff --git a/libs/surfaces/generic_midi/midiinvokable.h b/libs/surfaces/generic_midi/midiinvokable.h index b86bdb858b..40b3a9068c 100644 --- a/libs/surfaces/generic_midi/midiinvokable.h +++ b/libs/surfaces/generic_midi/midiinvokable.h @@ -62,7 +62,7 @@ class MIDIInvokable : public PBD::Stateful MIDI::channel_t control_channel; MIDI::byte* data; size_t data_size; - + void midi_sense_note (MIDI::Parser &, MIDI::EventTwoBytes *, bool is_on); void midi_sense_note_on (MIDI::Parser &p, MIDI::EventTwoBytes *tb); void midi_sense_note_off (MIDI::Parser &p, MIDI::EventTwoBytes *tb);