1 /***************************************************************************
2 * Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com) *
3 * This file is part of kdenlive. See www.kdenlive.org. *
5 * This program is free software; you can redistribute it and/or modify *
6 * it under the terms of the GNU General Public License as published by *
7 * the Free Software Foundation; either version 2 of the License, or *
8 * (at your option) any later version. *
9 ***************************************************************************/
16 #include <tools/kiss_fftr.h>
24 enum WindowType { Window_Rect, Window_Triangle, Window_Hamming };
26 /** Creates a vector containing the factors for the selected window functions.
27 The last element in the vector (at position size+1) contains the area of
28 this window function compared to the rectangular window (e.g. for a triangular
29 window the factor will be 0.5).
30 Knowing this factor is important for the Fourier Transformation as the
31 values in the frequency domain will be scaled by this factor and need to be
32 re-scaled for proper dB display.
33 The additional parameter describes:
34 * Nothing for the Rectangular window
35 * The left and right start values for the Triangular window (i.e. ranges between param and 1;
37 * Nothing for the Hamming window
39 static const QVector<float> window(const WindowType windowType, const int size, const float param = 0);
41 static const QString windowSignature(const WindowType windowType, const int size, const float param = 0);
43 /** Returns a signature for a kiss_fft configuration
44 used as a hash in the cache */
45 static const QString cfgSignature(const int size);
47 /** Calculates the Fourier Tranformation of the input audio frame.
48 The resulting values will be given in relative dezibel: The maximum power is 0 dB, lower powers have
50 * audioFrame: Interleaved format with #numChannels channels
51 * freqSpectrum: Array pointer to write the data into
52 * windowSize must be divisible by 2,
53 * freqSpectrum has to be of size windowSize/2
54 For windowType and param see the FFTTools::window() function above.
56 void fftNormalized(const QVector<int16_t> audioFrame, const uint channel, const uint numChannels, float *freqSpectrum,
57 const WindowType windowType, const uint windowSize, const float param = 0);
60 QHash<QString, kiss_fftr_cfg> m_fftCfgs; // FFT cfg cache
61 QHash<QString, QVector<float> > m_windowFunctions; // Window function cache