Merge pull request #297 from paulfd/smoother-initial-value
Smoother initial value
This commit is contained in:
commit
8f61463269
3 changed files with 10 additions and 7 deletions
|
|
@ -111,7 +111,7 @@ namespace Default
|
||||||
// Performance parameters: amplifier
|
// Performance parameters: amplifier
|
||||||
constexpr float globalVolume { -7.35f };
|
constexpr float globalVolume { -7.35f };
|
||||||
constexpr float volume { 0.0f };
|
constexpr float volume { 0.0f };
|
||||||
constexpr Range<float> volumeRange { -144.0, 6.0 };
|
constexpr Range<float> volumeRange { -144.0, 48.0 };
|
||||||
constexpr Range<float> volumeCCRange { -144.0, 48.0 };
|
constexpr Range<float> volumeCCRange { -144.0, 48.0 };
|
||||||
constexpr float amplitude { 100.0 };
|
constexpr float amplitude { 100.0 };
|
||||||
constexpr Range<float> amplitudeRange { 0.0, 100.0 };
|
constexpr Range<float> amplitudeRange { 0.0, 100.0 };
|
||||||
|
|
|
||||||
|
|
@ -136,21 +136,24 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, float value,
|
||||||
for (auto& modId : allModifiers) {
|
for (auto& modId : allModifiers) {
|
||||||
ASSERT(modifierSmoothers[modId].size() >= region->modifiers[modId].size());
|
ASSERT(modifierSmoothers[modId].size() >= region->modifiers[modId].size());
|
||||||
forEachWithSmoother(modId, [modId, this](const CCData<Modifier>& mod, Smoother& smoother) {
|
forEachWithSmoother(modId, [modId, this](const CCData<Modifier>& mod, Smoother& smoother) {
|
||||||
|
const auto ccValue = resources.midiState.getCCValue(mod.cc);
|
||||||
|
const auto curve = resources.curves.getCurve(mod.data.curve);
|
||||||
|
const auto finalValue = curve.evalNormalized(ccValue) * mod.data.value;
|
||||||
switch (modId) {
|
switch (modId) {
|
||||||
case Mod::volume:
|
case Mod::volume:
|
||||||
smoother.reset(db2mag(resources.midiState.getCCValue(mod.cc) * mod.data.value));
|
smoother.reset(db2mag(finalValue));
|
||||||
break;
|
break;
|
||||||
case Mod::pitch:
|
case Mod::pitch:
|
||||||
smoother.reset(centsFactor(resources.midiState.getCCValue(mod.cc) * mod.data.value));
|
smoother.reset(centsFactor(finalValue));
|
||||||
break;
|
break;
|
||||||
case Mod::amplitude:
|
case Mod::amplitude:
|
||||||
case Mod::pan:
|
case Mod::pan:
|
||||||
case Mod::width:
|
case Mod::width:
|
||||||
case Mod::position:
|
case Mod::position:
|
||||||
smoother.reset(normalizePercents(resources.midiState.getCCValue(mod.cc) * mod.data.value));
|
smoother.reset(normalizePercents(finalValue));
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
smoother.reset(resources.midiState.getCCValue(mod.cc) * mod.data.value);
|
smoother.reset(finalValue);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
smoother.setSmoothing(mod.data.smooth, sampleRate);
|
smoother.setSmoothing(mod.data.smooth, sampleRate);
|
||||||
|
|
|
||||||
|
|
@ -522,8 +522,8 @@ TEST_CASE("[Region] Parsing opcodes")
|
||||||
REQUIRE(region.volume == -123.0f);
|
REQUIRE(region.volume == -123.0f);
|
||||||
region.parseOpcode({ "volume", "-185" });
|
region.parseOpcode({ "volume", "-185" });
|
||||||
REQUIRE(region.volume == -144.0f);
|
REQUIRE(region.volume == -144.0f);
|
||||||
region.parseOpcode({ "volume", "19" });
|
region.parseOpcode({ "volume", "79" });
|
||||||
REQUIRE(region.volume == 6.0f);
|
REQUIRE(region.volume == 48.0f);
|
||||||
}
|
}
|
||||||
|
|
||||||
SECTION("pan")
|
SECTION("pan")
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue