Parse offset_cc
This commit is contained in:
parent
6eb71b288e
commit
64a591fb7a
4 changed files with 21 additions and 0 deletions
|
|
@ -49,6 +49,7 @@ namespace Default
|
||||||
constexpr uint32_t offset { 0 };
|
constexpr uint32_t offset { 0 };
|
||||||
constexpr uint32_t offsetRandom { 0 };
|
constexpr uint32_t offsetRandom { 0 };
|
||||||
constexpr Range<uint32_t> offsetRange { 0, std::numeric_limits<uint32_t>::max() };
|
constexpr Range<uint32_t> offsetRange { 0, std::numeric_limits<uint32_t>::max() };
|
||||||
|
constexpr Range<uint32_t> offsetCCRange = offsetRange;
|
||||||
constexpr Range<uint32_t> sampleEndRange { 0, std::numeric_limits<uint32_t>::max() };
|
constexpr Range<uint32_t> sampleEndRange { 0, std::numeric_limits<uint32_t>::max() };
|
||||||
constexpr Range<uint32_t> sampleCountRange { 0, std::numeric_limits<uint32_t>::max() };
|
constexpr Range<uint32_t> sampleCountRange { 0, std::numeric_limits<uint32_t>::max() };
|
||||||
constexpr SfzLoopMode loopMode { SfzLoopMode::no_loop };
|
constexpr SfzLoopMode loopMode { SfzLoopMode::no_loop };
|
||||||
|
|
|
||||||
|
|
@ -59,6 +59,12 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
||||||
case hash("offset_random"):
|
case hash("offset_random"):
|
||||||
setValueFromOpcode(opcode, offsetRandom, Default::offsetRange);
|
setValueFromOpcode(opcode, offsetRandom, Default::offsetRange);
|
||||||
break;
|
break;
|
||||||
|
case hash("offset_cc&"):
|
||||||
|
if (opcode.parameters.back() > config::numCCs)
|
||||||
|
return false;
|
||||||
|
if (auto value = readOpcode(opcode.value, Default::offsetCCRange))
|
||||||
|
offsetCC[opcode.parameters.back()] = *value;
|
||||||
|
break;
|
||||||
case hash("end"):
|
case hash("end"):
|
||||||
setValueFromOpcode(opcode, sampleEnd, Default::sampleEndRange);
|
setValueFromOpcode(opcode, sampleEnd, Default::sampleEndRange);
|
||||||
break;
|
break;
|
||||||
|
|
|
||||||
|
|
@ -232,6 +232,7 @@ struct Region {
|
||||||
float delayRandom { Default::delayRandom }; // delay_random
|
float delayRandom { Default::delayRandom }; // delay_random
|
||||||
uint32_t offset { Default::offset }; // offset
|
uint32_t offset { Default::offset }; // offset
|
||||||
uint32_t offsetRandom { Default::offsetRandom }; // offset_random
|
uint32_t offsetRandom { Default::offsetRandom }; // offset_random
|
||||||
|
CCMap<uint32_t> offsetCC { Default::offset };
|
||||||
uint32_t sampleEnd { Default::sampleEndRange.getEnd() }; // end
|
uint32_t sampleEnd { Default::sampleEndRange.getEnd() }; // end
|
||||||
absl::optional<uint32_t> sampleCount {}; // count
|
absl::optional<uint32_t> sampleCount {}; // count
|
||||||
absl::optional<SfzLoopMode> loopMode {}; // loopmode
|
absl::optional<SfzLoopMode> loopMode {}; // loopmode
|
||||||
|
|
|
||||||
|
|
@ -53,6 +53,19 @@ TEST_CASE("[Region] Parsing opcodes")
|
||||||
region.parseOpcode({ "offset", "-1" });
|
region.parseOpcode({ "offset", "-1" });
|
||||||
REQUIRE(region.offset == 0);
|
REQUIRE(region.offset == 0);
|
||||||
}
|
}
|
||||||
|
SECTION("offset_cc")
|
||||||
|
{
|
||||||
|
REQUIRE(region.offsetCC.empty());
|
||||||
|
region.parseOpcode({ "offset_cc1", "1" });
|
||||||
|
REQUIRE(region.offsetCC.contains(1));
|
||||||
|
REQUIRE(region.offsetCC[1] == 1);
|
||||||
|
region.parseOpcode({ "offset_cc2", "15420" });
|
||||||
|
REQUIRE(region.offsetCC.contains(2));
|
||||||
|
REQUIRE(region.offsetCC[2] == 15420);
|
||||||
|
region.parseOpcode({ "offset_cc2", "-1" });
|
||||||
|
REQUIRE(region.offsetCC[2] == 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
SECTION("offset_random")
|
SECTION("offset_random")
|
||||||
{
|
{
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue