Mercurial > hg > svgui
comparison widgets/LevelPanWidget.cpp @ 1305:21342513c252
Slightly nicer pan handling, avoiding showing spurious >0dB peaks
author | Chris Cannam |
---|---|
date | Mon, 25 Jun 2018 14:16:16 +0100 |
parents | a575dae05fbf |
children | 5db672d6de4f |
comparison
equal
deleted
inserted
replaced
1304:a575dae05fbf | 1305:21342513c252 |
---|---|
144 if (fabsf(convertsTo - level) > 1e-5) { | 144 if (fabsf(convertsTo - level) > 1e-5) { |
145 emitLevelChanged(); | 145 emitLevelChanged(); |
146 } | 146 } |
147 update(); | 147 update(); |
148 } | 148 } |
149 SVCERR << "setLevel: level " << level << " -> notch " << m_notch << " (which converts back to level " << getLevel() << ")" << endl; | |
150 } | 149 } |
151 | 150 |
152 float | 151 float |
153 LevelPanWidget::getLevel() const | 152 LevelPanWidget::getLevel() const |
154 { | 153 { |
488 } | 487 } |
489 } | 488 } |
490 | 489 |
491 if (monitoring) { | 490 if (monitoring) { |
492 paint.setPen(Qt::NoPen); | 491 paint.setPen(Qt::NoPen); |
492 | |
493 for (int pan = -maxPan; pan <= maxPan; ++pan) { | 493 for (int pan = -maxPan; pan <= maxPan; ++pan) { |
494 float audioPan = panToAudioPan(pan); | 494 float rprop = float(pan - (-maxPan)) / float(maxPan * 2); |
495 float audioLevel; | 495 float lprop = float(maxPan - pan) / float(maxPan * 2); |
496 if (audioPan < 0.f) { | 496 float audioLevel = |
497 audioLevel = m_monitorLeft + m_monitorRight * (1.f + audioPan); | 497 lprop * m_monitorLeft * m_monitorLeft + |
498 } else { | 498 rprop * m_monitorRight * m_monitorRight; |
499 audioLevel = m_monitorRight + m_monitorLeft * (1.f - audioPan); | |
500 } | |
501 int notchHere = audioLevelToNotch(audioLevel); | 499 int notchHere = audioLevelToNotch(audioLevel); |
500 | |
502 for (int notch = 1; notch <= notchHere; notch += 2) { | 501 for (int notch = 1; notch <= notchHere; notch += 2) { |
502 | |
503 paint.setBrush(notchToColour(notch)); | 503 paint.setBrush(notchToColour(notch)); |
504 QRectF clr = cellLightRect(rect, (notch-1)/2, pan); | 504 QRectF clr = cellLightRect(rect, (notch-1)/2, pan); |
505 double adj = thinLineWidth(rect)/2; | 505 // double adj = thinLineWidth(rect)/2; |
506 clr = clr.adjusted(adj, adj, -adj, -adj); | 506 // clr = clr.adjusted(adj, adj, -adj, -adj); |
507 paint.drawRoundedRect(clr, radius, radius); | |
508 | |
507 if (notch + 2 > notchHere && notchHere % 2 != 0) { | 509 if (notch + 2 > notchHere && notchHere % 2 != 0) { |
508 paint.drawPie(clr, 180 * 16, 180 * 16); | 510 paint.save(); |
509 } else { | 511 paint.setBrush(columnBackground); |
510 paint.drawEllipse(clr); | 512 paint.drawRoundedRect(QRectF(clr.x(), |
513 clr.y()-0.5, | |
514 clr.width(), | |
515 clr.height()/4 + thin), | |
516 radius, radius); | |
517 paint.drawRect(QRectF(clr.x(), | |
518 clr.y() + clr.height()/4 - thin, | |
519 clr.width(), | |
520 clr.height()/4 + thin)); | |
521 paint.restore(); | |
511 } | 522 } |
512 } | 523 } |
513 } | 524 } |
514 } | 525 } |
515 } | 526 } |