diff options
author | Chris Robinson <[email protected]> | 2020-05-04 16:16:55 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-05-04 16:16:55 -0700 |
commit | fcec76663f0ea24dd5d1f477f839ca2e781bf9b3 (patch) | |
tree | b8ad0b07d4f9e53e49faf6f5617780c18dd2d523 /alc | |
parent | 58d953f6aa15469cc0237a49c1b9d8460b7885ea (diff) |
Move some sin/cos constants out of a loop
Diffstat (limited to 'alc')
-rw-r--r-- | alc/alu.cpp | 21 |
1 files changed, 11 insertions, 10 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index 3e4bb0f0..bf713eda 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -1865,22 +1865,23 @@ void ApplyStablizer(FrontStablizer *Stablizer, const al::span<FloatBufferLine> B apply_splitter(Buffer[lidx], Stablizer->DelayBuf[lidx], Stablizer->LFilter, lsplit); apply_splitter(Buffer[ridx], Stablizer->DelayBuf[ridx], Stablizer->RFilter, rsplit); + /* This pans the separate low- and high-frequency sums between being on the + * center channel and the left/right channels. The low-frequency sum is + * 1/3rd toward center (2/3rds on left/right) and the high-frequency sum is + * 1/4th toward center (3/4ths on left/right). These values can be tweaked. + */ + const float cos_lf{std::cos(1.0f/3.0f * (al::MathDefs<float>::Pi()*0.5f))}; + const float cos_hf{std::cos(1.0f/4.0f * (al::MathDefs<float>::Pi()*0.5f))}; + const float sin_lf{std::sin(1.0f/3.0f * (al::MathDefs<float>::Pi()*0.5f))}; + const float sin_hf{std::sin(1.0f/4.0f * (al::MathDefs<float>::Pi()*0.5f))}; for(ALuint i{0};i < SamplesToDo;i++) { float lfsum{lsplit[0][i] + rsplit[0][i]}; float hfsum{lsplit[1][i] + rsplit[1][i]}; float s{lsplit[0][i] + lsplit[1][i] - rsplit[0][i] - rsplit[1][i]}; - /* This pans the separate low- and high-frequency sums between being on - * the center channel and the left/right channels. The low-frequency - * sum is 1/3rd toward center (2/3rds on left/right) and the high- - * frequency sum is 1/4th toward center (3/4ths on left/right). These - * values can be tweaked. - */ - float m{lfsum*std::cos(1.0f/3.0f * (al::MathDefs<float>::Pi()*0.5f)) + - hfsum*std::cos(1.0f/4.0f * (al::MathDefs<float>::Pi()*0.5f))}; - float c{lfsum*std::sin(1.0f/3.0f * (al::MathDefs<float>::Pi()*0.5f)) + - hfsum*std::sin(1.0f/4.0f * (al::MathDefs<float>::Pi()*0.5f))}; + float m{lfsum*cos_lf + hfsum*cos_hf}; + float c{lfsum*sin_lf + hfsum*sin_hf}; /* The generated center channel signal adds to the existing signal, * while the modified left and right channels replace. |