From 4b55f955d639b5d71beb0b77f5f73cab6f80da4e Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Thu, 16 Apr 2020 00:53:40 +0200 Subject: [PATCH] Add switch labels to the midnam --- src/sfizz/Synth.cpp | 9 +++++++++ src/sfizz/Synth.h | 1 + 2 files changed, 10 insertions(+) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 03f3cc34..6c30fe56 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -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()); diff --git a/src/sfizz/Synth.h b/src/sfizz/Synth.h index 738e54d2..0eddea0b 100644 --- a/src/sfizz/Synth.h +++ b/src/sfizz/Synth.h @@ -511,6 +511,7 @@ private: // Names for the CC and notes as set by label_cc and label_key std::vector ccLabels; std::vector keyLabels; + std::vector keyswitchLabels; // Default active switch if multiple keyswitchable regions are present absl::optional defaultSwitch;