Add note_polyphony and note_selfmask in the parser
This commit is contained in:
parent
fbb1cc9efc
commit
30061bdb4e
4 changed files with 44 additions and 0 deletions
|
|
@ -34,6 +34,7 @@ enum class SfzLoopMode { no_loop, one_shot, loop_continuous, loop_sustain };
|
|||
enum class SfzOffMode { fast, normal };
|
||||
enum class SfzVelocityOverride { current, previous };
|
||||
enum class SfzCrossfadeCurve { gain, power };
|
||||
enum class SfzSelfMask { mask, dontMask };
|
||||
|
||||
namespace sfz
|
||||
{
|
||||
|
|
@ -65,6 +66,8 @@ namespace Default
|
|||
constexpr uint32_t group { 0 };
|
||||
constexpr Range<uint32_t> groupRange { 0, std::numeric_limits<uint32_t>::max() };
|
||||
constexpr SfzOffMode offMode { SfzOffMode::fast };
|
||||
constexpr Range<uint32_t> polyphonyRange { 0, config::maxVoices };
|
||||
constexpr SfzSelfMask selfMask { SfzSelfMask::mask };
|
||||
|
||||
// Region logic: key mapping
|
||||
constexpr Range<uint8_t> keyRange { 0, 127 };
|
||||
|
|
|
|||
|
|
@ -124,6 +124,22 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unkown off mode:" << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("note_polyphony"):
|
||||
if (auto value = readOpcode(opcode.value, Default::polyphonyRange))
|
||||
notePolyphony = *value;
|
||||
break;
|
||||
case hash("note_selfmask"):
|
||||
switch (hash(opcode.value)) {
|
||||
case hash("on"):
|
||||
selfMask = SfzSelfMask::mask;
|
||||
break;
|
||||
case hash("off"):
|
||||
selfMask = SfzSelfMask::dontMask;
|
||||
break;
|
||||
default:
|
||||
DBG("Unkown self mask value:" << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
// Region logic: key mapping
|
||||
case hash("lokey"):
|
||||
setRangeStartFromOpcode(opcode, keyRange, Default::keyRange);
|
||||
|
|
|
|||
|
|
@ -240,6 +240,8 @@ struct Region {
|
|||
uint32_t group { Default::group }; // group
|
||||
absl::optional<uint32_t> offBy {}; // off_by
|
||||
SfzOffMode offMode { Default::offMode }; // off_mode
|
||||
absl::optional<uint32_t> notePolyphony {};
|
||||
SfzSelfMask selfMask { Default::selfMask };
|
||||
|
||||
// Region logic: key mapping
|
||||
Range<uint8_t> keyRange { Default::keyRange }; //lokey, hikey and key
|
||||
|
|
|
|||
|
|
@ -1407,6 +1407,29 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
region.parseOpcode({ "oscillator_phase", "361" });
|
||||
REQUIRE(region.oscillatorPhase == 360.0f);
|
||||
}
|
||||
|
||||
SECTION("Note polyphony")
|
||||
{
|
||||
REQUIRE(!region.notePolyphony);
|
||||
region.parseOpcode({ "note_polyphony", "45" });
|
||||
REQUIRE(region.notePolyphony);
|
||||
REQUIRE(*region.notePolyphony == 45);
|
||||
region.parseOpcode({ "note_polyphony", "-1" });
|
||||
REQUIRE(region.notePolyphony);
|
||||
REQUIRE(*region.notePolyphony == 0);
|
||||
}
|
||||
|
||||
SECTION("Note selfmask")
|
||||
{
|
||||
REQUIRE(region.selfMask == SfzSelfMask::mask);
|
||||
region.parseOpcode({ "note_selfmask", "off" });
|
||||
REQUIRE(region.selfMask == SfzSelfMask::dontMask);
|
||||
region.parseOpcode({ "note_selfmask", "on" });
|
||||
REQUIRE(region.selfMask == SfzSelfMask::mask);
|
||||
region.parseOpcode({ "note_selfmask", "off" });
|
||||
region.parseOpcode({ "note_selfmask", "garbage" });
|
||||
REQUIRE(region.selfMask == SfzSelfMask::dontMask);
|
||||
}
|
||||
}
|
||||
|
||||
// Specific region bugs
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue