ref: 3c6f5846c9649b270115758f3566462f7474ac13
parent: e3e8e9d285fcd014bff0648c5ff3b4a2d76d7961
author: Paul Brossier <piem@piem.org>
date: Thu Aug 20 09:15:54 EDT 2015
src/spectral/fft.c: if Ooura is used, make sure the fft size is a power of two
--- a/src/spectral/fft.c
+++ b/src/spectral/fft.c
@@ -167,6 +167,11 @@
s->fftSetup = vDSP_create_fftsetupD(s->log2fftsize, FFT_RADIX2);
#endif
#else // using OOURA
+ if (aubio_is_power_of_two(winsize) != 1) {
+ AUBIO_ERR("fft: can only create with sizes power of two,"
+ " requested %d\n", winsize);
+ return NULL;
+ }
s->winsize = winsize;
s->fft_size = winsize / 2 + 1;
s->compspec = new_fvec(winsize);
--- a/tests/src/spectral/test-fft.c
+++ b/tests/src/spectral/test-fft.c
@@ -2,6 +2,7 @@
int main (void)
{
+ int return_code = 0;
uint_t i, n_iters = 100; // number of iterations
uint_t win_s = 500; // window size
fvec_t * in = new_fvec (win_s); // input buffer
@@ -10,6 +11,11 @@
// create fft object
aubio_fft_t * fft = new_aubio_fft(win_s);
+ if (!fft) {
+ return_code = 1;
+ goto beach;
+ }
+
// fill input with some data
in->data[0] = 1;
in->data[1] = 2;
@@ -33,9 +39,10 @@
// cleam up
//fvec_print(out);
del_aubio_fft(fft);
+beach:
del_fvec(in);
del_cvec(fftgrain);
del_fvec(out);
aubio_cleanup();
- return 0;
+ return return_code;
}