From 532cd88e96ef351dcf1665dce2a4dc560510d329 Mon Sep 17 00:00:00 2001 From: Paul Fd Date: Sat, 7 Mar 2020 21:27:19 +0100 Subject: [PATCH] Add some tests on effect gains --- tests/SynthT.cpp | 60 ++++++++++++++++++++++++++++++ tests/TestFiles/Effects/to_mix.sfz | 11 ++++++ 2 files changed, 71 insertions(+) create mode 100644 tests/TestFiles/Effects/to_mix.sfz diff --git a/tests/SynthT.cpp b/tests/SynthT.cpp index 822f1d0a..9ed0c73c 100644 --- a/tests/SynthT.cpp +++ b/tests/SynthT.cpp @@ -259,3 +259,63 @@ TEST_CASE("[Synth] No effect in the main bus") REQUIRE( bus->gainToMain() == 1 ); REQUIRE( bus->gainToMix() == 0 ); } + +TEST_CASE("[Synth] One effect") +{ + sfz::Synth synth; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_1.sfz"); + auto bus = synth.getEffectBusView(0); + REQUIRE( bus != nullptr); // We have a main bus + REQUIRE( bus->numEffects() == 1 ); + REQUIRE( bus->gainToMain() == 1 ); + REQUIRE( bus->gainToMix() == 0 ); +} + +TEST_CASE("[Synth] Effect on a second bus") +{ + sfz::Synth synth; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_2.sfz"); + auto bus = synth.getEffectBusView(0); + REQUIRE( bus != nullptr); // We have a main bus + REQUIRE( bus->numEffects() == 0 ); + REQUIRE( bus->gainToMain() == 0.5 ); + REQUIRE( bus->gainToMix() == 0 ); + bus = synth.getEffectBusView(1); + REQUIRE( bus != nullptr); + REQUIRE( bus->numEffects() == 1 ); + REQUIRE( bus->gainToMain() == 0.5 ); + REQUIRE( bus->gainToMix() == 0 ); +} + + +TEST_CASE("[Synth] Effect on a third bus") +{ + sfz::Synth synth; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/bitcrusher_3.sfz"); + auto bus = synth.getEffectBusView(0); + REQUIRE( bus != nullptr); // We have a main bus + REQUIRE( bus->numEffects() == 0 ); + REQUIRE( bus->gainToMain() == 0.5 ); + REQUIRE( bus->gainToMix() == 0 ); + bus = synth.getEffectBusView(3); + REQUIRE( bus != nullptr); + REQUIRE( bus->numEffects() == 1 ); + REQUIRE( bus->gainToMain() == 0.5 ); + REQUIRE( bus->gainToMix() == 0 ); +} + +TEST_CASE("[Synth] Gain to mix") +{ + sfz::Synth synth; + synth.loadSfzFile(fs::current_path() / "tests/TestFiles/Effects/to_mix.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 ); + bus = synth.getEffectBusView(1); + REQUIRE( bus != nullptr); + REQUIRE( bus->numEffects() == 1 ); + REQUIRE( bus->gainToMain() == 0 ); + REQUIRE( bus->gainToMix() == 0.5 ); +} diff --git a/tests/TestFiles/Effects/to_mix.sfz b/tests/TestFiles/Effects/to_mix.sfz new file mode 100644 index 00000000..8f12e70e --- /dev/null +++ b/tests/TestFiles/Effects/to_mix.sfz @@ -0,0 +1,11 @@ + +lokey=0 +hikey=127 +sample=*sine + + +fx1tomix=50 +bus=fx1 +type=lofi +bitred=90 +decim=10