From d2c2a805064e504edd06841609be28e0ac38a26e Mon Sep 17 00:00:00 2001 From: Michael Gregorius Date: Sun, 14 Apr 2024 18:03:39 +0200 Subject: [PATCH] Update CMT submodule / Upgrade code for CMT delays (#7206) ## Bump CMT to d8bf8084aa3 Bump the CMT submodule to commit d8bf8084aa3 which contains the underlying fixes for issue #5167. The CMT delay uses `sprintf` calls to generate the technical names and display names of the delays. These calls are locale dependent. As a consequence for example the feedback delay might have been saved either as "fbdelay_0.1s" (point) or "fbdelay_0,1s" (comma) in a save file. The CMT fix makes sure that all delays use points in their names and thus that they now always report the same name strings. ## Add upgrade routine for CMT delays Add an upgrade routine for CMT delays which works in conjunction with the upgraded CMT submodule. Because the delays will now always report their name with points old save files which might contain versions with the comma must be upgraded to a name with a point. --- include/DataFile.h | 1 + plugins/LadspaEffect/cmt/cmt | 2 +- src/core/DataFile.cpp | 41 +++++++++++++++++++++++++++++++++++- 3 files changed, 42 insertions(+), 2 deletions(-) diff --git a/include/DataFile.h b/include/DataFile.h index ce5d4edf4..452481a7f 100644 --- a/include/DataFile.h +++ b/include/DataFile.h @@ -129,6 +129,7 @@ private: void upgrade_midiCCIndexing(); void upgrade_loopsRename(); void upgrade_noteTypes(); + void upgrade_fixCMTDelays(); // List of all upgrade methods static const std::vector UPGRADE_METHODS; diff --git a/plugins/LadspaEffect/cmt/cmt b/plugins/LadspaEffect/cmt/cmt index 6e6e291fb..d8bf8084a 160000 --- a/plugins/LadspaEffect/cmt/cmt +++ b/plugins/LadspaEffect/cmt/cmt @@ -1 +1 @@ -Subproject commit 6e6e291fbad1138c808860ba3f140a963b52fa58 +Subproject commit d8bf8084aa3a47497092f5ab99c843a55090d151 diff --git a/src/core/DataFile.cpp b/src/core/DataFile.cpp index eedb7f01d..00c6845f3 100644 --- a/src/core/DataFile.cpp +++ b/src/core/DataFile.cpp @@ -83,7 +83,8 @@ const std::vector DataFile::UPGRADE_METHODS = { &DataFile::upgrade_defaultTripleOscillatorHQ, &DataFile::upgrade_mixerRename , &DataFile::upgrade_bbTcoRename, &DataFile::upgrade_sampleAndHold , &DataFile::upgrade_midiCCIndexing, - &DataFile::upgrade_loopsRename , &DataFile::upgrade_noteTypes + &DataFile::upgrade_loopsRename , &DataFile::upgrade_noteTypes, + &DataFile::upgrade_fixCMTDelays }; // Vector of all versions that have upgrade routines. @@ -1684,6 +1685,44 @@ void DataFile::upgrade_noteTypes() } } +void DataFile::upgrade_fixCMTDelays() +{ + static const QMap nameMap { + { "delay_0,01s", "delay_0.01s" }, + { "delay_0,1s", "delay_0.1s" }, + { "fbdelay_0,01s", "fbdelay_0.01s" }, + { "fbdelay_0,1s", "fbdelay_0.1s" } + }; + + const auto effects = elementsByTagName("effect"); + + for (int i = 0; i < effects.size(); ++i) + { + auto effect = effects.item(i).toElement(); + + // We are only interested in LADSPA plugins + if (effect.attribute("name") != "ladspaeffect") { continue; } + + // Fetch all attributes (LMMS) beneath the LADSPA effect so that we can check the value of the plugin attribute (XML) + auto attributes = effect.elementsByTagName("attribute"); + for (int j = 0; j < attributes.size(); ++j) + { + auto attribute = attributes.item(j).toElement(); + + if (attribute.attribute("name") == "plugin") + { + const auto attributeValue = attribute.attribute("value"); + + const auto it = nameMap.constFind(attributeValue); + if (it != nameMap.constEnd()) + { + attribute.setAttribute("value", *it); + } + } + } + } +} + /** \brief Note range has been extended to match MIDI specification *