diff options
author | Chris Robinson <[email protected]> | 2020-05-25 16:57:38 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-05-25 16:57:38 -0700 |
commit | 8d77c59da45b1d4fe206ef8b6c5667fffb7c9d1b (patch) | |
tree | 18321b49a17fce0f4e82c7904ac12bc34878ddf8 /alc/voice.cpp | |
parent | 4e82feffef6c9c380e6f18a2836df72ac750dc26 (diff) |
Fade over more of the update with HRTF
Diffstat (limited to 'alc/voice.cpp')
-rw-r--r-- | alc/voice.cpp | 28 |
1 files changed, 5 insertions, 23 deletions
diff --git a/alc/voice.cpp b/alc/voice.cpp index 7d4f638c..c17cb4cc 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -481,13 +481,11 @@ void DoHrtfMix(const float *samples, const ALuint DstBufferSize, DirectParams &p std::copy_n(std::begin(HrtfSamples) + DstBufferSize, parms.Hrtf.History.size(), parms.Hrtf.History.begin()); - /* If fading, the old gain is not silence, and this is the first mixing - * pass, fade between the IRs. - */ + /* If fading and this is the first mixing pass, fade between the IRs. */ ALuint fademix{0u}; - if(Counter && parms.Hrtf.Old.Gain > GAIN_SILENCE_THRESHOLD && OutPos == 0) + if(Counter && OutPos == 0) { - fademix = minu(DstBufferSize, 128); + fademix = minu(DstBufferSize, Counter); float gain{TargetGain}; @@ -496,7 +494,7 @@ void DoHrtfMix(const float *samples, const ALuint DstBufferSize, DirectParams &p * interpolate between the old and new target gains given how much of * the fade time this mix handles. */ - if LIKELY(Counter > fademix) + if(Counter > fademix) { const float a{static_cast<float>(fademix) / static_cast<float>(Counter)}; gain = lerp(parms.Hrtf.Old.Gain, TargetGain, a); @@ -515,7 +513,7 @@ void DoHrtfMix(const float *samples, const ALuint DstBufferSize, DirectParams &p OutPos += fademix; } - if LIKELY(fademix < DstBufferSize) + if(fademix < DstBufferSize) { const ALuint todo{DstBufferSize - fademix}; float gain{TargetGain}; @@ -627,22 +625,6 @@ void Voice::mix(const State vstate, ALCcontext *Context, const ALuint SamplesToD } } } - else if((mFlags&VOICE_HAS_HRTF)) - { - for(auto &chandata : mChans) - { - DirectParams &parms = chandata.mDryParams; - if(!(parms.Hrtf.Old.Gain > GAIN_SILENCE_THRESHOLD)) - { - /* The old HRTF params are silent, so overwrite the old - * coefficients with the new, and reset the old gain to 0. The - * future mix will then fade from silence. - */ - parms.Hrtf.Old = parms.Hrtf.Target; - parms.Hrtf.Old.Gain = 0.0f; - } - } - } ALuint buffers_done{0u}; ALuint OutPos{0u}; |