abstractaudioscopewidget.cpp 1.83 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11
/***************************************************************************
 *   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.                                   *
 ***************************************************************************/

#include "abstractaudioscopewidget.h"
Vincent PINON's avatar
Vincent PINON committed
12

13
#include "renderer.h"
Till Theato's avatar
Till Theato committed
14
#include "monitor/monitor.h"
15 16


Simon Eugster's avatar
Simon Eugster committed
17 18 19 20 21 22 23
// Uncomment for debugging
//#define DEBUG_AASW

#ifdef DEBUG_AASW
#include <QDebug>
#endif

24
AbstractAudioScopeWidget::AbstractAudioScopeWidget(bool trackMouse, QWidget *parent) :
25
    AbstractScopeWidget(trackMouse, parent),
Simon Eugster's avatar
Simon Eugster committed
26 27 28 29 30
    m_freq(0),
    m_nChannels(0),
    m_nSamples(0),
    m_audioFrame(),
    m_newData(0)
31 32 33
{
}

Vincent PINON's avatar
Vincent PINON committed
34
void AbstractAudioScopeWidget::slotReceiveAudio(const QVector<qint16>& sampleData, int freq, int num_channels, int num_samples)
35
{
Simon Eugster's avatar
Simon Eugster committed
36
#ifdef DEBUG_AASW
37
    qDebug() << "Received audio for " << widgetName() << '.';
Simon Eugster's avatar
Simon Eugster committed
38
#endif
Simon Eugster's avatar
Simon Eugster committed
39 40 41 42
    m_audioFrame = sampleData;
    m_freq = freq;
    m_nChannels = num_channels;
    m_nSamples = num_samples;
Simon Eugster's avatar
Simon Eugster committed
43 44 45

    m_newData.fetchAndAddAcquire(1);

46
    AbstractScopeWidget::slotRenderZoneUpdated();
47 48
}

Laurent Montel's avatar
Laurent Montel committed
49 50 51
AbstractAudioScopeWidget::~AbstractAudioScopeWidget()
{
}
52

53
QImage AbstractAudioScopeWidget::renderScope(uint accelerationFactor)
54
{
Laurent Montel's avatar
Laurent Montel committed
55
    const int newData = m_newData.fetchAndStoreAcquire(0);
Simon Eugster's avatar
Simon Eugster committed
56 57

    return renderAudioScope(accelerationFactor, m_audioFrame, m_freq, m_nChannels, m_nSamples, newData);
58
}
Simon Eugster's avatar
Simon Eugster committed
59 60 61 62

#ifdef DEBUG_AASW
#undef DEBUG_AASW
#endif
Laurent Montel's avatar
Laurent Montel committed
63

64