File indexing completed on 2024-04-28 04:52:20

0001 /*
0002     SPDX-FileCopyrightText: 2010 Simon Andreas Eugster <simon.eu@gmail.com>
0003     This file is part of kdenlive. See www.kdenlive.org.
0004 
0005 SPDX-License-Identifier: GPL-3.0-only OR LicenseRef-KDE-Accepted-GPL
0006 */
0007 
0008 #include "abstractaudioscopewidget.h"
0009 
0010 #include "monitor/monitor.h"
0011 
0012 // Uncomment for debugging
0013 //#define DEBUG_AASW
0014 
0015 #ifdef DEBUG_AASW
0016 #include "kdenlive_debug.h"
0017 #endif
0018 
0019 AbstractAudioScopeWidget::AbstractAudioScopeWidget(bool trackMouse, QWidget *parent)
0020     : AbstractScopeWidget(trackMouse, parent)
0021     , m_audioFrame()
0022     , m_newData(0)
0023 {
0024 }
0025 
0026 void AbstractAudioScopeWidget::slotReceiveAudio(const audioShortVector &sampleData, int freq, int num_channels, int num_samples)
0027 {
0028 #ifdef DEBUG_AASW
0029     qCDebug(KDENLIVE_LOG) << "Received audio for " << widgetName() << '.';
0030 #endif
0031     m_audioFrame = sampleData;
0032     m_freq = freq;
0033     m_nChannels = num_channels;
0034     m_nSamples = num_samples;
0035 
0036     m_newData.fetchAndAddAcquire(1);
0037 
0038     AbstractScopeWidget::slotRenderZoneUpdated();
0039 }
0040 
0041 AbstractAudioScopeWidget::~AbstractAudioScopeWidget() = default;
0042 
0043 QImage AbstractAudioScopeWidget::renderScope(uint accelerationFactor)
0044 {
0045     const int newData = m_newData.fetchAndStoreAcquire(0);
0046 
0047     return renderAudioScope(accelerationFactor, m_audioFrame, m_freq, m_nChannels, m_nSamples, newData);
0048 }
0049 
0050 #ifdef DEBUG_AASW
0051 #undef DEBUG_AASW
0052 #endif