From b48bab33948dae90a27b4f8ccd3eb6b20d49ba86 Mon Sep 17 00:00:00 2001 From: Chris Robinson Date: Wed, 22 May 2019 03:03:24 -0700 Subject: Allow initializing splitter filters with constructors --- Alc/filters/splitter.h | 8 ++++++++ Alc/hrtf.cpp | 6 ++---- OpenAL32/alSource.cpp | 3 +-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/Alc/filters/splitter.h b/Alc/filters/splitter.h index 669d9d03..cd5fe864 100644 --- a/Alc/filters/splitter.h +++ b/Alc/filters/splitter.h @@ -14,6 +14,10 @@ class BandSplitterR { Real ap_z1{0.0f}; public: + BandSplitterR() = default; + BandSplitterR(const BandSplitterR&) = default; + BandSplitterR(Real f0norm) { init(f0norm); } + void init(Real f0norm); void clear() noexcept { lp_z1 = lp_z2 = ap_z1 = 0.0f; } void process(Real *hpout, Real *lpout, const Real *input, const int count); @@ -30,6 +34,10 @@ class SplitterAllpassR { Real z1{0.0f}; public: + SplitterAllpassR() = default; + SplitterAllpassR(const SplitterAllpassR&) = default; + SplitterAllpassR(Real f0norm) { init(f0norm); } + void init(Real f0norm); void clear() noexcept { z1 = 0.0f; } void process(Real *samples, int count); diff --git a/Alc/hrtf.cpp b/Alc/hrtf.cpp index 9fa79e22..ede8f8c5 100644 --- a/Alc/hrtf.cpp +++ b/Alc/hrtf.cpp @@ -339,10 +339,8 @@ void BuildBFormatHrtf(const HrtfEntry *Hrtf, DirectHrtfState *state, const ALsiz */ static constexpr ALsizei base_delay{DualBand ? 12 : 0}; const ALdouble xover_norm{400.0 / Hrtf->sampleRate}; - BandSplitterR splitter; - SplitterAllpassR allpass; - splitter.init(xover_norm); - allpass.init(xover_norm); + BandSplitterR splitter{xover_norm}; + SplitterAllpassR allpass{xover_norm}; auto tmpres = al::vector>(NumChannels); auto tmpfilt = al::vector>(3); diff --git a/OpenAL32/alSource.cpp b/OpenAL32/alSource.cpp index 513adb88..48f9a157 100644 --- a/OpenAL32/alSource.cpp +++ b/OpenAL32/alSource.cpp @@ -2936,8 +2936,7 @@ START_API_FUNC OrderFromChan = Order3DFromChan; } - BandSplitter splitter; - splitter.init(400.0f / static_cast(device->Frequency)); + BandSplitter splitter{400.0f / static_cast(device->Frequency)}; const auto scales = BFormatDec::GetHFOrderScales(1, device->mAmbiOrder); auto init_ambi = [scales,&OrderFromChan,&splitter](ALvoice::ResampleData &resdata) -> void -- cgit v1.2.3