]> git.sesse.net Git - kdenlive/blob - src/audioscopes/audiospectrum.h
Audio Spectrum updated
[kdenlive] / src / audioscopes / audiospectrum.h
1 /***************************************************************************
2  *   Copyright (C) 2010 by Simon Andreas Eugster (simon.eu@gmail.com)      *
3  *   This file is part of kdenlive. See www.kdenlive.org.                  *
4  *                                                                         *
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  ***************************************************************************/
10
11 #ifndef AUDIOSPECTRUM_H
12 #define AUDIOSPECTRUM_H
13
14 #include <QtCore>
15
16 #include "abstractaudioscopewidget.h"
17 #include "ui_audiospectrum_ui.h"
18 #include "tools/kiss_fftr.h"
19
20 class AudioSpectrum_UI;
21
22 class AudioSpectrum : public AbstractAudioScopeWidget {
23     Q_OBJECT
24
25 public:
26     AudioSpectrum(QWidget *parent = 0);
27     ~AudioSpectrum();
28
29     // Implemented virtual methods
30     QString widgetName() const;
31
32     static const QString directions[]; // Mainly for debug output
33     enum RescaleDirection { North, Northeast, East, Southeast };
34     enum RescaleDimension { Min_dB, Max_dB, Max_Hz };
35
36
37 protected:
38     ///// Implemented methods /////
39     QRect scopeRect();
40     QImage renderHUD(uint accelerationFactor);
41     QImage renderAudioScope(uint accelerationFactor, const QVector<int16_t> audioFrame, const int freq, const int num_channels, const int num_samples);
42     QImage renderBackground(uint accelerationFactor);
43     bool isHUDDependingOnInput() const;
44     bool isScopeDependingOnInput() const;
45     bool isBackgroundDependingOnInput() const;
46     virtual void readConfig();
47     void writeConfig();
48
49     void mouseMoveEvent(QMouseEvent *event);
50     void mousePressEvent(QMouseEvent *event);
51     void mouseReleaseEvent(QMouseEvent *event);
52
53 private:
54     Ui::AudioSpectrum_UI *ui;
55     kiss_fftr_cfg m_cfg;
56
57     QAction *m_aLockHz;
58     QAction *m_aLin;
59     QAction *m_aLog;
60     QActionGroup *m_agScale;
61
62     QSize m_distance;
63
64     /** Lower bound for the dB value to display */
65     int m_dBmin;
66     /** Upper bound (max: 0) */
67     int m_dBmax;
68
69     /** Maximum frequency (depends on the sampling rate)
70         Stored for the HUD painter */
71     uint m_freqMax;
72
73
74     ///// Movement detection /////
75     const int m_rescaleMinDist;
76     const float m_rescaleVerticalThreshold;
77
78     bool m_rescaleActive;
79     bool m_rescalePropertiesLocked;
80     bool m_rescaleFirstRescaleDone;
81     short m_rescaleScale;
82     Qt::KeyboardModifiers m_rescaleModifiers;
83     AudioSpectrum::RescaleDirection m_rescaleClockDirection;
84     QPoint m_rescaleStartPoint;
85
86
87
88 private slots:
89     void slotUpdateCfg();
90
91 };
92
93 #endif // AUDIOSPECTRUM_H