diff layer/SpectrogramLayer.cpp @ 279:47fe0352861e

* add pitch label to spectrogram harmonic cursor as well
author Chris Cannam
date Tue, 03 Jul 2007 18:56:27 +0000
parents a078aa2932cc
children 3c402c6052f6
line wrap: on
line diff
--- a/layer/SpectrogramLayer.cpp	Tue Jul 03 18:47:39 2007 +0000
+++ b/layer/SpectrogramLayer.cpp	Tue Jul 03 18:56:27 2007 +0000
@@ -2467,10 +2467,15 @@
     int sw = getVerticalScaleWidth(v, paint);
 
     QRect label(sw, cursorPos.y() - paint.fontMetrics().ascent() - 2,
-                paint.fontMetrics().width("123456 Hz") + sw + 2,
+                paint.fontMetrics().width("123456 Hz") + 2,
                 paint.fontMetrics().height());
     extents.push_back(label);
 
+    QRect pitch(sw, cursorPos.y() + 2,
+                paint.fontMetrics().width("C#10+50c") + 2,
+                paint.fontMetrics().height());
+    extents.push_back(pitch);
+
     return true;
 }
 
@@ -2493,7 +2498,21 @@
                        QString("%1 Hz").arg(fundamental),
                        View::OutlinedText);
 
-    //!!! and pitch label
+    if (Pitch::isFrequencyInMidiRange(fundamental)) {
+        QString pitchLabel = Pitch::getPitchLabelForFrequency(fundamental);
+        v->drawVisibleText(paint,
+                           sw + 2,
+                           cursorPos.y() + paint.fontMetrics().ascent() + 2,
+                           pitchLabel,
+                           View::OutlinedText);
+    }
+
+    /*!!!
+    long frame = getFrameForX(cursorPos.x());
+    RealTime rt = RealTime::frame2RealTime(frame, m_model->getSampleRate());
+    QString timeLabel = rt.toText(true).c_str();
+    ...
+    */
 
     int harmonic = 2;