diff options
author | Carl Hetherington <carl@carlh.net> | 2012-04-18 22:22:47 +0000 |
---|---|---|
committer | Carl Hetherington <carl@carlh.net> | 2012-04-18 22:22:47 +0000 |
commit | 2072261bb07aac3d84f2cb0959042f5289f200dc (patch) | |
tree | 3015e25fc51b534886cbde5205eb90b563345eeb /libs/ardour/audioregion.cc | |
parent | 95f5c3cc80bef3bcfc3d73a2e32e080b1d9b7fca (diff) |
Re-work fade operation to be closer to Mixbus; things
below the top region's fades are implicitly faded in
the opposite sense; restore short crossfades option.
git-svn-id: svn://localhost/ardour2/branches/3.0@12022 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/audioregion.cc')
-rw-r--r-- | libs/ardour/audioregion.cc | 20 |
1 files changed, 18 insertions, 2 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 617678d634..e4a7504ec1 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -385,6 +385,10 @@ AudioRegion::_read_at (const SourceList& srcs, framecnt_t limit, The caller has verified that we cover the desired section. */ + /* See doc/region_read.svg for a drawing which might help to explain + what is going on. + */ + assert (cnt >= 0); if (n_channels() == 0) { @@ -478,7 +482,7 @@ AudioRegion::_read_at (const SourceList& srcs, framecnt_t limit, /* READ DATA FROM THE SOURCE INTO mixdown_buffer. We can never read directly into buf, since it may contain data - from a transparent region `above' this one in the stack; we + from a transparent region `below' this one in the stack; we must always mix. */ @@ -532,6 +536,12 @@ AudioRegion::_read_at (const SourceList& srcs, framecnt_t limit, if (fade_in_limit != 0) { _fade_in->curve().get_vector (internal_offset, internal_offset + fade_in_limit, gain_buffer, fade_in_limit); + /* Fade the current data out */ + for (framecnt_t n = 0; n < fade_in_limit; ++n) { + buf[n] *= 1 - gain_buffer[n]; + } + + /* Mix our newly-read data in, with the fade */ for (framecnt_t n = 0; n < fade_in_limit; ++n) { buf[n] += mixdown_buffer[n] * gain_buffer[n]; } @@ -540,7 +550,13 @@ AudioRegion::_read_at (const SourceList& srcs, framecnt_t limit, if (fade_out_limit != 0) { framecnt_t const curve_offset = fade_interval_start - (limit - _fade_out->back()->when); _fade_out->curve().get_vector (curve_offset, curve_offset + fade_out_limit, gain_buffer, fade_out_limit); - + + /* Fade the current data in */ + for (framecnt_t n = 0, m = fade_out_offset; n < fade_out_limit; ++n, ++m) { + buf[m] *= 1 - gain_buffer[n]; + } + + /* Mix our newly-read data in, with the fade */ for (framecnt_t n = 0, m = fade_out_offset; n < fade_out_limit; ++n, ++m) { buf[m] += mixdown_buffer[m] * gain_buffer[n]; } |