aboutsummaryrefslogtreecommitdiffstats
path: root/alc/effects/pshifter.cpp
diff options
context:
space:
mode:
authorChris Robinson <[email protected]>2023-12-09 12:35:07 -0800
committerChris Robinson <[email protected]>2023-12-09 12:35:07 -0800
commit44fbc93909a1a1d1dc26c01feb32bf13a5140234 (patch)
treea9e9c5d7d9fcf6a47e654177dbbdfb5e3b2bd155 /alc/effects/pshifter.cpp
parentdecc10da2bdbb611cce63916f8c6f8b17ea45da1 (diff)
Be less messy with PFFFT
Remove a 1-element array for an over-allocated struct array. Also add a wrapper struct for C++.
Diffstat (limited to 'alc/effects/pshifter.cpp')
-rw-r--r--alc/effects/pshifter.cpp18
1 files changed, 6 insertions, 12 deletions
diff --git a/alc/effects/pshifter.cpp b/alc/effects/pshifter.cpp
index 0c27be30..871e866a 100644
--- a/alc/effects/pshifter.cpp
+++ b/alc/effects/pshifter.cpp
@@ -74,12 +74,6 @@ struct Windower {
const Windower gWindow{};
-struct PFFFTSetupDeleter {
- void operator()(PFFFT_Setup *ptr) { pffft_destroy_setup(ptr); }
-};
-using PFFFTSetupPtr = std::unique_ptr<PFFFT_Setup,PFFFTSetupDeleter>;
-
-
struct FrequencyBin {
float Magnitude;
float FreqBin;
@@ -99,7 +93,7 @@ struct PshifterState final : public EffectState {
std::array<float,StftHalfSize+1> mSumPhase;
std::array<float,StftSize> mOutputAccum;
- PFFFTSetupPtr mFft;
+ PFFFTSetup mFft;
alignas(16) std::array<float,StftSize> mFftBuffer;
alignas(16) std::array<float,StftSize> mFftWorkBuffer;
@@ -142,7 +136,7 @@ void PshifterState::deviceUpdate(const DeviceBase*, const BufferStorage*)
std::fill(std::begin(mTargetGains), std::end(mTargetGains), 0.0f);
if(!mFft)
- mFft = PFFFTSetupPtr{pffft_new_setup(StftSize, PFFFT_REAL)};
+ mFft = PFFFTSetup{StftSize, PFFFT_REAL};
}
void PshifterState::update(const ContextBase*, const EffectSlot *slot,
@@ -197,8 +191,8 @@ void PshifterState::process(const size_t samplesToDo,
mFftBuffer[k] = mFIFO[src] * gWindow.mData[k];
for(size_t src{0u}, k{StftSize-mPos};src < mPos;++src,++k)
mFftBuffer[k] = mFIFO[src] * gWindow.mData[k];
- pffft_transform_ordered(mFft.get(), mFftBuffer.data(), mFftBuffer.data(),
- mFftWorkBuffer.data(), PFFFT_FORWARD);
+ mFft.transform_ordered(mFftBuffer.data(), mFftBuffer.data(), mFftWorkBuffer.data(),
+ PFFFT_FORWARD);
/* Analyze the obtained data. Since the real FFT is symmetric, only
* StftHalfSize+1 samples are needed.
@@ -296,8 +290,8 @@ void PshifterState::process(const size_t samplesToDo,
/* Apply an inverse FFT to get the time-domain signal, and accumulate
* for the output with windowing.
*/
- pffft_transform_ordered(mFft.get(), mFftBuffer.data(), mFftBuffer.data(),
- mFftWorkBuffer.data(), PFFFT_BACKWARD);
+ mFft.transform_ordered(mFftBuffer.data(), mFftBuffer.data(), mFftWorkBuffer.data(),
+ PFFFT_BACKWARD);
static constexpr float scale{3.0f / OversampleFactor / StftSize};
for(size_t dst{mPos}, k{0u};dst < StftSize;++dst,++k)