diff options
author | Robin Gareus <robin@gareus.org> | 2014-05-29 21:03:46 +0200 |
---|---|---|
committer | Robin Gareus <robin@gareus.org> | 2014-05-29 22:41:13 +0200 |
commit | 1cfdad6ffbde0bc937ce352a212614dd7b9d5d61 (patch) | |
tree | 3564ec47dc3eeea64cef3323a5106dbed0442c09 /libs/ardour/audioregion.cc | |
parent | be575b7945eace2755960fe85145e445f9a9cf6c (diff) |
fixed number of steps for symmetric fades:
Extra steps are all below -20dB vs inverse signal being over -2dB.
linear interpolation -6dB steps is sufficient for the tail.
Diffstat (limited to 'libs/ardour/audioregion.cc')
-rw-r--r-- | libs/ardour/audioregion.cc | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/libs/ardour/audioregion.cc b/libs/ardour/audioregion.cc index 97e63b5e8c..f76b80dbb6 100644 --- a/libs/ardour/audioregion.cc +++ b/libs/ardour/audioregion.cc @@ -1032,11 +1032,9 @@ AudioRegion::set_fade_in (FadeShape shape, framecnt_t len) _fade_in->fast_simple_add (0.5 * len, 0.6); //now generate a fade-out curve by successively applying a gain drop const double breakpoint = 0.7; //linear for first 70% - for (int i = max(2, (int)ceil(num_steps / 9.0)); i < num_steps; i++) { - const double offset = 1.0 - breakpoint; - float coeff = 1.0 - breakpoint; - coeff *= powf(0.5, i * 9.0 / (double)num_steps); // -6dB per step for 7 steps - _fade_in->fast_simple_add (len * (breakpoint + (offset * (double)i / (double)num_steps)), coeff); + for (int i = 2; i < 9; ++i) { + const float coeff = (1.f - breakpoint) * powf (0.5, i); + _fade_in->fast_simple_add (len * (breakpoint + ((1.0 - breakpoint) * (double)i / 9.0)), coeff); } _fade_in->fast_simple_add (len, VERY_SMALL_SIGNAL); reverse_curve (c3, _fade_in.val()); @@ -1108,14 +1106,11 @@ AudioRegion::set_fade_out (FadeShape shape, framecnt_t len) //start with a nearly linear cuve _fade_out->fast_simple_add (0, 1); _fade_out->fast_simple_add (0.5 * len, 0.6); - //now generate a fade-out curve by successively applying a gain drop const double breakpoint = 0.7; //linear for first 70% - for (int i = max(2, (int)ceil(num_steps / 9.0)); i < num_steps; i++) { - const double offset = 1.0 - breakpoint; - float coeff = 1.0 - breakpoint; - coeff *= powf(0.5, i * 9.0 / (double)num_steps); // -6dB per step for 7 steps - _fade_out->fast_simple_add (len * (breakpoint + (offset * (double)i / (double)num_steps)), coeff); + for (int i = 2; i < 9; ++i) { + const float coeff = (1.f - breakpoint) * powf (0.5, i); + _fade_out->fast_simple_add (len * (breakpoint + ((1.0 - breakpoint) * (double)i / 9.0)), coeff); } _fade_out->fast_simple_add (len, VERY_SMALL_SIGNAL); reverse_curve (_inverse_fade_out.val(), _fade_out.val()); |