# HG changeset patch # User Chris Cannam # Date 1479742388 0 # Node ID b5c88c448ca2bf7e5070177c7561ba15a929bd88 # Parent 236ecb2c07584a873b47049f42fa0b2668115edb# Parent 6796afa25c8847470e6c4634d4a38f974781b440 Merge from branch bqfft diff -r 236ecb2c0758 -r b5c88c448ca2 widgets/WindowShapePreview.cpp --- a/widgets/WindowShapePreview.cpp Thu Nov 17 17:47:10 2016 +0000 +++ b/widgets/WindowShapePreview.cpp Mon Nov 21 15:33:08 2016 +0000 @@ -22,10 +22,14 @@ #include #include -#include "data/fft/FFTapi.h" +#include +#include +#include #include +using namespace std; + WindowShapePreview::WindowShapePreview(QWidget *parent) : QFrame(parent), @@ -126,24 +130,25 @@ int fftsize = 512; - float *input = (float *)fftf_malloc(fftsize * sizeof(float)); - fftf_complex *output = - (fftf_complex *)fftf_malloc(fftsize * sizeof(fftf_complex)); - fftf_plan plan = fftf_plan_dft_r2c_1d(fftsize, input, output, - FFTW_ESTIMATE); + breakfastquay::FFT fft(fftsize); + + vector input(fftsize); + vector> output(fftsize/2 + 1); + for (int i = 0; i < fftsize; ++i) input[i] = 0.f; for (int i = 0; i < step * 2; ++i) { input[fftsize/2 - step + i] = windower.getValue(i); } - - fftf_execute(plan); - fftf_destroy_plan(plan); + + fft.forwardInterleaved(input.data(), reinterpret_cast(output.data())); float maxdb = 0.f; float mindb = 0.f; bool first = true; for (int i = 0; i < fftsize/2; ++i) { - float power = output[i][0] * output[i][0] + output[i][1] * output[i][1]; + float power = + output[i].real() * output[i].real() + + output[i].imag() * output[i].imag(); float db = mindb; if (power > 0) { db = 20.f * log10f(power); @@ -176,7 +181,9 @@ // cerr << "maxdb = " << maxdb << ", mindb = " << mindb << ", maxval = " <