Better messaging
This commit is contained in:
parent
a98e909eeb
commit
5d8eda7428
2 changed files with 35 additions and 0 deletions
|
|
@ -188,6 +188,8 @@ void sfz::Synth::dispatchMessage(Client& client, int delay, const char* path, co
|
|||
GET_REGION_OR_BREAK(indices[0])
|
||||
if (region.sampleCount)
|
||||
client.receive<'h'>(delay, path, *region.sampleCount);
|
||||
else
|
||||
client.receive<'N'>(delay, path, {});
|
||||
} break;
|
||||
|
||||
MATCH("/region&/loop_range", "") {
|
||||
|
|
@ -226,6 +228,14 @@ void sfz::Synth::dispatchMessage(Client& client, int delay, const char* path, co
|
|||
client.receive<'f'>(delay, path, region.loopCrossfade);
|
||||
} break;
|
||||
|
||||
MATCH("/region&/loop_count", "") {
|
||||
GET_REGION_OR_BREAK(indices[0])
|
||||
if (region.loopCount)
|
||||
client.receive<'h'>(delay, path, *region.loopCount);
|
||||
else
|
||||
client.receive<'N'>(delay, path, {});
|
||||
} break;
|
||||
|
||||
MATCH("/region&/group", "") {
|
||||
GET_REGION_OR_BREAK(indices[0])
|
||||
client.receive<'h'>(delay, path, region.group);
|
||||
|
|
|
|||
|
|
@ -237,7 +237,9 @@ TEST_CASE("[Values] Count")
|
|||
synth.dispatchMessage(client, 0, "/region1/count", "", nullptr);
|
||||
synth.dispatchMessage(client, 0, "/region2/count", "", nullptr);
|
||||
std::vector<std::string> expected {
|
||||
"/region0/count,N : { }",
|
||||
"/region1/count,h : { 2 }",
|
||||
"/region2/count,N : { }",
|
||||
};
|
||||
REQUIRE(messageList == expected);
|
||||
}
|
||||
|
|
@ -348,6 +350,29 @@ TEST_CASE("[Values] Loop crossfade")
|
|||
REQUIRE(messageList == expected);
|
||||
}
|
||||
|
||||
TEST_CASE("[Values] Loop count")
|
||||
{
|
||||
Synth synth;
|
||||
std::vector<std::string> messageList;
|
||||
Client client(&messageList);
|
||||
client.setReceiveCallback(&simpleMessageReceiver);
|
||||
synth.loadSfzString(fs::current_path() / "tests/TestFiles/value_tests.sfz", R"(
|
||||
<region> sample=kick.wav
|
||||
<region> sample=kick.wav loop_count=2
|
||||
<region> sample=kick.wav loop_count=-1
|
||||
)");
|
||||
synth.dispatchMessage(client, 0, "/region0/loop_count", "", nullptr);
|
||||
synth.dispatchMessage(client, 0, "/region1/loop_count", "", nullptr);
|
||||
synth.dispatchMessage(client, 0, "/region2/loop_count", "", nullptr);
|
||||
std::vector<std::string> expected {
|
||||
"/region0/loop_count,N : { }",
|
||||
"/region1/loop_count,h : { 2 }",
|
||||
"/region2/loop_count,N : { }",
|
||||
};
|
||||
REQUIRE(messageList == expected);
|
||||
}
|
||||
|
||||
|
||||
TEST_CASE("[Values] Group")
|
||||
{
|
||||
Synth synth;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue