Skip to content

Commit

Permalink
fix: exclude stem sample for QML waveform
Browse files Browse the repository at this point in the history
  • Loading branch information
acolombier committed Sep 15, 2024
1 parent f464f7b commit 4cd65ab
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 2 deletions.
21 changes: 19 additions & 2 deletions src/qml/qmlplayerproxy.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -216,8 +216,25 @@ void QmlPlayerProxy::slotWaveformChanged() {
}
const int textureWidth = pWaveform->getTextureStride();
const int textureHeight = pWaveform->getTextureSize() / pWaveform->getTextureStride();
const uchar* data = reinterpret_cast<const uchar*>(pWaveform->data());
m_waveformTexture = QImage(data, textureWidth, textureHeight, QImage::Format_RGBA8888);

const WaveformData* data = pWaveform->data();
// Make a copy of the waveform data, stripping the stems portion. Note that the datasize is
// different from the texture size -- we want the full texture size so the upload works. See
// m_data in waveform/waveform.h.
if (m_waveformData.size() == 0 ||
static_cast<int>(m_waveformData.size()) !=
pWaveform->getTextureSize()) {
m_waveformData.resize(pWaveform->getTextureSize());
}
for (int i = 0; i < pWaveform->getDataSize(); i++) {
m_waveformData[i] = data[i].filtered;
}

m_waveformTexture =
QImage(reinterpret_cast<const uchar*>(m_waveformData.data()),
textureWidth,
textureHeight,
QImage::Format_RGBA8888);
DEBUG_ASSERT(!m_waveformTexture.isNull());
emit waveformTextureChanged();
}
Expand Down
2 changes: 2 additions & 0 deletions src/qml/qmlplayerproxy.h
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
#include "qml/qmlstemsmodel.h"
#include "track/cueinfo.h"
#include "track/track.h"
#include "waveform/waveform.h"

namespace mixxx {
namespace qml {
Expand Down Expand Up @@ -151,6 +152,7 @@ class QmlPlayerProxy : public QObject {
void waveformTextureStrideChanged();

private:
std::vector<WaveformFilteredData> m_waveformData;
QImage m_waveformTexture;
QPointer<BaseTrackPlayer> m_pTrackPlayer;
TrackPointer m_pCurrentTrack;
Expand Down

0 comments on commit 4cd65ab

Please sign in to comment.