From c8f94053866c3c0f1e796ca2e7fad36266534640 Mon Sep 17 00:00:00 2001 From: Robin Gareus Date: Wed, 15 Jan 2014 14:07:02 +0100 Subject: stereo-panner: clamp width during processing to valid range --- libs/panners/2in2out/panner_2in2out.cc | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'libs/panners') 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 -- cgit v1.2.3