changeset 589:a03aafaacb5a

* Make SV capable of importing the signal/audiofile structure now written out by Sonic Annotator
author Chris Cannam
date Thu, 14 May 2009 14:33:40 +0000
parents d04b8674b710
children 063da8955f65
files rdf/RDFImporter.cpp rdf/SimpleSPARQLQuery.h
diffstat 2 files changed, 25 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/rdf/RDFImporter.cpp	Wed May 13 13:30:08 2009 +0000
+++ b/rdf/RDFImporter.cpp	Thu May 14 14:33:40 2009 +0000
@@ -151,7 +151,7 @@
     getDataModelsAudio(models, reporter);
 
     if (m_sampleRate == 0) {
-        std::cerr << "RDFImporter::getDataModels: invalid sample rate" << std::endl;
+        std::cerr << "RDFImporter::getDataModels: invalid sample rate from audio" << std::endl;
         return models;
     }
 
@@ -182,18 +182,35 @@
 RDFImporterImpl::getDataModelsAudio(std::vector<Model *> &models,
                                     ProgressReporter *reporter)
 {
-    SimpleSPARQLQuery query = SimpleSPARQLQuery
+    SimpleSPARQLQuery query
         (SimpleSPARQLQuery::QueryFromSingleSource,
          QString
          (
              " PREFIX mo: <http://purl.org/ontology/mo/> "
              " SELECT ?signal ?source FROM <%1> "
-             " WHERE { ?signal a mo:Signal ; mo:available_as ?source } "
+             " WHERE { ?source a mo:AudioFile . "
+             "         ?signal a mo:Signal . "
+             "         ?source mo:encodes ?signal } "
              )
          .arg(m_uristring));
 
     SimpleSPARQLQuery::ResultList results = query.execute();
 
+    if (results.empty()) {
+
+        SimpleSPARQLQuery query2
+            (SimpleSPARQLQuery::QueryFromSingleSource,
+             QString
+             (
+                 " PREFIX mo: <http://purl.org/ontology/mo/> "
+                 " SELECT ?signal ?source FROM <%1> "
+                 " WHERE { ?signal a mo:Signal ; mo:available_as ?source } "
+                 )
+             .arg(m_uristring));
+        
+        results = query.execute();
+    }
+
     for (int i = 0; i < results.size(); ++i) {
 
         QString signal = results[i]["signal"].value;
@@ -254,7 +271,7 @@
         reporter->setMessage(RDFImporter::tr("Importing dense signal data from RDF..."));
     }
 
-    SimpleSPARQLQuery query = SimpleSPARQLQuery
+    SimpleSPARQLQuery query
         (SimpleSPARQLQuery::QueryFromSingleSource,
          QString
          (
--- a/rdf/SimpleSPARQLQuery.h	Wed May 13 13:30:08 2009 +0000
+++ b/rdf/SimpleSPARQLQuery.h	Thu May 14 14:33:40 2009 +0000
@@ -102,6 +102,10 @@
 protected:
     class Impl;
     Impl *m_impl;
+
+private:
+    SimpleSPARQLQuery(const SimpleSPARQLQuery &); // not provided
+    SimpleSPARQLQuery &operator=(const SimpleSPARQLQuery &); // not provided
 };
 
 #endif