summaryrefslogtreecommitdiff
path: root/libs/panners
diff options
context:
space:
mode:
authorRobin Gareus <robin@gareus.org>2014-01-15 14:07:02 +0100
committerRobin Gareus <robin@gareus.org>2014-01-15 14:07:02 +0100
commitc8f94053866c3c0f1e796ca2e7fad36266534640 (patch)
tree10922140b93bbe42638bea98e5fce3154e7cc3c0 /libs/panners
parentab838a126046c09017ec09a1971472f6be81bd51 (diff)
stereo-panner: clamp width during processing to valid range
Diffstat (limited to 'libs/panners')
-rw-r--r--libs/panners/2in2out/panner_2in2out.cc7
1 files changed, 7 insertions, 0 deletions
diff --git a/libs/panners/2in2out/panner_2in2out.cc b/libs/panners/2in2out/panner_2in2out.cc
index 860610ecfc..25ea1c401a 100644
--- a/libs/panners/2in2out/panner_2in2out.cc
+++ b/libs/panners/2in2out/panner_2in2out.cc
@@ -165,6 +165,11 @@ Panner2in2out::update ()
double width = this->width ();
const double direction_as_lr_fract = position ();
+ double const wrange = min (position(), (1 - position())) * 2;
+ if (fabs(width) > wrange) {
+ width = (width > 0 ? wrange : -wrange);
+ }
+
if (width < 0.0) {
width = -width;
pos[0] = direction_as_lr_fract + (width/2.0); // left signal lr_fract
@@ -428,6 +433,8 @@ Panner2in2out::distribute_one_automated (AudioBuffer& srcbuf, BufferSet& obufs,
panR = position[n] + (width[n]/2.0f); // center - width/2
}
+ panR = max(0.f, min(1.f, panR));
+
const float panL = 1 - panR;
/* note that are overwriting buffers, but its OK