Browse Source

Fix memory alignment for buffers used by pffft

Signed-off-by: falkTX <falktx@falktx.com>
pull/1936/head
falkTX 3 years ago
parent
commit
1759a19569
Signed by: falkTX <falktx@falktx.com> GPG Key ID: CDBAA37ABC74FBA0
2 changed files with 8 additions and 8 deletions
  1. +4
    -4
      include/dsp/fir.hpp
  2. +4
    -4
      src/dsp/minblep.cpp

+ 4
- 4
include/dsp/fir.hpp View File

@@ -42,16 +42,16 @@ struct RealTimeConvolver {
RealTimeConvolver(size_t blockSize) {
this->blockSize = blockSize;
pffft = pffft_new_setup(blockSize * 2, PFFFT_REAL);
outputTail = new float[blockSize];
outputTail = (float*) pffft_aligned_malloc(sizeof(float) * blockSize);
std::memset(outputTail, 0, blockSize * sizeof(float));
tmpBlock = new float[blockSize * 2];
tmpBlock = (float*) pffft_aligned_malloc(sizeof(float) * blockSize * 2);
std::memset(tmpBlock, 0, blockSize * 2 * sizeof(float));
}

~RealTimeConvolver() {
setKernel(NULL, 0);
delete[] outputTail;
delete[] tmpBlock;
pffft_aligned_free(outputTail);
pffft_aligned_free(tmpBlock);
pffft_destroy_setup(pffft);
}



+ 4
- 4
src/dsp/minblep.cpp View File

@@ -10,7 +10,7 @@ namespace dsp {
void minBlepImpulse(int z, int o, float* output) {
// Symmetric sinc array with `z` zero-crossings on each side
int n = 2 * z * o;
float* x = new float[n];
float* x = (float*) pffft_aligned_malloc(sizeof(float) * n);
for (int i = 0; i < n; i++) {
float p = math::rescale((float) i, 0.f, (float)(n - 1), (float) - z, (float) z);
x[i] = sinc(p);
@@ -20,7 +20,7 @@ void minBlepImpulse(int z, int o, float* output) {
blackmanHarrisWindow(x, n);

// Real cepstrum
float* fx = new float[2 * n];
float* fx = (float*) pffft_aligned_malloc(sizeof(float) * 2 * n);
// Valgrind complains that the array is uninitialized for some reason, unless we clear it.
std::memset(fx, 0, sizeof(float) * 2 * n);
RealFFT rfft(n);
@@ -75,8 +75,8 @@ void minBlepImpulse(int z, int o, float* output) {
std::memcpy(output, x, n * sizeof(float));

// Cleanup
delete[] x;
delete[] fx;
pffft_aligned_free(x);
pffft_aligned_free(fx);
}




Loading…
Cancel
Save