Timeline: declick loop boundaries.
This commit is contained in:
parent
ee2d86a012
commit
be3c9c6412
|
@ -115,14 +115,21 @@ Audio_Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channe
|
||||||
|
|
||||||
// printf( "reading region ofs = %lu, sofs = %lu, %lu-%lu\n", ofs, sofs, start, end );
|
// printf( "reading region ofs = %lu, sofs = %lu, %lu-%lu\n", ofs, sofs, start, end );
|
||||||
|
|
||||||
|
/* FIXME: keep the declick defults someplace else */
|
||||||
|
Fade declick;
|
||||||
|
|
||||||
|
declick.length = 256;
|
||||||
|
declick.type = Fade::Sigmoid;
|
||||||
|
|
||||||
if ( _loop )
|
if ( _loop )
|
||||||
{
|
{
|
||||||
nframes_t lofs = sofs % _loop;
|
nframes_t lofs = sofs % _loop;
|
||||||
nframes_t lstart = r.offset + lofs;
|
nframes_t lstart = r.offset + lofs;
|
||||||
|
|
||||||
|
|
||||||
if ( lofs + len > _loop )
|
if ( lofs + len > _loop )
|
||||||
{
|
{
|
||||||
/* this buffer covers a loop bounary */
|
/* this buffer covers a loop binary */
|
||||||
|
|
||||||
/* read the first part */
|
/* read the first part */
|
||||||
cnt = _clip->read( buf + ofs, channel, lstart, len - ( ( lofs + len ) - _loop ) );
|
cnt = _clip->read( buf + ofs, channel, lstart, len - ( ( lofs + len ) - _loop ) );
|
||||||
|
@ -135,6 +142,47 @@ Audio_Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channe
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cnt = _clip->read( buf + ofs, channel, lstart, len );
|
cnt = _clip->read( buf + ofs, channel, lstart, len );
|
||||||
|
|
||||||
|
/* this buffer is inside declicking proximity to the loop boundary */
|
||||||
|
|
||||||
|
if ( lofs + cnt + declick.length > _loop /* buffer ends within declick length of the end of loop */
|
||||||
|
&&
|
||||||
|
sofs + declick.length < r.length /* not the last loop */
|
||||||
|
)
|
||||||
|
{
|
||||||
|
/* */
|
||||||
|
/* fixme: what if loop is shorter than declick? */
|
||||||
|
const nframes_t declick_start = _loop - declick.length;
|
||||||
|
|
||||||
|
/* when the buffer covers the beginning of the
|
||||||
|
* declick, how many frames between the beginning of
|
||||||
|
* the buffer and the beginning of the declick */
|
||||||
|
const nframes_t declick_onset_offset = declick_start > lofs ? declick_start - lofs : 0;
|
||||||
|
|
||||||
|
/* how far into the declick we are */
|
||||||
|
const nframes_t declick_offset = lofs > declick_start ? lofs - declick_start : 0;
|
||||||
|
|
||||||
|
/* this is the end side of the loop boundary */
|
||||||
|
|
||||||
|
const nframes_t fl = cnt - declick_onset_offset;
|
||||||
|
|
||||||
|
declick.apply( buf + ofs + declick_onset_offset,
|
||||||
|
Fade::Out,
|
||||||
|
declick_offset, fl );
|
||||||
|
}
|
||||||
|
|
||||||
|
if ( lofs < declick.length /* buffer begins within declick length of beginning of loop */
|
||||||
|
&&
|
||||||
|
sofs > _loop ) /* not the first loop */
|
||||||
|
{
|
||||||
|
|
||||||
|
const nframes_t declick_end = declick.length;
|
||||||
|
|
||||||
|
const nframes_t click_len = lofs + cnt > declick_end ? declick_end - lofs : cnt;
|
||||||
|
|
||||||
|
/* this is the beginning of the loop next boundary */
|
||||||
|
declick.apply( buf + ofs, Fade::In, lofs, click_len );
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
cnt = _clip->read( buf + ofs, channel, start, len );
|
cnt = _clip->read( buf + ofs, channel, start, len );
|
||||||
|
@ -148,11 +196,6 @@ Audio_Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channe
|
||||||
|
|
||||||
/* perform declicking if necessary */
|
/* perform declicking if necessary */
|
||||||
|
|
||||||
/* FIXME: keep the declick defults someplace else */
|
|
||||||
Fade declick;
|
|
||||||
|
|
||||||
declick.length = 256;
|
|
||||||
declick.type = Fade::Linear;
|
|
||||||
|
|
||||||
{
|
{
|
||||||
assert( cnt <= nframes );
|
assert( cnt <= nframes );
|
||||||
|
|
Loading…
Reference in New Issue