Add switch labels to the midnam

This commit is contained in:
Paul Fd 2020-04-16 00:53:40 +02:00
parent aa4af91131
commit 4b55f955d6
2 changed files with 10 additions and 0 deletions

View file

@ -396,6 +396,10 @@ bool sfz::Synth::loadSfzFile(const fs::path& file)
}
}
if (region->keyswitchLabel && region->keyswitch)
keyswitchLabels.push_back({ *region->keyswitch, *region->keyswitchLabel });
// Some regions had group number but no "group-level" opcodes handled the polyphony
while (groupMaxPolyphony.size() <= region->group)
groupMaxPolyphony.push_back(config::maxVoices);
@ -891,6 +895,11 @@ std::string sfz::Synth::exportMidnam(absl::string_view model) const
{
pugi::xml_node nnl = device.append_child("NoteNameList");
nnl.append_attribute("Name").set_value("Notes");
for (const auto& pair : keyswitchLabels) {
pugi::xml_node nn = nnl.append_child("Note");
nn.append_attribute("Number").set_value(std::to_string(pair.first).c_str());
nn.append_attribute("Name").set_value(pair.second.c_str());
}
for (const auto& pair : keyLabels) {
pugi::xml_node nn = nnl.append_child("Note");
nn.append_attribute("Number").set_value(std::to_string(pair.first).c_str());

View file

@ -511,6 +511,7 @@ private:
// Names for the CC and notes as set by label_cc and label_key
std::vector<CCNamePair> ccLabels;
std::vector<NoteNamePair> keyLabels;
std::vector<NoteNamePair> keyswitchLabels;
// Default active switch if multiple keyswitchable regions are present
absl::optional<uint8_t> defaultSwitch;