Skip to content

Commit

Permalink
Revert "Merge pull request mixxxdj#11162 from daschuer/waveformscale"
Browse files Browse the repository at this point in the history
This reverts commit cfcd265, reversing
changes made to c8fb3bb.
  • Loading branch information
napaalm committed Mar 23, 2023
1 parent 09e6b56 commit efc66e2
Show file tree
Hide file tree
Showing 23 changed files with 158 additions and 234 deletions.
2 changes: 1 addition & 1 deletion src/track/track.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -772,7 +772,7 @@ QString Track::getURL() const {
return m_record.getUrl();
}

const ConstWaveformPointer& Track::getWaveform() const {
ConstWaveformPointer Track::getWaveform() const {
return m_waveform;
}

Expand Down
2 changes: 1 addition & 1 deletion src/track/track.h
Original file line number Diff line number Diff line change
Expand Up @@ -214,7 +214,7 @@ class Track : public QObject {
/// any metadata in file tags. Otherwise just the title (even if it is empty).
QString getTitleInfo() const;

const ConstWaveformPointer& getWaveform() const;
ConstWaveformPointer getWaveform() const;
void setWaveform(ConstWaveformPointer pWaveform);

ConstWaveformPointer getWaveformSummary() const;
Expand Down
50 changes: 24 additions & 26 deletions src/waveform/renderers/glslwaveformrenderersignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,14 +78,18 @@ bool GLSLWaveformRendererSignal::loadShaders() {
}

bool GLSLWaveformRendererSignal::loadTexture() {
TrackPointer trackInfo = m_waveformRenderer->getTrackInfo();
ConstWaveformPointer waveform;
int dataSize = 0;
const WaveformData* data = nullptr;

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform) {
dataSize = pWaveform->getDataSize();
if (dataSize > 1) {
data = pWaveform->data();
if (trackInfo) {
waveform = trackInfo->getWaveform();
if (waveform) {
dataSize = waveform->getDataSize();
if (dataSize > 1) {
data = waveform->data();
}
}
}

Expand All @@ -110,11 +114,11 @@ bool GLSLWaveformRendererSignal::loadTexture() {
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST);
glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST);

if (pWaveform != nullptr && data != nullptr) {
if (waveform != nullptr && data != nullptr) {
// Waveform ensures that getTextureSize is a multiple of
// getTextureStride so there is no rounding here.
int textureWidth = pWaveform->getTextureStride();
int textureHeight = pWaveform->getTextureSize() / pWaveform->getTextureStride();
int textureWidth = waveform->getTextureStride();
int textureHeight = waveform->getTextureSize() / waveform->getTextureStride();

glTexImage2D(GL_TEXTURE_2D, 0, GL_RGBA, textureWidth, textureHeight, 0,
GL_RGBA, GL_UNSIGNED_BYTE, data);
Expand Down Expand Up @@ -218,7 +222,7 @@ void GLSLWaveformRendererSignal::onSetTrack() {

slotWaveformUpdated();

const TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}
Expand Down Expand Up @@ -252,39 +256,34 @@ void GLSLWaveformRendererSignal::slotWaveformUpdated() {
}

void GLSLWaveformRendererSignal::draw(QPainter* painter, QPaintEvent* /*event*/) {
ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer trackInfo = m_waveformRenderer->getTrackInfo();
if (!trackInfo) {
return;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = trackInfo->getWaveform();
if (waveform.isNull()) {
return;
}

int dataSize = pWaveform->getDataSize();
int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return;
}

maybeInitializeGL();

// save the GL state set for QPainter
painter->beginNativePainting();

// NOTE(vRince): completion can change during loadTexture
// do not remove currenCompletion temp variable !
const int currentCompletion = pWaveform->getCompletion();
const int currentCompletion = waveform->getCompletion();
if (m_textureRenderedWaveformCompletion < currentCompletion) {
loadTexture();
m_textureRenderedWaveformCompletion = currentCompletion;
Expand All @@ -295,10 +294,9 @@ void GLSLWaveformRendererSignal::draw(QPainter* painter, QPaintEvent* /*event*/)
getGains(&allGain, &lowGain, &midGain, &highGain);

const auto firstVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getFirstDisplayedPosition() * trackSamples /
audioVisualRatio / 2.0);
m_waveformRenderer->getFirstDisplayedPosition() * dataSize / 2.0);
const auto lastVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getLastDisplayedPosition() * trackSamples / audioVisualRatio / 2.0);
m_waveformRenderer->getLastDisplayedPosition() * dataSize / 2.0);

// const int firstIndex = int(firstVisualIndex+0.5);
// firstVisualIndex = firstIndex - firstIndex%2;
Expand Down Expand Up @@ -331,8 +329,8 @@ void GLSLWaveformRendererSignal::draw(QPainter* painter, QPaintEvent* /*event*/)
m_frameShaderProgram->setUniformValue("framebufferSize", QVector2D(
m_framebuffer->width(), m_framebuffer->height()));
m_frameShaderProgram->setUniformValue("waveformLength", dataSize);
m_frameShaderProgram->setUniformValue("textureSize", pWaveform->getTextureSize());
m_frameShaderProgram->setUniformValue("textureStride", pWaveform->getTextureStride());
m_frameShaderProgram->setUniformValue("textureSize", waveform->getTextureSize());
m_frameShaderProgram->setUniformValue("textureStride", waveform->getTextureStride());

m_frameShaderProgram->setUniformValue("firstVisualIndex", firstVisualIndex);
m_frameShaderProgram->setUniformValue("lastVisualIndex", lastVisualIndex);
Expand Down
23 changes: 8 additions & 15 deletions src/waveform/renderers/glvsynctestrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,35 +34,28 @@ void GLVSyncTestRenderer::draw(QPainter* painter, QPaintEvent* /*event*/) {

timer.start();

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}

const int dataSize = pWaveform->getDataSize();
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return;
}

double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() *
trackSamples / audioVisualRatio;
double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() *
trackSamples / audioVisualRatio;
double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() * dataSize;
double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() * dataSize;

const int firstIndex = int(firstVisualIndex + 0.5);
firstVisualIndex = firstIndex - firstIndex % 2;
Expand Down
21 changes: 8 additions & 13 deletions src/waveform/renderers/glwaveformrendererfilteredsignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -25,35 +25,30 @@ void GLWaveformRendererFilteredSignal::onSetup(const QDomNode& /*node*/) {
void GLWaveformRendererFilteredSignal::draw(QPainter* painter, QPaintEvent* /*event*/) {
maybeInitializeGL();

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}

const int dataSize = pWaveform->getDataSize();
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return;
}

auto firstVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getFirstDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getFirstDisplayedPosition() * dataSize);
auto lastVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getLastDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getLastDisplayedPosition() * dataSize);
const auto lineWidth = static_cast<GLfloat>(
1.0 / m_waveformRenderer->getVisualSamplePerPixel() + 1);

