changeset 504:3376dc26dece

* Add FeatureWriter method to set basic track metadata; write it out from RDFFeatureWriter if present
author Chris Cannam
date Fri, 05 Dec 2008 11:09:44 +0000
parents 3176aade1a03
children db398832518b
files data/fileio/FileSource.cpp rdf/RDFFeatureWriter.cpp rdf/RDFFeatureWriter.h transform/FeatureWriter.h
diffstat 4 files changed, 43 insertions(+), 5 deletions(-) [+]
line wrap: on
line diff
--- a/data/fileio/FileSource.cpp	Fri Dec 05 09:40:42 2008 +0000
+++ b/data/fileio/FileSource.cpp	Fri Dec 05 11:09:44 2008 +0000
@@ -110,7 +110,9 @@
         emit ready();
     }
 
+#ifdef DEBUG_FILE_SOURCE
     std::cerr << "FileSource::FileSource(string) exiting" << std::endl;
+#endif
 }
 
 FileSource::FileSource(QUrl url, ProgressReporter *reporter) :
@@ -138,7 +140,9 @@
 
     init();
 
+#ifdef DEBUG_FILE_SOURCE
     std::cerr << "FileSource::FileSource(url) exiting" << std::endl;
+#endif
 }
 
 FileSource::FileSource(const FileSource &rf) :
@@ -188,7 +192,9 @@
 
     m_done = true;
 
+#ifdef DEBUG_FILE_SOURCE
     std::cerr << "FileSource::FileSource(copy ctor) exiting" << std::endl;
+#endif
 }
 
 FileSource::~FileSource()
--- a/rdf/RDFFeatureWriter.cpp	Fri Dec 05 09:40:42 2008 +0000
+++ b/rdf/RDFFeatureWriter.cpp	Fri Dec 05 11:09:44 2008 +0000
@@ -78,11 +78,21 @@
     }
 }
 
-void RDFFeatureWriter::write(QString trackId,
-                             const Transform &transform,
-                             const Plugin::OutputDescriptor& output,
-                             const Plugin::FeatureList& features,
-                             std::string summaryType)
+void
+RDFFeatureWriter::setTrackMetadata(QString trackId,
+                                   TrackMetadata metadata)
+{
+    std::cerr << "RDFFeatureWriter::setTrackMetadata: \""
+              << trackId.toStdString() << "\" -> \"" << metadata.title.toStdString() << "\",\"" << metadata.maker.toStdString() << "\"" << std::endl;
+    m_metadata[trackId] = metadata;
+}
+
+void
+RDFFeatureWriter::write(QString trackId,
+                        const Transform &transform,
+                        const Plugin::OutputDescriptor& output,
+                        const Plugin::FeatureList& features,
+                        std::string summaryType)
 {
     QString pluginId = transform.getPluginIdentifier();
 
@@ -170,6 +180,7 @@
     stream << "@prefix dc: <http://purl.org/dc/elements/1.1/> .\n"
            << "@prefix mo: <http://purl.org/ontology/mo/> .\n"
            << "@prefix af: <http://purl.org/ontology/af/> .\n"
+           << "@prefix foaf: <http://xmlns.com/foaf/0.1/> . \n"
            << "@prefix event: <http://purl.org/NET/c4dm/event.owl#> .\n"
            << "@prefix rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> .\n"
            << "@prefix rdfs: <http://www.w3.org/2000/01/rdf-schema#> .\n"
@@ -232,6 +243,16 @@
                << "> ;\n";
     }
 
+    if (m_metadata.find(trackId) != m_metadata.end()) {
+        TrackMetadata tm = m_metadata[trackId];
+        if (tm.title != "") {
+            stream << "    dc:title \"\"\"" << tm.title << "\"\"\" ;\n";
+        }
+        if (tm.maker != "") {
+            stream << "    dc:creator [ a mo:MusicArtist; foaf:name \"\"\"" << tm.maker << "\"\"\" ] ;\n";
+        }
+    }
+
     stream << "    mo:time [\n"
            << "        a tl:Interval ;\n"
            << "        tl:onTimeLine "
--- a/rdf/RDFFeatureWriter.h	Fri Dec 05 09:40:42 2008 +0000
+++ b/rdf/RDFFeatureWriter.h	Fri Dec 05 11:09:44 2008 +0000
@@ -47,6 +47,8 @@
     virtual ParameterList getSupportedParameters() const;
     virtual void setParameters(map<string, string> &params);
 
+    virtual void setTrackMetadata(QString trackid, TrackMetadata metadata);
+
     virtual void write(QString trackid,
                        const Transform &transform,
                        const Vamp::Plugin::OutputDescriptor &output,
@@ -59,6 +61,9 @@
     typedef map<QString, PluginRDFDescription> RDFDescriptionMap; // by plugin id
     RDFDescriptionMap m_rdfDescriptions;
 
+    typedef map<QString, TrackMetadata> TrackMetadataMap;
+    TrackMetadataMap m_metadata;
+
     void writePrefixes(QTextStream *);
     void writeSignalDescription(QTextStream *, QString);
     void writeLocalFeatureTypes(QTextStream *,
--- a/transform/FeatureWriter.h	Fri Dec 05 09:40:42 2008 +0000
+++ b/transform/FeatureWriter.h	Fri Dec 05 11:09:44 2008 +0000
@@ -53,6 +53,12 @@
         return;
     }
 
+    struct TrackMetadata {
+        QString title;
+        QString maker;
+    };
+    virtual void setTrackMetadata(QString trackid, TrackMetadata metadata) { }
+
     // may throw FailedToOpenFile or other exceptions
 
     virtual void write(QString trackid,