Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use HSV renderer for track's waveform overview #15

Closed
wants to merge 1 commit into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
61 changes: 36 additions & 25 deletions mixxx/src/widget/woverview.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -295,38 +295,49 @@ bool WOverview::drawNextPixmapPart() {
QPainter painter(m_pWaveformSourceImage);
painter.translate(0.0,(double)m_pWaveformSourceImage->height()/2.0);

QColor lowColor = m_signalColors.getLowColor();
QPen lowColorPen(QBrush(lowColor), 1);
// Get HSV of low color
double h,s,v;
m_signalColors.getLowColor().getHsvF(&h,&s,&v);

QColor midColor = m_signalColors.getMidColor();
QPen midColorPen(QBrush(midColor), 1);
QColor color;
float lo, hi, total;

QColor highColor = m_signalColors.getHighColor();
QPen highColorPen(QBrush(highColor), 1);
unsigned char maxLow[2] = {0, 0};
unsigned char maxHigh[2] = {0, 0};
unsigned char maxMid[2] = {0, 0};
unsigned char maxAll[2] = {0, 0};

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
unsigned char lowNeg = m_pWaveform->getLow(currentCompletion);
unsigned char lowPos = m_pWaveform->getLow(currentCompletion+1);
if (lowPos || lowNeg) {
painter.setPen(lowColorPen);
painter.drawLine(QPoint(currentCompletion / 2, -lowNeg),
QPoint(currentCompletion / 2, lowPos));
}
}
maxAll[0] = m_pWaveform->getAll(currentCompletion);
maxAll[1] = m_pWaveform->getAll(currentCompletion+1);
if (maxAll[0] || maxAll[1]) {
maxLow[0] = m_pWaveform->getLow(currentCompletion);
maxLow[1] = m_pWaveform->getLow(currentCompletion+1);
maxMid[0] = m_pWaveform->getMid(currentCompletion);
maxMid[1] = m_pWaveform->getMid(currentCompletion+1);
maxHigh[0] = m_pWaveform->getHigh(currentCompletion);
maxHigh[1] = m_pWaveform->getHigh(currentCompletion+1);

total = (maxLow[0] + maxLow[1] + maxMid[0] + maxMid[1] + maxHigh[0] + maxHigh[1]) * 1.2;

// prevent division by zero
if( total > 0 )
{
// Normalize low and high (mid not need, because it not change the color)
lo = (maxLow[0] + maxLow[1]) / total;
hi = (maxHigh[0] + maxHigh[1]) / total;
}
else
lo = hi = 0.0;

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
painter.setPen(midColorPen);
painter.drawLine(QPoint(currentCompletion / 2, - m_pWaveform->getMid(currentCompletion)),
QPoint(currentCompletion / 2, m_pWaveform->getMid(currentCompletion+1)));
}
// Set color
color.setHsvF(h, 1.0-hi, 1.0-lo);

for (currentCompletion = m_actualCompletion;
currentCompletion < nextCompletion; currentCompletion += 2) {
painter.setPen(highColorPen);
painter.drawLine(QPoint(currentCompletion / 2, - m_pWaveform->getHigh(currentCompletion)),
QPoint(currentCompletion / 2, m_pWaveform->getHigh(currentCompletion+1)));
painter.setPen(color);
painter.drawLine(QPoint(currentCompletion / 2, -maxAll[0]),
QPoint(currentCompletion / 2, maxAll[1]));
}
}

//evaluate waveform ratio peak
Expand Down