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/panning.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/panning.c')
-rw-r--r-- | Alc/panning.c | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/Alc/panning.c b/Alc/panning.c index 72b55792..7b551100 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -202,6 +202,14 @@ void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat CalcDirectionCoeffs(dir, spread, coeffs); } +void CalcAnglePairwiseCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]) +{ + ALfloat sign = (azimuth < 0.0f) ? -1.0f : 1.0f; + if(!(fabsf(azimuth) > F_PI_2)) + azimuth = minf(fabsf(azimuth) * F_PI_2 / (F_PI/6.0f), F_PI_2) * sign; + CalcAngleCoeffs(azimuth, elevation, spread, coeffs); +} + void ComputeAmbientGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]) { @@ -237,7 +245,7 @@ void ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, AL float gain = 0.0f; for(j = 0;j < numcoeffs;j++) gain += chancoeffs[i][j]*coeffs[j]; - gains[i] = gain * ingain; + gains[i] = clampf(gain, 0.0f, 1.0f) * ingain; } for(;i < MAX_OUTPUT_CHANNELS;i++) gains[i] = 0.0f; @@ -262,7 +270,7 @@ void ComputeFirstOrderGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, float gain = 0.0f; for(j = 0;j < 4;j++) gain += chancoeffs[i][j] * mtx[j]; - gains[i] = gain * ingain; + gains[i] = clampf(gain, 0.0f, 1.0f) * ingain; } for(;i < MAX_OUTPUT_CHANNELS;i++) gains[i] = 0.0f; @@ -454,8 +462,8 @@ static bool MakeSpeakerMap(ALCdevice *device, const AmbDecConf *conf, ALsizei sp static const ChannelMap MonoCfg[1] = { { FrontCenter, { 1.0f } }, }, StereoCfg[2] = { - { FrontLeft, { 5.00000000e-1f, 2.88675135e-1f, 0.0f, 0.00000000e+0f } }, - { FrontRight, { 5.00000000e-1f, -2.88675135e-1f, 0.0f, 0.00000000e+0f } }, + { FrontLeft, { 5.00000000e-1f, 2.88675135e-1f, 0.0f, 1.19573156e-1f } }, + { FrontRight, { 5.00000000e-1f, -2.88675135e-1f, 0.0f, 1.19573156e-1f } }, }, QuadCfg[4] = { { BackLeft, { 3.53553391e-1f, 2.04124145e-1f, 0.0f, -2.04124145e-1f } }, { FrontLeft, { 3.53553391e-1f, 2.04124145e-1f, 0.0f, 2.04124145e-1f } }, |