]> git.sesse.net Git - kdenlive/blob - src/scopes/audioscopes/abstractaudioscopewidget.cpp
Fix includes
[kdenlive] / src / scopes / audioscopes / abstractaudioscopewidget.cpp
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 #include "abstractaudioscopewidget.h"
12 #include "renderer.h"
13 #include "monitor.h"
14
15
16 // Uncomment for debugging
17 //#define DEBUG_AASW
18
19 #ifdef DEBUG_AASW
20 #include <QDebug>
21 #endif
22
23 AbstractAudioScopeWidget::AbstractAudioScopeWidget(bool trackMouse, QWidget *parent) :
24     AbstractScopeWidget(trackMouse, parent),
25     m_freq(0),
26     m_nChannels(0),
27     m_nSamples(0),
28     m_audioFrame(),
29     m_newData(0)
30 {
31 }
32
33 void AbstractAudioScopeWidget::slotReceiveAudio(const QVector<int16_t>& sampleData, int freq, int num_channels, int num_samples)
34 {
35 #ifdef DEBUG_AASW
36     qDebug() << "Received audio for " << widgetName() << ".";
37 #endif
38     m_audioFrame = sampleData;
39     m_freq = freq;
40     m_nChannels = num_channels;
41     m_nSamples = num_samples;
42
43     m_newData.fetchAndAddAcquire(1);
44
45     AbstractScopeWidget::slotRenderZoneUpdated();
46 }
47
48 AbstractAudioScopeWidget::~AbstractAudioScopeWidget()
49 {
50 }
51
52 QImage AbstractAudioScopeWidget::renderScope(uint accelerationFactor)
53 {
54     const int newData = m_newData.fetchAndStoreAcquire(0);
55
56     return renderAudioScope(accelerationFactor, m_audioFrame, m_freq, m_nChannels, m_nSamples, newData);
57 }
58
59 #ifdef DEBUG_AASW
60 #undef DEBUG_AASW
61 #endif
62
63 #include "abstractaudioscopewidget.moc"