Parse off time
This commit is contained in:
parent
7a1a2c9381
commit
d3cc4281d9
4 changed files with 23 additions and 1 deletions
|
|
@ -31,7 +31,7 @@
|
|||
|
||||
enum class SfzTrigger { attack, release, release_key, first, legato };
|
||||
enum class SfzLoopMode { no_loop, one_shot, loop_continuous, loop_sustain };
|
||||
enum class SfzOffMode { fast, normal };
|
||||
enum class SfzOffMode { fast, normal, time };
|
||||
enum class SfzVelocityOverride { current, previous };
|
||||
enum class SfzCrossfadeCurve { gain, power };
|
||||
enum class SfzSelfMask { mask, dontMask };
|
||||
|
|
@ -75,6 +75,7 @@ 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 float offTime { 6e-3f };
|
||||
constexpr Range<uint32_t> polyphonyRange { 0, config::maxVoices };
|
||||
constexpr SfzSelfMask selfMask { SfzSelfMask::mask };
|
||||
|
||||
|
|
|
|||
|
|
@ -161,10 +161,16 @@ bool sfz::Region::parseOpcode(const Opcode& rawOpcode)
|
|||
case hash("normal"):
|
||||
offMode = SfzOffMode::normal;
|
||||
break;
|
||||
case hash("time"):
|
||||
offMode = SfzOffMode::time;
|
||||
break;
|
||||
default:
|
||||
DBG("Unkown off mode:" << opcode.value);
|
||||
}
|
||||
break;
|
||||
case hash("off_time"):
|
||||
setValueFromOpcode(opcode, offTime, Default::egTimeRange);
|
||||
break;
|
||||
case hash("polyphony"):
|
||||
if (auto value = readOpcode(opcode.value, Default::polyphonyRange))
|
||||
polyphony = *value;
|
||||
|
|
|
|||
|
|
@ -286,6 +286,7 @@ struct Region {
|
|||
uint32_t group { Default::group }; // group
|
||||
absl::optional<uint32_t> offBy {}; // off_by
|
||||
SfzOffMode offMode { Default::offMode }; // off_mode
|
||||
float offTime { Default::offTime }; // off_mode
|
||||
absl::optional<uint32_t> notePolyphony {}; // note_polyphony
|
||||
unsigned polyphony { config::maxVoices }; // polyphony
|
||||
SfzSelfMask selfMask { Default::selfMask };
|
||||
|
|
|
|||
|
|
@ -195,6 +195,20 @@ TEST_CASE("[Region] Parsing opcodes")
|
|||
REQUIRE(region.offMode == SfzOffMode::fast);
|
||||
region.parseOpcode({ "off_mode", "normal" });
|
||||
REQUIRE(region.offMode == SfzOffMode::normal);
|
||||
region.parseOpcode({ "off_mode", "time" });
|
||||
REQUIRE(region.offMode == SfzOffMode::time);
|
||||
}
|
||||
|
||||
SECTION("off_time")
|
||||
{
|
||||
REQUIRE(region.offTime == 0.006f);
|
||||
region.parseOpcode({ "off_time", "0.1" });
|
||||
REQUIRE(region.offTime == 0.1f);
|
||||
region.parseOpcode({ "off_time", "0" });
|
||||
REQUIRE(region.offTime == 0.0f);
|
||||
region.parseOpcode({ "off_time", "0.1" });
|
||||
region.parseOpcode({ "off_time", "-1" });
|
||||
REQUIRE(region.offTime == 0.0f);
|
||||
}
|
||||
|
||||
SECTION("lokey, hikey, and key")
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue