basics of following MIDI track selection and rewiring input
This commit is contained in:
parent
d0b2767856
commit
0a8ab08e5f
|
@ -59,6 +59,7 @@ CONFIG_VARIABLE (int32_t, mmc_send_device_id, "mmc-send-device-id", 0)
|
|||
CONFIG_VARIABLE (int32_t, initial_program_change, "initial-program-change", -1)
|
||||
CONFIG_VARIABLE (bool, first_midi_bank_is_zero, "display-first-midi-bank-as-zero", false)
|
||||
CONFIG_VARIABLE (int32_t, inter_scene_gap_frames, "inter-scene-gap-frames", 1)
|
||||
CONFIG_VARIABLE (bool, midi_input_follows_selection, "midi-input-follows-selection", 1)
|
||||
|
||||
/* Timecode and related */
|
||||
|
||||
|
|
|
@ -593,7 +593,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||
}
|
||||
}
|
||||
}
|
||||
private:
|
||||
private:
|
||||
Session * _session;
|
||||
};
|
||||
|
||||
|
@ -1151,6 +1151,7 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||
|
||||
void auto_connect_thread_wakeup ();
|
||||
|
||||
|
||||
protected:
|
||||
friend class AudioEngine;
|
||||
void set_block_size (pframes_t nframes);
|
||||
|
@ -2033,6 +2034,10 @@ class LIBARDOUR_API Session : public PBD::StatefulDestructible, public PBD::Scop
|
|||
boost::shared_ptr<Route> get_midi_nth_route_by_id (PresentationInfo::order_t n) const;
|
||||
|
||||
std::string created_with;
|
||||
|
||||
void midi_track_presentation_info_changed (PBD::PropertyChange const &, boost::weak_ptr<MidiTrack>);
|
||||
void rewire_selected_midi (boost::shared_ptr<MidiTrack>);
|
||||
boost::weak_ptr<MidiTrack> current_midi_target;
|
||||
};
|
||||
|
||||
|
||||
|
|
|
@ -3474,6 +3474,7 @@ Session::add_routes_inner (RouteList& new_routes, bool input_auto_connect, bool
|
|||
if (mt) {
|
||||
mt->StepEditStatusChange.connect_same_thread (*this, boost::bind (&Session::step_edit_status_change, this, _1));
|
||||
mt->output()->changed.connect_same_thread (*this, boost::bind (&Session::midi_output_change_handler, this, _1, _2, boost::weak_ptr<Route>(mt)));
|
||||
mt->presentation_info().PropertyChanged.connect_same_thread (*this, boost::bind (&Session::midi_track_presentation_info_changed, this, _1, boost::weak_ptr<MidiTrack>(mt)));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -722,3 +722,55 @@ Session::mtc_input_port () const
|
|||
{
|
||||
return _midi_ports->mtc_input_port ();
|
||||
}
|
||||
|
||||
void
|
||||
Session::midi_track_presentation_info_changed (PropertyChange const& what_changed, boost::weak_ptr<MidiTrack> mt)
|
||||
{
|
||||
if (!Config->get_midi_input_follows_selection()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!what_changed.contains (Properties::selected)) {
|
||||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MidiTrack> new_midi_target (mt.lock ());
|
||||
|
||||
if (new_midi_target->presentation_info().selected()) {
|
||||
rewire_selected_midi (new_midi_target);
|
||||
}
|
||||
}
|
||||
|
||||
void
|
||||
Session::rewire_selected_midi (boost::shared_ptr<MidiTrack> new_midi_target)
|
||||
{
|
||||
if (!new_midi_target) {
|
||||
return;
|
||||
}
|
||||
|
||||
boost::shared_ptr<MidiTrack> old_midi_target = current_midi_target.lock ();
|
||||
|
||||
if (new_midi_target == old_midi_target) {
|
||||
return;
|
||||
}
|
||||
|
||||
PortManager::MidiSelectionPorts msp;
|
||||
|
||||
AudioEngine::instance()->get_midi_selection_ports (msp);
|
||||
|
||||
if (msp.empty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (old_midi_target) {
|
||||
for (PortManager::MidiSelectionPorts::const_iterator p = msp.begin(); p != msp.end(); ++p) {
|
||||
old_midi_target->input()->disconnect (old_midi_target->input()->nth (0), (*p), this);
|
||||
}
|
||||
}
|
||||
|
||||
for (PortManager::MidiSelectionPorts::const_iterator p = msp.begin(); p != msp.end(); ++p) {
|
||||
new_midi_target->input()->connect (new_midi_target->input()->nth(0), (*p), this);
|
||||
}
|
||||
|
||||
current_midi_target = new_midi_target;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user