diff options
author | Chris Robinson <[email protected]> | 2020-05-05 01:31:21 -0700 |
---|---|---|
committer | Chris Robinson <[email protected]> | 2020-05-05 01:34:14 -0700 |
commit | ee82db3966acf728935d2a9d26bb5b2ade62e368 (patch) | |
tree | f77da324bcf37847793fe03d92f93f2ce95926b9 | |
parent | deac36a1ebc009e755ef999bcbcdc41323c84ef0 (diff) |
Use a flexible array for the front stablizer delay buffers
-rw-r--r-- | alc/alc.cpp | 5 | ||||
-rw-r--r-- | alc/front_stablizer.h | 22 |
2 files changed, 19 insertions, 8 deletions
diff --git a/alc/alc.cpp b/alc/alc.cpp index acc99e6e..040bffa6 100644 --- a/alc/alc.cpp +++ b/alc/alc.cpp @@ -2095,7 +2095,10 @@ static ALCenum UpdateDeviceParams(ALCdevice *device, const int *attrList) case DevFmtX71: if(GetConfigValueBool(device->DeviceName.c_str(), nullptr, "front-stablizer", 0)) { - auto stablizer = std::make_unique<FrontStablizer>(); + auto stablizer = FrontStablizer::Create(device->channelsFromFmt()); + for(auto &buf : stablizer->DelayBuf) + std::fill(buf.begin(), buf.end(), 0.0f); + /* Initialize band-splitting filter for the mid signal, with a * crossover at 5khz (could be higher). */ diff --git a/alc/front_stablizer.h b/alc/front_stablizer.h index 179a1953..91309bf7 100644 --- a/alc/front_stablizer.h +++ b/alc/front_stablizer.h @@ -1,25 +1,33 @@ #ifndef ALC_FRONT_STABLIZER_H #define ALC_FRONT_STABLIZER_H +#include <array> +#include <memory> + #include "alcmain.h" #include "almalloc.h" -#include "devformat.h" #include "filters/splitter.h" struct FrontStablizer { static constexpr size_t DelayLength{256u}; + FrontStablizer(size_t numchans) : DelayBuf{numchans} { } + BandSplitter MidFilter; - alignas(16) float MidLF[BUFFERSIZE]; - alignas(16) float MidHF[BUFFERSIZE]; - alignas(16) float Side[BUFFERSIZE]; + alignas(16) float MidLF[BUFFERSIZE]{}; + alignas(16) float MidHF[BUFFERSIZE]{}; + alignas(16) float Side[BUFFERSIZE]{}; + + alignas(16) float TempBuf[BUFFERSIZE + DelayLength]{}; - alignas(16) float TempBuf[BUFFERSIZE + DelayLength]; + using DelayLine = std::array<float,DelayLength>; + al::FlexArray<DelayLine,16> DelayBuf; - alignas(16) float DelayBuf[MAX_OUTPUT_CHANNELS][DelayLength]; + static std::unique_ptr<FrontStablizer> Create(size_t numchans) + { return std::unique_ptr<FrontStablizer>{new(FamCount{numchans}) FrontStablizer{numchans}}; } - DEF_NEWDEL(FrontStablizer) + DEF_FAM_NEWDEL(FrontStablizer, DelayBuf) }; #endif /* ALC_FRONT_STABLIZER_H */ |