Skip to content

Commit

Permalink
Rebased on the new parser
Browse files Browse the repository at this point in the history
  • Loading branch information
paulfd committed Mar 6, 2020
1 parent 9ce32c6 commit 09cca79
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 22 deletions.
12 changes: 6 additions & 6 deletions src/sfizz/Region.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -733,17 +733,17 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange);
break;

case hash("effect"): // effect&
case hash("effect&"):
{
const auto effectNumber = opcode.backParameter();
if (!effectNumber || *effectNumber < 1 || *effectNumber > config::maxEffectBuses)
const auto effectNumber = opcode.parameters.back();
if (!effectNumber || effectNumber < 1 || effectNumber > config::maxEffectBuses)
break;
auto value = readOpcode<float>(opcode.value, { 0, 100 });
if (!value)
break;
if (static_cast<size_t>(*effectNumber + 1) > gainToEffect.size())
gainToEffect.resize(*effectNumber + 1);
gainToEffect[*effectNumber] = *value / 100;
if (static_cast<size_t>(effectNumber + 1) > gainToEffect.size())
gainToEffect.resize(effectNumber + 1);
gainToEffect[effectNumber] = *value / 100;
break;
}

Expand Down
26 changes: 10 additions & 16 deletions src/sfizz/Synth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -223,24 +223,18 @@ void sfz::Synth::handleEffectOpcodes(const std::vector<Opcode>& members)
getOrCreateBus(0).setGainToMain(*valueOpt / 100);
break;

case hash("fxtomain"): // fx&tomain
if (auto numberOpt = opcode.firstParameter()) {
unsigned number = *numberOpt;
if (number < 1 || number > config::maxEffectBuses)
break;
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
getOrCreateBus(number).setGainToMain(*valueOpt / 100);
}
case hash("fx&tomain"): // fx&tomain
if (opcode.parameters.front() < 1 || opcode.parameters.front() > config::maxEffectBuses)
break;
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
getOrCreateBus(opcode.parameters.front()).setGainToMain(*valueOpt / 100);
break;

case hash("fxtomix"): // fx&tomix
if (auto numberOpt = opcode.firstParameter()) {
unsigned number = *numberOpt;
if (number < 1 || number > config::maxEffectBuses)
break;
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
getOrCreateBus(number).setGainToMix(*valueOpt / 100);
}
case hash("fx&tomix"): // fx&tomix
if (opcode.parameters.front() < 1 || opcode.parameters.front() > config::maxEffectBuses)
break;
if (auto valueOpt = readOpcode<float>(opcode.value, { 0, 100 }))
getOrCreateBus(opcode.parameters.front()).setGainToMix(*valueOpt / 100);
break;
}
}
Expand Down

0 comments on commit 09cca79

Please sign in to comment.