diff options
author | Chris Robinson <[email protected]> | 2019-02-24 19:07:21 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-02-24 19:07:21 -0800 |
commit | 4d6b66163c76ae36952748e8fbf9c68113a1ea60 (patch) | |
tree | a7546c481e5f028f987c86656486ef24dd18917d /Alc/alu.cpp | |
parent | d6fb4d5f520e433410eab8fcd7beadabd563ece6 (diff) |
Convert the device frequency to float just once
Diffstat (limited to 'Alc/alu.cpp')
-rw-r--r-- | Alc/alu.cpp | 16 |
1 files changed, 7 insertions, 9 deletions
diff --git a/Alc/alu.cpp b/Alc/alu.cpp index 25a55982..85482084 100644 --- a/Alc/alu.cpp +++ b/Alc/alu.cpp @@ -496,6 +496,10 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev { FrontRight, Deg2Rad( 30.0f), Deg2Rad(0.0f) } }; + const auto Frequency = static_cast<ALfloat>(Device->Frequency); + const ALsizei NumSends{Device->NumAuxSends}; + ASSUME(NumSends >= 0); + bool DirectChannels{props->DirectChannels != AL_FALSE}; const ChanMap *chans{nullptr}; ALsizei num_channels{0}; @@ -574,8 +578,6 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev ClearArray(params.Gains.Target); } ); - const ALsizei NumSends{Device->NumAuxSends}; - ASSUME(NumSends >= 0); std::for_each(voice->Send.begin(), voice->Send.end(), [num_channels](ALvoice::SendData &send) -> void { @@ -604,8 +606,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev * excessive bass. */ const ALfloat mdist{maxf(Distance, Device->AvgSpeakerDist/4.0f)}; - const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (mdist * static_cast<ALfloat>(Device->Frequency))}; + const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)}; /* Only need to adjust the first channel of a B-Format source. */ voice->Direct.Params[0].NFCtrlFilter.adjust(w0); @@ -825,8 +826,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev * excessive bass. */ const ALfloat mdist{maxf(Distance, Device->AvgSpeakerDist/4.0f)}; - const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (mdist * static_cast<ALfloat>(Device->Frequency))}; + const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)}; /* Adjust NFC filters. */ for(ALsizei c{0};c < num_channels;c++) @@ -884,8 +884,7 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev * filters so they keep an appropriate history, in case the * source moves away from the listener. */ - const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / - (Device->AvgSpeakerDist * static_cast<ALfloat>(Device->Frequency))}; + const ALfloat w0{SPEEDOFSOUNDMETRESPERSEC / (Device->AvgSpeakerDist * Frequency)}; for(ALsizei c{0};c < num_channels;c++) voice->Direct.Params[c].NFCtrlFilter.adjust(w0); @@ -929,7 +928,6 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat Azi, const ALfloat Elev } } - const auto Frequency = static_cast<ALfloat>(Device->Frequency); { const ALfloat hfScale{props->Direct.HFReference / Frequency}; const ALfloat lfScale{props->Direct.LFReference / Frequency}; |