Use a separate method to warp the azimuth for plain stereo output

This commit is contained in:
Chris Robinson 2018-08-29 01:45:27 -07:00
parent dacd08dc5d
commit 529f387695
3 changed files with 25 additions and 27 deletions

View File

@ -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];

View File

@ -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])
{

View File

@ -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]);