1 /*
2  * Copyright (c) 2016-2017 Meltytech, LLC
3  * Author: Brian Matherly <code@brianmatherly.com>
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 3 of the License, or
8  * (at your option) any later version.
9  *
10  * This program is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
13  * GNU General Public License for more details.
14  *
15  * You should have received a copy of the GNU General Public License
16  * along with this program.  If not, see <http://www.gnu.org/licenses/>.
17  */
18 
19 #ifndef AUDIOLOUDNESSSCOPEWIDGET_H
20 #define AUDIOLOUDNESSSCOPEWIDGET_H
21 
22 #include "scopewidget.h"
23 #include <QMutex>
24 #include <QImage>
25 #include <QVector>
26 #include <MltFilter.h>
27 
28 class QQuickWidget;
29 class QLabel;
30 class QTimer;
31 
32 class AudioLoudnessScopeWidget Q_DECL_FINAL : public ScopeWidget
33 {
34     Q_OBJECT
35 
36 public:
37     explicit AudioLoudnessScopeWidget();
38     ~AudioLoudnessScopeWidget();
39     QString getTitle() Q_DECL_OVERRIDE;
40     void setOrientation(Qt::Orientation orientation) Q_DECL_OVERRIDE;
41     void setOrientation(Qt::Orientation orientation, bool force);
42 
43 protected:
44     bool event(QEvent *event) Q_DECL_OVERRIDE;
45 
46 private slots:
47     void resetQview();
48     void onResetButtonClicked();
49     void onIntegratedToggled(bool checked);
50     void onShorttermToggled(bool checked);
51     void onMomentaryToggled(bool checked);
52     void onRangeToggled(bool checked);
53     void onPeakToggled(bool checked);
54     void onTruePeakToggled(bool checked);
55     void updateMeters(void);
56 
57 private:
58     // Functions run in scope thread.
59     void refreshScope(const QSize& size, bool full) Q_DECL_OVERRIDE;
60 
61     // Members accessed by scope thread.
62     Mlt::Filter* m_loudnessFilter;
63     double m_peak;
64     double m_true_peak;
65     bool m_newData;
66 
67     // Members accessed by GUI thread.
68     Qt::Orientation m_orientation;
69     QQuickWidget* m_qview;
70     QLabel* m_timeLabel;
71     QTimer* m_timer;
72 };
73 
74 #endif // AUDIOLOUDNESSSCOPEWIDGET_H
75