From d9caa7fd9a55e5b21a35971f17e26d8c26838a6b Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 7 May 2020 17:22:40 +0200 Subject: [PATCH] Prepare timecode-generator direct-out Generator ports (like TransportMaster slaves), should not be re-sampled when vari-speeding. Instead the Timecode/Clock should directly use the engine-speed. For this to happen, they need to be special-cased: no re-sampler latency, direct access to engine-buffers. --- libs/ardour/ardour/types.h | 5 ++++- libs/ardour/audio_port.cc | 2 +- libs/ardour/port.cc | 6 +++--- libs/ardour/port_manager.cc | 14 +++++++------- 4 files changed, 15 insertions(+), 12 deletions(-) diff --git a/libs/ardour/ardour/types.h b/libs/ardour/ardour/types.h index 12a0ee51e3..31ecba195e 100644 --- a/libs/ardour/ardour/types.h +++ b/libs/ardour/ardour/types.h @@ -735,7 +735,10 @@ enum PortFlags { /* non-JACK related flags */ Hidden = 0x20, Shadow = 0x40, - TransportMasterPort = 0x80 + + TransportMasterPort = 0x80, // incoming data, used by slaves + TransportGenerator = 0x100, // outgoing, timecode/clock generators + TransportSyncPort = 0x180 // = TransportMasterPort | TransportGenerator }; enum MidiPortFlags { diff --git a/libs/ardour/audio_port.cc b/libs/ardour/audio_port.cc index 6d0a90a187..ddbb2238df 100644 --- a/libs/ardour/audio_port.cc +++ b/libs/ardour/audio_port.cc @@ -136,7 +136,7 @@ AudioPort::get_audio_buffer (pframes_t nframes) Sample* addr; - if (!externally_connected ()) { + if (!externally_connected () || 0 != (flags() & TransportSyncPort)) { addr = (Sample *) port_engine.get_buffer (_port_handle, nframes); } else { /* _data was read and resampled as necessary in ::cycle_start */ diff --git a/libs/ardour/port.cc b/libs/ardour/port.cc index d3d5670552..f2fba52116 100644 --- a/libs/ardour/port.cc +++ b/libs/ardour/port.cc @@ -370,7 +370,7 @@ Port::set_public_latency_range (LatencyRange const& range, bool playback) const if (_port_handle) { LatencyRange r (range); - if (externally_connected () && 0 == (_flags & TransportMasterPort)) { + if (externally_connected () && 0 == (_flags & TransportSyncPort)) { #if 0 r.min *= _speed_ratio; r.max *= _speed_ratio; @@ -436,7 +436,7 @@ Port::public_latency_range (bool /*playback*/) const if (_port_handle) { r = port_engine.get_latency_range (_port_handle, sends_output() ? true : false); - if (externally_connected () && 0 == (_flags & TransportMasterPort)) { + if (externally_connected () && 0 == (_flags & TransportSyncPort)) { #if 0 r.min /= _speed_ratio; r.max /= _speed_ratio; @@ -485,7 +485,7 @@ Port::get_connected_latency_range (LatencyRange& range, bool playback) const if (remote_port) { lr = port_engine.get_latency_range (remote_port, playback); - if (externally_connected () && 0 == (_flags & TransportMasterPort)) { + if (externally_connected () && 0 == (_flags & TransportSyncPort)) { #if 0 lr.min /= _speed_ratio; lr.max /= _speed_ratio; diff --git a/libs/ardour/port_manager.cc b/libs/ardour/port_manager.cc index 24148e6a77..3807b868fa 100644 --- a/libs/ardour/port_manager.cc +++ b/libs/ardour/port_manager.cc @@ -395,7 +395,7 @@ PortManager::register_port (DataType dtype, const string& portname, bool input, /* limit the possible flags that can be set */ - flags = PortFlags (flags & (Hidden|Shadow|IsTerminal|TransportMasterPort)); + flags = PortFlags (flags & (Hidden|Shadow|IsTerminal|TransportSyncPort)); try { if (dtype == DataType::AUDIO) { @@ -809,14 +809,14 @@ PortManager::cycle_start (pframes_t nframes, Session* s) if (s && s->rt_tasklist () && fabs (Port::speed_ratio ()) != 1.0) { RTTaskList::TaskList tl; for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { tl.push_back (boost::bind (&Port::cycle_start, p->second, nframes)); } } s->rt_tasklist()->process (tl); } else { for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { p->second->cycle_start (nframes); } } @@ -830,14 +830,14 @@ PortManager::cycle_end (pframes_t nframes, Session* s) if (0 && s && s->rt_tasklist () && fabs (Port::speed_ratio ()) != 1.0) { RTTaskList::TaskList tl; for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { tl.push_back (boost::bind (&Port::cycle_end, p->second, nframes)); } } s->rt_tasklist()->process (tl); } else { for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { p->second->cycle_end (nframes); } } @@ -939,14 +939,14 @@ PortManager::cycle_end_fade_out (gain_t base_gain, gain_t gain_step, pframes_t n if (0 && s && s->rt_tasklist () && fabs (Port::speed_ratio ()) != 1.0) { RTTaskList::TaskList tl; for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { tl.push_back (boost::bind (&Port::cycle_end, p->second, nframes)); } } s->rt_tasklist()->process (tl); } else { for (Ports::iterator p = _cycle_ports->begin(); p != _cycle_ports->end(); ++p) { - if (!(p->second->flags() & TransportMasterPort)) { + if (!(p->second->flags() & TransportSyncPort)) { p->second->cycle_end (nframes); } }