changeset 20:742e6882e187

* Refactor sparse models. Previously the 1D and time-value models duplicated a lot of code; now there is a base class (SparseModel) templated on the stored point type, and the subclasses define point types with the necessary characteristics. * Add NoteModel, a new SparseModel subclass. * Reorganise local feature description display. Instead of asking the layer to draw its own, just query it for a textual description and draw that in Pane. Greatly simplifies this part of the layer code. * Add local feature descriptions to colour 3D plot and waveform layers. * Add pitch in MIDI-pitch-and-cents to spectrogram layer. * Give AudioGenerator its own mutex to shorten lock times in CallbackPlaySource. * Minor adjustments to layers menu &c
author Chris Cannam
date Thu, 02 Feb 2006 16:10:19 +0000
parents a7ed14263fe4
children 5da86cc182bd
files base/Layer.h base/View.cpp base/ViewManager.cpp transform/FeatureExtractionPluginTransform.cpp transform/TransformFactory.cpp
diffstat 5 files changed, 49 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/base/Layer.h	Wed Feb 01 14:49:49 2006 +0000
+++ b/base/Layer.h	Thu Feb 02 16:10:19 2006 +0000
@@ -63,14 +63,8 @@
     virtual int getVerticalScaleWidth(QPainter &) const { return 0; }
     virtual void paintVerticalScale(QPainter &, QRect) const { }
 
-    //!!! I don't like these.  The layer should return a structured
-    //string-based description list and the pane should render it
-    //itself.
-
-    virtual QRect getFeatureDescriptionRect(QPainter &, QPoint) const {
-	return QRect(0, 0, 0, 0);
-    }
-    virtual void paintLocalFeatureDescription(QPainter &, QRect, QPoint) const {
+    virtual QString getFeatureDescription(QPoint &) const {
+	return "";
     }
 
     //!!! We also need a method (like the vertical scale method) for
--- a/base/View.cpp	Wed Feb 01 14:49:49 2006 +0000
+++ b/base/View.cpp	Thu Feb 02 16:10:19 2006 +0000
@@ -516,6 +516,12 @@
     m_playPointerFrame = f;
     if (!visible) return;
 
+    if (QApplication::keyboardModifiers() != Qt::NoModifier) {
+	std::cerr << "View::viewManagerPlaybackFrameChanged: modifiers == "
+		  << QApplication::keyboardModifiers()
+		  << std::endl;
+    }
+
     switch (m_followPlay) {
 
     case PlaybackScrollContinuous:
--- a/base/ViewManager.cpp	Wed Feb 01 14:49:49 2006 +0000
+++ b/base/ViewManager.cpp	Thu Feb 02 16:10:19 2006 +0000
@@ -25,7 +25,7 @@
     m_inProgressExclusive(true),
     m_toolMode(NavigateMode),
     m_playLoopMode(false),
-    m_playSelectionMode(true)
+    m_playSelectionMode(false)
 {
     connect(this, 
 	    SIGNAL(centreFrameChanged(void *, unsigned long, bool)),
--- a/transform/FeatureExtractionPluginTransform.cpp	Wed Feb 01 14:49:49 2006 +0000
+++ b/transform/FeatureExtractionPluginTransform.cpp	Thu Feb 02 16:10:19 2006 +0000
@@ -110,7 +110,8 @@
 
     if (valueCount == 0) {
 
-	m_output = new SparseOneDimensionalModel(modelRate, modelResolution);
+	m_output = new SparseOneDimensionalModel(modelRate, modelResolution,
+						 false);
 
     } else if (valueCount == 1 ||
 
@@ -125,6 +126,15 @@
 	
 	m_output = new DenseThreeDimensionalModel(modelRate, modelResolution,
 						  valueCount, false);
+
+	if (!m_descriptor->valueNames.empty()) {
+	    std::vector<QString> names;
+	    for (size_t i = 0; i < m_descriptor->valueNames.size(); ++i) {
+		names.push_back(m_descriptor->valueNames[i].c_str());
+	    }
+	    (dynamic_cast<DenseThreeDimensionalModel *>(m_output))
+		->setBinNames(names);
+	}
     }
 }
 
--- a/transform/TransformFactory.cpp	Wed Feb 01 14:49:49 2006 +0000
+++ b/transform/TransformFactory.cpp	Thu Feb 02 16:10:19 2006 +0000
@@ -58,35 +58,41 @@
 	FeatureExtractionPluginFactory *factory =
 	    FeatureExtractionPluginFactory::instanceFor(pluginId);
 
-	if (factory) {
-	    //!!! well, really we want to be able to query this without having to instantiate
+	if (!factory) {
+	    std::cerr << "WARNING: TransformFactory::populateTransforms: No feature extraction plugin factory for instance " << pluginId.toLocal8Bit().data() << std::endl;
+	    continue;
+	}
 
-	    FeatureExtractionPlugin *plugin = 
-		factory->instantiatePlugin(pluginId, 48000);
+	//!!! well, really we want to be able to query this without having to instantiate
 
-	    QString pluginDescription = plugin->getDescription().c_str();
+	FeatureExtractionPlugin *plugin = 
+	    factory->instantiatePlugin(pluginId, 48000);
 
-	    if (plugin) {
+	if (!plugin) {
+	    std::cerr << "WARNING: TransformFactory::populateTransforms: Failed to instantiate plugin " << pluginId.toLocal8Bit().data() << std::endl;
+	    continue;
+	}
+		
+	QString pluginDescription = plugin->getDescription().c_str();
+	FeatureExtractionPlugin::OutputList outputs =
+	    plugin->getOutputDescriptors();
 
-		FeatureExtractionPlugin::OutputList outputs =
-		    plugin->getOutputDescriptors();
+	for (size_t j = 0; j < outputs.size(); ++j) {
 
-		if (outputs.size() == 1) {
-		    m_transforms[QString("%1:%2")
-				 .arg(pluginId)
-				 .arg(outputs[0].name.c_str())]
-			= pluginDescription;
-		} else {
-		    for (size_t j = 0; j < outputs.size(); ++j) {
-			m_transforms[QString("%1:%2")
-				     .arg(pluginId)
-				     .arg(outputs[j].name.c_str())]
-			    = QString("%1: %2")
-			    .arg(pluginDescription)
-			    .arg(outputs[j].description.c_str());
-		    }
-		}
+	    QString transformName = QString("%1:%2")
+		    .arg(pluginId).arg(outputs[j].name.c_str());
+
+	    QString userDescription;
+
+	    if (outputs.size() == 1) {
+		userDescription = pluginDescription;
+	    } else {
+		userDescription = QString("%1: %2")
+		    .arg(pluginDescription)
+		    .arg(outputs[j].description.c_str());
 	    }
+
+	    m_transforms[transformName] = userDescription;
 	}
     }
 }