Skip to content

Commit

Permalink
Update CMT submodule / Upgrade code for CMT delays (#7206)
Browse files Browse the repository at this point in the history
## 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.
  • Loading branch information
michaelgregorius committed Apr 14, 2024
1 parent d3ab315 commit d2c2a80
Show file tree
Hide file tree
Showing 3 changed files with 42 additions and 2 deletions.
1 change: 1 addition & 0 deletions include/DataFile.h
Expand Up @@ -129,6 +129,7 @@ class LMMS_EXPORT DataFile : public QDomDocument
void upgrade_midiCCIndexing();
void upgrade_loopsRename();
void upgrade_noteTypes();
void upgrade_fixCMTDelays();

// List of all upgrade methods
static const std::vector<UpgradeMethod> UPGRADE_METHODS;
Expand Down
2 changes: 1 addition & 1 deletion plugins/LadspaEffect/cmt/cmt
Submodule cmt updated 2 files
+4 −1 src/cmt.h
+13 −4 src/delay.cpp
41 changes: 40 additions & 1 deletion src/core/DataFile.cpp
Expand Up @@ -83,7 +83,8 @@ const std::vector<DataFile::UpgradeMethod> 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.
Expand Down Expand Up @@ -1684,6 +1685,44 @@ void DataFile::upgrade_noteTypes()
}
}

void DataFile::upgrade_fixCMTDelays()
{
static const QMap<QString, QString> 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
*
Expand Down

0 comments on commit d2c2a80

Please sign in to comment.