comparison rdf/RDFImporter.cpp @ 673:a1ae2c1f80ab

* Use note model when importing RDF types with "note" in them
author Chris Cannam
date Wed, 09 Mar 2011 11:48:01 +0000
parents b1dc68507e46
children b4a8d8221eaf
comparison
equal deleted inserted replaced
672:5f75414d85f6 673:a1ae2c1f80ab
212 .arg(m_uristring)); 212 .arg(m_uristring));
213 213
214 results = query.execute(); 214 results = query.execute();
215 } 215 }
216 216
217 for (int i = 0; i < results.size(); ++i) { 217 for (int i = 0; i < (int)results.size(); ++i) {
218 218
219 QString signal = results[i]["signal"].value; 219 QString signal = results[i]["signal"].value;
220 QString source = results[i]["source"].value; 220 QString source = results[i]["source"].value;
221 221
222 std::cerr << "NOTE: Seeking signal source \"" << source.toStdString() 222 std::cerr << "NOTE: Seeking signal source \"" << source.toStdString()
318 if (query.wasCancelled()) { 318 if (query.wasCancelled()) {
319 m_errorString = "Query cancelled"; 319 m_errorString = "Query cancelled";
320 return; 320 return;
321 } 321 }
322 322
323 for (int i = 0; i < results.size(); ++i) { 323 for (int i = 0; i < (int)results.size(); ++i) {
324 324
325 QString feature = results[i]["feature"].value; 325 QString feature = results[i]["feature"].value;
326 QString type = results[i]["feature_signal_type"].value; 326 QString type = results[i]["feature_signal_type"].value;
327 QString value = results[i]["value"].value; 327 QString value = results[i]["value"].value;
328 328
697 // Map from timeline uri to event type to dimensionality to 697 // Map from timeline uri to event type to dimensionality to
698 // presence of duration to model ptr. Whee! 698 // presence of duration to model ptr. Whee!
699 std::map<QString, std::map<QString, std::map<int, std::map<bool, Model *> > > > 699 std::map<QString, std::map<QString, std::map<int, std::map<bool, Model *> > > >
700 modelMap; 700 modelMap;
701 701
702 for (int i = 0; i < results.size(); ++i) { 702 for (int i = 0; i < (int)results.size(); ++i) {
703 703
704 if (i % 4 == 0) { 704 if (i % 4 == 0) {
705 if (reporter) reporter->setProgress(i/4); 705 if (reporter) reporter->setProgress(i/4);
706 } 706 }
707 707
716 bool haveTime = false; 716 bool haveTime = false;
717 bool haveDuration = false; 717 bool haveDuration = false;
718 718
719 QString label = ""; 719 QString label = "";
720 bool text = (type.contains("Text") || type.contains("text")); // Ha, ha 720 bool text = (type.contains("Text") || type.contains("text")); // Ha, ha
721 bool note = (type.contains("Note") || type.contains("note")); // Guffaw
721 722
722 if (text) { 723 if (text) {
723 label = SimpleSPARQLQuery::singleResultQuery 724 label = SimpleSPARQLQuery::singleResultQuery
724 (s, textQueryString.arg(thinguri), "label").value; 725 (s, textQueryString.arg(thinguri), "label").value;
725 } 726 }
815 model = new NoteModel(m_sampleRate, 1, false); 816 model = new NoteModel(m_sampleRate, 1, false);
816 } 817 }
817 818
818 } else { // haveDuration 819 } else { // haveDuration
819 820
820 if (dimensions == 1 || dimensions == 2) { 821 if (note || (dimensions > 2)) {
822
823 model = new NoteModel(m_sampleRate, 1, false);
824
825 } else {
821 826
822 // If our units are frequency or midi pitch, we 827 // If our units are frequency or midi pitch, we
823 // should be using a note model... hm 828 // should be using a note model... hm
824 829
825 model = new RegionModel(m_sampleRate, 1, false); 830 model = new RegionModel(m_sampleRate, 1, false);
826
827 } else {
828
829 // We don't have a three-dimensional sparse model,
830 // so use a note model. We do have some logic (in
831 // extractStructure below) for guessing whether
832 // this should after all have been a dense model,
833 // but it's hard to apply it because we don't have
834 // all the necessary timing data yet... hmm
835
836 model = new NoteModel(m_sampleRate, 1, false);
837 } 831 }
838 } 832 }
839 833
840 model->setRDFTypeURI(type); 834 model->setRDFTypeURI(type);
841 835