diff options
author | Chris Robinson <chris.kcat@gmail.com> | 2017-02-23 00:23:16 -0800 |
---|---|---|
committer | Chris Robinson <chris.kcat@gmail.com> | 2017-02-23 01:32:44 -0800 |
commit | 08948079e93cbb7321be5715df36f54c5e6be3b7 (patch) | |
tree | 5901fce0305094cc843698671c2689208e2f8df5 /Alc/ALu.c | |
parent | 0ce4c9b8fa90df6111fb81debf583b0fc9200063 (diff) |
Alter how panpot/pair-wise panning works
This change allows pair-wise panning to mostly go through the normal ambisonic
panning methods, with one special-case. First, a term is added to the stereo
decoder matrix's X coefficient so that a centered sound is reduced by -3dB on
each output channel. Panning in front creates a similar gain response to the
typical
L = sqrt(1-pan)
R = sqrt(pan)
for pan = [0,1]. Panning behind the listener can reduce (up to) an additional
-10dB, creating a audible difference between front and back sounds as if
simulating head obstruction.
Secondly, as a special-case, the source positions are warped when calculating
the ambisonic coefficients so that full left panning is reached at -30 degrees
and full right at +30 degrees. This is to retain the expected 60-degree stereo
width. This warping does not apply to B-Format buffer input, although it
otherwise has the same gain responses.
Diffstat (limited to 'Alc/ALu.c')
-rw-r--r-- | Alc/ALu.c | 38 |
1 files changed, 10 insertions, 28 deletions
@@ -679,23 +679,12 @@ static void CalcNonAttnSourceParams(ALvoice *voice, const struct ALsourceProps * } if(Device->Render_Mode == StereoPair) - { - /* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */ - ALfloat x = sinf(chans[c].angle) * cosf(chans[c].elevation); - coeffs[0] = clampf(-x, -0.5f, 0.5f) + 0.5f; - voice->Direct.Params[c].Gains.Target[0] = sqrtf(coeffs[0]) * DryGain; - voice->Direct.Params[c].Gains.Target[1] = sqrtf(1.0f-coeffs[0]) * DryGain; - for(j = 2;j < MAX_OUTPUT_CHANNELS;j++) - voice->Direct.Params[c].Gains.Target[j] = 0.0f; - - CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs); - } + CalcAnglePairwiseCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs); else - { CalcAngleCoeffs(chans[c].angle, chans[c].elevation, 0.0f, coeffs); - ComputePanningGains(Device->Dry, coeffs, DryGain, - voice->Direct.Params[c].Gains.Target); - } + ComputePanningGains(Device->Dry, + coeffs, DryGain, voice->Direct.Params[c].Gains.Target + ); for(i = 0;i < NumSends;i++) { @@ -1173,22 +1162,15 @@ static void CalcAttnSourceParams(ALvoice *voice, const struct ALsourceProps *pro if(Device->Render_Mode == StereoPair) { - /* Clamp X so it remains within 30 degrees of 0 or 180 degree azimuth. */ - ALfloat x = -dir[0] * (0.5f * (cosf(spread*0.5f) + 1.0f)); - x = clampf(x, -0.5f, 0.5f) + 0.5f; - voice->Direct.Params[0].Gains.Target[0] = sqrtf(x) * DryGain; - voice->Direct.Params[0].Gains.Target[1] = sqrtf(1.0f-x) * DryGain; - for(i = 2;i < MAX_OUTPUT_CHANNELS;i++) - voice->Direct.Params[0].Gains.Target[i] = 0.0f; - - CalcDirectionCoeffs(dir, spread, coeffs); + ALfloat ev = asinf(clampf(dir[1], -1.0f, 1.0f)); + ALfloat az = atan2f(dir[0], -dir[2]); + CalcAnglePairwiseCoeffs(az, ev, radius, coeffs); } else - { CalcDirectionCoeffs(dir, spread, coeffs); - ComputePanningGains(Device->Dry, coeffs, DryGain, - voice->Direct.Params[0].Gains.Target); - } + ComputePanningGains(Device->Dry, + coeffs, DryGain, voice->Direct.Params[0].Gains.Target + ); for(i = 0;i < NumSends;i++) { |