summaryrefslogtreecommitdiff
path: root/libs/ardour/utils.cc
diff options
context:
space:
mode:
authorPaul Davis <paul@linuxaudiosystems.com>2006-08-31 13:23:43 +0000
committerPaul Davis <paul@linuxaudiosystems.com>2006-08-31 13:23:43 +0000
commit21d85f1854461ab6209d23e278fe289505cd106c (patch)
tree0c6d154757bcfb6c49223e59fc75a433e8e79bb2 /libs/ardour/utils.cc
parentdde980289aaf264863186eead99fd98a67cc6862 (diff)
merge changes from harrison branch back into trunk, by hand
git-svn-id: svn://localhost/ardour2/trunk@878 d708f5d6-7413-0410-9779-e7cbd77b26cf
Diffstat (limited to 'libs/ardour/utils.cc')
-rw-r--r--libs/ardour/utils.cc27
1 files changed, 27 insertions, 0 deletions
diff --git a/libs/ardour/utils.cc b/libs/ardour/utils.cc
index 78e5572a3d..5f676964d2 100644
--- a/libs/ardour/utils.cc
+++ b/libs/ardour/utils.cc
@@ -271,3 +271,30 @@ CFStringRefToStdString(CFStringRef stringRef)
return result;
}
#endif // HAVE_COREAUDIO
+
+void
+compute_equal_power_fades (jack_nframes_t nframes, float* in, float* out)
+{
+ double step;
+
+ step = 1.0/nframes;
+
+ in[0] = 0.0f;
+
+ for (int i = 1; i < nframes - 1; ++i) {
+ in[i] = in[i-1] + step;
+ }
+
+ in[nframes-1] = 1.0;
+
+ const float pan_law_attenuation = -3.0f;
+ const float scale = 2.0f - 4.0f * powf (10.0f,pan_law_attenuation/20.0f);
+
+ for (unsigned long n = 0; n < nframes; ++n) {
+ float inVal = in[n];
+ float outVal = 1 - inVal;
+ out[n] = outVal * (scale * outVal + 1.0f - scale);
+ in[n] = inVal * (scale * inVal + 1.0f - scale);
+ }
+}
+