Skip to content

Commit

Permalink
Formula preset with custon out names save names in LFO preset (#7873)
Browse files Browse the repository at this point in the history
Closes #7351
  • Loading branch information
baconpaul authored Nov 29, 2024
1 parent e96c99d commit a114028
Showing 1 changed file with 40 additions and 0 deletions.
40 changes: 40 additions & 0 deletions src/common/ModulatorPresetManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,26 @@ void ModulatorPreset::savePresetToUser(const fs::path &location, SurgeStorage *s
lfox.InsertEndChild(fm);
}

if (lfotype == lt_formula)
{
TiXmlElement xtraName("indexNames");
bool hasAny{false};
for (int i = 0; i < max_lfo_indices; ++i)
{
if (s->getPatch().LFOBankLabel[scene][lfoid][i][0] != 0)
{
hasAny = true;
TiXmlElement xn("name");
xn.SetAttribute("index", i);
xn.SetAttribute("name", s->getPatch().LFOBankLabel[scene][lfoid][i]);
xtraName.InsertEndChild(xn);
}
}
if (hasAny)
{
lfox.InsertEndChild(xtraName);
}
}
doc.InsertEndChild(lfox);

if (!doc.SaveFile(fullLocation))
Expand Down Expand Up @@ -239,6 +259,26 @@ void ModulatorPreset::loadPresetFrom(const fs::path &location, SurgeStorage *s,
if (frm)
s->getPatch().formulaFromXMLElement(&(s->getPatch().formulamods[scene][lfoid]), frm);
}

auto xn = lfox->FirstChildElement("indexNames");
if (xn)
{
auto nn = xn->FirstChildElement("name");
while (nn)
{
auto na = nn->Attribute("name");
int ni{0};
auto res = nn->QueryIntAttribute("index", &ni);
if (na && res == TIXML_SUCCESS && ni >= 0 && ni < max_lfo_indices)
{
memset(s->getPatch().LFOBankLabel[scene][lfoid][ni], 0,
CUSTOM_CONTROLLER_LABEL_SIZE * sizeof(char));
strncpy(s->getPatch().LFOBankLabel[scene][lfoid][ni], na,
CUSTOM_CONTROLLER_LABEL_SIZE - 1);
}
nn = nn->NextSiblingElement("name");
}
}
}

/*
Expand Down

0 comments on commit a114028

Please sign in to comment.