Expand Down
21 changes: 8 additions & 13 deletions src/waveform/renderers/glwaveformrendererrgb.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,30 @@ void GLWaveformRendererRGB::onSetup(const QDomNode& /* node */) {
void GLWaveformRendererRGB::draw(QPainter* painter, QPaintEvent* /*event*/) {
maybeInitializeGL();

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}

const int dataSize = pWaveform->getDataSize();
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return;
}

auto firstVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getFirstDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getFirstDisplayedPosition() * dataSize);
auto lastVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getLastDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getLastDisplayedPosition() * dataSize);
const auto lineWidth = static_cast<GLfloat>(
(1.0 / m_waveformRenderer->getVisualSamplePerPixel()) + 1.5);

Expand Down
21 changes: 8 additions & 13 deletions src/waveform/renderers/glwaveformrenderersimplesignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,35 +27,30 @@ inline void setPoint(QPointF& point, qreal x, qreal y) {
void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*event*/) {
maybeInitializeGL();

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}

const int dataSize = pWaveform->getDataSize();
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return;
}

auto firstVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getFirstDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getFirstDisplayedPosition() * dataSize);
auto lastVisualIndex = static_cast<GLfloat>(
m_waveformRenderer->getLastDisplayedPosition() * trackSamples / audioVisualRatio);
m_waveformRenderer->getLastDisplayedPosition() * dataSize);
const auto lineWidth = static_cast<GLfloat>(
1.0 / m_waveformRenderer->getVisualSamplePerPixel() + 1);

Expand Down
13 changes: 9 additions & 4 deletions src/waveform/renderers/qtvsynctestrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -33,17 +33,22 @@ void QtVSyncTestRenderer::draw(QPainter* pPainter, QPaintEvent* /*event*/) {

timer.start();

ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return;
}

const int dataSize = pWaveform->getDataSize();
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return;
}

const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return;
}
Expand Down
25 changes: 8 additions & 17 deletions src/waveform/renderers/qtwaveformrendererfilteredsignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -97,37 +97,28 @@ inline void setPoint(QPointF& point, qreal x, qreal y) {
int QtWaveformRendererFilteredSignal::buildPolygon() {
// We have to check the track is present because it might have been unloaded
// between the call to draw and the call to buildPolygon
ConstWaveformPointer pWaveform = m_waveformRenderer->getWaveform();
if (pWaveform.isNull()) {
TrackPointer pTrack = m_waveformRenderer->getTrackInfo();
if (!pTrack) {
return 0;
}

const double audioVisualRatio = pWaveform->getAudioVisualRatio();
if (audioVisualRatio <= 0) {
ConstWaveformPointer waveform = pTrack->getWaveform();
if (waveform.isNull()) {
return 0;
}

const int dataSize = pWaveform->getDataSize();
const int dataSize = waveform->getDataSize();
if (dataSize <= 1) {
return 0;
}

const WaveformData* data = pWaveform->data();
const WaveformData* data = waveform->data();
if (data == nullptr) {
return 0;
}

const int trackSamples = m_waveformRenderer->getTrackSamples();
if (trackSamples <= 0) {
return 0;
}

const double firstVisualIndex =
m_waveformRenderer->getFirstDisplayedPosition() * trackSamples /
audioVisualRatio;
const double lastVisualIndex =
m_waveformRenderer->getLastDisplayedPosition() * trackSamples /
audioVisualRatio;
const double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() * dataSize;
const double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() * dataSize;

m_polygon[0].clear();
m_polygon[1].clear();
Expand Down
Loading

0 comments on commit efc66e2

Please sign in to comment.