diff layer/SpectrumLayer.cpp @ 592:a13aa5320221 sonification

Extends the audio feedback of the piano scale to the Spectrum layer (horizontal piano keyboard). Increase of the piano keyboard width (SpectrogramLayer) and height (SpectrumLayer) for layout purposes. A get method should be added to obtain the scale size parameter outside the layer class.
author mathieub <mathieu.barthet@eecs.qmul.ac.uk>
date Wed, 06 Jul 2011 18:05:42 +0100
parents 4806715f7a19
children c080d14ff414
line wrap: on
line diff
--- a/layer/SpectrumLayer.cpp	Fri Jun 24 16:42:48 2011 +0100
+++ b/layer/SpectrumLayer.cpp	Wed Jul 06 18:05:42 2011 +0100
@@ -25,7 +25,7 @@
 
 #include <QPainter>
 #include <QTextStream>
-
+#include <QMouseEvent>
 
 SpectrumLayer::SpectrumLayer() :
     m_originModel(0),
@@ -673,7 +673,9 @@
 
     int pkh = 0;
 //!!!    if (m_binScale == LogBins) {
-        pkh = 10;
+        //pkh = 10; //too small
+    pkh = 20;
+
 //!!!    }
 
     paint.save();
@@ -823,6 +825,17 @@
     paint.restore();
 }
 
+/*
+int
+SpectrumLayer::getHorizontalScaleHeight(View *v, QPainter &paint) const
+{
+    int h = v->height();
+    int pkh = 10;
+
+    return h - pkh - 1;
+}*/
+
+
 void
 SpectrumLayer::getBiasCurve(BiasCurve &curve) const
 {
@@ -860,4 +873,30 @@
     setShowPeaks(showPeaks);
 }
 
-    
+bool
+SpectrumLayer::scaleClicked(const View *v, QMouseEvent *e)
+{
+    std::cerr<< "Mouse click detected in the spectrum scale area: (" << e->x() << "," << e->y() << ")" << std::endl;
+
+    float freq;
+    QString unit;
+    float *centsOffsetReturn = 0;
+    float concertA = 0.0;
+    int midipitch;
+
+    if (getXScaleValue(v, e->x(), freq, unit)) {
+
+        midipitch = Pitch::getPitchForFrequency(freq,centsOffsetReturn,concertA);
+
+        std::cerr<< "Frequency: " << freq << " " << unit.toStdString() << " (midi pitch = " << midipitch << ")" << std::endl;
+
+        if ((midipitch>=0)&&(midipitch<127)) {
+            v->playExampleNote(midipitch);
+        }
+
+        return true;
+
+    } else {
+        return false;
+    }
+}