diff options
-rw-r--r-- | alc/alu.cpp | 9 | ||||
-rw-r--r-- | alc/voice.cpp | 32 | ||||
-rw-r--r-- | alc/voice.h | 10 |
3 files changed, 23 insertions, 28 deletions
diff --git a/alc/alu.cpp b/alc/alu.cpp index 6d3e5549..8c2ee164 100644 --- a/alc/alu.cpp +++ b/alc/alu.cpp @@ -132,11 +132,6 @@ struct ChanMap { ALfloat elevation; }; -void ClearArray(ALfloat (&f)[MAX_OUTPUT_CHANNELS]) -{ - std::fill(std::begin(f), std::end(f), 0.0f); -} - HrtfDirectMixerFunc MixDirectHrtf = MixDirectHrtf_<CTag>; inline MixerFunc SelectMixer() @@ -633,9 +628,9 @@ void CalcPanningAndFilters(ALvoice *voice, const ALfloat xpos, const ALfloat ypo [NumSends](ALvoice::ChannelData &chandata) -> void { chandata.mDryParams.Hrtf.Target = HrtfFilter{}; - ClearArray(chandata.mDryParams.Gains.Target); + chandata.mDryParams.Gains.Target.fill(0.0f); std::for_each(chandata.mWetParams.begin(), chandata.mWetParams.begin()+NumSends, - [](SendParams ¶ms) -> void { ClearArray(params.Gains.Target); }); + [](SendParams ¶ms) -> void { params.Gains.Target.fill(0.0f); }); }); voice->mFlags &= ~(VOICE_HAS_HRTF | VOICE_HAS_NFC); diff --git a/alc/voice.cpp b/alc/voice.cpp index 02378fc6..7eb791d5 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -525,7 +525,7 @@ void DoNfcMix(ALvoice::TargetData &Direct, const float *TargetGains, DirectParam { const size_t outcount{Device->NumChannelsPerOrder[0]}; MixSamples({samples, DstBufferSize}, Direct.Buffer.first(outcount), - parms.Gains.Current, TargetGains, Counter, OutPos); + parms.Gains.Current.data(), TargetGains, Counter, OutPos); const al::span<float> nfcsamples{Device->NfcSampleData, DstBufferSize}; size_t chanoffset{outcount}; @@ -536,7 +536,7 @@ void DoNfcMix(ALvoice::TargetData &Direct, const float *TargetGains, DirectParam if(chancount < 1) return; (parms.NFCtrlFilter.*process)(nfcsamples.data(), samples, nfcsamples.size()); MixSamples(nfcsamples, Direct.Buffer.subspan(chanoffset, chancount), - parms.Gains.Current+chanoffset, TargetGains+chanoffset, Counter, OutPos); + &parms.Gains.Current[chanoffset], &TargetGains[chanoffset], Counter, OutPos); chanoffset += chancount; }; apply_nfc(&NfcFilter::process1, Device->NumChannelsPerOrder[1]); @@ -548,7 +548,7 @@ void DoNfcMix(ALvoice::TargetData &Direct, const float *TargetGains, DirectParam void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) { - static constexpr ALfloat SilentTarget[MAX_OUTPUT_CHANNELS]{}; + static constexpr std::array<float,MAX_OUTPUT_CHANNELS> SilentTarget{}; ASSUME(SamplesToDo > 0); @@ -584,8 +584,7 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) { DirectParams &parms = chandata.mDryParams; if(!(mFlags&VOICE_HAS_HRTF)) - std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), - std::begin(parms.Gains.Current)); + parms.Gains.Current = parms.Gains.Target; else parms.Hrtf.Old = parms.Hrtf.Target; } @@ -595,8 +594,7 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) continue; SendParams &parms = chandata.mWetParams[send]; - std::copy(std::begin(parms.Gains.Target), std::end(parms.Gains.Target), - std::begin(parms.Gains.Current)); + parms.Gains.Current = parms.Gains.Target; } } } @@ -720,17 +718,17 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) } else if((mFlags&VOICE_HAS_NFC)) { - const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? - SilentTarget : parms.Gains.Target}; + const float *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? + SilentTarget.data() : parms.Gains.Target.data()}; DoNfcMix(mDirect, TargetGains, parms, samples, DstBufferSize, Counter, OutPos, Device); } else { - const ALfloat *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? - SilentTarget : parms.Gains.Target}; - MixSamples({samples, DstBufferSize}, mDirect.Buffer, parms.Gains.Current, - TargetGains, Counter, OutPos); + const float *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? + SilentTarget.data() : parms.Gains.Target.data()}; + MixSamples({samples, DstBufferSize}, mDirect.Buffer, + parms.Gains.Current.data(), TargetGains, Counter, OutPos); } } @@ -743,10 +741,10 @@ void ALvoice::mix(State vstate, ALCcontext *Context, const ALuint SamplesToDo) const ALfloat *samples{DoFilters(&parms.LowPass, &parms.HighPass, FilterBuf, ResampledData, DstBufferSize, mSend[send].FilterType)}; - const ALfloat *TargetGains{UNLIKELY(vstate==ALvoice::Stopping) ? SilentTarget : - parms.Gains.Target}; - MixSamples({samples, DstBufferSize}, mSend[send].Buffer, parms.Gains.Current, - TargetGains, Counter, OutPos); + const float *TargetGains{UNLIKELY(vstate == ALvoice::Stopping) ? + SilentTarget.data() : parms.Gains.Target.data()}; + MixSamples({samples, DstBufferSize}, mSend[send].Buffer, + parms.Gains.Current.data(), TargetGains, Counter, OutPos); } } /* Update positions */ diff --git a/alc/voice.h b/alc/voice.h index 0d5d9ca4..206e2e6b 100644 --- a/alc/voice.h +++ b/alc/voice.h @@ -1,6 +1,8 @@ #ifndef VOICE_H #define VOICE_H +#include <array> + #include "AL/al.h" #include "AL/alext.h" @@ -96,8 +98,8 @@ struct DirectParams { } Hrtf; struct { - float Current[MAX_OUTPUT_CHANNELS]; - float Target[MAX_OUTPUT_CHANNELS]; + std::array<float,MAX_OUTPUT_CHANNELS> Current; + std::array<float,MAX_OUTPUT_CHANNELS> Target; } Gains; }; @@ -106,8 +108,8 @@ struct SendParams { BiquadFilter HighPass; struct { - float Current[MAX_OUTPUT_CHANNELS]; - float Target[MAX_OUTPUT_CHANNELS]; + std::array<float,MAX_OUTPUT_CHANNELS> Current; + std::array<float,MAX_OUTPUT_CHANNELS> Target; } Gains; }; |