From 6377451027f19edf3081c31dd432e6af6b5a421d Mon Sep 17 00:00:00 2001 From: Paul Ferrand Date: Sun, 29 Dec 2019 23:00:57 +0100 Subject: [PATCH] Added tests for note-offs --- tests/FilesT.cpp | 48 +++++++++++++++++++++++++++++++++++++- tests/TestFiles/off_by.sfz | 4 ++++ 2 files changed, 51 insertions(+), 1 deletion(-) create mode 100644 tests/TestFiles/off_by.sfz diff --git a/tests/FilesT.cpp b/tests/FilesT.cpp index 25dff03d..01a4ea2c 100644 --- a/tests/FilesT.cpp +++ b/tests/FilesT.cpp @@ -404,6 +404,53 @@ TEST_CASE("[Files] Note and octave offsets") REQUIRE( synth.getRegionView(6)->pitchKeycenter == 50 ); } +TEST_CASE("[Files] Off by with different delays") +{ + sfz::Synth synth; + synth.setSamplesPerBlock(256); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/off_by.sfz"); + REQUIRE( synth.getNumRegions() == 4 ); + synth.noteOn(0, 63, 63); + REQUIRE( synth.getNumActiveVoices() == 1 ); + auto group1Voice = synth.getVoiceView(0); + REQUIRE( group1Voice->getRegion()->group == 1ul ); + REQUIRE( group1Voice->getRegion()->offBy == 2ul ); + synth.noteOn(100, 64, 63); + REQUIRE( group1Voice->canBeStolen() ); +} + +TEST_CASE("[Files] Off by with the same delays") +{ + sfz::Synth synth; + synth.setSamplesPerBlock(256); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/off_by.sfz"); + REQUIRE( synth.getNumRegions() == 4 ); + synth.noteOn(0, 63, 63); + REQUIRE( synth.getNumActiveVoices() == 1 ); + auto group1Voice = synth.getVoiceView(0); + REQUIRE( group1Voice->getRegion()->group == 1ul ); + REQUIRE( group1Voice->getRegion()->offBy == 2ul ); + synth.noteOn(0, 64, 63); + REQUIRE( !group1Voice->canBeStolen() ); +} + +TEST_CASE("[Files] Off by with the same notes at the same time") +{ + sfz::Synth synth; + synth.setSamplesPerBlock(256); + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/off_by.sfz"); + REQUIRE( synth.getNumRegions() == 4 ); + synth.noteOn(0, 65, 63); + REQUIRE( synth.getNumActiveVoices() == 2 ); + synth.noteOn(0, 65, 63); + REQUIRE( synth.getNumActiveVoices() == 4 ); + sfz::AudioBuffer buffer { 2, 256 }; + synth.renderBlock(buffer); + synth.noteOn(0, 65, 63); + synth.renderBlock(buffer); + REQUIRE( synth.getNumActiveVoices() == 2 ); +} + TEST_CASE("[Files] Off modes") { sfz::Synth synth; @@ -427,7 +474,6 @@ TEST_CASE("[Files] Off modes") REQUIRE( synth.getNumActiveVoices() == 2 ); REQUIRE( fastVoice->isFree() ); REQUIRE( !normalVoice->isFree() ); - } TEST_CASE("[Files] Looped regions taken from files and possibly overriden") diff --git a/tests/TestFiles/off_by.sfz b/tests/TestFiles/off_by.sfz new file mode 100644 index 00000000..48dd8924 --- /dev/null +++ b/tests/TestFiles/off_by.sfz @@ -0,0 +1,4 @@ + group=1 off_by=2 key=63 off_mode=fast ampeg_release=0.1 sample=mono_sample.wav + group=2 off_by=3 key=64 off_mode=fast ampeg_release=0.1 sample=mono_sample.wav + group=3 off_by=3 key=65 off_mode=fast ampeg_release=0.1 sample=mono_sample.wav + group=3 off_by=3 key=65 off_mode=fast ampeg_release=0.1 sample=mono_sample.wav