Merge pull request #349 from paulfd/kinwie-polyphony-test
Kinwie polyphony tests
This commit is contained in:
commit
023b6cd0d1
3 changed files with 67 additions and 1 deletions
|
|
@ -226,6 +226,9 @@ void sfz::Synth::handleMasterOpcodes(const std::vector<Opcode>& members)
|
||||||
if (auto value = readOpcode(member.value, Default::polyphonyRange))
|
if (auto value = readOpcode(member.value, Default::polyphonyRange))
|
||||||
currentSet->setPolyphonyLimit(*value);
|
currentSet->setPolyphonyLimit(*value);
|
||||||
break;
|
break;
|
||||||
|
case hash("sw_default"):
|
||||||
|
setValueFromOpcode(member, defaultSwitch, Default::keyRange);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
@ -267,6 +270,9 @@ void sfz::Synth::handleGroupOpcodes(const std::vector<Opcode>& members, const st
|
||||||
case hash("polyphony"):
|
case hash("polyphony"):
|
||||||
setValueFromOpcode(member, maxPolyphony, Default::polyphonyRange);
|
setValueFromOpcode(member, maxPolyphony, Default::polyphonyRange);
|
||||||
break;
|
break;
|
||||||
|
case hash("sw_default"):
|
||||||
|
setValueFromOpcode(member, defaultSwitch, Default::keyRange);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
@ -924,7 +930,7 @@ void sfz::Synth::noteOnDispatch(int delay, int noteNumber, float velocity) noexc
|
||||||
notePolyphonyCounter += 1;
|
notePolyphonyCounter += 1;
|
||||||
switch (region->selfMask) {
|
switch (region->selfMask) {
|
||||||
case SfzSelfMask::mask:
|
case SfzSelfMask::mask:
|
||||||
if (voice->getTriggerValue() < velocity) {
|
if (voice->getTriggerValue() <= velocity) {
|
||||||
if (!selfMaskCandidate || selfMaskCandidate->getTriggerValue() > voice->getTriggerValue())
|
if (!selfMaskCandidate || selfMaskCandidate->getTriggerValue() > voice->getTriggerValue())
|
||||||
selfMaskCandidate = voice.get();
|
selfMaskCandidate = voice.get();
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -224,3 +224,21 @@ TEST_CASE("[Polyphony] Not self-masking")
|
||||||
REQUIRE(synth.getVoiceView(2)->getTriggerValue() == 64_norm);
|
REQUIRE(synth.getVoiceView(2)->getTriggerValue() == 64_norm);
|
||||||
REQUIRE(!synth.getVoiceView(2)->releasedOrFree());
|
REQUIRE(!synth.getVoiceView(2)->releasedOrFree());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Polyphony] Self-masking with the exact same velocity")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path(), R"(
|
||||||
|
<region> sample=*sine key=64 note_polyphony=2
|
||||||
|
)");
|
||||||
|
synth.noteOn(0, 64, 64);
|
||||||
|
synth.noteOn(0, 64, 63);
|
||||||
|
synth.noteOn(0, 64, 63);
|
||||||
|
REQUIRE(synth.getNumActiveVoices(true) == 3); // One of these is releasing
|
||||||
|
REQUIRE(synth.getVoiceView(0)->getTriggerValue() == 64_norm);
|
||||||
|
REQUIRE(!synth.getVoiceView(0)->releasedOrFree());
|
||||||
|
REQUIRE(synth.getVoiceView(1)->getTriggerValue() == 63_norm);
|
||||||
|
REQUIRE(synth.getVoiceView(1)->releasedOrFree()); // The first one is the masking candidate since they have the same velocity
|
||||||
|
REQUIRE(synth.getVoiceView(2)->getTriggerValue() == 63_norm);
|
||||||
|
REQUIRE(!synth.getVoiceView(2)->releasedOrFree());
|
||||||
|
}
|
||||||
|
|
|
||||||
|
|
@ -939,3 +939,45 @@ TEST_CASE("[Synth] If rt_dead is active the release sample can sound after the a
|
||||||
|
|
||||||
REQUIRE( synth.getRegionView(1)->delayedReleases.empty() );
|
REQUIRE( synth.getRegionView(1)->delayedReleases.empty() );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Synth] sw_default works at a global level")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path(), R"(
|
||||||
|
<global> sw_default=36 sw_lokey=36 sw_hikey=39
|
||||||
|
<region> sw_last=36 key=62 sample=*sine
|
||||||
|
<region> sw_last=37 key=63 sample=*sine
|
||||||
|
)");
|
||||||
|
synth.noteOn(0, 63, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 0 );
|
||||||
|
synth.noteOn(0, 62, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Synth] sw_default works at a master level")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path(), R"(
|
||||||
|
<master> sw_default=36 sw_lokey=36 sw_hikey=39
|
||||||
|
<region> sw_last=36 key=62 sample=*sine
|
||||||
|
<region> sw_last=37 key=63 sample=*sine
|
||||||
|
)");
|
||||||
|
synth.noteOn(0, 63, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 0 );
|
||||||
|
synth.noteOn(0, 62, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 1 );
|
||||||
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Synth] sw_default works at a group level")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
synth.loadSfzString(fs::current_path(), R"(
|
||||||
|
<group> sw_default=36 sw_lokey=36 sw_hikey=39
|
||||||
|
<region> sw_last=36 key=62 sample=*sine
|
||||||
|
<region> sw_last=37 key=63 sample=*sine
|
||||||
|
)");
|
||||||
|
synth.noteOn(0, 63, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 0 );
|
||||||
|
synth.noteOn(0, 62, 85);
|
||||||
|
REQUIRE( synth.getNumActiveVoices(true) == 1 );
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue