changeset 24:6b794a2af3d9

* Add Chromagram plugin, and make a number of fixes to the dense 3d model and colour 3d plot class to accommodate it * Add pitch-conversion methods in base/Pitch * Commit previously overlooked Command.cpp
author Chris Cannam
date Wed, 01 Feb 2006 14:49:49 +0000
parents ca57f70b0e48
children dcdb21b62dbb
files layer/Colour3DPlotLayer.cpp layer/Colour3DPlotLayer.h layer/SpectrogramLayer.cpp
diffstat 3 files changed, 38 insertions(+), 8 deletions(-) [+]
line wrap: on
line diff
--- a/layer/Colour3DPlotLayer.cpp	Tue Jan 31 17:19:45 2006 +0000
+++ b/layer/Colour3DPlotLayer.cpp	Wed Feb 01 14:49:49 2006 +0000
@@ -158,6 +158,8 @@
 		//!!! divide-by-zero!
 		int pixel = int(((value - min) * 256) / (max - min));
 
+		if (pixel == 256) pixel = 255;
+
 		m_cache->setPixel(f / modelWindow, y, pixel);
 	    }
 	}
@@ -225,14 +227,18 @@
 
 	    if (sx >= 0 && sx < m_cache->width() &&
 		sy >= 0 && sy < m_cache->height()) {
-		int dv = m_cache->pixelIndex(sx, sy);
-		if (dv != 0 && paint.fontMetrics().height() < (h / sh)) {
-		    QString text = QString("%1").arg(dv);
-		    if (paint.fontMetrics().width(text) < w - 3) {
-			paint.setPen(Qt::white);
-			paint.drawText(rx0 + 2,
-				       ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(),
-				       QString("%1").arg(dv));
+		if (w > 10) {
+		    int dv = m_cache->pixelIndex(sx, sy);
+//		    if (dv != 0 && paint.fontMetrics().height() < (h / sh)) {
+		    if (paint.fontMetrics().height() < (h / sh)) {
+			float value = m_model->getBinValue(fx, sy);
+			QString text = QString("%1").arg(value); //dv);
+			if (paint.fontMetrics().width(text) < w - 3) {
+			    paint.setPen(Qt::white);
+			    paint.drawText(rx0 + 2,
+					   ry0 - h / sh - 1 + 2 + paint.fontMetrics().ascent(),
+					   QString("%1").arg(value));
+			}
 		    }
 		}
 	    }
@@ -266,6 +272,23 @@
 */
 }
 
+int
+Colour3DPlotLayer::getNearestFeatureFrame(int frame,
+					  size_t &resolution,
+					  bool snapRight) const
+{
+    if (!m_model) {
+	return Layer::getNearestFeatureFrame(frame, resolution, snapRight);
+    }
+
+    resolution = m_model->getWindowSize();
+    
+    int returnFrame = (frame / resolution) * resolution;
+    if (snapRight) returnFrame += resolution;
+    
+    return returnFrame;
+}
+
 #ifdef INCLUDE_MOCFILES
 #include "Colour3DPlotLayer.moc.cpp"
 #endif
--- a/layer/Colour3DPlotLayer.h	Tue Jan 31 17:19:45 2006 +0000
+++ b/layer/Colour3DPlotLayer.h	Wed Feb 01 14:49:49 2006 +0000
@@ -43,8 +43,14 @@
     virtual const Model *getModel() const { return m_model; }
     virtual void paint(QPainter &paint, QRect rect) const;
 
+    virtual int getNearestFeatureFrame(int frame, 
+				       size_t &resolution,
+				       bool snapRight = true) const;
+
     void setModel(const DenseThreeDimensionalModel *model);
 
+    virtual int getCompletion() const { return m_model->getCompletion(); }
+
 
 /*
     virtual PropertyList getProperties() const;
--- a/layer/SpectrogramLayer.cpp	Tue Jan 31 17:19:45 2006 +0000
+++ b/layer/SpectrogramLayer.cpp	Wed Feb 01 14:49:49 2006 +0000
@@ -13,6 +13,7 @@
 #include "base/Profiler.h"
 #include "base/AudioLevel.h"
 #include "base/Window.h"
+#include "base/Pitch.h"
 
 #include <QPainter>
 #include <QImage>