diff transform/FeatureExtractionModelTransformer.cpp @ 558:1d7ebc05157e

* Some fairly simplistic code to set up layer type properties based on RDF data about feature types (both when running transforms and when importing features from RDF files).
author Chris Cannam
date Thu, 12 Feb 2009 15:26:43 +0000
parents a40023bebd15
children 3bbac921b70a
line wrap: on
line diff
--- a/transform/FeatureExtractionModelTransformer.cpp	Tue Feb 10 17:24:30 2009 +0000
+++ b/transform/FeatureExtractionModelTransformer.cpp	Thu Feb 12 15:26:43 2009 +0000
@@ -30,6 +30,7 @@
 #include "data/model/RegionModel.h"
 #include "data/model/FFTModel.h"
 #include "data/model/WaveFileModel.h"
+#include "rdf/PluginRDFDescription.h"
 
 #include "TransformFactory.h"
 
@@ -167,9 +168,20 @@
 	return;
     }
 
+    createOutputModel();
+}
+
+void
+FeatureExtractionModelTransformer::createOutputModel()
+{
+    DenseTimeValueModel *input = getConformingInput();
+
 //    std::cerr << "FeatureExtractionModelTransformer: output sample type "
 //	      << m_descriptor->sampleType << std::endl;
 
+    PluginRDFDescription description(m_transform.getPluginIdentifier());
+    QString outputId = m_transform.getOutput();
+
     int binCount = 1;
     float minValue = 0.0, maxValue = 0.0;
     bool haveExtents = false;
@@ -228,6 +240,9 @@
 	m_output = new SparseOneDimensionalModel(modelRate, modelResolution,
 						 false);
 
+        QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
+        m_output->setRDFTypeURI(outputEventTypeURI);
+
     } else if ((preDurationPlugin && binCount > 1 &&
                 (m_descriptor->sampleType ==
                  Vamp::Plugin::OutputDescriptor::VariableSampleRate)) ||
@@ -294,6 +309,9 @@
             m_output = model;
         }
 
+        QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
+        m_output->setRDFTypeURI(outputEventTypeURI);
+
     } else if (binCount == 1 ||
                (m_descriptor->sampleType == 
                 Vamp::Plugin::OutputDescriptor::VariableSampleRate)) {
@@ -315,10 +333,15 @@
             model = new SparseTimeValueModel
                 (modelRate, modelResolution, false);
         }
+
+        Vamp::Plugin::OutputList outputs = m_plugin->getOutputDescriptors();
         model->setScaleUnits(outputs[m_outputFeatureNo].unit.c_str());
 
         m_output = model;
 
+        QString outputEventTypeURI = description.getOutputEventTypeURI(outputId);
+        m_output->setRDFTypeURI(outputEventTypeURI);
+
     } else {
 
         // Anything that is not a 1D, note, or interval model and that
@@ -340,6 +363,9 @@
 	}
         
         m_output = model;
+
+        QString outputSignalTypeURI = description.getOutputSignalTypeURI(outputId);
+        m_output->setRDFTypeURI(outputSignalTypeURI);
     }
 
     if (m_output) m_output->setSourceModel(input);