Mercurial > hg > svapp
comparison framework/SVFileReader.cpp @ 450:d9d132c0e240 alignment_view
Merge from default branch
author | Chris Cannam |
---|---|
date | Mon, 20 Apr 2015 09:21:32 +0100 |
parents | da520a68595a |
children | dc1a360f2b69 |
comparison
equal
deleted
inserted
replaced
430:adfb2948fabf | 450:d9d132c0e240 |
---|---|
448 | 448 |
449 QString name = attributes.value("name"); | 449 QString name = attributes.value("name"); |
450 | 450 |
451 SVDEBUG << "SVFileReader::readModel: model name \"" << name << "\"" << endl; | 451 SVDEBUG << "SVFileReader::readModel: model name \"" << name << "\"" << endl; |
452 | 452 |
453 READ_MANDATORY(int, sampleRate, toInt); | 453 READ_MANDATORY(double, sampleRate, toDouble); |
454 | 454 |
455 QString type = attributes.value("type").trimmed(); | 455 QString type = attributes.value("type").trimmed(); |
456 bool isMainModel = (attributes.value("mainModel").trimmed() == "true"); | 456 bool isMainModel = (attributes.value("mainModel").trimmed() == "true"); |
457 | 457 |
458 if (type == "wavefile") { | 458 if (type == "wavefile") { |
476 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << endl; | 476 cerr << "SVFileReader::readModel: Failed to retrieve file \"" << path << "\" for wave file model: Source unavailable" << endl; |
477 } else { | 477 } else { |
478 | 478 |
479 file.waitForData(); | 479 file.waitForData(); |
480 | 480 |
481 int rate = sampleRate; | 481 sv_samplerate_t rate = sampleRate; |
482 | 482 |
483 if (Preferences::getInstance()->getFixedSampleRate() != 0) { | 483 if (Preferences::getInstance()->getFixedSampleRate() != 0) { |
484 rate = Preferences::getInstance()->getFixedSampleRate(); | 484 rate = Preferences::getInstance()->getFixedSampleRate(); |
485 } else if (rate == 0 && | 485 } else if (rate == 0 && |
486 !isMainModel && | 486 !isMainModel && |
884 Model *model = m_models[modelId]; | 884 Model *model = m_models[modelId]; |
885 m_document->setModel(layer, model); | 885 m_document->setModel(layer, model); |
886 } else { | 886 } else { |
887 cerr << "WARNING: SV-XML: Unknown model id " << modelId | 887 cerr << "WARNING: SV-XML: Unknown model id " << modelId |
888 << " in layer definition" << endl; | 888 << " in layer definition" << endl; |
889 | |
890 // Don't add a layer with an unknown model id | |
891 m_document->deleteLayer(layer); | |
892 m_layers[id] = layer = 0; | |
893 return false; | |
889 } | 894 } |
890 } | 895 } |
891 | 896 |
892 layer->setProperties(attributes); | 897 if (layer) layer->setProperties(attributes); |
893 } | 898 } |
894 | 899 |
895 if (!m_inData && m_currentPane) { | 900 if (!m_inData && m_currentPane && layer) { |
896 | 901 |
897 QString visible = attributes.value("visible"); | 902 QString visible = attributes.value("visible"); |
898 bool dormant = (visible == "false"); | 903 bool dormant = (visible == "false"); |
899 | 904 |
900 // We need to do this both before and after adding the layer | 905 // We need to do this both before and after adding the layer |
910 | 915 |
911 layer->setLayerDormant(m_currentPane, dormant); | 916 layer->setLayerDormant(m_currentPane, dormant); |
912 } | 917 } |
913 | 918 |
914 m_currentLayer = layer; | 919 m_currentLayer = layer; |
915 m_inLayer = true; | 920 m_inLayer = (layer != 0); |
916 | 921 |
917 return true; | 922 return true; |
918 } | 923 } |
919 | 924 |
920 bool | 925 bool |
997 | 1002 |
998 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *> | 1003 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *> |
999 (m_currentDataset); | 1004 (m_currentDataset); |
1000 | 1005 |
1001 if (stvm) { | 1006 if (stvm) { |
1002 cerr << "Current dataset is a sparse time-value model" << endl; | 1007 // cerr << "Current dataset is a sparse time-value model" << endl; |
1003 float value = 0.0; | 1008 float value = 0.0; |
1004 value = attributes.value("value").trimmed().toFloat(&ok); | 1009 value = attributes.value("value").trimmed().toFloat(&ok); |
1005 QString label = attributes.value("label"); | 1010 QString label = attributes.value("label"); |
1006 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); | 1011 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); |
1007 return ok; | 1012 return ok; |
1008 } | 1013 } |
1009 | 1014 |
1010 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset); | 1015 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset); |
1011 | 1016 |
1012 if (nm) { | 1017 if (nm) { |
1013 cerr << "Current dataset is a note model" << endl; | 1018 // cerr << "Current dataset is a note model" << endl; |
1014 float value = 0.0; | 1019 float value = 0.0; |
1015 value = attributes.value("value").trimmed().toFloat(&ok); | 1020 value = attributes.value("value").trimmed().toFloat(&ok); |
1016 int duration = 0; | 1021 int duration = 0; |
1017 duration = attributes.value("duration").trimmed().toInt(&ok); | 1022 duration = attributes.value("duration").trimmed().toInt(&ok); |
1018 QString label = attributes.value("label"); | 1023 QString label = attributes.value("label"); |
1026 } | 1031 } |
1027 | 1032 |
1028 FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(m_currentDataset); | 1033 FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(m_currentDataset); |
1029 | 1034 |
1030 if (fnm) { | 1035 if (fnm) { |
1031 cerr << "Current dataset is a flexinote model" << endl; | 1036 // cerr << "Current dataset is a flexinote model" << endl; |
1032 float value = 0.0; | 1037 float value = 0.0; |
1033 value = attributes.value("value").trimmed().toFloat(&ok); | 1038 value = attributes.value("value").trimmed().toFloat(&ok); |
1034 int duration = 0; | 1039 int duration = 0; |
1035 duration = attributes.value("duration").trimmed().toInt(&ok); | 1040 duration = attributes.value("duration").trimmed().toInt(&ok); |
1036 QString label = attributes.value("label"); | 1041 QString label = attributes.value("label"); |
1044 } | 1049 } |
1045 | 1050 |
1046 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset); | 1051 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset); |
1047 | 1052 |
1048 if (rm) { | 1053 if (rm) { |
1049 cerr << "Current dataset is a region model" << endl; | 1054 // cerr << "Current dataset is a region model" << endl; |
1050 float value = 0.0; | 1055 float value = 0.0; |
1051 value = attributes.value("value").trimmed().toFloat(&ok); | 1056 value = attributes.value("value").trimmed().toFloat(&ok); |
1052 int duration = 0; | 1057 int duration = 0; |
1053 duration = attributes.value("duration").trimmed().toInt(&ok); | 1058 duration = attributes.value("duration").trimmed().toInt(&ok); |
1054 QString label = attributes.value("label"); | 1059 QString label = attributes.value("label"); |