# HG changeset patch # User Chris Cannam # Date 1568985589 -3600 # Node ID dde6ff56a84b55723a685245eb88b7b95ef864ba # Parent 721eb532840d8ee4adf62b07efec98158fd03229 Add support for time-frequency box layer diff -r 721eb532840d -r dde6ff56a84b framework/SVFileReader.cpp --- a/framework/SVFileReader.cpp Mon Sep 16 13:28:40 2019 +0100 +++ b/framework/SVFileReader.cpp Fri Sep 20 14:19:49 2019 +0100 @@ -34,6 +34,7 @@ #include "data/model/RegionModel.h" #include "data/model/TextModel.h" #include "data/model/ImageModel.h" +#include "data/model/TimeFrequencyBoxModel.h" #include "data/model/AlignmentModel.h" #include "data/model/AggregateWaveModel.h" @@ -686,6 +687,11 @@ // Paths are no longer actually models Path *path = new Path(sampleRate, resolution); m_paths[id] = path; + } else if (attributes.value("subtype") == "timefrequencybox") { + auto model = std::make_shared + (sampleRate, resolution, notifyOnAdd); + model->setObjectName(name); + m_models[id] = ModelById::add(model); } else { std::shared_ptr model; if (haveMinMax) { @@ -1057,6 +1063,7 @@ good = (ModelById::isa(modelId) || ModelById::isa(modelId) || + ModelById::isa(modelId) || path); break; @@ -1111,18 +1118,15 @@ } if (auto stvm = ModelById::getAs(modelId)) { - float value = 0.0; - value = attributes.value("value").trimmed().toFloat(&ok); + float value = attributes.value("value").trimmed().toFloat(&ok); QString label = attributes.value("label"); stvm->add(Event(frame, value, label)); return ok; } if (auto nm = ModelById::getAs(modelId)) { - float value = 0.0; - value = attributes.value("value").trimmed().toFloat(&ok); - int duration = 0; - duration = attributes.value("duration").trimmed().toInt(&ok); + float value = attributes.value("value").trimmed().toFloat(&ok); + int duration = attributes.value("duration").trimmed().toInt(&ok); QString label = attributes.value("label"); float level = attributes.value("level").trimmed().toFloat(&ok); if (!ok) { // level is optional @@ -1134,23 +1138,29 @@ } if (auto rm = ModelById::getAs(modelId)) { - float value = 0.0; - value = attributes.value("value").trimmed().toFloat(&ok); - int duration = 0; - duration = attributes.value("duration").trimmed().toInt(&ok); + float value = attributes.value("value").trimmed().toFloat(&ok); + int duration = attributes.value("duration").trimmed().toInt(&ok); QString label = attributes.value("label"); rm->add(Event(frame, value, duration, label)); return ok; } if (auto tm = ModelById::getAs(modelId)) { - float height = 0.0; - height = attributes.value("height").trimmed().toFloat(&ok); + float height = attributes.value("height").trimmed().toFloat(&ok); QString label = attributes.value("label"); tm->add(Event(frame, height, label)); return ok; } + if (auto bm = ModelById::getAs(modelId)) { + float frequency = attributes.value("frequency").trimmed().toFloat(&ok); + float extent = attributes.value("extent").trimmed().toFloat(&ok); + int duration = attributes.value("duration").trimmed().toInt(&ok); + QString label = attributes.value("label"); + bm->add(Event(frame, frequency, duration, extent, label)); + return ok; + } + if (auto im = ModelById::getAs(modelId)) { QString image = attributes.value("image"); QString label = attributes.value("label");