diff options
author | Chris Robinson <[email protected]> | 2019-12-24 23:41:26 -0800 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2019-12-24 23:41:26 -0800 |
commit | de2c64c06f256323dad457a353fd396f01ef1f21 (patch) | |
tree | 66ba5b7abcd5f863c8664d5ae0a9bddfe238245f | |
parent | 04b8f2a0422a8c98915f48c40e17f7decf557c7c (diff) |
Pass a span to the NFC filters
-rw-r--r-- | alc/filters/nfc.cpp | 24 | ||||
-rw-r--r-- | alc/filters/nfc.h | 10 | ||||
-rw-r--r-- | alc/voice.cpp | 4 |
3 files changed, 16 insertions, 22 deletions
diff --git a/alc/filters/nfc.cpp b/alc/filters/nfc.cpp index e4436b27..9a28517c 100644 --- a/alc/filters/nfc.cpp +++ b/alc/filters/nfc.cpp @@ -278,10 +278,8 @@ void NfcFilter::adjust(const float w0) noexcept } -void NfcFilter::process1(float *RESTRICT dst, const float *RESTRICT src, const size_t count) +void NfcFilter::process1(const al::span<const float> src, float *RESTRICT dst) { - ASSUME(count > 0); - const float gain{first.gain}; const float b1{first.b1}; const float a1{first.a1}; @@ -293,14 +291,12 @@ void NfcFilter::process1(float *RESTRICT dst, const float *RESTRICT src, const s z1 += y; return out; }; - std::transform(src, src+count, dst, proc_sample); + std::transform(src.cbegin(), src.cend(), dst, proc_sample); first.z[0] = z1; } -void NfcFilter::process2(float *RESTRICT dst, const float *RESTRICT src, const size_t count) +void NfcFilter::process2(const al::span<const float> src, float *RESTRICT dst) { - ASSUME(count > 0); - const float gain{second.gain}; const float b1{second.b1}; const float b2{second.b2}; @@ -316,15 +312,13 @@ void NfcFilter::process2(float *RESTRICT dst, const float *RESTRICT src, const s z1 += y; return out; }; - std::transform(src, src+count, dst, proc_sample); + std::transform(src.cbegin(), src.cend(), dst, proc_sample); second.z[0] = z1; second.z[1] = z2; } -void NfcFilter::process3(float *RESTRICT dst, const float *RESTRICT src, const size_t count) +void NfcFilter::process3(const al::span<const float> src, float *RESTRICT dst) { - ASSUME(count > 0); - const float gain{third.gain}; const float b1{third.b1}; const float b2{third.b2}; @@ -347,16 +341,14 @@ void NfcFilter::process3(float *RESTRICT dst, const float *RESTRICT src, const s z3 += y; return out; }; - std::transform(src, src+count, dst, proc_sample); + std::transform(src.cbegin(), src.cend(), dst, proc_sample); third.z[0] = z1; third.z[1] = z2; third.z[2] = z3; } -void NfcFilter::process4(float *RESTRICT dst, const float *RESTRICT src, const size_t count) +void NfcFilter::process4(const al::span<const float> src, float *RESTRICT dst) { - ASSUME(count > 0); - const float gain{fourth.gain}; const float b1{fourth.b1}; const float b2{fourth.b2}; @@ -383,7 +375,7 @@ void NfcFilter::process4(float *RESTRICT dst, const float *RESTRICT src, const s z3 += y; return out; }; - std::transform(src, src+count, dst, proc_sample); + std::transform(src.cbegin(), src.cend(), dst, proc_sample); fourth.z[0] = z1; fourth.z[1] = z2; fourth.z[2] = z3; diff --git a/alc/filters/nfc.h b/alc/filters/nfc.h index d2bf3339..2327c966 100644 --- a/alc/filters/nfc.h +++ b/alc/filters/nfc.h @@ -3,6 +3,8 @@ #include <cstddef> +#include "alspan.h" + struct NfcFilter1 { float base_gain, gain; @@ -46,16 +48,16 @@ public: void adjust(const float w0) noexcept; /* Near-field control filter for first-order ambisonic channels (1-3). */ - void process1(float *RESTRICT dst, const float *RESTRICT src, const size_t count); + void process1(const al::span<const float> src, float *RESTRICT dst); /* Near-field control filter for second-order ambisonic channels (4-8). */ - void process2(float *RESTRICT dst, const float *RESTRICT src, const size_t count); + void process2(const al::span<const float> src, float *RESTRICT dst); /* Near-field control filter for third-order ambisonic channels (9-15). */ - void process3(float *RESTRICT dst, const float *RESTRICT src, const size_t count); + void process3(const al::span<const float> src, float *RESTRICT dst); /* Near-field control filter for fourth-order ambisonic channels (16-24). */ - void process4(float *RESTRICT dst, const float *RESTRICT src, const size_t count); + void process4(const al::span<const float> src, float *RESTRICT dst); }; #endif /* FILTER_NFC_H */ diff --git a/alc/voice.cpp b/alc/voice.cpp index f4d9bb68..14680a78 100644 --- a/alc/voice.cpp +++ b/alc/voice.cpp @@ -516,12 +516,12 @@ void DoNfcMix(const al::span<const float> samples, const al::span<FloatBufferLin const al::span<float> nfcsamples{Device->NfcSampleData, samples.size()}; size_t chanoffset{outcount}; - using FilterProc = void (NfcFilter::*)(float*,const float*,const size_t); + using FilterProc = void (NfcFilter::*)(const al::span<const float>, float*); auto apply_nfc = [OutBuffer,&parms,samples,TargetGains,Counter,OutPos,&chanoffset,nfcsamples]( const FilterProc process, const size_t chancount) -> void { if(chancount < 1) return; - (parms.NFCtrlFilter.*process)(nfcsamples.data(), samples.data(), nfcsamples.size()); + (parms.NFCtrlFilter.*process)(samples, nfcsamples.data()); MixSamples(nfcsamples, OutBuffer.subspan(chanoffset, chancount), &parms.Gains.Current[chanoffset], &TargetGains[chanoffset], Counter, OutPos); chanoffset += chancount; |