From 8139becb1898187729b0ea57f145302d4975bf3a Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Thu, 28 Sep 2017 06:31:12 +0200 Subject: Ongoing work on latency compensation The general goal is to align transport-sample to be the audible frame and use that as "anchor" for all processing. transport_sample cannot become negative (00:00:00:00 is the first audible frame). Internally transport pre-rolls (read-ahead) before the transport starts to move. This allows inputs and disk to prefill the pipeline. When starting to roll, the session counts down a global "remaning preroll" counter, which is the worst-latency from in-to-out. Each route in turn will start processing at its own output-latency. Route::process_output_buffers() - which does the actual processing incl disk i/o - begins by offsetting the "current sample" by the route's process-latency and decrements the offset for each latent processor. At the end of the function the output will be aligned and match transport-sample - downstream-playback-latency (if any). PS. This commit is a first step only: transport looping & vari-speed have not yet been implemented/updated. --- libs/ardour/disk_reader.cc | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'libs/ardour/disk_reader.cc') diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index a9f403d40b..624a9ac17d 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -253,11 +253,17 @@ DiskReader::run (BufferSet& bufs, samplepos_t start_sample, samplepos_t end_samp } } - if (speed == 0.0 && (ms == MonitoringDisk)) { - /* stopped. Don't accidentally pass any data from disk - * into our outputs (e.g. via interpolation) - */ - bufs.silence (nframes, 0); + if (speed == 0.0) { + /* stopped. Don't accidentally pass any data from disk + * into our outputs (e.g. via interpolation) + * nor jump ahead playback_sample when not rolling + */ + if (ms == MonitoringDisk) { + /* when monitoring disk, clear input data so far, + * everything before the disk processor is not relevant. + */ + bufs.silence (nframes, 0); + } return; } @@ -625,6 +631,8 @@ DiskReader::seek (samplepos_t sample, bool complete_refill) ChannelList::iterator chan; boost::shared_ptr c = channels.reader(); + //sample = std::max ((samplecnt_t)0, sample -_session.worst_output_latency ()); + for (n = 0, chan = c->begin(); chan != c->end(); ++chan, ++n) { (*chan)->buf->reset (); } -- cgit v1.2.3