Mercurial > hg > sonic-annotator
comparison runner/JAMSFeatureWriter.cpp @ 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 | d0be35a305cc |
comparison
equal
deleted
inserted
replaced
161:4b19d824a213 | 162:447230267c0d |
---|---|
19 using Vamp::Plugin; | 19 using Vamp::Plugin; |
20 using Vamp::PluginBase; | 20 using Vamp::PluginBase; |
21 | 21 |
22 #include "base/Exceptions.h" | 22 #include "base/Exceptions.h" |
23 #include "rdf/PluginRDFIndexer.h" | 23 #include "rdf/PluginRDFIndexer.h" |
24 | |
25 #include "version.h" | |
24 | 26 |
25 JAMSFeatureWriter::JAMSFeatureWriter() : | 27 JAMSFeatureWriter::JAMSFeatureWriter() : |
26 FileFeatureWriter(SupportOneFilePerTrackTransform | | 28 FileFeatureWriter(SupportOneFilePerTrackTransform | |
27 SupportOneFilePerTrack | | 29 SupportOneFilePerTrack | |
28 SupportOneFileTotal | | 30 SupportOneFileTotal | |
72 | 74 |
73 void | 75 void |
74 JAMSFeatureWriter::setTrackMetadata(QString trackId, TrackMetadata metadata) | 76 JAMSFeatureWriter::setTrackMetadata(QString trackId, TrackMetadata metadata) |
75 { | 77 { |
76 QString json | 78 QString json |
77 ("\n\"file_metadata\":\n" | 79 ("\n\"file_metadata\": {\n" |
78 " { \"artist\": \"%1\",\n" | 80 " \"artist\": \"%1\",\n" |
79 " \"title\": \"%2\" },\n"); | 81 " \"title\": \"%2\"\n},\n"); |
80 m_metadata[trackId] = json.arg(metadata.maker).arg(metadata.title); | 82 m_metadata[trackId] = json.arg(metadata.maker).arg(metadata.title); |
81 cerr << "setTrackMetadata: metadata is: " << m_metadata[trackId] << endl; | 83 cerr << "setTrackMetadata: metadata is: " << m_metadata[trackId] << endl; |
82 } | 84 } |
83 | 85 |
84 static double | 86 static double |
116 | 118 |
117 if (m_data.find(tt) == m_data.end()) { | 119 if (m_data.find(tt) == m_data.end()) { |
118 | 120 |
119 identifyTask(transform); | 121 identifyTask(transform); |
120 | 122 |
121 QString json("\"%1\": [ "); | 123 QString json |
122 m_data[tt] = json.arg(getTaskKey(m_tasks[transformId])); | 124 ("\"%1\": [ { \n" |
125 " \"annotation_metadata\": {\n" | |
126 " \"annotation_tools\": \"Sonic Annotator v%2\",\n" | |
127 " \"data_source\": \"Automatic feature extraction\",\n" | |
128 " \"annotator\": { \"transform_id\": \"%3\" }\n" | |
129 " },\n" | |
130 " \"data\": ["); | |
131 m_data[tt] = json | |
132 .arg(getTaskKey(m_tasks[transformId])) | |
133 .arg(RUNNER_VERSION) | |
134 .arg(transformId); | |
123 justBegun = true; | 135 justBegun = true; |
124 } | 136 } |
125 | 137 |
126 QString d = m_data[tt]; | 138 QString d = m_data[tt]; |
127 | 139 |
204 if (startedStreams.find(sptr) != startedStreams.end()) { | 216 if (startedStreams.find(sptr) != startedStreams.end()) { |
205 *sptr << "," << endl; | 217 *sptr << "," << endl; |
206 } | 218 } |
207 startedStreams.insert(sptr); | 219 startedStreams.insert(sptr); |
208 | 220 |
209 *sptr << data << "\n ]"; | 221 *sptr << data << "\n ]\n} ]"; |
210 } | 222 } |
211 | 223 |
212 for (FileStreamMap::const_iterator i = m_streams.begin(); | 224 for (FileStreamMap::const_iterator i = m_streams.begin(); |
213 i != m_streams.end(); ++i) { | 225 i != m_streams.end(); ++i) { |
214 *(i->second) << endl << "}" << endl; | 226 *(i->second) << endl << "}" << endl; |