From 6d2521312e609af08744622e13c9df2d9a8331b2 Mon Sep 17 00:00:00 2001 From: Jonathan Moore Liles Date: Sun, 27 Apr 2008 00:21:19 -0500 Subject: [PATCH] Fix math error in fade application. --- Timeline/Region.C | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/Timeline/Region.C b/Timeline/Region.C index 825af4c..457df31 100644 --- a/Timeline/Region.C +++ b/Timeline/Region.C @@ -900,7 +900,7 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co /* apply gain */ - buffer_apply_gain( buf, cnt, _scale ); + buffer_apply_gain( buf + ofs, cnt, _scale ); /* perform declicking if necessary */ @@ -920,7 +920,9 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co { const long d = 0 - sofs; - fade.apply( buf + ofs, Fade::In, d, d + fade.length, cnt - ofs ); + assert( cnt <= nframes ); + + fade.apply( buf + ofs, Fade::In, d, d + fade.length, cnt ); } fade = declick < _fade_out ? _fade_out : declick; @@ -931,6 +933,8 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co { const nframes_t d = r.end - start; + assert( cnt <= nframes ); + fade.apply( buf, Fade::Out, cnt + (long)d - fade.length, cnt + d, cnt ); } }