]> git.sesse.net Git - kdenlive/blobdiff - src/audioscopes/audiospectrum.h
Audio Spectrum: Different Window functions added (Rectangle, Triangle, and Hamming)
[kdenlive] / src / audioscopes / audiospectrum.h
index 94e0a3217812ef4cc238704e6656ad3bf50b6707..61a738317901e4ff056940123a507f9617661b99 100644 (file)
@@ -1,29 +1,45 @@
+/***************************************************************************
+ *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
+ *   This file is part of kdenlive. See www.kdenlive.org.                  *
+ *                                                                         *
+ *   This program is free software; you can redistribute it and/or modify  *
+ *   it under the terms of the GNU General Public License as published by  *
+ *   the Free Software Foundation; either version 2 of the License, or     *
+ *   (at your option) any later version.                                   *
+ ***************************************************************************/
+
 #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"
 
 class AudioSpectrum_UI;
-
 class AudioSpectrum : public AbstractAudioScopeWidget {
     Q_OBJECT
 
 public:
-    AudioSpectrum(Monitor *projMonitor, Monitor *clipMonitor, QWidget *parent = 0);
+    AudioSpectrum(QWidget *parent = 0);
     ~AudioSpectrum();
 
     // Implemented virtual methods
     QString widgetName() const;
 
+    static const QString directions[]; // Mainly for debug output
+    enum RescaleDirection { North, Northeast, East, Southeast };
+    enum RescaleDimension { Min_dB, Max_dB, Max_Hz };
+
+
 protected:
     ///// Implemented methods /////
     QRect scopeRect();
     QImage renderHUD(uint accelerationFactor);
-    QImage renderScope(uint accelerationFactor, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples);
+    QImage renderAudioScope(uint accelerationFactor, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples);
     QImage renderBackground(uint accelerationFactor);
     bool isHUDDependingOnInput() const;
     bool isScopeDependingOnInput() const;
@@ -31,13 +47,48 @@ protected:
     virtual void readConfig();
     void writeConfig();
 
+    void mouseMoveEvent(QMouseEvent *event);
+    void mousePressEvent(QMouseEvent *event);
+    void mouseReleaseEvent(QMouseEvent *event);
+
 private:
     Ui::AudioSpectrum_UI *ui;
     kiss_fftr_cfg m_cfg;
+    QHash<QString, QVector<float> > m_windowFunctions;
+
+    QAction *m_aLockHz;
+
+    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 */
+    uint m_freqMax;
+
+
+    ///// Movement detection /////
+    const int m_rescaleMinDist;
+    const float m_rescaleVerticalThreshold;
+
+    bool m_rescaleActive;
+    bool m_rescalePropertiesLocked;
+    bool m_rescaleFirstRescaleDone;
+    short m_rescaleScale;
+    Qt::KeyboardModifiers m_rescaleModifiers;
+    AudioSpectrum::RescaleDirection m_rescaleClockDirection;
+    QPoint m_rescaleStartPoint;
+
+
 
-    QAction *m_aLin;
-    QAction *m_aLog;
-    QActionGroup *m_agScale;
+private slots:
+    void slotUpdateCfg();
 
 };