comparison framework/SVFileReader.cpp @ 343:a93802543a5a tonioni

A lot of work on saving and reloading sessions: save flexinote layer type and hybrid spectrogram normalisation, etc
author Chris Cannam
date Wed, 02 Apr 2014 21:50:04 +0100
parents 4eccff14b4d8
children 2da91cceed64 0876ea394902
comparison
equal deleted inserted replaced
342:4eccff14b4d8 343:a93802543a5a
29 #include "data/model/WaveFileModel.h" 29 #include "data/model/WaveFileModel.h"
30 #include "data/model/EditableDenseThreeDimensionalModel.h" 30 #include "data/model/EditableDenseThreeDimensionalModel.h"
31 #include "data/model/SparseOneDimensionalModel.h" 31 #include "data/model/SparseOneDimensionalModel.h"
32 #include "data/model/SparseTimeValueModel.h" 32 #include "data/model/SparseTimeValueModel.h"
33 #include "data/model/NoteModel.h" 33 #include "data/model/NoteModel.h"
34 #include "data/model/FlexiNoteModel.h"
34 #include "data/model/RegionModel.h" 35 #include "data/model/RegionModel.h"
35 #include "data/model/TextModel.h" 36 #include "data/model/TextModel.h"
36 #include "data/model/ImageModel.h" 37 #include "data/model/ImageModel.h"
37 #include "data/model/AlignmentModel.h" 38 #include "data/model/AlignmentModel.h"
38 39
622 } 623 }
623 model->setValueQuantization(valueQuantization); 624 model->setValueQuantization(valueQuantization);
624 model->setScaleUnits(units); 625 model->setScaleUnits(units);
625 model->setObjectName(name); 626 model->setObjectName(name);
626 m_models[id] = model; 627 m_models[id] = model;
628 } else if (attributes.value("subtype") == "flexinote") {
629 FlexiNoteModel *model;
630 if (haveMinMax) {
631 model = new FlexiNoteModel
632 (sampleRate, resolution, minimum, maximum, notifyOnAdd);
633 } else {
634 model = new FlexiNoteModel
635 (sampleRate, resolution, notifyOnAdd);
636 }
637 model->setValueQuantization(valueQuantization);
638 model->setScaleUnits(units);
639 model->setObjectName(name);
640 m_models[id] = model;
627 } else { 641 } else {
628 // note models written out by SV 1.3 and earlier 642 // note models written out by SV 1.3 and earlier
629 // have no subtype, so we can't test that 643 // have no subtype, so we can't test that
630 NoteModel *model; 644 NoteModel *model;
631 if (haveMinMax) { 645 if (haveMinMax) {
932 else if (dynamic_cast<PathModel *>(model)) good = true; 946 else if (dynamic_cast<PathModel *>(model)) good = true;
933 break; 947 break;
934 948
935 case 3: 949 case 3:
936 if (dynamic_cast<NoteModel *>(model)) good = true; 950 if (dynamic_cast<NoteModel *>(model)) good = true;
951 else if (dynamic_cast<FlexiNoteModel *>(model)) good = true;
937 else if (dynamic_cast<RegionModel *>(model)) good = true; 952 else if (dynamic_cast<RegionModel *>(model)) good = true;
938 else if (dynamic_cast<EditableDenseThreeDimensionalModel *>(model)) { 953 else if (dynamic_cast<EditableDenseThreeDimensionalModel *>(model)) {
939 m_datasetSeparator = attributes.value("separator"); 954 m_datasetSeparator = attributes.value("separator");
940 good = true; 955 good = true;
941 } 956 }
973 988
974 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *> 989 SparseTimeValueModel *stvm = dynamic_cast<SparseTimeValueModel *>
975 (m_currentDataset); 990 (m_currentDataset);
976 991
977 if (stvm) { 992 if (stvm) {
978 // cerr << "Current dataset is a sparse time-value model" << endl; 993 cerr << "Current dataset is a sparse time-value model" << endl;
979 float value = 0.0; 994 float value = 0.0;
980 value = attributes.value("value").trimmed().toFloat(&ok); 995 value = attributes.value("value").trimmed().toFloat(&ok);
981 QString label = attributes.value("label"); 996 QString label = attributes.value("label");
982 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label)); 997 stvm->addPoint(SparseTimeValueModel::Point(frame, value, label));
983 return ok; 998 return ok;
984 } 999 }
985 1000
986 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset); 1001 NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset);
987 1002
988 if (nm) { 1003 if (nm) {
989 // cerr << "Current dataset is a note model" << endl; 1004 cerr << "Current dataset is a note model" << endl;
990 float value = 0.0; 1005 float value = 0.0;
991 value = attributes.value("value").trimmed().toFloat(&ok); 1006 value = attributes.value("value").trimmed().toFloat(&ok);
992 size_t duration = 0; 1007 size_t duration = 0;
993 duration = attributes.value("duration").trimmed().toUInt(&ok); 1008 duration = attributes.value("duration").trimmed().toUInt(&ok);
994 QString label = attributes.value("label"); 1009 QString label = attributes.value("label");
999 } 1014 }
1000 nm->addPoint(NoteModel::Point(frame, value, duration, level, label)); 1015 nm->addPoint(NoteModel::Point(frame, value, duration, level, label));
1001 return ok; 1016 return ok;
1002 } 1017 }
1003 1018
1019 FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(m_currentDataset);
1020
1021 if (fnm) {
1022 cerr << "Current dataset is a flexinote model" << endl;
1023 float value = 0.0;
1024 value = attributes.value("value").trimmed().toFloat(&ok);
1025 size_t duration = 0;
1026 duration = attributes.value("duration").trimmed().toUInt(&ok);
1027 QString label = attributes.value("label");
1028 float level = attributes.value("level").trimmed().toFloat(&ok);
1029 if (!ok) { // level is optional
1030 level = 1.f;
1031 ok = true;
1032 }
1033 fnm->addPoint(FlexiNoteModel::Point(frame, value, duration, level, label));
1034 return ok;
1035 }
1036
1004 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset); 1037 RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset);
1005 1038
1006 if (rm) { 1039 if (rm) {
1007 // cerr << "Current dataset is a note model" << endl; 1040 cerr << "Current dataset is a region model" << endl;
1008 float value = 0.0; 1041 float value = 0.0;
1009 value = attributes.value("value").trimmed().toFloat(&ok); 1042 value = attributes.value("value").trimmed().toFloat(&ok);
1010 size_t duration = 0; 1043 size_t duration = 0;
1011 duration = attributes.value("duration").trimmed().toUInt(&ok); 1044 duration = attributes.value("duration").trimmed().toUInt(&ok);
1012 QString label = attributes.value("label"); 1045 QString label = attributes.value("label");