changeset 960:6f97f5149cb3

Display note name derived from value, when hovering over time-value feature if the scale unit is Hz
author Chris Cannam
date Tue, 12 May 2015 14:25:00 +0100
parents 2633a1d73e39
children b12cd1c2dad5
files layer/TimeValueLayer.cpp
diffstat 1 files changed, 20 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/layer/TimeValueLayer.cpp	Tue May 12 12:31:37 2015 +0100
+++ b/layer/TimeValueLayer.cpp	Tue May 12 14:25:00 2015 +0100
@@ -20,6 +20,7 @@
 #include "base/Profiler.h"
 #include "base/LogRange.h"
 #include "base/RangeMapper.h"
+#include "base/Pitch.h"
 #include "ColourDatabase.h"
 #include "view/View.h"
 
@@ -606,20 +607,31 @@
 
     RealTime rt = RealTime::frame2RealTime(useFrame, m_model->getSampleRate());
     
+    QString valueText;
+    float value = points.begin()->value;
+    QString unit = getScaleUnits();
+
+    if (unit == "Hz") {
+        valueText = tr("%1 Hz (%2, %3)")
+            .arg(value)
+            .arg(Pitch::getPitchLabelForFrequency(value))
+            .arg(Pitch::getPitchForFrequency(value));
+    } else if (unit != "") {
+        valueText = tr("%1 %2").arg(value).arg(unit);
+    } else {
+        valueText = tr("%1").arg(value);
+    }
+    
     QString text;
-    QString unit = getScaleUnits();
-    if (unit != "") unit = " " + unit;
 
     if (points.begin()->label == "") {
-	text = QString(tr("Time:\t%1\nValue:\t%2%3\nNo label"))
+	text = QString(tr("Time:\t%1\nValue:\t%2\nNo label"))
 	    .arg(rt.toText(true).c_str())
-	    .arg(points.begin()->value)
-            .arg(unit);
+	    .arg(valueText);
     } else {
-	text = QString(tr("Time:\t%1\nValue:\t%2%3\nLabel:\t%4"))
+	text = QString(tr("Time:\t%1\nValue:\t%2\nLabel:\t%4"))
 	    .arg(rt.toText(true).c_str())
-	    .arg(points.begin()->value)
-            .arg(unit)
+	    .arg(valueText)
 	    .arg(points.begin()->label);
     }