aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--Alc/ALu.c27
-rw-r--r--Alc/panning.c9
-rw-r--r--OpenAL32/Include/alu.h16
3 files changed, 25 insertions, 27 deletions
diff --git a/Alc/ALu.c b/Alc/ALu.c
index dc24755d..d033c0c4 100644
--- a/Alc/ALu.c
+++ b/Alc/ALu.c
@@ -648,10 +648,12 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo
voice->Flags |= VOICE_HAS_NFC;
}
- if(Device->Render_Mode == StereoPair)
- CalcAnglePairwiseCoeffs(Azi, Elev, Spread, coeffs);
- else
- CalcAngleCoeffs(Azi, Elev, Spread, coeffs);
+ /* A scalar of 3 for plain stereo results in +/-30 degrees being
+ * moved to +/-90 degrees for direct right and left speaker
+ * responses.
+ */
+ CalcAngleCoeffs((Device->Render_Mode==StereoPair) ? ScaleAzimuthFront(Azi, 3.0f) : Azi,
+ Elev, Spread, coeffs);
/* NOTE: W needs to be scaled by sqrt(2) due to FuMa normalization. */
ComputeDryPanGains(&Device->Dry, coeffs, DryGain*1.414213562f,
@@ -895,10 +897,8 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo
/* Calculate the directional coefficients once, which apply to all
* input channels.
*/
- if(Device->Render_Mode == StereoPair)
- CalcAnglePairwiseCoeffs(Azi, Elev, Spread, coeffs);
- else
- CalcAngleCoeffs(Azi, Elev, Spread, coeffs);
+ CalcAngleCoeffs((Device->Render_Mode==StereoPair) ? ScaleAzimuthFront(Azi, 3.0f) : Azi,
+ Elev, Spread, coeffs);
for(c = 0;c < num_channels;c++)
{
@@ -970,14 +970,15 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo
continue;
}
- if(Device->Render_Mode == StereoPair)
- CalcAnglePairwiseCoeffs(chans[c].angle, chans[c].elevation, Spread, coeffs);
- else
- CalcAngleCoeffs(chans[c].angle, chans[c].elevation, Spread, coeffs);
+ CalcAngleCoeffs(
+ (Device->Render_Mode==StereoPair) ? ScaleAzimuthFront(chans[c].angle, 3.0f)
+ : chans[c].angle,
+ chans[c].elevation, Spread, coeffs
+ );
+
ComputeDryPanGains(&Device->Dry,
coeffs, DryGain, voice->Direct.Params[c].Gains.Target
);
-
for(i = 0;i < NumSends;i++)
{
const ALeffectslot *Slot = SendSlots[i];
diff --git a/Alc/panning.c b/Alc/panning.c
index 51d65a24..d114295b 100644
--- a/Alc/panning.c
+++ b/Alc/panning.c
@@ -40,6 +40,7 @@
extern inline void CalcDirectionCoeffs(const ALfloat dir[3], ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
extern inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
+extern inline float ScaleAzimuthFront(float azimuth, float scale);
extern inline void ComputeDryPanGains(const DryMixParams *dry, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
extern inline void ComputeFirstOrderGains(const BFMixParams *foa, const ALfloat mtx[4], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);
@@ -150,14 +151,6 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf
}
}
-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 ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, ALsizei numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS])
{
diff --git a/OpenAL32/Include/alu.h b/OpenAL32/Include/alu.h
index c09caa65..ed318ada 100644
--- a/OpenAL32/Include/alu.h
+++ b/OpenAL32/Include/alu.h
@@ -477,14 +477,18 @@ inline void CalcAngleCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread,
}
/**
- * CalcAnglePairwiseCoeffs
+ * ScaleAzimuthFront
*
- * Calculates ambisonic coefficients based on azimuth and elevation. The
- * azimuth and elevation parameters are in radians, going right and up
- * respectively. This pairwise variant warps the result such that +30 azimuth
- * is full right, and -30 azimuth is full left.
+ * Scales the given azimuth toward the side (+/- pi/2 radians) for positions in
+ * front.
*/
-void CalcAnglePairwiseCoeffs(ALfloat azimuth, ALfloat elevation, ALfloat spread, ALfloat coeffs[MAX_AMBI_COEFFS]);
+inline float ScaleAzimuthFront(float azimuth, float scale)
+{
+ ALfloat sign = (azimuth < 0.0f) ? -1.0f : 1.0f;
+ if(!(fabsf(azimuth) > F_PI_2))
+ return minf(fabsf(azimuth) * scale, F_PI_2) * sign;
+ return azimuth;
+}
void ComputePanningGainsMC(const ChannelConfig *chancoeffs, ALsizei numchans, ALsizei numcoeffs, const ALfloat coeffs[MAX_AMBI_COEFFS], ALfloat ingain, ALfloat gains[MAX_OUTPUT_CHANNELS]);