diff transform/TransformFactory.cpp @ 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 4563a72c1d8b
children bac8b14ab355
line wrap: on
line diff
--- 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;
 	}
     }
 }