changeset 1391:c39f2d439d59 spectrogramparam

Toward highlighting peaks on spectrum
author Chris Cannam
date Tue, 13 Nov 2018 15:16:48 +0000
parents 3c99083a4d83
children 900bed394f5a
files layer/FlexiNoteLayer.cpp layer/Layer.h layer/NoteLayer.cpp layer/RegionLayer.cpp layer/SpectrumLayer.cpp layer/TimeInstantLayer.cpp layer/TimeRulerLayer.cpp layer/TimeValueLayer.cpp view/Pane.cpp
diffstat 9 files changed, 28 insertions(+), 9 deletions(-) [+]
line wrap: on
line diff
--- a/layer/FlexiNoteLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/FlexiNoteLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -439,7 +439,7 @@
     }
 
     if (!usePoints.empty()) {
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
         int px = v->getXForFrame(usePoints.begin()->frame);
         if ((px > x && px - x > fuzz) ||
             (px < x && x - px > fuzz + 1)) {
--- a/layer/Layer.h	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/Layer.h	Tue Nov 13 15:16:48 2018 +0000
@@ -414,6 +414,12 @@
 
     virtual PlayParameters *getPlayParameters();
 
+    /**
+     * True if this layer will need to place text labels when it is
+     * painted. The view will take into account how many layers are
+     * requesting this, and will provide a distinct y-coord to each
+     * layer on request via View::getTextLabelHeight().
+     */
     virtual bool needsTextLabelHeight() const { return false; }
 
     /**
--- a/layer/NoteLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/NoteLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -421,7 +421,7 @@
     }
 
     if (!usePoints.empty()) {
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
         int px = v->getXForFrame(usePoints.begin()->frame);
         if ((px > x && px - x > fuzz) ||
             (px < x && x - px > fuzz + 1)) {
--- a/layer/RegionLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/RegionLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -335,7 +335,7 @@
     }
 
     if (!usePoints.empty()) {
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
         int px = v->getXForFrame(usePoints.begin()->frame);
         if ((px > x && px - x > fuzz) ||
             (px < x && x - px > fuzz + 1)) {
--- a/layer/SpectrumLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/SpectrumLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -709,6 +709,11 @@
     int xorigin = getVerticalScaleWidth(v, false, paint) + 1;
     int scaleHeight = getHorizontalScaleHeight(v, paint);
 
+    QPoint localPos;
+    bool shouldIlluminate = v->shouldIlluminateLocalFeatures(this, localPos);
+
+    cerr << "shouldIlluminate = " << shouldIlluminate << ", localPos = " << localPos.x() << "," << localPos.y() << endl;
+    
     if (fft && m_showPeaks) {
 
         // draw peak lines
@@ -738,6 +743,8 @@
 
         int px = -1;
 
+        int fuzz = ViewManager::scalePixelSize(2);
+        
         for (FFTModel::PeakSet::iterator i = peaks.begin();
              i != peaks.end(); ++i) {
 
@@ -746,7 +753,7 @@
             if (x == px) {
                 continue;
             }
-
+            
             int bin = i->first;
             
 //            cerr << "bin = " << bin << ", thresh = " << thresh << ", value = " << fft->getMagnitudeAt(col, bin) << endl;
@@ -754,6 +761,12 @@
             double value = fft->getValueAt(col, bin);
             if (value < thresh) continue;
             if (bin < cs) value *= curve[bin];
+
+            bool highlightThis = false;
+            if (std::abs(localPos.x() - x) <= fuzz) {
+                highlightThis = true;
+                cerr << "should highlight this one (at " << x << ")" << endl;
+            }
             
             double norm = 0.f;
             // don't need return value, need norm:            
--- a/layer/TimeInstantLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/TimeInstantLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -191,7 +191,7 @@
     }
 
     if (!usePoints.empty()) {
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
         int px = v->getXForFrame(usePoints.begin()->frame);
         if ((px > x && px - x > fuzz) ||
             (px < x && x - px > fuzz + 1)) {
--- a/layer/TimeRulerLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/TimeRulerLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -113,7 +113,7 @@
             dr = abs(v->getXForFrame(right) - x);
         }
 
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
 
         if (dl >= 0 && dr >= 0) {
             if (dl < dr) {
--- a/layer/TimeValueLayer.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/layer/TimeValueLayer.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -565,7 +565,7 @@
     }
 
     if (!usePoints.empty()) {
-        int fuzz = 2;
+        int fuzz = ViewManager::scalePixelSize(2);
         int px = v->getXForFrame(usePoints.begin()->frame);
         if ((px > x && px - x > fuzz) ||
             (px < x && x - px > fuzz + 3)) {
--- a/view/Pane.cpp	Tue Nov 13 14:48:42 2018 +0000
+++ b/view/Pane.cpp	Tue Nov 13 15:16:48 2018 +0000
@@ -300,8 +300,8 @@
 
 bool
 Pane::shouldIlluminateLocalSelection(QPoint &pos,
-                     bool &closeToLeft,
-                     bool &closeToRight) const
+                                     bool &closeToLeft,
+                                     bool &closeToRight) const
 {
     if (m_identifyFeatures &&
         m_manager &&