18 #include "layer/Layer.h" 19 #include "view/View.h" 20 #include "base/PlayParameters.h" 21 #include "base/PlayParameterRepository.h" 22 #include "base/Preferences.h" 24 #include "data/fileio/AudioFileReaderFactory.h" 25 #include "data/fileio/FileSource.h" 27 #include "data/fileio/FileFinder.h" 29 #include "data/model/ReadOnlyWaveFileModel.h" 30 #include "data/model/EditableDenseThreeDimensionalModel.h" 31 #include "data/model/SparseOneDimensionalModel.h" 32 #include "data/model/SparseTimeValueModel.h" 33 #include "data/model/NoteModel.h" 34 #include "data/model/RegionModel.h" 35 #include "data/model/TextModel.h" 36 #include "data/model/ImageModel.h" 37 #include "data/model/BoxModel.h" 38 #include "data/model/AlignmentModel.h" 39 #include "data/model/AggregateWaveModel.h" 41 #include "transform/TransformFactory.h" 43 #include "view/Pane.h" 45 #include "widgets/ProgressDialog.h" 50 #include <QMessageBox> 51 #include <QFileDialog> 59 m_paneCallback(callback),
61 m_currentPane(nullptr),
62 m_currentDataset(XmlExportable::NO_ID),
63 m_currentLayer(nullptr),
64 m_pendingDerivedModel(XmlExportable::NO_ID),
65 m_currentTransformChannel(0),
66 m_currentTransformIsNewStyle(true),
67 m_datasetSeparator(
" "),
72 m_inSelections(false),
81 QXmlInputSource inputSource;
82 inputSource.setData(xmlData);
89 QXmlSimpleReader reader;
90 reader.setContentHandler(
this);
91 reader.setErrorHandler(
this);
92 m_ok = reader.parse(inputSource);
104 SVCERR <<
"WARNING: SV-XML: File ended with " 109 std::set<ModelId> unaddedModels;
113 unaddedModels.insert(i.second);
117 if (!unaddedModels.empty()) {
118 SVCERR <<
"WARNING: SV-XML: File contained " 119 << unaddedModels.size() <<
" unused models" 121 for (
auto m: unaddedModels) {
122 ModelById::release(m);
127 SVCERR <<
"WARNING: SV-XML: File contained " 128 <<
m_paths.size() <<
" unused paths" 138 const QString &qName,
139 const QXmlAttributes &attributes)
141 QString name = qName.toLower();
170 }
else if (name ==
"data") {
176 }
else if (name ==
"display") {
181 }
else if (name ==
"window") {
185 }
else if (name ==
"model") {
189 }
else if (name ==
"dataset") {
193 }
else if (name ==
"bin") {
197 }
else if (name ==
"point") {
201 }
else if (name ==
"row") {
205 }
else if (name ==
"layer") {
210 }
else if (name ==
"view") {
215 }
else if (name ==
"derivation") {
220 }
else if (name ==
"playparameters") {
224 }
else if (name ==
"plugin") {
228 }
else if (name ==
"selections") {
233 }
else if (name ==
"selection") {
237 }
else if (name ==
"measurement") {
241 }
else if (name ==
"transform") {
245 }
else if (name ==
"parameter") {
250 SVCERR <<
"WARNING: SV-XML: Unexpected element \"" 251 << name <<
"\"" << endl;
255 SVCERR <<
"WARNING: SV-XML: Failed to completely process element \"" 256 << name <<
"\"" << endl;
270 SVCERR <<
"WARNING: SV-XML: Failed to read row data content for row " <<
m_rowNumber << endl;
279 const QString &qName)
281 QString name = qName.toLower();
283 if (name ==
"dataset") {
287 bool foundInAwaiting =
false;
291 m_awaitingDatasets.erase(i.first);
292 foundInAwaiting =
true;
297 if (!foundInAwaiting) {
298 SVCERR <<
"WARNING: SV-XML: Dataset precedes model, or no model uses dataset" << endl;
304 }
else if (name ==
"data") {
309 }
else if (name ==
"derivation") {
313 SVCERR <<
"WARNING: SV-XML: No valid output model id " 314 <<
"for derivation" << endl;
316 SVCERR <<
"WARNING: SV-XML: Derivation has existing model " 318 <<
" as target, not regenerating" << endl;
331 }
else if (message !=
"") {
352 }
else if (name ==
"row") {
354 }
else if (name ==
"layer") {
356 }
else if (name ==
"view") {
358 }
else if (name ==
"selections") {
360 }
else if (name ==
"playparameters") {
371 QString(
"ERROR: SV-XML: %1 at line %2, column %3")
372 .arg(exception.message())
373 .arg(exception.lineNumber())
374 .arg(exception.columnNumber());
376 return QXmlDefaultHandler::error(exception);
383 QString(
"FATAL ERROR: SV-XML: %1 at line %2, column %3")
384 .arg(exception.message())
385 .arg(exception.lineNumber())
386 .arg(exception.columnNumber());
388 return QXmlDefaultHandler::fatalError(exception);
392 #define READ_MANDATORY(TYPE, NAME, CONVERSION) \ 393 TYPE NAME = attributes.value(#NAME).trimmed().CONVERSION(&ok); \ 395 SVCERR << "WARNING: SV-XML: Missing or invalid mandatory " #TYPE " attribute \"" #NAME "\"" << endl; \ 412 std::map<ExportId, PendingAggregateRec> stillPending;
420 AggregateWaveModel::ChannelSpecList specs;
424 ModelId modelId =
m_models[componentId];
425 auto rs = ModelById::getAs<RangeSummarisableTimeValueModel>
428 specs.push_back(AggregateWaveModel::ModelChannelSpec
432 SVDEBUG <<
"SVFileReader::makeAggregateModels: " 433 <<
"Component model id " << componentId
434 <<
"in aggregate model id " <<
id 435 <<
"does not appear to be convertible to " 436 <<
"RangeSummarisableTimeValueModel" 441 SVDEBUG <<
"SVFileReader::makeAggregateModels: " 442 <<
"Unknown component model id " 443 << componentId <<
" in aggregate model id " <<
id 444 <<
", hoping we won't be needing it just yet" 451 stillPending[id] = rec;
453 auto model = std::make_shared<AggregateWaveModel>(specs);
454 model->setObjectName(rec.
name);
455 m_models[id] = ModelById::add(model);
457 SVDEBUG <<
"SVFileReader::makeAggregateModels: created aggregate " 458 <<
"model id " <<
id <<
" with " << specs.size()
459 <<
" components" << endl;
463 m_pendingAggregates = stillPending;
473 ModelId modelId = i.second;
496 SVCERR <<
"WARNING: SV-XML: Ignoring duplicate model id " <<
id 501 QString name = attributes.value(
"name");
503 SVDEBUG <<
"SVFileReader::readModel: model name \"" << name <<
"\"" << endl;
507 QString type = attributes.value(
"type").trimmed();
508 bool isMainModel = (attributes.value(
"mainModel").trimmed() ==
"true");
510 if (type ==
"wavefile") {
512 WaveFileModel *model =
nullptr;
513 FileFinder *ff = FileFinder::getInstance();
514 QString originalPath = attributes.value(
"file");
515 QString path = ff->find(FileFinder::AudioFile,
518 SVDEBUG <<
"Wave file originalPath = " << originalPath <<
", path = " 521 ProgressDialog dialog(tr(
"Opening file or URL..."),
true, 2000);
522 FileSource file(path, &dialog);
523 file.waitForStatus();
526 SVCERR <<
"SVFileReader::readModel: Failed to retrieve file \"" << path <<
"\" for wave file model: " << file.getErrorString() << endl;
527 }
else if (!file.isAvailable()) {
528 SVCERR <<
"SVFileReader::readModel: Failed to retrieve file \"" << path <<
"\" for wave file model: Source unavailable" << endl;
533 sv_samplerate_t rate = sampleRate;
535 if (Preferences::getInstance()->getFixedSampleRate() != 0) {
536 rate = Preferences::getInstance()->getFixedSampleRate();
537 }
else if (rate == 0 &&
539 Preferences::getInstance()->getResampleOnLoad()) {
540 auto mm = ModelById::getAs<WaveFileModel>
542 if (mm) rate = mm->getSampleRate();
545 model =
new ReadOnlyWaveFileModel(file, rate);
546 if (!model->isOK()) {
557 model->setObjectName(name);
559 ModelId modelId = ModelById::add(std::shared_ptr<Model>(model));
571 }
else if (type ==
"aggregatewave") {
573 QString components = attributes.value(
"components");
574 QStringList componentIdStrings = components.split(
",");
575 std::vector<int> componentIds;
576 for (
auto cidStr: componentIdStrings) {
578 int cid = cidStr.toInt(&ok);
580 SVCERR <<
"SVFileReader::readModel: Failed to convert component model id from part \"" << cidStr <<
"\" in \"" << components <<
"\"" << endl;
582 componentIds.push_back(cid);
595 }
else if (type ==
"dense") {
604 if (dimensions == 3) {
609 auto model = std::make_shared<EditableDenseThreeDimensionalModel>
610 (sampleRate, windowSize, yBinCount);
612 model->setObjectName(name);
613 m_models[id] = ModelById::add(model);
615 float minimum = attributes.value(
"minimum").trimmed().toFloat(&ok);
616 if (ok) model->setMinimumLevel(minimum);
618 float maximum = attributes.value(
"maximum").trimmed().toFloat(&ok);
619 if (ok) model->setMaximumLevel(maximum);
621 int dataset = attributes.value(
"dataset").trimmed().toInt(&ok);
624 int startFrame = attributes.value(
"startFrame").trimmed().toInt(&ok);
625 if (ok) model->setStartFrame(startFrame);
631 SVCERR <<
"WARNING: SV-XML: Unexpected dense model dimension (" 632 << dimensions <<
")" << endl;
634 }
else if (type ==
"sparse") {
638 if (dimensions == 1) {
642 if (attributes.value(
"subtype") ==
"image") {
644 bool notifyOnAdd = (attributes.value(
"notifyOnAdd") ==
"true");
645 auto model = std::make_shared<ImageModel>
646 (sampleRate, resolution, notifyOnAdd);
647 model->setObjectName(name);
648 m_models[id] = ModelById::add(model);
652 auto model = std::make_shared<SparseOneDimensionalModel>
653 (sampleRate, resolution);
654 model->setObjectName(name);
655 m_models[id] = ModelById::add(model);
658 int dataset = attributes.value(
"dataset").trimmed().toInt(&ok);
663 }
else if (dimensions == 2 || dimensions == 3) {
667 bool haveMinMax =
true;
668 float minimum = attributes.value(
"minimum").trimmed().toFloat(&ok);
669 if (!ok) haveMinMax =
false;
670 float maximum = attributes.value(
"maximum").trimmed().toFloat(&ok);
671 if (!ok) haveMinMax =
false;
673 float valueQuantization =
674 attributes.value(
"valueQuantization").trimmed().toFloat(&ok);
676 bool notifyOnAdd = (attributes.value(
"notifyOnAdd") ==
"true");
678 QString units = attributes.value(
"units");
680 if (dimensions == 2) {
681 if (attributes.value(
"subtype") ==
"text") {
682 auto model = std::make_shared<TextModel>
683 (sampleRate, resolution, notifyOnAdd);
684 model->setObjectName(name);
685 m_models[id] = ModelById::add(model);
686 }
else if (attributes.value(
"subtype") ==
"path") {
688 Path *path =
new Path(sampleRate, resolution);
690 }
else if (attributes.value(
"subtype") ==
"box" ||
691 attributes.value(
"subtype") ==
"timefrequencybox") {
692 auto model = std::make_shared<BoxModel>
693 (sampleRate, resolution, notifyOnAdd);
694 model->setScaleUnits(units);
695 model->setObjectName(name);
696 m_models[id] = ModelById::add(model);
698 std::shared_ptr<SparseTimeValueModel> model;
700 model = std::make_shared<SparseTimeValueModel>
701 (sampleRate, resolution, minimum, maximum,
704 model = std::make_shared<SparseTimeValueModel>
705 (sampleRate, resolution, notifyOnAdd);
707 model->setScaleUnits(units);
708 model->setObjectName(name);
709 m_models[id] = ModelById::add(model);
712 if (attributes.value(
"subtype") ==
"region") {
713 std::shared_ptr<RegionModel> model;
715 model = std::make_shared<RegionModel>
716 (sampleRate, resolution, minimum, maximum,
719 model = std::make_shared<RegionModel>
720 (sampleRate, resolution, notifyOnAdd);
722 model->setValueQuantization(valueQuantization);
723 model->setScaleUnits(units);
724 model->setObjectName(name);
725 m_models[id] = ModelById::add(model);
726 }
else if (attributes.value(
"subtype") ==
"flexinote") {
727 std::shared_ptr<NoteModel> model;
729 model = std::make_shared<NoteModel>
730 (sampleRate, resolution, minimum, maximum,
732 NoteModel::FLEXI_NOTE);
734 model = std::make_shared<NoteModel>
735 (sampleRate, resolution, notifyOnAdd,
736 NoteModel::FLEXI_NOTE);
738 model->setValueQuantization(valueQuantization);
739 model->setScaleUnits(units);
740 model->setObjectName(name);
741 m_models[id] = ModelById::add(model);
745 std::shared_ptr<NoteModel> model;
747 model = std::make_shared<NoteModel>
748 (sampleRate, resolution, minimum, maximum, notifyOnAdd);
750 model = std::make_shared<NoteModel>
751 (sampleRate, resolution, notifyOnAdd);
753 model->setValueQuantization(valueQuantization);
754 model->setScaleUnits(units);
755 model->setObjectName(name);
756 m_models[id] = ModelById::add(model);
760 int dataset = attributes.value(
"dataset").trimmed().toInt(&ok);
767 SVCERR <<
"WARNING: SV-XML: Unexpected sparse model dimension (" 768 << dimensions <<
")" << endl;
771 }
else if (type ==
"alignment") {
777 ModelId refModel, alignedModel;
778 Path *pathPtr =
nullptr;
783 SVCERR <<
"WARNING: SV-XML: Unknown reference model id " 784 << reference <<
" in alignment model id " <<
id 791 SVCERR <<
"WARNING: SV-XML: Unknown aligned model id " 792 << aligned <<
" in alignment model id " <<
id 799 SVCERR <<
"WARNING: SV-XML: Unknown path id " 800 << path <<
" in alignment model id " <<
id 804 if (!refModel.isNone() && !alignedModel.isNone() && pathPtr) {
805 auto model = std::make_shared<AlignmentModel>
806 (refModel, alignedModel, ModelId());
807 model->setPath(*pathPtr);
808 model->setObjectName(name);
809 m_models[id] = ModelById::add(model);
810 if (
auto am = ModelById::get(alignedModel)) {
823 SVCERR <<
"WARNING: SV-XML: Unexpected model type \"" 824 << type <<
"\" for model id " <<
id << endl;
833 QString type = attributes.value(
"type");
836 if (type !=
"pane") {
837 SVCERR <<
"WARNING: SV-XML: Unexpected view type \"" 838 << type <<
"\"" << endl;
844 SVDEBUG <<
"SVFileReader::addPane: pane is " <<
m_currentPane << endl;
847 SVCERR <<
"WARNING: SV-XML: Internal error: Failed to add pane!" 862 QString tracking = attributes.value(
"tracking");
865 int deepZoom = attributes.value(
"deepZoom").trimmed().toInt(&ok);
866 if (ok && zoom == 1 && deepZoom > 1) {
867 zoomLevel = { ZoomLevel::PixelsPerFrame, deepZoom };
869 zoomLevel = { ZoomLevel::FramesPerPixel, zoom };
873 view->setFollowGlobalPan(followPan);
874 view->setFollowGlobalZoom(followZoom);
875 view->setPlaybackFollow(tracking ==
"scroll" ? PlaybackScrollContinuous :
876 tracking ==
"page" ? PlaybackScrollPageWithCentre :
877 tracking ==
"daw" ? PlaybackScrollPage
881 view->setCentreFrame(centre);
882 view->setZoomLevel(zoomLevel);
888 int height = attributes.value(
"height").toInt(&ok);
899 QString type = attributes.value(
"type");
903 id = attributes.value(
"id").trimmed().toInt(&ok);
906 SVCERR <<
"WARNING: SV-XML: No layer id for layer of type \"" 912 Layer *layer =
nullptr;
913 bool isNewLayer =
false;
924 SVCERR <<
"WARNING: SV-XML: Ignoring duplicate layer id " <<
id 925 <<
" in data section" << endl;
930 (LayerFactory::getInstance()->getLayerTypeForName(type));
940 SVCERR <<
"WARNING: SV-XML: No current pane for layer " <<
id 941 <<
" in view section" << endl;
950 SVCERR <<
"WARNING: SV-XML: Layer id " <<
id 951 <<
" in view section has not been defined -- defining it here" 955 (LayerFactory::getInstance()->getLayerTypeForName(type));
965 SVCERR <<
"WARNING: SV-XML: Failed to add layer of type \"" 973 QString name = attributes.value(
"name");
974 layer->setObjectName(name);
976 QString presentationName = attributes.value(
"presentationName");
977 layer->setPresentationName(presentationName);
980 bool modelOk =
false;
981 modelId = attributes.value(
"model").trimmed().toInt(&modelOk);
987 SVCERR <<
"WARNING: SV-XML: Unknown model id " << modelId
988 <<
" in layer definition" << endl;
989 if (!layer->canExistWithoutModel()) {
999 if (layer) layer->setProperties(attributes);
1004 QString visible = attributes.value(
"visible");
1005 bool dormant = (visible ==
"false");
1036 SVCERR <<
"WARNING: SV-XML: Unwanted dataset " <<
id << endl;
1043 Path *path =
nullptr;
1050 SVCERR <<
"WARNING: SV-XML: Internal error: Unknown model or path " 1051 << modelId <<
" awaiting dataset " <<
id << endl;
1057 switch (dimensions) {
1060 (ModelById::isa<SparseOneDimensionalModel>(modelId) ||
1061 ModelById::isa<ImageModel>(modelId));
1066 (ModelById::isa<SparseTimeValueModel>(modelId) ||
1067 ModelById::isa<TextModel>(modelId) ||
1068 ModelById::isa<BoxModel>(modelId) ||
1073 if (ModelById::isa<EditableDenseThreeDimensionalModel>(modelId)) {
1078 (ModelById::isa<NoteModel>(modelId) ||
1079 ModelById::isa<RegionModel>(modelId));
1085 SVCERR <<
"WARNING: SV-XML: Model id " << modelId <<
" has wrong number of dimensions or inappropriate type for " << dimensions <<
"-D dataset " <<
id << endl;
1103 int mapframe = attributes.value(
"mapframe").trimmed().toInt(&ok);
1104 path->add(PathPoint(frame, mapframe));
1109 SVCERR <<
"WARNING: SV-XML: Point element found in non-point dataset" 1116 if (
auto sodm = ModelById::getAs<SparseOneDimensionalModel>(modelId)) {
1117 QString label = attributes.value(
"label");
1118 sodm->add(Event(frame, label));
1122 if (
auto stvm = ModelById::getAs<SparseTimeValueModel>(modelId)) {
1123 float value = attributes.value(
"value").trimmed().toFloat(&ok);
1124 QString label = attributes.value(
"label");
1125 stvm->add(Event(frame, value, label));
1129 if (
auto nm = ModelById::getAs<NoteModel>(modelId)) {
1130 float value = attributes.value(
"value").trimmed().toFloat(&ok);
1131 int duration = attributes.value(
"duration").trimmed().toInt(&ok);
1132 QString label = attributes.value(
"label");
1133 float level = attributes.value(
"level").trimmed().toFloat(&ok);
1138 nm->add(Event(frame, value, duration, level, label));
1142 if (
auto rm = ModelById::getAs<RegionModel>(modelId)) {
1143 float value = attributes.value(
"value").trimmed().toFloat(&ok);
1144 int duration = attributes.value(
"duration").trimmed().toInt(&ok);
1145 QString label = attributes.value(
"label");
1146 rm->add(Event(frame, value, duration, label));
1150 if (
auto tm = ModelById::getAs<TextModel>(modelId)) {
1151 float height = attributes.value(
"height").trimmed().toFloat(&ok);
1152 QString label = attributes.value(
"label");
1153 tm->add(Event(frame, height, label));
1157 if (
auto bm = ModelById::getAs<BoxModel>(modelId)) {
1158 float value = attributes.value(
"value").trimmed().toFloat(&ok);
1160 value = attributes.value(
"frequency").trimmed().toFloat(&ok);
1161 if (bm->getScaleUnits() ==
"") {
1162 bm->setScaleUnits(
"Hz");
1165 float extent = attributes.value(
"extent").trimmed().toFloat(&ok);
1166 int duration = attributes.value(
"duration").trimmed().toInt(&ok);
1167 QString label = attributes.value(
"label");
1168 bm->add(Event(frame, value, duration, extent, label));
1172 if (
auto im = ModelById::getAs<ImageModel>(modelId)) {
1173 QString image = attributes.value(
"image");
1174 QString label = attributes.value(
"label");
1175 im->add(Event(frame).withURI(image).withLabel(label));
1179 SVCERR <<
"WARNING: SV-XML: Point element found in non-point dataset" 1189 SVCERR <<
"WARNING: SV-XML: Bin definition found in incompatible dataset" 1196 if (
auto dtdm = ModelById::getAs<EditableDenseThreeDimensionalModel>
1200 int n = attributes.value(
"number").trimmed().toInt(&ok);
1202 SVCERR <<
"WARNING: SV-XML: Missing or invalid bin number" 1207 QString name = attributes.value(
"name");
1208 dtdm->setBinName(n, name);
1212 SVCERR <<
"WARNING: SV-XML: Bin definition found in incompatible dataset" 1225 m_rowNumber = attributes.value(
"n").trimmed().toInt(&ok);
1227 SVCERR <<
"WARNING: SV-XML: Missing or invalid row number" 1243 SVCERR <<
"WARNING: SV-XML: Row data found in non-row dataset" << endl;
1248 bool warned =
false;
1250 if (
auto dtdm = ModelById::getAs<EditableDenseThreeDimensionalModel>
1255 DenseThreeDimensionalModel::Column values;
1257 for (QStringList::iterator i = data.begin(); i != data.end(); ++i) {
1259 if (
int(values.size()) == dtdm->getHeight()) {
1261 SVCERR <<
"WARNING: SV-XML: Too many y-bins in 3-D dataset row " 1268 float value = i->toFloat(&ok);
1270 SVCERR <<
"WARNING: SV-XML: Bad floating-point value " 1271 << i->toLocal8Bit().data()
1272 <<
" in row data" << endl;
1274 values.push_back(value);
1282 SVCERR <<
"WARNING: SV-XML: Row data found in non-row dataset" << endl;
1289 int modelExportId = 0;
1290 bool modelOk =
false;
1291 modelExportId = attributes.value(
"model").trimmed().toInt(&modelOk);
1294 SVCERR <<
"WARNING: SV-XML: No model id specified for derivation" << endl;
1308 bool sourceOk =
false;
1309 sourceId = attributes.value(
"source").trimmed().toInt(&sourceOk);
1314 SVDEBUG <<
"NOTE: SV-XML: Can't find a model with id " << sourceId
1315 <<
" for derivation source, falling back to main model" << endl;
1322 int channel = attributes.value(
"channel").trimmed().toInt(&ok);
1326 QString type = attributes.value(
"type");
1328 if (type ==
"transform") {
1333 SVDEBUG <<
"NOTE: SV-XML: Reading old-style derivation element" 1337 QString transformId = attributes.value(
"transform");
1341 int stepSize = attributes.value(
"stepSize").trimmed().toInt(&ok);
1344 int blockSize = attributes.value(
"blockSize").trimmed().toInt(&ok);
1347 int windowType = attributes.value(
"windowType").trimmed().toInt(&ok);
1351 if (!currentTransformSourceModel)
return true;
1353 sv_samplerate_t sampleRate = currentTransformSourceModel->getSampleRate();
1355 QString startFrameStr = attributes.value(
"startFrame");
1356 QString durationStr = attributes.value(
"duration");
1361 if (startFrameStr !=
"") {
1362 startFrame = startFrameStr.trimmed().toInt(&ok);
1363 if (!ok) startFrame = 0;
1365 if (durationStr !=
"") {
1366 duration = durationStr.trimmed().toInt(&ok);
1367 if (!ok) duration = 0;
1371 (RealTime::frame2RealTime(startFrame, sampleRate));
1374 (RealTime::frame2RealTime(duration, sampleRate));
1384 int modelExportId = 0;
1385 bool modelOk =
false;
1386 modelExportId = attributes.value(
"model").trimmed().toInt(&modelOk);
1389 SVCERR <<
"WARNING: SV-XML: No model id specified for play parameters" << endl;
1397 auto parameters = PlayParameterRepository::getInstance()->
1398 getPlayParameters(
m_models[modelExportId].untyped);
1401 SVCERR <<
"WARNING: SV-XML: Play parameters for model " 1403 <<
" not found - has model been added to document?" 1408 bool muted = (attributes.value(
"mute").trimmed() ==
"true");
1409 parameters->setPlayMuted(muted);
1411 float pan = attributes.value(
"pan").toFloat(&ok);
1412 if (ok) parameters->setPlayPan(pan);
1414 float gain = attributes.value(
"gain").toFloat(&ok);
1415 if (ok) parameters->setPlayGain(gain);
1417 QString clipId = attributes.value(
"clipId");
1418 if (clipId !=
"") parameters->setPlayClipId(clipId);
1426 SVCERR <<
"WARNING: SV-XML: Unknown model " << modelExportId
1427 <<
" for play parameters" << endl;
1442 SVCERR <<
"WARNING: SV-XML: Plugin found outside derivation or play parameters" << endl;
1455 QString configurationXml =
"<plugin";
1457 for (
int i = 0; i < attributes.length(); ++i) {
1458 configurationXml += QString(
" %1=\"%2\"")
1459 .arg(attributes.qName(i))
1460 .arg(XmlExportable::encodeEntities(attributes.value(i)));
1463 configurationXml +=
"/>";
1465 TransformFactory::getInstance()->
1476 QString ident = attributes.value(
"identifier");
1477 if (ident ==
"sample_player") {
1478 QString clipId = attributes.value(
"program");
1489 SVCERR <<
"WARNING: SV-XML: Transform found outside derivation" << endl;
1502 SVCERR <<
"WARNING: SV-XML: Parameter found outside derivation" << endl;
1506 QString name = attributes.value(
"name");
1508 SVCERR <<
"WARNING: SV-XML: Ignoring nameless transform parameter" 1513 float value = attributes.value(
"value").trimmed().toFloat();
1535 SVDEBUG <<
"SVFileReader::readMeasurement: inLayer " 1539 SVCERR <<
"WARNING: SV-XML: Measurement found outside layer" << endl;
1563 QXmlSimpleReader reader;
1564 reader.setContentHandler(
this);
1565 reader.setErrorHandler(
this);
1566 reader.parse(source);
1573 const QString &qName,
1574 const QXmlAttributes& atts)
override 1576 QString name = qName.toLower();
1592 }
else if (name ==
"data") {
1593 if (!m_inSv)
return true;
1595 }
else if (name ==
"model") {
1597 if (atts.value(
"mainModel").trimmed() ==
"true") {
1609 const QString &qName)
override 1611 QString name = qName.toLower();
1618 }
else if (name ==
"data") {
1640 QXmlInputSource source(&file);
1641 identifier.
parse(source);
bool readView(const QXmlAttributes &)
void setMainModel(ModelId)
Set the main model (the source for playback sample rate, etc) to the given wave file model...
virtual void addSelection(sv_frame_t start, sv_frame_t end)=0
Transform m_currentTransform
bool fatalError(const QXmlParseException &exception) override
std::map< ExportId, PendingAggregateRec > m_pendingAggregates
bool haveModel(ExportId id)
SVFileReaderPaneCallback & m_paneCallback
SVFileReader::FileType m_type
XmlExportable::ExportId ExportId
bool readPlugin(const QXmlAttributes &)
ModelId m_currentDerivedModel
std::map< ExportId, ExportId > m_awaitingDatasets
bool readSelection(const QXmlAttributes &)
bool startElement(const QString &namespaceURI, const QString &localName, const QString &qName, const QXmlAttributes &atts) override
bool addPointToDataset(const QXmlAttributes &)
bool addRowToDataset(const QXmlAttributes &)
ModelId m_currentTransformSource
ExportId m_pendingDerivedModel
QString m_datasetSeparator
void addNonDerivedModel(ModelId)
Add an imported model, i.e.
SVFileReader loads Sonic Visualiser XML files.
bool readDerivation(const QXmlAttributes &)
Layer * createLayer(LayerFactory::LayerType)
Create and return a new layer of the given type, associated with no model.
bool readMeasurement(const QXmlAttributes &)
bool readDatasetStart(const QXmlAttributes &)
bool error(const QXmlParseException &exception) override
void parse(QXmlInputSource &source)
ModelId getMainModel()
Get the main model (the source for playback sample rate, etc).
SVFileReader(Document *document, SVFileReaderPaneCallback &callback, QString location="")
bool readWindow(const QXmlAttributes &)
~SVFileIdentifier() override
static FileType identifyXmlFile(QString path)
#define READ_MANDATORY(TYPE, NAME, CONVERSION)
bool readPluginForTransform(const QXmlAttributes &)
bool addBinToDataset(const QXmlAttributes &)
std::map< ExportId, Layer * > m_layers
virtual Pane * addPane()=0
void modelRegenerationWarning(QString layerName, QString transformName, QString message)
bool m_currentTransformIsNewStyle
ExportId m_currentDataset
bool readLayer(const QXmlAttributes &)
A Sonic Visualiser document consists of a set of data models, and also the visualisation layers used ...
void modelRegenerationFailed(QString layerName, QString transformName, QString message)
bool startElement(const QString &, const QString &, const QString &qName, const QXmlAttributes &atts) override
SVFileReader::FileType getType() const
std::set< ModelId > m_addedModels
std::shared_ptr< PlayParameters > m_currentPlayParameters
void addLayerToView(View *, Layer *)
Add the given layer to the given view.
bool readTransform(const QXmlAttributes &)
void makeAggregateModels()
bool characters(const QString &) override
void setModel(Layer *, ModelId)
Associate the given model with the given layer.
bool readModel(const QXmlAttributes &)
std::vector< ExportId > components
std::map< ExportId, Path * > m_paths
bool readParameter(const QXmlAttributes &)
void parse(const QString &xmlData)
bool readPlayParameters(const QXmlAttributes &)
bool endElement(const QString &namespaceURI, const QString &localName, const QString &qName) override
void setIncomplete(bool i)
bool readRowData(const QString &)
void addAlreadyDerivedModel(const Transform &transform, const ModelTransformer::Input &input, ModelId outputModelToAdd)
Add a derived model associated with the given transform.
bool readPluginForPlayback(const QXmlAttributes &)
void deleteLayer(Layer *, bool force=false)
Delete the given layer, and also its associated model if no longer used by any other layer...
ModelId addDerivedModel(const Transform &transform, const ModelTransformer::Input &input, QString &returnedMessage)
Add a derived model associated with the given transform, running the transform and returning the resu...
int m_currentTransformChannel
virtual ~SVFileReaderPaneCallback()
std::map< ExportId, ModelId > m_models
bool endElement(const QString &, const QString &, const QString &qName) override