Mercurial > hg > svapp
comparison framework/SVFileReader.cpp @ 371:dfcc5b355f33
Merge from branch warnfix_no_size_t
author | Chris Cannam |
---|---|
date | Wed, 18 Jun 2014 13:51:38 +0100 |
parents | f1cab64363d7 |
children | 6a84102c006a |
comparison
equal
deleted
inserted
replaced
355:e7a3fa8f4eec | 371:dfcc5b355f33 |
---|---|
298 m_inData = false; | 298 m_inData = false; |
299 | 299 |
300 } else if (name == "derivation") { | 300 } else if (name == "derivation") { |
301 | 301 |
302 if (!m_currentDerivedModel) { | 302 if (!m_currentDerivedModel) { |
303 if (m_currentDerivedModel < 0) { | 303 if (m_currentDerivedModelId < 0) { |
304 cerr << "WARNING: SV-XML: Bad derivation output model id " | 304 cerr << "WARNING: SV-XML: Bad derivation output model id " |
305 << m_currentDerivedModelId << endl; | 305 << m_currentDerivedModelId << endl; |
306 } else if (haveModel(m_currentDerivedModelId)) { | 306 } else if (haveModel(m_currentDerivedModelId)) { |
307 cerr << "WARNING: SV-XML: Derivation has existing model " | 307 cerr << "WARNING: SV-XML: Derivation has existing model " |
308 << m_currentDerivedModelId | 308 << m_currentDerivedModelId |
446 SVDEBUG << "SVFileReader::readModel: model name \"" << name << "\"" << endl; | 446 SVDEBUG << "SVFileReader::readModel: model name \"" << name << "\"" << endl; |
447 | 447 |
448 READ_MANDATORY(int, sampleRate, toInt); | 448 READ_MANDATORY(int, sampleRate, toInt); |
449 | 449 |
450 QString type = attributes.value("type").trimmed(); | 450 QString type = attributes.value("type").trimmed(); |
451 bool mainModel = (attributes.value("mainModel").trimmed() == "true"); | 451 bool isMainModel = (attributes.value("mainModel").trimmed() == "true"); |
452 | 452 |
453 if (type == "wavefile") { | 453 if (type == "wavefile") { |
454 | 454 |
455 WaveFileModel *model = 0; | 455 WaveFileModel *model = 0; |
456 FileFinder *ff = FileFinder::getInstance(); | 456 FileFinder *ff = FileFinder::getInstance(); |
471 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << endl; | 471 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << endl; |
472 } else { | 472 } else { |
473 | 473 |
474 file.waitForData(); | 474 file.waitForData(); |
475 | 475 |
476 size_t rate = 0; | 476 int rate = sampleRate; |
477 | 477 |
478 if (!mainModel && | 478 if (Preferences::getInstance()->getFixedSampleRate() != 0) { |
479 Preferences::getInstance()->getResampleOnLoad()) { | 479 rate = Preferences::getInstance()->getFixedSampleRate(); |
480 } else if (rate == 0 && | |
481 !isMainModel && | |
482 Preferences::getInstance()->getResampleOnLoad()) { | |
480 WaveFileModel *mm = m_document->getMainModel(); | 483 WaveFileModel *mm = m_document->getMainModel(); |
481 if (mm) rate = mm->getSampleRate(); | 484 if (mm) rate = mm->getSampleRate(); |
482 } | 485 } |
483 | 486 |
484 model = new WaveFileModel(file, rate); | 487 model = new WaveFileModel(file, rate); |
490 | 493 |
491 if (!model) return false; | 494 if (!model) return false; |
492 | 495 |
493 model->setObjectName(name); | 496 model->setObjectName(name); |
494 m_models[id] = model; | 497 m_models[id] = model; |
495 if (mainModel) { | 498 if (isMainModel) { |
496 m_document->setMainModel(model); | 499 m_document->setMainModel(model); |
497 m_addedModels.insert(model); | 500 m_addedModels.insert(model); |
498 } | 501 } |
499 // Derived models will be added when their derivation | 502 // Derived models will be added when their derivation |
500 // is found. | 503 // is found. |
752 | 755 |
753 View *view = m_currentPane; | 756 View *view = m_currentPane; |
754 | 757 |
755 // The view properties first | 758 // The view properties first |
756 | 759 |
757 READ_MANDATORY(size_t, centre, toUInt); | 760 READ_MANDATORY(int, centre, toInt); |
758 READ_MANDATORY(size_t, zoom, toUInt); | 761 READ_MANDATORY(int, zoom, toInt); |
759 READ_MANDATORY(int, followPan, toInt); | 762 READ_MANDATORY(int, followPan, toInt); |
760 READ_MANDATORY(int, followZoom, toInt); | 763 READ_MANDATORY(int, followZoom, toInt); |
761 QString tracking = attributes.value("tracking"); | 764 QString tracking = attributes.value("tracking"); |
762 | 765 |
763 // Specify the follow modes before we set the actual values | 766 // Specify the follow modes before we set the actual values |
1002 | 1005 |
1003 if (nm) { | 1006 if (nm) { |
1004 cerr << "Current dataset is a note model" << endl; | 1007 cerr << "Current dataset is a note model" << endl; |
1005 float value = 0.0; | 1008 float value = 0.0; |
1006 value = attributes.value("value").trimmed().toFloat(&ok); | 1009 value = attributes.value("value").trimmed().toFloat(&ok); |
1007 size_t duration = 0; | 1010 int duration = 0; |
1008 duration = attributes.value("duration").trimmed().toUInt(&ok); | 1011 duration = attributes.value("duration").trimmed().toInt(&ok); |
1009 QString label = attributes.value("label"); | 1012 QString label = attributes.value("label"); |
1010 float level = attributes.value("level").trimmed().toFloat(&ok); | 1013 float level = attributes.value("level").trimmed().toFloat(&ok); |
1011 if (!ok) { // level is optional | 1014 if (!ok) { // level is optional |
1012 level = 1.f; | 1015 level = 1.f; |
1013 ok = true; | 1016 ok = true; |
1020 | 1023 |
1021 if (fnm) { | 1024 if (fnm) { |
1022 cerr << "Current dataset is a flexinote model" << endl; | 1025 cerr << "Current dataset is a flexinote model" << endl; |
1023 float value = 0.0; | 1026 float value = 0.0; |
1024 value = attributes.value("value").trimmed().toFloat(&ok); | 1027 value = attributes.value("value").trimmed().toFloat(&ok); |
1025 size_t duration = 0; | 1028 int duration = 0; |
1026 duration = attributes.value("duration").trimmed().toUInt(&ok); | 1029 duration = attributes.value("duration").trimmed().toInt(&ok); |
1027 QString label = attributes.value("label"); | 1030 QString label = attributes.value("label"); |
1028 float level = attributes.value("level").trimmed().toFloat(&ok); | 1031 float level = attributes.value("level").trimmed().toFloat(&ok); |
1029 if (!ok) { // level is optional | 1032 if (!ok) { // level is optional |
1030 level = 1.f; | 1033 level = 1.f; |
1031 ok = true; | 1034 ok = true; |
1038 | 1041 |
1039 if (rm) { | 1042 if (rm) { |
1040 cerr << "Current dataset is a region model" << endl; | 1043 cerr << "Current dataset is a region model" << endl; |
1041 float value = 0.0; | 1044 float value = 0.0; |
1042 value = attributes.value("value").trimmed().toFloat(&ok); | 1045 value = attributes.value("value").trimmed().toFloat(&ok); |
1043 size_t duration = 0; | 1046 int duration = 0; |
1044 duration = attributes.value("duration").trimmed().toUInt(&ok); | 1047 duration = attributes.value("duration").trimmed().toInt(&ok); |
1045 QString label = attributes.value("label"); | 1048 QString label = attributes.value("label"); |
1046 rm->addPoint(RegionModel::Point(frame, value, duration, label)); | 1049 rm->addPoint(RegionModel::Point(frame, value, duration, label)); |
1047 return ok; | 1050 return ok; |
1048 } | 1051 } |
1049 | 1052 |
1148 | 1151 |
1149 DenseThreeDimensionalModel::Column values; | 1152 DenseThreeDimensionalModel::Column values; |
1150 | 1153 |
1151 for (QStringList::iterator i = data.begin(); i != data.end(); ++i) { | 1154 for (QStringList::iterator i = data.begin(); i != data.end(); ++i) { |
1152 | 1155 |
1153 if (values.size() == dtdm->getHeight()) { | 1156 if (values.size() == (int)dtdm->getHeight()) { |
1154 if (!warned) { | 1157 if (!warned) { |
1155 cerr << "WARNING: SV-XML: Too many y-bins in 3-D dataset row " | 1158 cerr << "WARNING: SV-XML: Too many y-bins in 3-D dataset row " |
1156 << m_rowNumber << endl; | 1159 << m_rowNumber << endl; |
1157 warned = true; | 1160 warned = true; |
1158 } | 1161 } |
1243 if (!m_currentTransformSource) return true; | 1246 if (!m_currentTransformSource) return true; |
1244 | 1247 |
1245 QString startFrameStr = attributes.value("startFrame"); | 1248 QString startFrameStr = attributes.value("startFrame"); |
1246 QString durationStr = attributes.value("duration"); | 1249 QString durationStr = attributes.value("duration"); |
1247 | 1250 |
1248 size_t startFrame = 0; | 1251 int startFrame = 0; |
1249 size_t duration = 0; | 1252 int duration = 0; |
1250 | 1253 |
1251 if (startFrameStr != "") { | 1254 if (startFrameStr != "") { |
1252 startFrame = startFrameStr.trimmed().toInt(&ok); | 1255 startFrame = startFrameStr.trimmed().toInt(&ok); |
1253 if (!ok) startFrame = 0; | 1256 if (!ok) startFrame = 0; |
1254 } | 1257 } |