X-Git-Url: https://main.carlh.net/gitweb/?a=blobdiff_plain;f=libs%2Fardour%2Fprocessor.cc;h=39c3d68ad7941d8ac35a852e057cd2f0486521f6;hb=0eaf7b1e18ba0f6e9ce600f0a99c0fd218b44d81;hp=19b6f303672abc013dd7ac728b09642a486bd54e;hpb=00a4ad712c2d5ac73f04b0f43906590b24a22fb6;p=ardour.git diff --git a/libs/ardour/processor.cc b/libs/ardour/processor.cc index 19b6f30367..39c3d68ad7 100644 --- a/libs/ardour/processor.cc +++ b/libs/ardour/processor.cc @@ -275,6 +275,34 @@ Processor::configure_io (ChanCount in, ChanCount out) return true; } +bool +Processor::map_loop_range (samplepos_t& start, samplepos_t& end) const +{ + if (!_loop_location) { + return false; + } + if (start >= end) { + /* no backwards looping */ + return false; + } + + const samplepos_t loop_end = _loop_location->end (); + if (start < loop_end) { + return false; + } + + const samplepos_t loop_start = _loop_location->start (); + const samplecnt_t looplen = loop_end - loop_start; + const sampleoffset_t start_off = (start - loop_start) % looplen; + const samplepos_t start_pos = loop_start + start_off; + + assert (start >= start_pos); + end -= start - start_pos; + start = start_pos; + assert (end > start); + return true; +} + void Processor::set_display_to_user (bool yn) {