Don't drop frames when buffer crosses loop boundaries.

This commit is contained in:
Jonathan Moore Liles 2008-05-31 16:00:00 -05:00
parent e8ea8724ce
commit 801c1c484c
1 changed files with 14 additions and 9 deletions

View File

@ -118,19 +118,24 @@ Audio_Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channe
if ( _loop ) if ( _loop )
{ {
nframes_t lofs = sofs % _loop;
nframes_t lstart = r.offset + lofs;
/* /\* keep things simple *\/ */ if ( lofs + len > _loop )
/* assert( _loop > len ); */ {
/* this buffer covers a loop bounary */
nframes_t lstart = r.offset + ( sofs % _loop ); /* read the first part */
cnt = _clip->read( buf + ofs, channel, lstart, len - ( ( lofs + len ) - _loop ) );
/* read the second part */
cnt += _clip->read( buf + ofs + cnt, channel, lstart + cnt, len - cnt );
cnt = _clip->read( buf + ofs, channel, lstart, len ); /* TODO: declick/crossfade transition? */
/* /\* read the part before the loop point *\/ */
/* cnt = _clip->read( buf + ofs, channel, start, min( len, _loop - start ) ); */
/* /\* read the part after the loop point *\/ */
/* cnt += _clip->read( buf + ofs + cnt, channel, _loop, len - cnt ); */
assert( cnt == len );
}
else
cnt = _clip->read( buf + ofs, channel, lstart, len );
} }
else else
cnt = _clip->read( buf + ofs, channel, start, len ); cnt = _clip->read( buf + ofs, channel, start, len );