Add fade in/out option to the content audio tab (#1026).
[dcpomatic.git] / src / lib / maths_util.cc
index 35e3879c4aedd939d7fc784f520ac1eb6f6c2e56..76681afb63e81a11a7382382609d8a8f74add182 100644 (file)
@@ -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);
+}
+