#include "ardour/slave.h"
#include "ardour/ticker.h"
-#include "i18n.h"
+#include "pbd/i18n.h"
using namespace std;
using namespace ARDOUR;
// or a new full timecode will be queued next cycle.
while (outbound_mtc_timecode_frame < t) {
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
- outbound_mtc_timecode_frame += _frames_per_timecode_frame;
+ outbound_mtc_timecode_frame += _samples_per_timecode_frame;
}
- double const quarter_frame_duration = ((framecnt_t) _frames_per_timecode_frame) / 4.0;
+ double const quarter_frame_duration = ((framecnt_t) _samples_per_timecode_frame) / 4.0;
if (ceil((t - mtc_tc) / quarter_frame_duration) > 0) {
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
- outbound_mtc_timecode_frame += _frames_per_timecode_frame;
+ outbound_mtc_timecode_frame += _samples_per_timecode_frame;
}
DEBUG_TRACE (DEBUG::MTC, string_compose ("Full MTC TC %1 (off %2)\n", outbound_mtc_timecode_frame, mtc_offset));
if (((mtc_timecode_bits >> 5) != MIDI::MTC_25_FPS) && (transmitting_timecode_time.frames % 2)) {
// start MTC quarter frame transmission on an even frame
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
- outbound_mtc_timecode_frame += _frames_per_timecode_frame;
+ outbound_mtc_timecode_frame += _samples_per_timecode_frame;
}
next_quarter_frame_to_send = 0;
assert (next_quarter_frame_to_send <= 7);
/* Duration of one quarter frame */
- double const quarter_frame_duration = _frames_per_timecode_frame / 4.0;
+ double const quarter_frame_duration = _samples_per_timecode_frame / 4.0;
DEBUG_TRACE (DEBUG::MTC, string_compose ("TF %1 SF %2 MT %3 QF %4 QD %5\n",
_transport_frame, start_frame, outbound_mtc_timecode_frame,
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
Timecode::increment (transmitting_timecode_time, config.get_subframes_per_frame());
// Increment timing of first quarter frame
- outbound_mtc_timecode_frame += 2.0 * _frames_per_timecode_frame;
+ outbound_mtc_timecode_frame += 2.0 * _samples_per_timecode_frame;
}
}
{
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;
+ }
+
+ vector<string> msp;
+ AudioEngine::instance()->get_midi_selection_ports (msp);
+
+ if (!msp.empty()) {
+
+ if (old_midi_target) {
+ old_midi_target->input()->disconnect (this);
+ }
+
+ for (vector<string>::const_iterator p = msp.begin(); p != msp.end(); ++p) {
+ /* disconnect the port from everything */
+ AudioEngine::instance()->disconnect (*p);
+ /* connect it to the new target */
+ new_midi_target->input()->connect (new_midi_target->input()->nth(0), (*p), this);
+ }
+ }
+
+ current_midi_target = new_midi_target;
+}
+
+void
+Session::rewire_midi_selection_ports ()
+{
+ if (!Config->get_midi_input_follows_selection()) {
+ return;
+ }
+
+ boost::shared_ptr<MidiTrack> target = current_midi_target.lock();
+
+ if (!target) {
+ return;
+ }
+
+ vector<string> msp;
+ AudioEngine::instance()->get_midi_selection_ports (msp);
+
+ if (msp.empty()) {
+ return;
+ }
+
+ target->input()->disconnect (this);
+
+ for (vector<string>::const_iterator p = msp.begin(); p != msp.end(); ++p) {
+ AudioEngine::instance()->disconnect (*p);
+ target->input()->connect (target->input()->nth (0), (*p), this);
+ }
+}