WIP tests

This commit is contained in:
Paul Fd 2020-03-06 11:10:56 +01:00
parent 235069fd27
commit 9ce32c636c
5 changed files with 90 additions and 2 deletions

View file

@ -13,7 +13,7 @@ constexpr int blockSize { 256 };
TEST_CASE("[Synth] Play and check active voices")
{
sfz::Synth synth;
synth.setSamplesPerBlock(256);
synth.setSamplesPerBlock(blockSize);
sfz::AudioBuffer<float> buffer { 2, blockSize };
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
@ -29,7 +29,7 @@ TEST_CASE("[Synth] Play and check active voices")
TEST_CASE("[Synth] Change the number of voice while playing")
{
sfz::Synth synth;
synth.setSamplesPerBlock(256);
synth.setSamplesPerBlock(blockSize);
sfz::AudioBuffer<float> buffer { 2, blockSize };
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/groups_avl.sfz");
@ -210,3 +210,52 @@ TEST_CASE("[Synth] Trigger=release_key and an envelope properly kills the voice
synth.renderBlock(buffer);
REQUIRE( synth.getVoiceView(0)->isFree() );
}
TEST_CASE("[Synth] Number of effect buses and resetting behavior")
{
sfz::Synth synth;
synth.setSamplesPerBlock(blockSize);
sfz::AudioBuffer<float> buffer { 2, blockSize };
REQUIRE( synth.getEffectBusView(0) == nullptr); // No effects at first
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
// Check that we can render blocks
for (int i = 0; i < 100; ++i)
synth.renderBlock(buffer);
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_2.sfz");
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
REQUIRE( synth.getEffectBusView(1) != nullptr); // and an FX bus
// Check that we can render blocks
for (int i = 0; i < 100; ++i)
synth.renderBlock(buffer);
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
REQUIRE( synth.getEffectBusView(1) == nullptr); // and no FX bus
// Check that we can render blocks
for (int i = 0; i < 100; ++i)
synth.renderBlock(buffer);
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_3.sfz");
REQUIRE( synth.getEffectBusView(0) != nullptr); // We have a main bus
REQUIRE( synth.getEffectBusView(1) == nullptr); // empty/uninitialized fx bus
REQUIRE( synth.getEffectBusView(2) == nullptr); // empty/uninitialized fx bus
REQUIRE( synth.getEffectBusView(3) != nullptr); // and an FX bus (because we built up to fx3)
REQUIRE( synth.getEffectBusView(3)->numEffects() == 1);
// Check that we can render blocks
for (int i = 0; i < 100; ++i)
synth.renderBlock(buffer);
}
TEST_CASE("[Synth] No effect in the main bus")
{
sfz::Synth synth;
synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/base.sfz");
auto bus = synth.getEffectBusView(0);
REQUIRE( bus != nullptr); // We have a main bus
REQUIRE( bus->numEffects() == 0 );
REQUIRE( bus->gainToMain() == 1 );
REQUIRE( bus->gainToMix() == 0 );
}

View file

@ -0,0 +1,4 @@
<region>
lokey=0
hikey=127
sample=*sine

View file

@ -0,0 +1,9 @@
<region>
lokey=0
hikey=127
sample=*sine
<effect>
type=lofi
bitred=90
decim=10

View file

@ -0,0 +1,13 @@
<region>
lokey=0
hikey=127
sample=*sine
effect1=100
<effect>
directtomain=50
fx1tomain=50
type=lofi
bus=fx1
bitred=90
decim=10

View file

@ -0,0 +1,13 @@
<region>
lokey=0
hikey=127
sample=*sine
effect1=100
<effect>
directtomain=50
fx3tomain=50
type=lofi
bus=fx3
bitred=90
decim=10