]> git.sesse.net Git - kdenlive/blobdiff - src/audioscopes/audiospectrum.h
Audio Spectrum: Moved FFT calculation to FFTTools for re-use
[kdenlive] / src / audioscopes / audiospectrum.h
index 3e714895ee8cedb991b2ddee479dade1b9d0a543..e3e2498ece4a19e5ef553a79addda77b22e5efb2 100644 (file)
@@ -8,17 +8,25 @@
  *   (at your option) any later version.                                   *
  ***************************************************************************/
 
+/**
+   Displays a spectral power distribution of audio samples.
+   The frequency distribution is calculated by means of a Fast Fourier Transformation.
+   For more information see Wikipedia:FFT and the code comments.
+*/
+
 #ifndef AUDIOSPECTRUM_H
 #define AUDIOSPECTRUM_H
 
 #include <QtCore>
+#include <QVector>
+#include <QHash>
 
 #include "abstractaudioscopewidget.h"
 #include "ui_audiospectrum_ui.h"
 #include "tools/kiss_fftr.h"
+#include "ffttools.h"
 
 class AudioSpectrum_UI;
-
 class AudioSpectrum : public AbstractAudioScopeWidget {
     Q_OBJECT
 
@@ -52,23 +60,29 @@ protected:
 
 private:
     Ui::AudioSpectrum_UI *ui;
-    kiss_fftr_cfg m_cfg;
 
-    QAction *m_aLockHz;
-    QAction *m_aLin;
-    QAction *m_aLog;
-    QActionGroup *m_agScale;
+    QAction *m_aResetHz;
+
+    FFTTools m_fftTools;
 
-    QSize m_distance;
+    /** Contains the plot only; m_scopeRect contains text and widgets as well */
+    QRect m_innerScopeRect;
 
     /** Lower bound for the dB value to display */
     int m_dBmin;
     /** Upper bound (max: 0) */
     int m_dBmax;
 
-    /** Maximum frequency (depends on the sampling rate)
-        Stored for the HUD painter */
+    /** Maximum frequency (limited by the sampling rate if determined automatically).
+        Stored for the painters. */
     uint m_freqMax;
+    /** The user has chosen a custom frequency. */
+    bool m_customFreq;
+
+
+    /** Returns a signature for a kiss_fft configuration
+        used as a hash in the cache */
+    static const QString cfgSignature(const int size);
 
 
     ///// Movement detection /////
@@ -86,7 +100,7 @@ private:
 
 
 private slots:
-    void slotUpdateCfg();
+    void slotResetMaxFreq();
 
 };