changeset 162:447230267c0d jams

Add some metadata; and the data is nested more deeply than I thought
author Chris Cannam
date Wed, 15 Oct 2014 13:02:44 +0100
parents 4b19d824a213
children ddc47a055434
files runner/FeatureExtractionManager.cpp runner/JAMSFeatureWriter.cpp
diffstat 2 files changed, 19 insertions(+), 7 deletions(-) [+]
line wrap: on
line diff
--- a/runner/FeatureExtractionManager.cpp	Wed Oct 15 11:33:14 2014 +0100
+++ b/runner/FeatureExtractionManager.cpp	Wed Oct 15 13:02:44 2014 +0100
@@ -728,7 +728,7 @@
                 FeatureWriter::TrackMetadata m;
                 m.title = reader->getTitle();
                 m.maker = reader->getMaker();
-                if (m.title != "" && m.maker != "") {
+                if (m.title != "" || m.maker != "") {
                     writers[j]->setTrackMetadata(audioSource, m);
                 }
             }
--- a/runner/JAMSFeatureWriter.cpp	Wed Oct 15 11:33:14 2014 +0100
+++ b/runner/JAMSFeatureWriter.cpp	Wed Oct 15 13:02:44 2014 +0100
@@ -22,6 +22,8 @@
 #include "base/Exceptions.h"
 #include "rdf/PluginRDFIndexer.h"
 
+#include "version.h"
+
 JAMSFeatureWriter::JAMSFeatureWriter() :
     FileFeatureWriter(SupportOneFilePerTrackTransform |
                       SupportOneFilePerTrack |
@@ -74,9 +76,9 @@
 JAMSFeatureWriter::setTrackMetadata(QString trackId, TrackMetadata metadata)
 {
     QString json
-	("\n\"file_metadata\":\n"
-	 "  { \"artist\": \"%1\",\n"
-	 "    \"title\": \"%2\" },\n");
+	("\n\"file_metadata\": {\n"
+	 "  \"artist\": \"%1\",\n"
+	 "  \"title\": \"%2\"\n},\n");
     m_metadata[trackId] = json.arg(metadata.maker).arg(metadata.title);
     cerr << "setTrackMetadata: metadata is: " << m_metadata[trackId] << endl;
 }
@@ -118,8 +120,18 @@
 
 	identifyTask(transform);
 
-        QString json("\"%1\": [ ");
-        m_data[tt] = json.arg(getTaskKey(m_tasks[transformId]));
+        QString json
+            ("\"%1\": [ { \n"
+             "  \"annotation_metadata\": {\n"
+             "    \"annotation_tools\": \"Sonic Annotator v%2\",\n"
+             "    \"data_source\": \"Automatic feature extraction\",\n"
+             "    \"annotator\": { \"transform_id\": \"%3\" }\n"
+             "  },\n"
+             "  \"data\": [");
+        m_data[tt] = json
+            .arg(getTaskKey(m_tasks[transformId]))
+            .arg(RUNNER_VERSION)
+            .arg(transformId);
         justBegun = true;
     }
 
@@ -206,7 +218,7 @@
         }
         startedStreams.insert(sptr);
         
-        *sptr << data << "\n  ]";
+        *sptr << data << "\n  ]\n} ]";
     }
         
     for (FileStreamMap::const_iterator i = m_streams.begin();