Merge pull request #1024 from paulfd/cc-switch-choke
Choke notes when the layer is disabled, even if the group and note are the same
This commit is contained in:
commit
b796564338
2 changed files with 23 additions and 1 deletions
|
|
@ -218,6 +218,7 @@ struct Voice::Impl
|
||||||
const NumericId<Voice> id_;
|
const NumericId<Voice> id_;
|
||||||
StateListener* stateListener_ = nullptr;
|
StateListener* stateListener_ = nullptr;
|
||||||
|
|
||||||
|
const Layer* layer_ { nullptr };
|
||||||
const Region* region_ { nullptr };
|
const Region* region_ { nullptr };
|
||||||
|
|
||||||
State state_ { State::idle };
|
State state_ { State::idle };
|
||||||
|
|
@ -411,6 +412,7 @@ bool Voice::startVoice(Layer* layer, int delay, const TriggerEvent& event) noexc
|
||||||
MidiState& midiState = resources.getMidiState();
|
MidiState& midiState = resources.getMidiState();
|
||||||
CurveSet& curveSet = resources.getCurves();
|
CurveSet& curveSet = resources.getCurves();
|
||||||
|
|
||||||
|
impl.layer_ = layer;
|
||||||
const Region& region = layer->getRegion();
|
const Region& region = layer->getRegion();
|
||||||
impl.region_ = ®ion;
|
impl.region_ = ®ion;
|
||||||
|
|
||||||
|
|
@ -1663,6 +1665,7 @@ bool Voice::Impl::released() const noexcept
|
||||||
bool Voice::checkOffGroup(const Region* other, int delay, int noteNumber) noexcept
|
bool Voice::checkOffGroup(const Region* other, int delay, int noteNumber) noexcept
|
||||||
{
|
{
|
||||||
Impl& impl = *impl_;
|
Impl& impl = *impl_;
|
||||||
|
const Layer* layer = impl.layer_;
|
||||||
const Region* region = impl.region_;
|
const Region* region = impl.region_;
|
||||||
if (region == nullptr || other == nullptr)
|
if (region == nullptr || other == nullptr)
|
||||||
return false;
|
return false;
|
||||||
|
|
@ -1673,7 +1676,7 @@ bool Voice::checkOffGroup(const Region* other, int delay, int noteNumber) noexce
|
||||||
if ((impl.triggerEvent_.type == TriggerEventType::NoteOn
|
if ((impl.triggerEvent_.type == TriggerEventType::NoteOn
|
||||||
|| impl.triggerEvent_.type == TriggerEventType::CC)
|
|| impl.triggerEvent_.type == TriggerEventType::CC)
|
||||||
&& region->offBy && *region->offBy == other->group
|
&& region->offBy && *region->offBy == other->group
|
||||||
&& (region->group != other->group || noteNumber != impl.triggerEvent_.number)) {
|
&& (region->group != other->group || !layer->ccSwitched_.all() || noteNumber != impl.triggerEvent_.number)) {
|
||||||
off(delay);
|
off(delay);
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
@ -1685,6 +1688,7 @@ void Voice::reset() noexcept
|
||||||
{
|
{
|
||||||
Impl& impl = *impl_;
|
Impl& impl = *impl_;
|
||||||
impl.switchState(State::idle);
|
impl.switchState(State::idle);
|
||||||
|
impl.layer_ = nullptr;
|
||||||
impl.region_ = nullptr;
|
impl.region_ = nullptr;
|
||||||
impl.currentPromise_.reset();
|
impl.currentPromise_.reset();
|
||||||
impl.sourcePosition_ = 0;
|
impl.sourcePosition_ = 0;
|
||||||
|
|
|
||||||
|
|
@ -570,3 +570,21 @@ TEST_CASE("[Polyphony] Choke long release tails with note_polyphony")
|
||||||
REQUIRE( numPlayingVoices(synth) == 1 ); // Not released, attack phase
|
REQUIRE( numPlayingVoices(synth) == 1 ); // Not released, attack phase
|
||||||
REQUIRE( numActiveVoices(synth) == 1 );
|
REQUIRE( numActiveVoices(synth) == 1 );
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_CASE("[Polyphony] Choke same group and note if the region is switched off (e.g. by a CC switch)")
|
||||||
|
{
|
||||||
|
sfz::Synth synth;
|
||||||
|
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
|
||||||
|
synth.loadSfzString(fs::current_path() / "tests/TestFiles/polyphony.sfz", R"(
|
||||||
|
<global> group=1 off_by=1
|
||||||
|
<region> locc1=0 hicc1=63 sample=*saw
|
||||||
|
<region> locc1=64 hicc1=127 sample=*sine
|
||||||
|
)");
|
||||||
|
synth.noteOn(0, 60, 63 );
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*saw" } );
|
||||||
|
synth.cc(0, 1, 127);
|
||||||
|
synth.noteOn(0, 60, 63 );
|
||||||
|
synth.renderBlock(buffer);
|
||||||
|
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine" } );
|
||||||
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue