changeset 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 63dec7dc11cc
files framework/SVFileReader.cpp
diffstat 1 files changed, 36 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/framework/SVFileReader.cpp	Wed Apr 02 21:25:56 2014 +0100
+++ b/framework/SVFileReader.cpp	Wed Apr 02 21:50:04 2014 +0100
@@ -31,6 +31,7 @@
 #include "data/model/SparseOneDimensionalModel.h"
 #include "data/model/SparseTimeValueModel.h"
 #include "data/model/NoteModel.h"
+#include "data/model/FlexiNoteModel.h"
 #include "data/model/RegionModel.h"
 #include "data/model/TextModel.h"
 #include "data/model/ImageModel.h"
@@ -624,6 +625,19 @@
                     model->setScaleUnits(units);
                     model->setObjectName(name);
                     m_models[id] = model;
+                } else if (attributes.value("subtype") == "flexinote") {
+                    FlexiNoteModel *model;
+                    if (haveMinMax) {
+                        model = new FlexiNoteModel
+                            (sampleRate, resolution, minimum, maximum, notifyOnAdd);
+                    } else {
+                        model = new FlexiNoteModel
+                            (sampleRate, resolution, notifyOnAdd);
+                    }
+                    model->setValueQuantization(valueQuantization);
+                    model->setScaleUnits(units);
+                    model->setObjectName(name);
+                    m_models[id] = model;
                 } else {
                     // note models written out by SV 1.3 and earlier
                     // have no subtype, so we can't test that
@@ -934,6 +948,7 @@
 
     case 3:
 	if (dynamic_cast<NoteModel *>(model)) good = true;
+	else if (dynamic_cast<FlexiNoteModel *>(model)) good = true;
 	else if (dynamic_cast<RegionModel *>(model)) good = true;
 	else if (dynamic_cast<EditableDenseThreeDimensionalModel *>(model)) {
 	    m_datasetSeparator = attributes.value("separator");
@@ -975,7 +990,7 @@
 	(m_currentDataset);
 
     if (stvm) {
-//        cerr << "Current dataset is a sparse time-value model" << endl;
+        cerr << "Current dataset is a sparse time-value model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	QString label = attributes.value("label");
@@ -986,7 +1001,7 @@
     NoteModel *nm = dynamic_cast<NoteModel *>(m_currentDataset);
 
     if (nm) {
-//        cerr << "Current dataset is a note model" << endl;
+        cerr << "Current dataset is a note model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	size_t duration = 0;
@@ -1001,10 +1016,28 @@
 	return ok;
     }
 
+    FlexiNoteModel *fnm = dynamic_cast<FlexiNoteModel *>(m_currentDataset);
+
+    if (fnm) {
+        cerr << "Current dataset is a flexinote model" << endl;
+	float value = 0.0;
+	value = attributes.value("value").trimmed().toFloat(&ok);
+	size_t duration = 0;
+	duration = attributes.value("duration").trimmed().toUInt(&ok);
+	QString label = attributes.value("label");
+        float level = attributes.value("level").trimmed().toFloat(&ok);
+        if (!ok) { // level is optional
+            level = 1.f;
+            ok = true;
+        }
+	fnm->addPoint(FlexiNoteModel::Point(frame, value, duration, level, label));
+	return ok;
+    }
+
     RegionModel *rm = dynamic_cast<RegionModel *>(m_currentDataset);
 
     if (rm) {
-//        cerr << "Current dataset is a note model" << endl;
+        cerr << "Current dataset is a region model" << endl;
 	float value = 0.0;
 	value = attributes.value("value").trimmed().toFloat(&ok);
 	size_t duration = 0;