summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2020-04-27 15:02:22 -0600
committerPaul Davis <paul@linuxaudiosystems.com>2020-04-27 15:02:29 -0600
commitc56e99cd098d4bd59bc3db94e0a34d18090d93e8 (patch)
tree4dd039b6ad437cb48ed60730fb0cf28ba37cb3f5
parent1280360a65bedb6574d0cbbf7e349993db62a334 (diff)
nominal improvement for MTC master: use port latency to adjust sampletimes that MTC events "occured at"
-rw-r--r--libs/ardour/ardour/transport_master.h3
-rw-r--r--libs/ardour/mtc_slave.cc16
2 files changed, 19 insertions, 0 deletions
diff --git a/libs/ardour/ardour/transport_master.h b/libs/ardour/ardour/transport_master.h
index 5800e4d1c3..f4b5bd6978 100644
--- a/libs/ardour/ardour/transport_master.h
+++ b/libs/ardour/ardour/transport_master.h
@@ -501,6 +501,9 @@ class LIBARDOUR_API MTC_TransportMaster : public TimecodeTransportMaster, public
void init_mtc_dll(samplepos_t, double);
void parse_timecode_offset();
void parameter_changed(std::string const & p);
+
+ void resync_latency();
+ LatencyRange mtc_slave_latency;
};
class LIBARDOUR_API LTC_TransportMaster : public TimecodeTransportMaster {
diff --git a/libs/ardour/mtc_slave.cc b/libs/ardour/mtc_slave.cc
index b73742d7f9..848e972244 100644
--- a/libs/ardour/mtc_slave.cc
+++ b/libs/ardour/mtc_slave.cc
@@ -70,6 +70,10 @@ MTC_TransportMaster::MTC_TransportMaster (std::string const & name)
, printed_timecode_warning (false)
{
init ();
+
+ resync_latency();
+
+ AudioEngine::instance()->GraphReordered.connect_same_thread (port_connections, boost::bind (&MTC_TransportMaster::resync_latency, this));
}
MTC_TransportMaster::~MTC_TransportMaster()
@@ -89,6 +93,16 @@ MTC_TransportMaster::init ()
}
void
+MTC_TransportMaster::resync_latency()
+{
+ DEBUG_TRACE (DEBUG::MTC, "MTC resync_latency()\n");
+
+ if (_port) {
+ _port->get_connected_latency_range (mtc_slave_latency, false);
+ }
+}
+
+void
MTC_TransportMaster::create_port ()
{
if ((_port = create_midi_port (string_compose ("%1 in", _name))) == 0) {
@@ -129,6 +143,8 @@ MTC_TransportMaster::pre_process (MIDI::pframes_t nframes, samplepos_t now, boos
maybe_reset ();
+ now -= mtc_slave_latency.max;
+
_midi_port->read_and_parse_entire_midi_buffer_with_no_speed_adjustment (nframes, parser, now);
if (session_pos) {