Use a flexible array for the front stablizer delay buffers

This commit is contained in:
Chris Robinson
2020-05-05 01:31:21 -07:00
parent deac36a1eb
commit ee82db3966
2 changed files with 19 additions and 8 deletions
+4 -1
View File
@@ -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).
*/
+15 -7
View File
@@ -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]{};
alignas(16) float DelayBuf[MAX_OUTPUT_CHANNELS][DelayLength];
using DelayLine = std::array<float,DelayLength>;
al::FlexArray<DelayLine,16> DelayBuf;
DEF_NEWDEL(FrontStablizer)
static std::unique_ptr<FrontStablizer> Create(size_t numchans)
{ return std::unique_ptr<FrontStablizer>{new(FamCount{numchans}) FrontStablizer{numchans}}; }
DEF_FAM_NEWDEL(FrontStablizer, DelayBuf)
};
#endif /* ALC_FRONT_STABLIZER_H */