From 5a3eb9f10863abeea248adb2acf5df44a2b0a048 Mon Sep 17 00:00:00 2001 From: Vasile Vilvoiu Date: Mon, 19 Jul 2021 20:46:56 +0300 Subject: Move normalization from ValueMap to FFT class. --- src/fft.cpp | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) (limited to 'src/fft.cpp') diff --git a/src/fft.cpp b/src/fft.cpp index 8f94986..2802346 100644 --- a/src/fft.cpp +++ b/src/fft.cpp @@ -104,6 +104,11 @@ FFT::Compute(const ComplexWindow& input) (void *) this->out_, lhl * sizeof(fftw_complex)); + /* fftw does not normalize; divide by the window size */ + for (auto& v : output) { + v /= (double)output.size(); + } + return output; } @@ -231,4 +236,4 @@ FFT::Crop(const RealWindow& input, double rate, double fmin, double fmax) /* return corresponding subvector */ return RealWindow(input.begin() + i_fmin, input.begin() + i_fmax); -} \ No newline at end of file +} -- cgit v1.2.3