Homogeneize the treatment of percentage defaults and values

This commit is contained in:
Paul Ferrand 2020-03-29 19:32:27 +02:00
parent ca2ee8dc58
commit 9e824df346
2 changed files with 7 additions and 6 deletions

View file

@ -295,7 +295,8 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange);
break;
case hash("amplitude"):
setValueFromOpcode(opcode, amplitude, Default::amplitudeRange);
if (auto value = readOpcode(opcode.value, Default::amplitudeRange))
amplitude = normalizePercents(*value);
break;
case hash("amplitude_cc&"): // fallthrough
case hash("amplitude_oncc&"):
@ -985,7 +986,7 @@ float sfz::Region::getBaseVolumedB(int noteNumber) const noexcept
float sfz::Region::getBaseGain() const noexcept
{
return normalizePercents(amplitude);
return amplitude;
}
float sfz::Region::getPhase() const noexcept

View file

@ -272,10 +272,10 @@ struct Region {
// Performance parameters: amplifier
float volume { Default::volume }; // volume
float amplitude { Default::amplitude }; // amplitude
float pan { Default::pan }; // pan
float width { Default::width }; // width
float position { Default::position }; // position
float amplitude { normalizePercents(Default::amplitude) }; // amplitude
float pan { normalizePercents(Default::pan) }; // pan
float width { normalizePercents(Default::width) }; // width
float position { normalizePercents(Default::position) }; // position
absl::optional<CCValuePair<float>> volumeCC; // volume_oncc
CCMap<float> amplitudeCC { Default::zeroModifier }; // amplitude_oncc
CCMap<float> panCC { Default::zeroModifier }; // pan_oncc