Skip to content

Commit

Permalink
Properly align a buffer given to PFFFT
Browse files Browse the repository at this point in the history
  • Loading branch information
kcat committed Oct 15, 2023
1 parent af4f92c commit facad22
Showing 1 changed file with 5 additions and 4 deletions.
9 changes: 5 additions & 4 deletions core/uhjfilter.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
#include "opthelpers.h"
#include "pffft.h"
#include "phase_shifter.h"
#include "vector.h"


UhjQualityType UhjDecodeQuality{UhjQualityType::Default};
Expand Down Expand Up @@ -96,8 +97,8 @@ struct SplitFilter {
fftBuffer[i] = std::conj(fftBuffer[fft_size - i]);
inverse_fft(al::span{fftBuffer.get(), fft_size});

/* Store the first segment of the buffer to apply as a time-domain
* filter (backwards for more efficient processing).
/* Store the first segment of the filter to apply in the time-domain
* (backwards for more efficient processing).
*/
auto fftiter = fftBuffer.get() + sSampleLength - 1;
for(float &coeff : mPShift.mCoeffs)
Expand All @@ -109,7 +110,7 @@ struct SplitFilter {
/* The remaining segments of the filter are converted back to the
* frequency domain, each on their own (0 stuffed).
*/
auto fftTmp = std::make_unique<float[]>(sFftLength);
auto fftTmp = al::vector<float,16>(sFftLength);
float *filter{mFilterData.data()};
for(size_t s{0};s < sNumSegments;++s)
{
Expand All @@ -127,7 +128,7 @@ struct SplitFilter {
fftTmp[i*2 + 1] = static_cast<float>((i == 0) ? fftBuffer[sSampleLength].real()
: fftBuffer[i].imag()) / float{sFftLength};
}
pffft_zreorder(mFft.get(), fftTmp.get(), filter, PFFFT_BACKWARD);
pffft_zreorder(mFft.get(), fftTmp.data(), filter, PFFFT_BACKWARD);
filter += sFftLength;
}
}
Expand Down

0 comments on commit facad22

Please sign in to comment.