summaryrefslogtreecommitdiff
path: root/libs/ardour/audioengine.cc
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2017-10-29 18:30:18 +0100
committerRobin Gareus <robin@gareus.org>2017-10-29 20:04:00 +0100
commit927788a0b0bf6a621e7cee60365f4e8cbd67d829 (patch)
tree43ebe89319b4b9416391f2f195dbc4f8effad161 /libs/ardour/audioengine.cc
parent7fb3c3e137d7a96998f21a4ec275339b4bc08c1a (diff)
Move vari-speed into backend (resample ports)
Previously Ardour used a /local/ per track vari-speed mechanism. Now that the disk-reader is a latency-compensated processor, the speed of each disk-reader would need to be maintained locally, offset by each disk-reader's output latency. Furthermore each disk-reader may produce a different number of samples, depending on its global alignment. This commit introduces port-data resampling directly at the engine-level: Up/down-sample all input ports at the beginning, and down/up-sample output port-data using the inverse ratio at the end of the session's process cycle. The session itself is unaware of the speed-change, and only needs to handle transport speeds {-1, 0, +1}. This also allows for aligned cue-monitoring and vari-speed recording, and also pitch-shifts synthesized MIDI along.
Diffstat (limited to 'libs/ardour/audioengine.cc')
-rw-r--r--libs/ardour/audioengine.cc23
1 files changed, 22 insertions, 1 deletions
diff --git a/libs/ardour/audioengine.cc b/libs/ardour/audioengine.cc
index 03c13e38fd..da512cc51d 100644
--- a/libs/ardour/audioengine.cc
+++ b/libs/ardour/audioengine.cc
@@ -190,6 +190,7 @@ int
AudioEngine::process_callback (pframes_t nframes)
{
Glib::Threads::Mutex::Lock tm (_process_lock, Glib::Threads::TRY_LOCK);
+ Port::set_speed_ratio (1.0);
PT_TIMING_REF;
PT_TIMING_CHECK (1);
@@ -357,6 +358,14 @@ AudioEngine::process_callback (pframes_t nframes)
return 0;
}
+ if (!_freewheeling || Freewheel.empty()) {
+ // run a list of slaves here
+ // - multiple slaves (ow_many_dsp_threads() in paralell)
+ // - session can pick one (ask for position & speed)
+ // - GUI can display all
+ Port::set_speed_ratio (_session->engine_speed ());
+ }
+
/* tell all relevant objects that we're starting a new cycle */
InternalSend::CycleStart (nframes);
@@ -373,7 +382,19 @@ AudioEngine::process_callback (pframes_t nframes)
if (_freewheeling && !Freewheel.empty()) {
Freewheel (nframes);
} else {
- _session->process (nframes);
+ if (Port::cycle_nframes () <= nframes) {
+ _session->process (Port::cycle_nframes ());
+ } else {
+ pframes_t remain = Port::cycle_nframes ();
+ while (remain > 0) {
+ pframes_t nf = std::min (remain, nframes);
+ _session->process (nf);
+ remain -= nf;
+ if (remain > 0) {
+ split_cycle (nf);
+ }
+ }
+ }
}
if (_freewheeling) {