aboutsummaryrefslogtreecommitdiffstats
path: root/src/Resampler.cpp
diff options
context:
space:
mode:
authorMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-25 05:22:59 +0100
committerMatthias P. Braendli <matthias.braendli@mpb.li>2017-12-25 05:22:59 +0100
commitb855183f0878fac7f09017539b6a4504e00cf6e4 (patch)
treeb98753dac466735020681b7534787b2133fd204c /src/Resampler.cpp
parent8ff127f33a6173d612a00a7c3cb4dd25b9bffcd0 (diff)
parent515959935cd7c741db5aca5b20bfb7611749fbfb (diff)
downloaddabmod-b855183f0878fac7f09017539b6a4504e00cf6e4.tar.gz
dabmod-b855183f0878fac7f09017539b6a4504e00cf6e4.tar.bz2
dabmod-b855183f0878fac7f09017539b6a4504e00cf6e4.zip
Merge branch 'next' into outputRefactoring
Diffstat (limited to 'src/Resampler.cpp')
-rw-r--r--src/Resampler.cpp10
1 files changed, 7 insertions, 3 deletions
diff --git a/src/Resampler.cpp b/src/Resampler.cpp
index 8069a61..42951c5 100644
--- a/src/Resampler.cpp
+++ b/src/Resampler.cpp
@@ -27,10 +27,11 @@
#include "Resampler.h"
#include "PcDebug.h"
-#include <malloc.h>
+#include <string>
+#include <stdexcept>
+#include <stdlib.h>
#include <sys/types.h>
#include <string.h>
-#include <stdexcept>
#include <assert.h>
#define FFT_REAL(x) x[0]
@@ -81,7 +82,10 @@ Resampler::Resampler(size_t inputRate, size_t outputRate, size_t resolution) :
myFactor = 1.0f / myFftSizeOut * outputRate / inputRate;
}
- myWindow = (float*)memalign(16, myFftSizeIn * sizeof(float));
+ const int ret = posix_memalign((void**)(&myWindow), 16, myFftSizeIn * sizeof(float));
+ if (ret != 0) {
+ throw std::runtime_error("memory allocation failed: " + std::to_string(ret));
+ }
for (size_t i = 0; i < myFftSizeIn; ++i) {
myWindow[i] = (float)(0.5 * (1.0 - cos(2.0 * M_PI * i / (myFftSizeIn - 1))));
PDEBUG("Window[%zu] = %f\n", i, myWindow[i]);