Fix (I think) a math error in fade out application.

This commit is contained in:
Jonathan Moore Liles 2008-04-21 14:16:12 -05:00
parent b0dc6b0dc8
commit c4532c70d7
1 changed files with 8 additions and 2 deletions

View File

@ -700,7 +700,7 @@ Region::normalize ( void )
/**********/ /**********/
/** Apply a (portion of) fade-out from /start/ to /end/ assuming a /** Apply a (portion of) fade from /start/ to /end/ assuming a
* buffer size of /nframes/. /start/ and /end/ are relative to the * buffer size of /nframes/. /start/ and /end/ are relative to the
* given buffer, and /start/ may be negative. */ * given buffer, and /start/ may be negative. */
void void
@ -708,9 +708,14 @@ Region::Fade::apply ( sample_t *buf, Region::Fade::fade_dir_e dir, long start, n
{ {
// printf( "apply fade %s: start=%ld end=%lu\n", dir == Fade::Out ? "out" : "in", start, end ); // printf( "apply fade %s: start=%ld end=%lu\n", dir == Fade::Out ? "out" : "in", start, end );
if ( ! nframes )
return;
const nframes_t i = start > 0 ? start : 0; const nframes_t i = start > 0 ? start : 0;
const nframes_t e = end > nframes ? nframes : end; const nframes_t e = end > nframes ? nframes : end;
assert( i < nframes );
const float inc = increment(); const float inc = increment();
float fi = ( i - start ) / (float)length; float fi = ( i - start ) / (float)length;
@ -902,7 +907,8 @@ Region::read ( sample_t *buf, nframes_t pos, nframes_t nframes, int channel ) co
fade = declick < _fade_out ? _fade_out : declick; fade = declick < _fade_out ? _fade_out : declick;
/* do fade out if necessary */ /* do fade out if necessary */
if ( start + cnt + fade.length > r.end ) // if ( start + cnt + fade.length > r.end )
if ( start + fade.length > r.end )
{ {
const nframes_t d = r.end - start; const nframes_t d = r.end - start;