changeset 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
files widgets/LevelPanWidget.cpp
diffstat 1 files changed, 24 insertions(+), 13 deletions(-) [+]
line wrap: on
line diff
--- a/widgets/LevelPanWidget.cpp	Fri Jun 22 17:51:47 2018 +0100
+++ b/widgets/LevelPanWidget.cpp	Mon Jun 25 14:16:16 2018 +0100
@@ -146,7 +146,6 @@
         }
         update();
     }
-    SVCERR << "setLevel: level " << level << " -> notch " << m_notch << " (which converts back to level " << getLevel() << ")" << endl;
 }
 
 float
@@ -490,24 +489,36 @@
 
     if (monitoring) {
         paint.setPen(Qt::NoPen);
+
         for (int pan = -maxPan; pan <= maxPan; ++pan) {
-            float audioPan = panToAudioPan(pan);
-            float audioLevel;
-            if (audioPan < 0.f) {
-                audioLevel = m_monitorLeft + m_monitorRight * (1.f + audioPan);
-            } else {
-                audioLevel = m_monitorRight + m_monitorLeft * (1.f - audioPan);
-            }
+            float rprop = float(pan - (-maxPan)) / float(maxPan * 2);
+            float lprop = float(maxPan - pan) / float(maxPan * 2);
+            float audioLevel =
+                lprop * m_monitorLeft * m_monitorLeft +
+                rprop * m_monitorRight * m_monitorRight;
             int notchHere = audioLevelToNotch(audioLevel);
+
             for (int notch = 1; notch <= notchHere; notch += 2) {
+                
                 paint.setBrush(notchToColour(notch));
                 QRectF clr = cellLightRect(rect, (notch-1)/2, pan);
-                double adj = thinLineWidth(rect)/2;
-                clr = clr.adjusted(adj, adj, -adj, -adj);
+//                double adj = thinLineWidth(rect)/2;
+//                clr = clr.adjusted(adj, adj, -adj, -adj);
+                paint.drawRoundedRect(clr, radius, radius);
+
                 if (notch + 2 > notchHere && notchHere % 2 != 0) {
-                    paint.drawPie(clr, 180 * 16, 180 * 16);
-                } else {
-                    paint.drawEllipse(clr);
+                    paint.save();
+                    paint.setBrush(columnBackground);
+                    paint.drawRoundedRect(QRectF(clr.x(),
+                                                 clr.y()-0.5,
+                                                 clr.width(),
+                                                 clr.height()/4 + thin),
+                                          radius, radius);
+                    paint.drawRect(QRectF(clr.x(),
+                                          clr.y() + clr.height()/4 - thin,
+                                          clr.width(),
+                                          clr.height()/4 + thin));
+                    paint.restore();
                 }
             }
         }