From 5cbd21af51d7fa6d295d2955eb199566078baf22 Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Mon, 30 Dec 2019 00:32:15 +0100 Subject: [PATCH] For libraries that do not specify keyswitch ranges only add regions to the activation list if it has actual keyswitch opcodes --- src/sfizz/Region.h | 2 ++ src/sfizz/Synth.cpp | 3 ++- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/src/sfizz/Region.h b/src/sfizz/Region.h index ebe08187..7f035ddd 100644 --- a/src/sfizz/Region.h +++ b/src/sfizz/Region.h @@ -219,6 +219,8 @@ struct Region { uint32_t loopStart(Oversampling factor = Oversampling::x1) const noexcept; uint32_t loopEnd(Oversampling factor = Oversampling::x1) const noexcept; + bool hasKeyswitches() const noexcept { return keyswitchDown || keyswitchUp || keyswitch || previousNote; } + // Sound source: sample playback std::string sample {}; // Sample float delay { Default::delay }; // delay diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 4030347b..511e94c7 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -273,7 +273,8 @@ bool sfz::Synth::loadSfzFile(const fs::path& filename) } for (auto note = 0; note < 128; note++) { - if (region->keyRange.containsWithEnd(note) || region->keyswitchRange.containsWithEnd(note)) + if (region->keyRange.containsWithEnd(note) || + (region->hasKeyswitches() && region->keyswitchRange.containsWithEnd(note))) noteActivationLists[note].push_back(region); }