comparison rdf/RDFImporter.cpp @ 617:24f06d34ac99

* When importing regions without values, generate a different value for each distinct label
author Chris Cannam
date Thu, 15 Oct 2009 11:32:21 +0000
parents 3a61a4df6d53
children b1dc68507e46
comparison
equal deleted inserted replaced
616:3a61a4df6d53 617:24f06d34ac99
58 QString m_uristring; 58 QString m_uristring;
59 QString m_errorString; 59 QString m_errorString;
60 std::map<QString, Model *> m_audioModelMap; 60 std::map<QString, Model *> m_audioModelMap;
61 int m_sampleRate; 61 int m_sampleRate;
62 62
63 std::map<Model *, std::map<QString, float> > m_labelValueMap;
64
63 static bool m_prefixesLoaded; 65 static bool m_prefixesLoaded;
64 static void loadPrefixes(ProgressReporter *reporter); 66 static void loadPrefixes(ProgressReporter *reporter);
65 67
66 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *); 68 void getDataModelsAudio(std::vector<Model *> &, ProgressReporter *);
67 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *); 69 void getDataModelsSparse(std::vector<Model *> &, ProgressReporter *);
241 if (ff) { 243 if (ff) {
242 QString path = ff->find(FileFinder::AudioFile, 244 QString path = ff->find(FileFinder::AudioFile,
243 fs->getLocation(), 245 fs->getLocation(),
244 m_uristring); 246 m_uristring);
245 if (path != "") { 247 if (path != "") {
248 std::cerr << "File finder returns: \"" << path.toStdString()
249 << "\"" << std::endl;
246 delete fs; 250 delete fs;
247 fs = new FileSource(path, reporter); 251 fs = new FileSource(path, reporter);
248 if (!fs->isAvailable()) { 252 if (!fs->isAvailable()) {
249 delete fs; 253 delete fs;
250 m_errorString = QString("Signal source \"%1\" is not available").arg(source); 254 m_errorString = QString("Signal source \"%1\" is not available").arg(source);
936 } 940 }
937 941
938 RegionModel *rm = 942 RegionModel *rm =
939 dynamic_cast<RegionModel *>(model); 943 dynamic_cast<RegionModel *>(model);
940 if (rm) { 944 if (rm) {
945 float value = 0.f;
946 if (values.empty()) {
947 // no values? map each unique label to a distinct value
948 if (m_labelValueMap[model].find(label) == m_labelValueMap[model].end()) {
949 m_labelValueMap[model][label] = rm->getValueMaximum() + 1.f;
950 }
951 value = m_labelValueMap[model][label];
952 } else {
953 value = values[0];
954 }
941 if (haveDuration) { 955 if (haveDuration) {
942 RegionModel::Point point 956 RegionModel::Point point(ftime, value, fduration, label);
943 (ftime, values.empty() ? 0.f : values[0], fduration, label);
944 rm->addPoint(point); 957 rm->addPoint(point);
945 } else { 958 } else {
946 // This won't actually happen -- we only create region models 959 // This won't actually happen -- we only create region models
947 // if we do have duration -- but just for completeness 960 // if we do have duration -- but just for completeness
948 float value = 0.f, duration = 1.f; 961 float duration = 1.f;
949 if (!values.empty()) { 962 if (!values.empty()) {
950 value = values[0]; 963 value = values[0];
951 if (values.size() > 1) { 964 if (values.size() > 1) {
952 duration = values[1]; 965 duration = values[1];
953 } 966 }