diff options
author | Chris Robinson <[email protected]> | 2018-09-19 19:53:25 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2018-09-19 19:53:25 -0700 |
commit | 48b7745a49296bd70e16fbf8eeed2d47c84e72a9 (patch) | |
tree | eec7bdf5ff04e65188aee24b5b3978c0cbffbf0e /Alc | |
parent | 9ef4dd42474c3ecc266362df47fd5a6cca8dcbb4 (diff) |
Add macros for commonly used square roots
Diffstat (limited to 'Alc')
-rw-r--r-- | Alc/ALu.c | 16 | ||||
-rw-r--r-- | Alc/effects/reverb.c | 13 | ||||
-rw-r--r-- | Alc/panning.c | 6 |
3 files changed, 16 insertions, 19 deletions
@@ -656,14 +656,14 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo Elev, Spread, coeffs); /* NOTE: W needs to be scaled by sqrt(2) due to FuMa normalization. */ - ComputeDryPanGains(&Device->Dry, coeffs, DryGain*1.414213562f, + ComputeDryPanGains(&Device->Dry, coeffs, DryGain*SQRTF_2, voice->Direct.Params[0].Gains.Target); for(i = 0;i < NumSends;i++) { const ALeffectslot *Slot = SendSlots[i]; if(Slot) - ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, - coeffs, WetGain[i]*1.414213562f, voice->Send[i].Params[0].Gains.Target + ComputePanningGainsBF(Slot->ChanMap, Slot->NumChannels, coeffs, + WetGain[i]*SQRTF_2, voice->Send[i].Params[0].Gains.Target ); } } @@ -672,8 +672,6 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo /* Local B-Format sources have their XYZ channels rotated according * to the orientation. */ - const ALfloat sqrt_2 = sqrtf(2.0f); - const ALfloat sqrt_3 = sqrtf(3.0f); ALfloat N[3], V[3], U[3]; aluMatrixf matrix; @@ -717,10 +715,10 @@ static void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALflo */ aluMatrixfSet(&matrix, // ACN0 ACN1 ACN2 ACN3 - sqrt_2, 0.0f, 0.0f, 0.0f, // Ambi W - 0.0f, -N[0]*sqrt_3, N[1]*sqrt_3, -N[2]*sqrt_3, // Ambi X - 0.0f, U[0]*sqrt_3, -U[1]*sqrt_3, U[2]*sqrt_3, // Ambi Y - 0.0f, -V[0]*sqrt_3, V[1]*sqrt_3, -V[2]*sqrt_3 // Ambi Z + SQRTF_2, 0.0f, 0.0f, 0.0f, // Ambi W + 0.0f, -N[0]*SQRTF_3, N[1]*SQRTF_3, -N[2]*SQRTF_3, // Ambi X + 0.0f, U[0]*SQRTF_3, -U[1]*SQRTF_3, U[2]*SQRTF_3, // Ambi Y + 0.0f, -V[0]*SQRTF_3, V[1]*SQRTF_3, -V[2]*SQRTF_3 // Ambi Z ); voice->Direct.Buffer = Device->FOAOut.Buffer; diff --git a/Alc/effects/reverb.c b/Alc/effects/reverb.c index 4459abf2..6fdd53cd 100644 --- a/Alc/effects/reverb.c +++ b/Alc/effects/reverb.c @@ -802,7 +802,6 @@ static ALvoid UpdateLateLines(const ALfloat density, const ALfloat diffusion, co */ static aluMatrixf GetTransformFromVector(const ALfloat *vec) { - const ALfloat sqrt_3 = 1.732050808f; aluMatrixf focus; ALfloat norm[3]; ALfloat mag; @@ -817,9 +816,9 @@ static aluMatrixf GetTransformFromVector(const ALfloat *vec) mag = sqrtf(vec[0]*vec[0] + vec[1]*vec[1] + vec[2]*vec[2]); if(mag > 1.0f) { - norm[0] = vec[0] / mag * -sqrt_3; - norm[1] = vec[1] / mag * sqrt_3; - norm[2] = vec[2] / mag * sqrt_3; + norm[0] = vec[0] / mag * -SQRTF_3; + norm[1] = vec[1] / mag * SQRTF_3; + norm[2] = vec[2] / mag * SQRTF_3; mag = 1.0f; } else @@ -828,9 +827,9 @@ static aluMatrixf GetTransformFromVector(const ALfloat *vec) * term. There's no need to renormalize the magnitude since it would * just be reapplied in the matrix. */ - norm[0] = vec[0] * -sqrt_3; - norm[1] = vec[1] * sqrt_3; - norm[2] = vec[2] * sqrt_3; + norm[0] = vec[0] * -SQRTF_3; + norm[1] = vec[1] * SQRTF_3; + norm[2] = vec[2] * SQRTF_3; } aluMatrixfSet(&focus, diff --git a/Alc/panning.c b/Alc/panning.c index d114295b..ce0550cf 100644 --- a/Alc/panning.c +++ b/Alc/panning.c @@ -75,9 +75,9 @@ void CalcAmbiCoeffs(const ALfloat y, const ALfloat z, const ALfloat x, const ALf /* Zeroth-order */ coeffs[0] = 1.0f; /* ACN 0 = 1 */ /* First-order */ - coeffs[1] = 1.732050808f * y; /* ACN 1 = sqrt(3) * Y */ - coeffs[2] = 1.732050808f * z; /* ACN 2 = sqrt(3) * Z */ - coeffs[3] = 1.732050808f * x; /* ACN 3 = sqrt(3) * X */ + coeffs[1] = SQRTF_3 * y; /* ACN 1 = sqrt(3) * Y */ + coeffs[2] = SQRTF_3 * z; /* ACN 2 = sqrt(3) * Z */ + coeffs[3] = SQRTF_3 * x; /* ACN 3 = sqrt(3) * X */ /* Second-order */ coeffs[4] = 3.872983346f * x * y; /* ACN 4 = sqrt(15) * X * Y */ coeffs[5] = 3.872983346f * y * z; /* ACN 5 = sqrt(15) * Y * Z */ |