Gracefully handle non-conforming floating point values for integer opcodes
This commit is contained in:
parent
3da8109170
commit
965321166c
4 changed files with 14 additions and 5 deletions
|
|
@ -46,11 +46,9 @@ public:
|
|||
const std::vector<std::filesystem::path>& getIncludedFiles() const noexcept { return includedFiles; }
|
||||
void disableRecursiveIncludeGuard() { recursiveIncludeGuard = false; }
|
||||
void enableRecursiveIncludeGuard() { recursiveIncludeGuard = true; }
|
||||
|
||||
protected:
|
||||
virtual void callback(std::string_view header, const std::vector<Opcode>& members) = 0;
|
||||
std::filesystem::path rootDirectory { std::filesystem::current_path() };
|
||||
|
||||
private:
|
||||
bool recursiveIncludeGuard { false };
|
||||
std::map<std::string, std::string> defines;
|
||||
|
|
|
|||
|
|
@ -133,17 +133,17 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
{
|
||||
for (auto& member : members) {
|
||||
switch (hash(member.opcode)) {
|
||||
case hash("Set_cc"): [[fallthrough]]
|
||||
case hash("Set_cc"): [[fallthrough]];
|
||||
case hash("set_cc"):
|
||||
if (member.parameter && Default::ccRange.containsWithEnd(*member.parameter))
|
||||
setValueFromOpcode(member, ccState[*member.parameter], Default::ccRange);
|
||||
break;
|
||||
case hash("Label_cc"): [[fallthrough]]
|
||||
case hash("Label_cc"): [[fallthrough]];
|
||||
case hash("label_cc"):
|
||||
if (member.parameter && Default::ccRange.containsWithEnd(*member.parameter))
|
||||
ccNames.emplace_back(*member.parameter, member.value);
|
||||
break;
|
||||
case hash("Default_path"): [[fallthrough]]
|
||||
case hash("Default_path"): [[fallthrough]];
|
||||
case hash("default_path"):
|
||||
if (auto newPath = std::filesystem::path(member.value); std::filesystem::exists(newPath))
|
||||
rootDirectory = newPath;
|
||||
|
|
|
|||
|
|
@ -4,6 +4,7 @@
|
|||
project(sfizz)
|
||||
|
||||
set(SFIZZ_TEST_SOURCES
|
||||
RegionT.cpp
|
||||
RegexT.cpp
|
||||
HelpersT.cpp
|
||||
HelpersT.cpp
|
||||
|
|
|
|||
|
|
@ -1011,4 +1011,14 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(region.amplitudeEG.ccStart->second == -100.0f);
|
||||
REQUIRE(region.amplitudeEG.ccSustain->second == -100.0f);
|
||||
}
|
||||
}
|
||||
|
||||
// Specific region bugs
|
||||
TEST_CASE("[Region] Non-conforming floating point values in integer opcodes")
|
||||
{
|
||||
sfz::Region region;
|
||||
region.parseOpcode({ "offset", "2014.5" });
|
||||
REQUIRE(region.offset == 2014);
|
||||
region.parseOpcode({ "pitch_keytrack", "-2.1" });
|
||||
REQUIRE(region.pitchKeytrack == -2);
|
||||
}
|
||||
Loading…
Add table
Reference in a new issue