1 /*
2     SPDX-FileCopyrightText: 2010 Simon Andreas Eugster <simon.eu@gmail.com>
3     This file is part of kdenlive. See www.kdenlive.org.
4 
5 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
6 */
7 
8 #ifndef ABSTRACTAUDIOSCOPEWIDGET_H
9 #define ABSTRACTAUDIOSCOPEWIDGET_H
10 
11 #include <QWidget>
12 
13 #include <cstdint>
14 
15 #include "../../definitions.h"
16 #include "../abstractscopewidget.h"
17 
18 class Render;
19 
20 /**
21  * @brief Abstract class for scopes analyzing audio samples.
22  */
23 class AbstractAudioScopeWidget : public AbstractScopeWidget
24 {
25     Q_OBJECT
26 public:
27     explicit AbstractAudioScopeWidget(bool trackMouse = false, QWidget *parent = nullptr);
28     ~AbstractAudioScopeWidget() override;
29 
30 public slots:
31     void slotReceiveAudio(const audioShortVector &sampleData, int freq, int num_channels, int num_samples);
32 
33 protected:
34     /** @brief This is just a wrapper function, subclasses can use renderAudioScope. */
35     QImage renderScope(uint accelerationFactor) override;
36 
37     ///// Unimplemented Methods /////
38     /** @brief Scope renderer. Must emit signalScopeRenderingFinished()
39         when calculation has finished, to allow multi-threading.
40         accelerationFactor hints how much faster than usual the calculation should be accomplished, if possible. */
41     virtual QImage renderAudioScope(uint accelerationFactor, const audioShortVector &audioFrame, const int freq, const int num_channels, const int num_samples,
42                                     const int newData) = 0;
43 
44     int m_freq{0};
45     int m_nChannels{0};
46     int m_nSamples{0};
47 
48 private:
49     audioShortVector m_audioFrame;
50     QAtomicInt m_newData;
51 };
52 
53 #endif // ABSTRACTAUDIOSCOPEWIDGET_H
54