Mercurial > hg > svcore
comparison rdf/RDFImporter.cpp @ 1040:a1cd5abcb38b cxx11
Introduce and use a samplerate type
author | Chris Cannam |
---|---|
date | Wed, 04 Mar 2015 12:01:04 +0000 |
parents | b14064bd1f97 |
children | b9faee02afa5 |
comparison
equal
deleted
inserted
replaced
1039:b14064bd1f97 | 1040:a1cd5abcb38b |
---|---|
48 using Dataquay::PropertyObject; | 48 using Dataquay::PropertyObject; |
49 | 49 |
50 class RDFImporterImpl | 50 class RDFImporterImpl |
51 { | 51 { |
52 public: | 52 public: |
53 RDFImporterImpl(QString url, int sampleRate); | 53 RDFImporterImpl(QString url, sv_samplerate_t sampleRate); |
54 virtual ~RDFImporterImpl(); | 54 virtual ~RDFImporterImpl(); |
55 | 55 |
56 void setSampleRate(int sampleRate) { m_sampleRate = sampleRate; } | 56 void setSampleRate(sv_samplerate_t sampleRate) { m_sampleRate = sampleRate; } |
57 | 57 |
58 bool isOK(); | 58 bool isOK(); |
59 QString getErrorString() const; | 59 QString getErrorString() const; |
60 | 60 |
61 std::vector<Model *> getDataModels(ProgressReporter *); | 61 std::vector<Model *> getDataModels(ProgressReporter *); |
65 Uri expand(QString s) { return m_store->expand(s); } | 65 Uri expand(QString s) { return m_store->expand(s); } |
66 | 66 |
67 QString m_uristring; | 67 QString m_uristring; |
68 QString m_errorString; | 68 QString m_errorString; |
69 std::map<QString, Model *> m_audioModelMap; | 69 std::map<QString, Model *> m_audioModelMap; |
70 int m_sampleRate; | 70 sv_samplerate_t m_sampleRate; |
71 | 71 |
72 std::map<Model *, std::map<QString, float> > m_labelValueMap; | 72 std::map<Model *, std::map<QString, float> > m_labelValueMap; |
73 | 73 |
74 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *); | 74 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *); |
75 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *); | 75 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *); |
76 void getDataModelsDense(std::vector<Model *> &, ProgressReporter *); | 76 void getDataModelsDense(std::vector<Model *> &, ProgressReporter *); |
77 | 77 |
78 void getDenseModelTitle(Model *, QString, QString); | 78 void getDenseModelTitle(Model *, QString, QString); |
79 | 79 |
80 void getDenseFeatureProperties(QString featureUri, | 80 void getDenseFeatureProperties(QString featureUri, |
81 int &sampleRate, int &windowLength, | 81 sv_samplerate_t &sampleRate, int &windowLength, |
82 int &hopSize, int &width, int &height); | 82 int &hopSize, int &width, int &height); |
83 | 83 |
84 void fillModel(Model *, sv_frame_t, sv_frame_t, | 84 void fillModel(Model *, sv_frame_t, sv_frame_t, |
85 bool, std::vector<float> &, QString); | 85 bool, std::vector<float> &, QString); |
86 }; | 86 }; |
89 RDFImporter::getKnownExtensions() | 89 RDFImporter::getKnownExtensions() |
90 { | 90 { |
91 return "*.rdf *.n3 *.ttl"; | 91 return "*.rdf *.n3 *.ttl"; |
92 } | 92 } |
93 | 93 |
94 RDFImporter::RDFImporter(QString url, int sampleRate) : | 94 RDFImporter::RDFImporter(QString url, sv_samplerate_t sampleRate) : |
95 m_d(new RDFImporterImpl(url, sampleRate)) | 95 m_d(new RDFImporterImpl(url, sampleRate)) |
96 { | 96 { |
97 } | 97 } |
98 | 98 |
99 RDFImporter::~RDFImporter() | 99 RDFImporter::~RDFImporter() |
100 { | 100 { |
101 delete m_d; | 101 delete m_d; |
102 } | 102 } |
103 | 103 |
104 void | 104 void |
105 RDFImporter::setSampleRate(int sampleRate) | 105 RDFImporter::setSampleRate(sv_samplerate_t sampleRate) |
106 { | 106 { |
107 m_d->setSampleRate(sampleRate); | 107 m_d->setSampleRate(sampleRate); |
108 } | 108 } |
109 | 109 |
110 bool | 110 bool |
123 RDFImporter::getDataModels(ProgressReporter *r) | 123 RDFImporter::getDataModels(ProgressReporter *r) |
124 { | 124 { |
125 return m_d->getDataModels(r); | 125 return m_d->getDataModels(r); |
126 } | 126 } |
127 | 127 |
128 RDFImporterImpl::RDFImporterImpl(QString uri, int sampleRate) : | 128 RDFImporterImpl::RDFImporterImpl(QString uri, sv_samplerate_t sampleRate) : |
129 m_store(new BasicStore), | 129 m_store(new BasicStore), |
130 m_uristring(uri), | 130 m_uristring(uri), |
131 m_sampleRate(sampleRate) | 131 m_sampleRate(sampleRate) |
132 { | 132 { |
133 //!!! retrieve data if remote... then | 133 //!!! retrieve data if remote... then |
308 QString type = t.value; | 308 QString type = t.value; |
309 QString value = v.value; | 309 QString value = v.value; |
310 | 310 |
311 if (type == "" || value == "") continue; | 311 if (type == "" || value == "") continue; |
312 | 312 |
313 int sampleRate = 0; | 313 sv_samplerate_t sampleRate = 0; |
314 int windowLength = 0; | 314 int windowLength = 0; |
315 int hopSize = 0; | 315 int hopSize = 0; |
316 int width = 0; | 316 int width = 0; |
317 int height = 0; | 317 int height = 0; |
318 getDenseFeatureProperties | 318 getDenseFeatureProperties |
415 SVDEBUG << "RDFImporterImpl::getDenseModelTitle: No title available for feature <" << featureUri << ">" << endl; | 415 SVDEBUG << "RDFImporterImpl::getDenseModelTitle: No title available for feature <" << featureUri << ">" << endl; |
416 } | 416 } |
417 | 417 |
418 void | 418 void |
419 RDFImporterImpl::getDenseFeatureProperties(QString featureUri, | 419 RDFImporterImpl::getDenseFeatureProperties(QString featureUri, |
420 int &sampleRate, int &windowLength, | 420 sv_samplerate_t &sampleRate, int &windowLength, |
421 int &hopSize, int &width, int &height) | 421 int &hopSize, int &width, int &height) |
422 { | 422 { |
423 Node dim = m_store->complete | 423 Node dim = m_store->complete |
424 (Triple(Uri(featureUri), expand("af:dimensions"), Node())); | 424 (Triple(Uri(featureUri), expand("af:dimensions"), Node())); |
425 | 425 |
466 } | 466 } |
467 | 467 |
468 PropertyObject po(m_store, "tl:", map); | 468 PropertyObject po(m_store, "tl:", map); |
469 | 469 |
470 if (po.hasProperty("sampleRate")) { | 470 if (po.hasProperty("sampleRate")) { |
471 sampleRate = po.getProperty("sampleRate").toInt(); | 471 sampleRate = po.getProperty("sampleRate").toDouble(); |
472 } | 472 } |
473 if (po.hasProperty("hopSize")) { | 473 if (po.hasProperty("hopSize")) { |
474 hopSize = po.getProperty("hopSize").toInt(); | 474 hopSize = po.getProperty("hopSize").toInt(); |
475 } | 475 } |
476 if (po.hasProperty("windowLength")) { | 476 if (po.hasProperty("windowLength")) { |