Skip to content

Commit

Permalink
Add tests for note-aware polyaft
Browse files Browse the repository at this point in the history
- Test triggering with note information
- Test choking
- Fix logic: don't check that the new CC value changed on polyaftertouch
    cc130 messages (hopefully e-drums don't send multiple polyafts for
    the same note like some controllers do for the pedals...)
  • Loading branch information
paulfd committed Oct 15, 2023
1 parent bf5a778 commit 9259a1d
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 1 deletion.
2 changes: 1 addition & 1 deletion src/sfizz/Layer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ bool Layer::registerCC(int ccNumber, float ccValue, float randValue, int extende
sequenceSwitched_ =
((sequenceCounter_++ % region.sequenceLength) == region.sequencePosition - 1);

if (isSwitchedOn() && (ccValue != midiState_.getCCValue(ccNumber)))
if (isSwitchedOn() && (ccNumber == ExtendedCCs::polyphonicAftertouch || ccValue != midiState_.getCCValue(ccNumber)))
return true;
}

Expand Down
25 changes: 25 additions & 0 deletions tests/PolyphonyT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -588,3 +588,28 @@ TEST_CASE("[Polyphony] Choke same group and note if the region is switched off (
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine" } );
}

TEST_CASE("[Polyphony] Choking on poly-aftertouch respects the note number")
{
sfz::Synth synth;
sfz::AudioBuffer<float> buffer { 2, static_cast<unsigned>(synth.getSamplesPerBlock()) };
synth.loadSfzString(fs::current_path() / "tests/TestFiles/polyat_choke.sfz", R"(
<region> key=55 group=1 off_by=2 sample=*saw
<region> key=55 group=2 on_locc130=127 on_hicc130=127 trigger=release polyphony=1 sample=*sine
)");
synth.noteOn(0, 55, 63 );
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*saw" } );
synth.hdPolyAftertouch(0, 54, 1.0f);
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*saw" } );
synth.hdPolyAftertouch(0, 57, 1.0f);
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*saw" } );
synth.hdPolyAftertouch(0, 55, 1.0f);
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine"} );
synth.hdPolyAftertouch(0, 55, 0.0f);
synth.renderBlock(buffer);
REQUIRE( playingSamples(synth) == std::vector<std::string> { "*sine"} );
}
20 changes: 20 additions & 0 deletions tests/RegionTriggersT.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -426,3 +426,23 @@ TEST_CASE("[Triggers] Offed voices with CC triggers do not activate release trig
synth.hdcc(10, 64, 10_norm);
REQUIRE(playingSamples(synth) == std::vector<std::string> { "*saw" });
}

TEST_CASE("[Triggers] Respect poly-aftertouch note values when triggering on cc130")
{
Synth synth;
synth.loadSfzString(fs::current_path() / "tests/TestFiles/poly_at_trigger.sfz", R"(
<region> key=55 on_locc130=127 on_hicc130=127 sample=*saw
<region> key=57 on_locc130=127 on_hicc130=127 sample=*sine
)");

synth.polyAftertouch(0, 54, 127);
REQUIRE(playingSamples(synth) == std::vector<std::string> { });
synth.polyAftertouch(0, 56, 127);
REQUIRE(playingSamples(synth) == std::vector<std::string> { });
synth.polyAftertouch(0, 58, 127);
REQUIRE(playingSamples(synth) == std::vector<std::string> { });
synth.polyAftertouch(0, 55, 127);
REQUIRE(playingSamples(synth) == std::vector<std::string> { "*saw" });
synth.polyAftertouch(10, 57, 127);
REQUIRE(playingSamples(synth) == std::vector<std::string> { "*saw", "*sine" });
}

0 comments on commit 9259a1d

Please sign in to comment.