zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 4f1db1ebfa6a31cf37633ee470c9af407eb8896d
parent f0a34795dd8543df36e44ad346c0c1fdff703284
Author: Johannes Lorenz <[email protected]>
Date:   Fri, 24 Mar 2023 17:12:00 +0100

Savefile: Don't write ports twice

This uses two new rtosc features:

* "alreadyWritten": Ports that were already written will not be written
  again
* "propsToExclude": Ports with property "non-realtime" will not be
  written from the Master port tree

Diffstat:
Msrc/Misc/Master.cpp | 4+++-
Msrc/Misc/Master.h | 3++-
Msrc/Misc/MiddleWare.cpp | 7++++---
3 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/src/Misc/Master.cpp b/src/Misc/Master.cpp @@ -1809,10 +1809,12 @@ char* Master::getXMLData() // this is being called as a "read only op" directly by the MiddleWare thread; // note that the Master itself is frozen -std::string Master::saveOSC(std::string savefile) +std::string Master::saveOSC(std::string savefile, std::set<std::string>& alreadyWritten) { return rtosc::save_to_file(ports, this, nullptr, version_in_rtosc_fmt(), // both unused + alreadyWritten, + {"non-realtime"}, // excluded non-reatlime ports savefile); } diff --git a/src/Misc/Master.h b/src/Misc/Master.h @@ -17,6 +17,7 @@ #include "../globals.h" #include "Microtonal.h" #include <atomic> +#include <set> #include <rtosc/automations.h> #include <rtosc/miditable.h> #include <rtosc/savefile.h> @@ -78,7 +79,7 @@ class Master int loadXML(const char *filename); /**Append all settings to an OSC savefile (as specified by RT OSC)*/ - std::string saveOSC(std::string savefile); + std::string saveOSC(std::string savefile, std::set<std::string>& alreadyWritten); /**loads all settings from an OSC file (as specified by RT OSC) * @param dispatcher Message dispatcher and modifier * @return 0 for ok or <0 if there is an error*/ diff --git a/src/Misc/MiddleWare.cpp b/src/Misc/MiddleWare.cpp @@ -758,18 +758,19 @@ public: master2.frozenState = true; std::string savefile; + std::set<std::string> alreadyWritten; rtosc_version m_version = { (unsigned char) version.get_major(), (unsigned char) version.get_minor(), (unsigned char) version.get_revision() }; - savefile = rtosc::save_to_file(getNonRtParamPorts(), this, "ZynAddSubFX", m_version); + savefile = rtosc::save_to_file(getNonRtParamPorts(), this, "ZynAddSubFX", m_version, alreadyWritten, {}); savefile += '\n'; - doReadOnlyOp([this,filename,&dispatcher,&master2,&savefile,&res]() + doReadOnlyOp([this,filename,&dispatcher,&master2,&savefile,&res,&alreadyWritten]() { - savefile = master->saveOSC(savefile); + savefile = master->saveOSC(savefile, alreadyWritten); #if 1 // load the savefile string into another master to compare the results // between the original and the savefile-loaded master