comparison rdf/RDFFeatureWriter.cpp @ 585:cbc884787a08

* If we have track metadata, write it out in a separate mo:Track associated with this audio file instead of incorrectly associating it with the Signal. Also, make the audio file encode the signal instead of having the signal "available_as" the audio file (apparently available_as is not in the domain of signals).
author Chris Cannam
date Fri, 08 May 2009 10:09:47 +0000
parents bf1f6d68a142
children 4ab8e8f7d7ed
comparison
equal deleted inserted replaced
584:bf1f6d68a142 585:cbc884787a08
250 uint64_t signalCount = m_count++; 250 uint64_t signalCount = m_count++;
251 251
252 if (m_trackSignalURIs.find(trackId) == m_trackSignalURIs.end()) { 252 if (m_trackSignalURIs.find(trackId) == m_trackSignalURIs.end()) {
253 m_trackSignalURIs[trackId] = QString(":signal_%1").arg(signalCount); 253 m_trackSignalURIs[trackId] = QString(":signal_%1").arg(signalCount);
254 } 254 }
255 255
256 if (m_suri != NULL) { 256 if (m_suri != NULL) {
257 m_trackSignalURIs[trackId] = "<" + m_suri + ">"; 257 m_trackSignalURIs[trackId] = "<" + m_suri + ">";
258 } 258 }
259 QString signalURI = m_trackSignalURIs[trackId]; 259 QString signalURI = m_trackSignalURIs[trackId];
260 260
261 if (m_trackTrackURIs.find(trackId) == m_trackTrackURIs.end()) {
262 m_trackTrackURIs[trackId] = QString(":track_%1").arg(signalCount);
263 }
264 QString trackURI = m_trackTrackURIs[trackId];
265
261 if (m_trackTimelineURIs.find(trackId) == m_trackTimelineURIs.end()) { 266 if (m_trackTimelineURIs.find(trackId) == m_trackTimelineURIs.end()) {
262 m_trackTimelineURIs[trackId] = QString(":signal_timeline_%1").arg(signalCount); 267 m_trackTimelineURIs[trackId] = QString(":signal_timeline_%1").arg(signalCount);
263 } 268 }
264 QString timelineURI = m_trackTimelineURIs[trackId]; 269 QString timelineURI = m_trackTimelineURIs[trackId];
265 270
266 if (trackId != "") {
267 stream << "\n<" << url.toEncoded().data() << "> a mo:AudioFile .\n\n";
268 }
269
270 stream << signalURI << " a mo:Signal ;\n";
271
272 if (trackId != "") {
273 stream << " mo:available_as <" << url.toEncoded().data()
274 << "> ;\n";
275 }
276
277 if (m_metadata.find(trackId) != m_metadata.end()) { 271 if (m_metadata.find(trackId) != m_metadata.end()) {
278 TrackMetadata tm = m_metadata[trackId]; 272 TrackMetadata tm = m_metadata[trackId];
279 if (tm.title != "") { 273 if (tm.title != "" || tm.maker != "") {
280 stream << " dc:title \"\"\"" << tm.title << "\"\"\" ;\n"; 274 // We only write a Track at all if we have some
281 } 275 // title/artist metadata to put in it. Otherwise we can't
282 if (tm.maker != "") { 276 // be sure that what we have is a Track, in the
283 stream << " foaf:maker [ a mo:MusicArtist; foaf:name \"\"\"" << tm.maker << "\"\"\" ] ;\n"; 277 // publication sense -- it may just be a fragment, a test
284 } 278 // file, whatever. Since we'd have no metadata to
285 } 279 // associate with our Track, the only effect of including
280 // a Track would be to assert that this was one, which is
281 // the one thing we wouldn't know...
282 stream << trackURI << " a mo:Track ";
283 if (tm.title != "") {
284 stream << ";\n dc:title \"\"\"" << tm.title << "\"\"\" ";
285 }
286 if (tm.maker != "") {
287 stream << ";\n foaf:maker [ a mo:MusicArtist; foaf:name \"\"\"" << tm.maker << "\"\"\" ] ";
288 }
289 if (trackId != "") {
290 stream << ";\n mo:available_as <" << url.toEncoded().data() << "> ";
291 }
292 stream << ".\n\n";
293 }
294 }
295
296 if (trackId != "") {
297 stream << "<" << url.toEncoded().data() << "> a mo:AudioFile ;\n";
298 stream << " mo:encodes " << signalURI << ".\n\n";
299 }
300
301 stream << signalURI << " a mo:Signal ;\n";
286 302
287 stream << " mo:time [\n" 303 stream << " mo:time [\n"
288 << " a tl:Interval ;\n" 304 << " a tl:Interval ;\n"
289 << " tl:onTimeLine " 305 << " tl:onTimeLine "
290 << timelineURI << "\n ] .\n\n"; 306 << timelineURI << "\n ] .\n\n";
307
308 stream << timelineURI << " a tl:Timeline .\n";
291 } 309 }
292 310
293 void 311 void
294 RDFFeatureWriter::writeLocalFeatureTypes(QTextStream *sptr, 312 RDFFeatureWriter::writeLocalFeatureTypes(QTextStream *sptr,
295 const Transform &transform, 313 const Transform &transform,