Browse Source

alignedMalloc is unneeded.

tags/v1.0.0
Andrew Belt 5 years ago
parent
commit
0a71dde25e
2 changed files with 5 additions and 19 deletions
  1. +1
    -15
      include/dsp/fft.hpp
  2. +4
    -4
      src/dsp/minblep.cpp

+ 1
- 15
include/dsp/fft.hpp View File

@@ -7,24 +7,10 @@ namespace rack {
namespace dsp {


/** Allocates an array to 64-byte boundaries.
Must call alignedFree() on the buffer to free.
*/
template <typename T>
T *alignedMalloc(size_t len) {
return (T*) pffft_aligned_malloc(len * sizeof(T));
}

template <typename T>
void alignedFree(T *p) {
pffft_aligned_free(p);
}


/** Real-valued FFT context.
Wrapper for [PFFFT](https://bitbucket.org/jpommier/pffft/)
`length` must be a multiple of 32.
Buffers must be aligned to 16-byte boundaries, e.g. with alignedMalloc().
Buffers must be aligned to 16-byte boundaries. new[] and malloc() do this for you.
*/
struct RealFFT {
PFFFT_Setup *setup;


+ 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 = alignedMalloc<float>(n);
float *x = new 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 = alignedMalloc<float>(2*n);
float *fx = new float[2*n];
RealFFT rfft(n);
rfft.rfft(x, fx);
// fx = log(abs(fx))
@@ -73,8 +73,8 @@ void minBlepImpulse(int z, int o, float *output) {
std::memcpy(output, x, n * sizeof(float));

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




Loading…
Cancel
Save