diff options
-rw-r--r-- | al/source.cpp | 2 | ||||
-rw-r--r-- | al/state.cpp | 10 | ||||
-rw-r--r-- | alc/alc.cpp | 2 | ||||
-rw-r--r-- | alc/alcontext.h | 2 | ||||
-rw-r--r-- | alc/alu.cpp | 24 | ||||
-rw-r--r-- | alc/alu.h | 12 | ||||
-rw-r--r-- | alc/effects/compressor.cpp | 2 | ||||
-rw-r--r-- | alc/effects/distortion.cpp | 2 | ||||
-rw-r--r-- | alc/effects/reverb.cpp | 8 | ||||
-rw-r--r-- | alc/mixer/hrtfbase.h | 4 | ||||
-rw-r--r-- | alc/mixer/mixer_c.cpp | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_neon.cpp | 2 | ||||
-rw-r--r-- | alc/mixer/mixer_sse.cpp | 2 | ||||
-rw-r--r-- | alc/panning.cpp | 4 |
14 files changed, 39 insertions, 39 deletions
diff --git a/al/source.cpp b/al/source.cpp index 42c2d028..d3227c95 100644 --- a/al/source.cpp +++ b/al/source.cpp @@ -500,7 +500,7 @@ void InitVoice(Voice *voice, ALsource *source, ALbufferlistitem *BufferList, ALC if(device->AvgSpeakerDist > 0.0f) { - const float w1{SPEEDOFSOUNDMETRESPERSEC / + const float w1{SpeedOfSoundMetersPerSec / (device->AvgSpeakerDist * static_cast<float>(device->Frequency))}; for(auto &chandata : voice->mChans) chandata.mDryParams.NFCtrlFilter.init(w1); diff --git a/al/state.cpp b/al/state.cpp index dcc87972..ee05d3b9 100644 --- a/al/state.cpp +++ b/al/state.cpp @@ -214,7 +214,7 @@ START_API_FUNC break; case AL_GAIN_LIMIT_SOFT: - if(GAIN_MIX_MAX/context->mGainBoost != 0.0f) + if(GainMixMax/context->mGainBoost != 0.0f) value = AL_TRUE; break; @@ -267,7 +267,7 @@ START_API_FUNC break; case AL_GAIN_LIMIT_SOFT: - value = ALdouble{GAIN_MIX_MAX}/context->mGainBoost; + value = ALdouble{GainMixMax}/context->mGainBoost; break; case AL_NUM_RESAMPLERS_SOFT: @@ -318,7 +318,7 @@ START_API_FUNC break; case AL_GAIN_LIMIT_SOFT: - value = GAIN_MIX_MAX/context->mGainBoost; + value = GainMixMax/context->mGainBoost; break; case AL_NUM_RESAMPLERS_SOFT: @@ -369,7 +369,7 @@ START_API_FUNC break; case AL_GAIN_LIMIT_SOFT: - value = static_cast<ALint>(GAIN_MIX_MAX/context->mGainBoost); + value = static_cast<ALint>(GainMixMax/context->mGainBoost); break; case AL_NUM_RESAMPLERS_SOFT: @@ -420,7 +420,7 @@ START_API_FUNC break; case AL_GAIN_LIMIT_SOFT: - value = static_cast<ALint64SOFT>(GAIN_MIX_MAX/context->mGainBoost); + value = static_cast<ALint64SOFT>(GainMixMax/context->mGainBoost); break; case AL_NUM_RESAMPLERS_SOFT: diff --git a/alc/alc.cpp b/alc/alc.cpp index 6a599dda..9c4be5ed 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2241,7 +2241,7 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) if(device->AvgSpeakerDist > 0.0f) { /* Reinitialize the NFC filters for new parameters. */ - const float w1{SPEEDOFSOUNDMETRESPERSEC / + const float w1{SpeedOfSoundMetersPerSec / (device->AvgSpeakerDist * static_cast<float>(device->Frequency))}; for(auto &chandata : voice->mChans) chandata.mDryParams.NFCtrlFilter.init(w1); diff --git a/alc/alcontext.h b/alc/alcontext.h index 73a6617e..59775849 100644 --- a/alc/alcontext.h +++ b/alc/alcontext.h @@ -114,7 +114,7 @@ struct ALCcontext : public al::intrusive_ref<ALCcontext> { float mDopplerFactor{1.0f}; float mDopplerVelocity{1.0f}; - float mSpeedOfSound{SPEEDOFSOUNDMETRESPERSEC}; + float mSpeedOfSound{SpeedOfSoundMetersPerSec}; std::atomic_flag mPropsClean; std::atomic<bool> mDeferUpdates{false}; diff --git a/alc/alu.cpp b/alc/alu.cpp index 722ef1e1..c4d8e8f4 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -839,7 +839,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con * excessive bass. */ const float mdist{maxf(Distance, Device->AvgSpeakerDist/4.0f)}; - const float w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)}; + const float w0{SpeedOfSoundMetersPerSec / (mdist * Frequency)}; /* Only need to adjust the first channel of a B-Format source. */ voice->mChans[0].mDryParams.NFCtrlFilter.adjust(w0); @@ -1091,7 +1091,7 @@ void CalcPanningAndFilters(Voice *voice, const float xpos, const float ypos, con * excessive bass. */ const float mdist{maxf(Distance, Device->AvgSpeakerDist/4.0f)}; - const float w0{SPEEDOFSOUNDMETRESPERSEC / (mdist * Frequency)}; + const float w0{SpeedOfSoundMetersPerSec / (mdist * Frequency)}; /* Adjust NFC filters. */ for(size_t c{0};c < num_channels;c++) @@ -1253,14 +1253,14 @@ void CalcNonAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcon const ALlistener &Listener = ALContext->mListener; GainTriplet DryGain; DryGain.Base = minf(clampf(props->Gain, props->MinGain, props->MaxGain) * props->Direct.Gain * - Listener.Params.Gain, GAIN_MIX_MAX); + Listener.Params.Gain, GainMixMax); DryGain.HF = props->Direct.GainHF; DryGain.LF = props->Direct.GainLF; GainTriplet WetGain[MAX_SENDS]; for(ALuint i{0};i < Device->NumAuxSends;i++) { WetGain[i].Base = minf(clampf(props->Gain, props->MinGain, props->MaxGain) * - props->Send[i].Gain * Listener.Params.Gain, GAIN_MIX_MAX); + props->Send[i].Gain * Listener.Params.Gain, GainMixMax); WetGain[i].HF = props->Send[i].GainHF; WetGain[i].LF = props->Send[i].GainLF; } @@ -1299,7 +1299,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex /* Calculate the distances to where this effect's decay reaches * -60dB. */ - DecayDistance[i].Base = SendSlots[i]->Params.DecayTime * SPEEDOFSOUNDMETRESPERSEC; + DecayDistance[i].Base = SendSlots[i]->Params.DecayTime * SpeedOfSoundMetersPerSec; DecayDistance[i].LF = DecayDistance[i].Base * SendSlots[i]->Params.DecayLFRatio; DecayDistance[i].HF = DecayDistance[i].Base * SendSlots[i]->Params.DecayHFRatio; if(SendSlots[i]->Params.DecayHFLimit) @@ -1312,7 +1312,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex * decay distance (so it doesn't take any longer to decay * than the air would allow). */ - constexpr float log10_decaygain{-3.0f/*std::log10(REVERB_DECAY_GAIN)*/}; + constexpr float log10_decaygain{-3.0f/*std::log10(ReverbDecayGain)*/}; const float absorb_dist{log10_decaygain / std::log10(airAbsorption)}; DecayDistance[i].HF = minf(absorb_dist, DecayDistance[i].HF); } @@ -1465,13 +1465,13 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex /* Apply gain and frequency filters */ DryGain.Base = minf(clampf(DryGain.Base, props->MinGain, props->MaxGain) * props->Direct.Gain * - Listener.Params.Gain, GAIN_MIX_MAX); + Listener.Params.Gain, GainMixMax); DryGain.HF *= props->Direct.GainHF; DryGain.LF *= props->Direct.GainLF; for(ALuint i{0};i < NumSends;i++) { WetGain[i].Base = minf(clampf(WetGain[i].Base, props->MinGain, props->MaxGain) * - props->Send[i].Gain * Listener.Params.Gain, GAIN_MIX_MAX); + props->Send[i].Gain * Listener.Params.Gain, GainMixMax); WetGain[i].HF *= props->Send[i].GainHF; WetGain[i].LF *= props->Send[i].GainLF; } @@ -1483,7 +1483,7 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex Listener.Params.MetersPerUnit}; if(props->AirAbsorptionFactor > 0.0f) { - const float hfattn{std::pow(AIRABSORBGAINHF, meters_base*props->AirAbsorptionFactor)}; + const float hfattn{std::pow(AirAbsorbGainHF, meters_base*props->AirAbsorptionFactor)}; DryGain.HF *= hfattn; std::for_each(std::begin(WetGain), std::begin(WetGain)+NumSends, [hfattn](GainTriplet &gain) noexcept -> void { gain.HF *= hfattn; }); @@ -1500,16 +1500,16 @@ void CalcAttnSourceParams(Voice *voice, const VoiceProps *props, const ALCcontex if(!(DecayDistance[i].Base > 0.0f)) continue; - const float gain{std::pow(REVERB_DECAY_GAIN, meters_base/DecayDistance[i].Base)}; + const float gain{std::pow(ReverbDecayGain, meters_base/DecayDistance[i].Base)}; WetGain[i].Base *= gain; /* Yes, the wet path's air absorption is applied with * WetGainAuto on, rather than WetGainHFAuto. */ if(gain > 0.0f) { - float gainhf{std::pow(REVERB_DECAY_GAIN, meters_base/DecayDistance[i].HF)}; + float gainhf{std::pow(ReverbDecayGain, meters_base/DecayDistance[i].HF)}; WetGain[i].HF *= minf(gainhf / gain, 1.0f); - float gainlf{std::pow(REVERB_DECAY_GAIN, meters_base/DecayDistance[i].LF)}; + float gainlf{std::pow(ReverbDecayGain, meters_base/DecayDistance[i].LF)}; WetGain[i].LF *= minf(gainlf / gain, 1.0f); } } @@ -26,15 +26,15 @@ using MixerFunc = void(*)(const al::span<const float> InSamples, extern MixerFunc MixSamples; -#define GAIN_MIX_MAX 1000.0f /* +60dB */ +constexpr float GainMixMax{1000.0f}; /* +60dB */ -#define GAIN_SILENCE_THRESHOLD 0.00001f /* -100dB */ +constexpr float GainSilenceThreshold{0.00001f}; /* -100dB */ -#define SPEEDOFSOUNDMETRESPERSEC 343.3f -#define AIRABSORBGAINHF 0.99426f /* -0.05dB */ +constexpr float SpeedOfSoundMetersPerSec{343.3f}; +constexpr float AirAbsorbGainHF{0.99426f}; /* -0.05dB */ -/* Target gain for the reverb decay feedback reaching the decay time. */ -#define REVERB_DECAY_GAIN 0.001f /* -60 dB */ +/** Target gain for the reverb decay feedback reaching the decay time. */ +constexpr float ReverbDecayGain{0.001f}; /* -60 dB */ #define FRACTIONBITS 12 #define FRACTIONONE (1<<FRACTIONBITS) diff --git a/alc/effects/compressor.cpp b/alc/effects/compressor.cpp index 6724482e..e02dec3b 100644 --- a/alc/effects/compressor.cpp +++ b/alc/effects/compressor.cpp @@ -137,7 +137,7 @@ void CompressorState::process(const size_t samplesToDo, const al::span<const Flo for(FloatBufferLine &output : samplesOut) { const float gain{*(outgains++)}; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; for(size_t i{0u};i < td;i++) diff --git a/alc/effects/distortion.cpp b/alc/effects/distortion.cpp index 93f0e006..be787b78 100644 --- a/alc/effects/distortion.cpp +++ b/alc/effects/distortion.cpp @@ -139,7 +139,7 @@ void DistortionState::process(const size_t samplesToDo, const al::span<const Flo * storing only one sample out of four. */ const float gain{*(outgains++)}; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; for(size_t i{0u};i < todo;i++) diff --git a/alc/effects/reverb.cpp b/alc/effects/reverb.cpp index 502a4cf2..3fa0b271 100644 --- a/alc/effects/reverb.cpp +++ b/alc/effects/reverb.cpp @@ -449,7 +449,7 @@ struct ReverbState final : public EffectState { const float *RESTRICT input{al::assume_aligned<16>(InSamples)}; InSamples += InStride; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; for(float &sample : OutBuffer) @@ -684,14 +684,14 @@ void ReverbState::deviceUpdate(const ALCdevice *device) * until the decay reaches -60 dB. */ inline float CalcDecayCoeff(const float length, const float decayTime) -{ return std::pow(REVERB_DECAY_GAIN, length/decayTime); } +{ return std::pow(ReverbDecayGain, length/decayTime); } /* Calculate a decay length from a coefficient and the time until the decay * reaches -60 dB. */ inline float CalcDecayLength(const float coeff, const float decayTime) { - constexpr float log10_decaygain{-3.0f/*std::log10(REVERB_DECAY_GAIN)=std::log10(0.001f)*/}; + constexpr float log10_decaygain{-3.0f/*std::log10(ReverbDecayGain)*/}; return std::log10(coeff) * decayTime / log10_decaygain; } @@ -740,7 +740,7 @@ float CalcLimitedHfRatio(const float hfRatio, const float airAbsorptionGainHF, * equation, solve for HF ratio. The delay length is cancelled out of * the equation, so it can be calculated once for all lines. */ - float limitRatio{1.0f / SPEEDOFSOUNDMETRESPERSEC / + float limitRatio{1.0f / SpeedOfSoundMetersPerSec / CalcDecayLength(airAbsorptionGainHF, decayTime)}; /* Using the limit calculated above, apply the upper bound to the HF ratio. */ diff --git a/alc/mixer/hrtfbase.h b/alc/mixer/hrtfbase.h index 4ec6c95d..1b76e66d 100644 --- a/alc/mixer/hrtfbase.h +++ b/alc/mixer/hrtfbase.h @@ -48,7 +48,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl const auto &NewCoeffs = *newparams->Coeffs; const float newGainStep{newparams->GainStep}; - if LIKELY(oldparams->Gain > GAIN_SILENCE_THRESHOLD) + if LIKELY(oldparams->Gain > GainSilenceThreshold) { size_t ldelay{HRTF_HISTORY_LENGTH - oldparams->Delay[0]}; size_t rdelay{HRTF_HISTORY_LENGTH - oldparams->Delay[1]}; @@ -64,7 +64,7 @@ inline void MixHrtfBlendBase(const float *InSamples, float2 *RESTRICT AccumSampl } } - if LIKELY(newGainStep*static_cast<float>(BufferSize) > GAIN_SILENCE_THRESHOLD) + if LIKELY(newGainStep*static_cast<float>(BufferSize) > GainSilenceThreshold) { size_t ldelay{HRTF_HISTORY_LENGTH+1 - newparams->Delay[0]}; size_t rdelay{HRTF_HISTORY_LENGTH+1 - newparams->Delay[1]}; diff --git a/alc/mixer/mixer_c.cpp b/alc/mixer/mixer_c.cpp index af8ff3b1..5d71e0a4 100644 --- a/alc/mixer/mixer_c.cpp +++ b/alc/mixer/mixer_c.cpp @@ -188,7 +188,7 @@ void Mix_<CTag>(const al::span<const float> InSamples, const al::span<FloatBuffe ++CurrentGains; ++TargetGains; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; for(;pos != InSamples.size();++pos) dst[pos] += InSamples[pos] * gain; diff --git a/alc/mixer/mixer_neon.cpp b/alc/mixer/mixer_neon.cpp index 2573e791..cfa541c7 100644 --- a/alc/mixer/mixer_neon.cpp +++ b/alc/mixer/mixer_neon.cpp @@ -274,7 +274,7 @@ void Mix_<NEONTag>(const al::span<const float> InSamples, const al::span<FloatBu ++CurrentGains; ++TargetGains; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; if(size_t todo{(InSamples.size()-pos) >> 2}) { diff --git a/alc/mixer/mixer_sse.cpp b/alc/mixer/mixer_sse.cpp index 85cddcae..e1aa479c 100644 --- a/alc/mixer/mixer_sse.cpp +++ b/alc/mixer/mixer_sse.cpp @@ -247,7 +247,7 @@ void Mix_<SSETag>(const al::span<const float> InSamples, const al::span<FloatBuf ++CurrentGains; ++TargetGains; - if(!(std::fabs(gain) > GAIN_SILENCE_THRESHOLD)) + if(!(std::fabs(gain) > GainSilenceThreshold)) continue; if(size_t todo{(InSamples.size()-pos) >> 2}) { diff --git a/alc/panning.cpp b/alc/panning.cpp index ad4ba32e..15a05136 100644 --- a/alc/panning.cpp +++ b/alc/panning.cpp @@ -255,7 +255,7 @@ void InitDistanceComp(ALCdevice *device, const AmbDecConf *conf, if(!GetConfigValueBool(devname, "decoder", "distance-comp", 1) || !(maxdist > 0.0f)) return; - const auto distSampleScale = static_cast<float>(device->Frequency) / SPEEDOFSOUNDMETRESPERSEC; + const auto distSampleScale = static_cast<float>(device->Frequency) / SpeedOfSoundMetersPerSec; const auto ChanDelay = device->ChannelDelay.as_span(); size_t total{0u}; for(size_t i{0u};i < conf->Speakers.size();i++) @@ -508,7 +508,7 @@ void InitPanning(ALCdevice *device, const bool hqdec=false, const bool stablize= float nfc_delay{ConfigValueFloat(devname, "decoder", "nfc-ref-delay").value_or(0.0f)}; if(nfc_delay > 0.0f) - InitNearFieldCtrl(device, nfc_delay * SPEEDOFSOUNDMETRESPERSEC, device->mAmbiOrder, + InitNearFieldCtrl(device, nfc_delay * SpeedOfSoundMetersPerSec, device->mAmbiOrder, true); } else |