X-Git-Url: https://git.carlh.net/gitweb/?a=blobdiff_plain;f=gtk2_ardour%2Ffft.cc;h=a4e34bf2aafedbb56116c372772ef017c2320506;hb=549de1f298ad777febe201c6c50e2303a6ca0c4d;hp=f78a1e94ad2f1935313765c16e1e67f8bb452388;hpb=a75868c767dc5a74f4b7361a6255972bad7f7c61;p=ardour.git diff --git a/gtk2_ardour/fft.cc b/gtk2_ardour/fft.cc index f78a1e94ad..a4e34bf2aa 100644 --- a/gtk2_ardour/fft.cc +++ b/gtk2_ardour/fft.cc @@ -23,6 +23,8 @@ #include #include +using namespace GTKArdour; + FFT::FFT(uint32_t windowSize) : _window_size(windowSize), _data_size(_window_size/2), @@ -46,7 +48,7 @@ FFT::reset() { memset(_power_at_bin, 0, sizeof(float) * _data_size); memset(_phase_at_bin, 0, sizeof(float) * _data_size); - + _iterations = 0; } @@ -74,11 +76,11 @@ FFT::analyze(ARDOUR::Sample *input, WindowingType windowing_type) #define Re (_fftOutput[i]) #define Im (_fftOutput[_window_size-i]) - for (uint32_t i=1; i < _data_size - 1; i++) { + for (uint32_t i=1; i < _data_size - 1; i++) { power = (Re * Re) + (Im * Im); phase = atanf(Im / Re); - + if (Re < 0.0 && Im > 0.0) { phase += M_PI; } else if (Re < 0.0 && Im < 0.0) { @@ -96,7 +98,7 @@ void FFT::calculate() { if (_iterations > 1) { - for (uint32_t i=0; i < _data_size - 1; i++) { + for (uint32_t i=0; i < _data_size - 1; i++) { _power_at_bin[i] /= (float)_iterations; _phase_at_bin[i] /= (float)_iterations; } @@ -114,14 +116,14 @@ FFT::get_hann_window() _hann_window = (float *) malloc(sizeof(float) * _window_size); double sum = 0.0; - + for (uint32_t i=0; i < _window_size; i++) { _hann_window[i]=0.81f * ( 0.5f - (0.5f * (float) cos(2.0f * M_PI * (float)i / (float)(_window_size)))); sum += _hann_window[i]; } double isum = 1.0 / sum; - + for (uint32_t i=0; i < _window_size; i++) { _hann_window[i] *= isum; }