From 98a3a96d409a3201107ad7aab2c67cb070c1e9cc Mon Sep 17 00:00:00 2001 From: Paul Davis Date: Tue, 12 May 2020 10:07:24 -0600 Subject: [PATCH] use more standard mechanism for "squishing" start of audio read into loop range --- libs/ardour/disk_reader.cc | 12 +++--------- 1 file changed, 3 insertions(+), 9 deletions(-) diff --git a/libs/ardour/disk_reader.cc b/libs/ardour/disk_reader.cc index 29e53df87a..a911870ebf 100644 --- a/libs/ardour/disk_reader.cc +++ b/libs/ardour/disk_reader.cc @@ -972,7 +972,6 @@ DiskReader::audio_read (Sample* sum_buffer, /* XXX we don't currently play loops in reverse. not sure why */ if (!reversed) { - samplecnt_t loop_length = 0; /* Make the use of a Location atomic for this read operation. @@ -985,15 +984,10 @@ DiskReader::audio_read (Sample* sum_buffer, if ((loc = _loop_location) != 0) { loop_start = loc->start (); loop_end = loc->end (); - loop_length = loop_end - loop_start; - } - /* if we are looping, ensure that the first sample we read is at the - * correct position within the loop. - */ - - if (loc && start >= loop_end) { - start = loop_start + ((start - loop_start) % loop_length); + /* Evoral::Range has inclusive range semantics. Ugh. Hence the -1 */ + const Evoral::Range loop_range (loop_start, loop_end - 1); + start = loop_range.squish (start); } }