diff --git a/libs/ardour/ardour/session.h b/libs/ardour/ardour/session.h index 2a90230c73..b48b326a60 100644 --- a/libs/ardour/ardour/session.h +++ b/libs/ardour/ardour/session.h @@ -980,6 +980,8 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop MIDI::MachineControl& mmc() { return *_mmc; } + void reconnect_midi_scene_ports (bool); + protected: friend class AudioEngine; void set_block_size (pframes_t nframes); diff --git a/libs/ardour/session.cc b/libs/ardour/session.cc index 94153de1cf..f6d04b1be9 100644 --- a/libs/ardour/session.cc +++ b/libs/ardour/session.cc @@ -2375,6 +2375,40 @@ Session::reconnect_existing_routes (bool withLock, bool reconnect_master, bool r */ } +void +Session::reconnect_midi_scene_ports(bool inputs) +{ + if (inputs) { + scene_in()->disconnect_all (); + + std::vector midi_port_states; + EngineStateController::instance()->get_physical_midi_input_states (midi_port_states); + + std::vector::iterator state_iter = midi_port_states.begin(); + + for (; state_iter != midi_port_states.end(); ++state_iter) { + if (state_iter->active && state_iter->available && state_iter->connected) { + scene_in()->connect (state_iter->name); + } + } + + } else { + scene_out()->disconnect_all (); + + std::vector midi_port_states; + EngineStateController::instance()->get_physical_midi_output_states (midi_port_states); + + std::vector::iterator state_iter = midi_port_states.begin(); + + for (; state_iter != midi_port_states.end(); ++state_iter) { + if (state_iter->active && state_iter->available && state_iter->connected) { + scene_out()->connect (state_iter->name); + } + } + + } +} + /** Caller must not hold process lock * @param name_template string to use for the start of the name, or "" to use "Audio".