changeset 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 32d156c75df7
files data/model/Model.h rdf/RDFImporter.cpp transform/FeatureExtractionModelTransformer.cpp transform/FeatureExtractionModelTransformer.h
diffstat 4 files changed, 49 insertions(+), 0 deletions(-) [+]
line wrap: on
line diff
--- a/data/model/Model.h	Tue Feb 10 17:24:30 2009 +0000
+++ b/data/model/Model.h	Thu Feb 12 15:26:43 2009 +0000
@@ -195,6 +195,20 @@
      */
     virtual int getAlignmentCompletion() const;
 
+    /**
+     * Set the event, feature, or signal type URI for the features
+     * contained in this model, according to the Audio Features RDF
+     * ontology.
+     */
+    void setRDFTypeURI(QString uri) { m_typeUri = uri; }
+
+    /**
+     * Retrieve the event, feature, or signal type URI for the
+     * features contained in this model, if previously set with
+     * setRDFTypeURI.
+     */
+    QString getRDFTypeURI() const { return m_typeUri; }
+
     virtual void toXml(QTextStream &stream,
                        QString indent = "",
                        QString extraAttributes = "") const;
@@ -257,6 +271,7 @@
 
     Model *m_sourceModel;
     AlignmentModel *m_alignment;
+    QString m_typeUri;
     bool m_aboutToDelete;
 };
 
--- a/rdf/RDFImporter.cpp	Tue Feb 10 17:24:30 2009 +0000
+++ b/rdf/RDFImporter.cpp	Thu Feb 12 15:26:43 2009 +0000
@@ -337,6 +337,8 @@
 
             getDenseModelTitle(m, feature, type);
         
+            m->setRDFTypeURI(type);
+
             models.push_back(m);
 
         } else {
@@ -364,6 +366,8 @@
 
             getDenseModelTitle(m, feature, type);
         
+            m->setRDFTypeURI(type);
+
             models.push_back(m);
         }
     }
@@ -796,6 +800,8 @@
                 }
             }
 
+            model->setRDFTypeURI(type);
+
             if (m_audioModelMap.find(source) != m_audioModelMap.end()) {
                 std::cerr << "source model for " << model << " is " << m_audioModelMap[source] << std::endl;
                 model->setSourceModel(m_audioModelMap[source]);
--- 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);
--- a/transform/FeatureExtractionModelTransformer.h	Tue Feb 10 17:24:30 2009 +0000
+++ b/transform/FeatureExtractionModelTransformer.h	Thu Feb 12 15:26:43 2009 +0000
@@ -42,6 +42,8 @@
     Vamp::Plugin::OutputDescriptor *m_descriptor;
     int m_outputFeatureNo;
 
+    void createOutputModel();
+
     void addFeature(size_t blockFrame,
 		    const Vamp::Plugin::Feature &feature);