diff options
| author | Carl Hetherington <cth@carlh.net> | 2022-01-23 22:21:29 +0100 |
|---|---|---|
| committer | Carl Hetherington <cth@carlh.net> | 2022-04-04 23:09:12 +0200 |
| commit | 0e164ad80f0ceff9d643f3b466690d013c3be19d (patch) | |
| tree | c656a136c12ff3c5d9bf8f7331610162de0c0592 /src/lib/maths_util.cc | |
| parent | 8eb951b71fa90e54c8da64e54cf5ddf6bf0809cf (diff) | |
Add fade in/out option to the content audio tab (#1026).
Diffstat (limited to 'src/lib/maths_util.cc')
| -rw-r--r-- | src/lib/maths_util.cc | 17 |
1 files changed, 17 insertions, 0 deletions
diff --git a/src/lib/maths_util.cc b/src/lib/maths_util.cc index 35e3879c4..76681afb6 100644 --- a/src/lib/maths_util.cc +++ b/src/lib/maths_util.cc @@ -19,6 +19,7 @@ */ +#include "maths_util.h" #include <cmath> @@ -35,3 +36,19 @@ linear_to_db (double linear) return 20 * log10(linear); } + +float +logarithmic_fade_in_curve (float t) +{ + auto const c = clamp(t, 0.0f, 1.0f); + return std::exp(2 * (c - 1)) * c; +} + + +float +logarithmic_fade_out_curve (float t) +{ + auto const c = clamp(t, 0.0f, 1.0f); + return std::exp(-2 * c) * (1 - c); +} + |
