From 162673939a092f9d775e47df332792306f741655 Mon Sep 17 00:00:00 2001 From: Jean Pierre Cimalando Date: Wed, 7 Oct 2020 14:36:27 +0200 Subject: [PATCH] Map CC11 expression --- src/sfizz/Synth.cpp | 7 +++++++ tests/ModulationsT.cpp | 5 +++++ tests/TestHelpers.cpp | 5 +++++ 3 files changed, 17 insertions(+) diff --git a/src/sfizz/Synth.cpp b/src/sfizz/Synth.cpp index 1a2f7183..ed183bfd 100644 --- a/src/sfizz/Synth.cpp +++ b/src/sfizz/Synth.cpp @@ -233,10 +233,12 @@ void sfz::Synth::clear() fill(absl::MakeSpan(ccInitialValues), 0.0f); initCc(7, 100); // volume initHdcc(10, 0.5f); // pan + initHdcc(11, 1.0f); // expression // set default controller labels insertPairUniquely(ccLabels, 7, "Volume"); insertPairUniquely(ccLabels, 10, "Pan"); + insertPairUniquely(ccLabels, 11, "Expression"); } void sfz::Synth::handleMasterOpcodes(const std::vector& members) @@ -676,6 +678,11 @@ void sfz::Synth::finalizeSfzLoad() ModKey::createCC(10, 1, defaultSmoothness, 0), ModKey::createNXYZ(ModId::Pan, region.id)).sourceDepth = 100.0f; } + if (!usedCCs.test(11)) { + region.getOrCreateConnection( + ModKey::createCC(11, 4, defaultSmoothness, 0), + ModKey::createNXYZ(ModId::Amplitude, region.id)).sourceDepth = 100.0f; + } } modificationTime = checkModificationTime(); diff --git a/tests/ModulationsT.cpp b/tests/ModulationsT.cpp index d5dc49af..0e1a863b 100644 --- a/tests/ModulationsT.cpp +++ b/tests/ModulationsT.cpp @@ -249,6 +249,7 @@ TEST_CASE("[Modulations] FlexEG Ampeg target") const std::string graph = synth.getResources().modMatrix.toDotGraph(); REQUIRE(graph == createModulationDotGraph({ R"("Controller 10 {curve=1, smooth=10, step=0}" -> "Pan {0}")", + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("Controller 7 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("EG 1 {0}" -> "MasterAmplitude {0}")", })); @@ -273,6 +274,7 @@ TEST_CASE("[Modulations] FlexEG Ampeg target with 2 FlexEGs") const std::string graph = synth.getResources().modMatrix.toDotGraph(); REQUIRE(graph == createModulationDotGraph({ R"("Controller 10 {curve=1, smooth=10, step=0}" -> "Pan {0}")", + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("Controller 7 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("EG 2 {0}" -> "MasterAmplitude {0}")", })); @@ -299,6 +301,7 @@ TEST_CASE("[Modulations] FlexEG Ampeg target with multiple EGs targeting ampeg") const std::string graph = synth.getResources().modMatrix.toDotGraph(); REQUIRE(graph == createModulationDotGraph({ R"("Controller 10 {curve=1, smooth=10, step=0}" -> "Pan {0}")", + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("Controller 7 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("EG 1 {0}" -> "MasterAmplitude {0}")", })); @@ -316,6 +319,7 @@ TEST_CASE("[Modulations] Override the default volume controller") REQUIRE(graph == createModulationDotGraph({ R"("AmplitudeEG {0}" -> "MasterAmplitude {0}")", R"("Controller 10 {curve=1, smooth=10, step=0}" -> "Pan {0}")", + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("Controller 7 {curve=0, smooth=0, step=0}" -> "Pitch {0}")", })); } @@ -331,6 +335,7 @@ TEST_CASE("[Modulations] Override the default pan controller") const std::string graph = synth.getResources().modMatrix.toDotGraph(); REQUIRE(graph == createModulationDotGraph({ R"("AmplitudeEG {0}" -> "MasterAmplitude {0}")", + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", R"("Controller 7 {curve=4, smooth=10, step=0}" -> "Amplitude {0}")", })); } diff --git a/tests/TestHelpers.cpp b/tests/TestHelpers.cpp index c5b3691d..0f3f76f6 100644 --- a/tests/TestHelpers.cpp +++ b/tests/TestHelpers.cpp @@ -97,6 +97,11 @@ std::string createDefaultGraph(std::vector lines, int numRegions) regionIdx, R"(}")" )); + lines.push_back(absl::StrCat( + R"("Controller 11 {curve=4, smooth=10, step=0}" -> "Amplitude {)", + regionIdx, + R"(}")" + )); } return createModulationDotGraph(lines);