Fallthroughs
This commit is contained in:
parent
d1706c4df4
commit
0b90ab722f
4 changed files with 47 additions and 47 deletions
|
|
@ -54,7 +54,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
|||
|
||||
currentState = State::Attack;
|
||||
step = (peak - currentValue) / (attack > 0 ? attack : 1);
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Attack:
|
||||
if (attack-- > 0) {
|
||||
currentValue += step;
|
||||
|
|
@ -63,14 +63,14 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
|||
|
||||
currentState = State::Hold;
|
||||
currentValue = peak;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Hold:
|
||||
if (hold-- > 0)
|
||||
return currentValue;
|
||||
|
||||
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
|
||||
currentState = State::Decay;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Decay:
|
||||
if (decay-- > 0) {
|
||||
currentValue *= step;
|
||||
|
|
@ -79,7 +79,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
|||
|
||||
currentState = State::Sustain;
|
||||
currentValue = sustain;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Sustain:
|
||||
if (freeRunning)
|
||||
shouldRelease = true;
|
||||
|
|
@ -92,7 +92,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
|
|||
|
||||
currentState = State::Done;
|
||||
currentValue = 0.0;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
default:
|
||||
return 0.0;
|
||||
}
|
||||
|
|
@ -116,7 +116,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
|||
|
||||
currentState = State::Attack;
|
||||
step = (peak - start) / (attack > 0 ? attack : 1);
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Attack:
|
||||
length = min(remainingSamples, attack);
|
||||
currentValue = linearRamp<Type>(output, currentValue, step);
|
||||
|
|
@ -128,7 +128,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
|||
|
||||
currentValue = peak;
|
||||
currentState = State::Hold;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Hold:
|
||||
length = min(remainingSamples, hold);
|
||||
fill<Type>(output, currentValue);
|
||||
|
|
@ -140,7 +140,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
|||
|
||||
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
|
||||
currentState = State::Decay;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Decay:
|
||||
length = min(remainingSamples, decay);
|
||||
currentValue = multiplicativeRamp<Type>(output, currentValue, step);
|
||||
|
|
@ -152,7 +152,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
|||
|
||||
currentValue = sustain;
|
||||
currentState = State::Sustain;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Sustain:
|
||||
if (freeRunning)
|
||||
shouldRelease = true;
|
||||
|
|
@ -168,9 +168,9 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
|
|||
|
||||
currentValue = 0.0;
|
||||
currentState = State::Done;
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case State::Done:
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -78,11 +78,11 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer<float>& input, sfz::AudioBu
|
|||
case Oversampling::x8:
|
||||
for (auto& upsampler: upsampler8x)
|
||||
upsampler.set_coefs(coeffsStage8x.data());
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case Oversampling::x4:
|
||||
for (auto& upsampler: upsampler4x)
|
||||
upsampler.set_coefs(coeffsStage4x.data());
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case Oversampling::x2:
|
||||
for (auto& upsampler: upsampler2x)
|
||||
upsampler.set_coefs(coeffsStage2x.data());
|
||||
|
|
|
|||
|
|
@ -66,7 +66,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("count"):
|
||||
setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange);
|
||||
break;
|
||||
case hash("loopmode"): [[fallthrough]];
|
||||
case hash("loopmode"): // fallthrough
|
||||
case hash("loop_mode"):
|
||||
switch (hash(opcode.value)) {
|
||||
case hash("no_loop"):
|
||||
|
|
@ -85,21 +85,21 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unkown loop mode:" << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("loopend"): [[fallthrough]];
|
||||
case hash("loopend"): // fallthrough
|
||||
case hash("loop_end"):
|
||||
setRangeEndFromOpcode(opcode, loopRange, Default::loopRange);
|
||||
break;
|
||||
case hash("loopstart"): [[fallthrough]];
|
||||
case hash("loopstart"): // fallthrough
|
||||
case hash("loop_start"):
|
||||
setRangeStartFromOpcode(opcode, loopRange, Default::loopRange);
|
||||
break;
|
||||
|
||||
// Instrument settings: voice lifecycle
|
||||
case hash("group"): [[fallthrough]];
|
||||
case hash("group"): // fallthrough
|
||||
case hash("polyphony_group"):
|
||||
setValueFromOpcode(opcode, group, Default::groupRange);
|
||||
break;
|
||||
case hash("offby"): [[fallthrough]];
|
||||
case hash("offby"): // fallthrough
|
||||
case hash("off_by"):
|
||||
setValueFromOpcode(opcode, offBy, Default::groupRange);
|
||||
break;
|
||||
|
|
@ -237,11 +237,11 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
DBG("Unknown trigger mode: " << std::string(opcode.value));
|
||||
}
|
||||
break;
|
||||
case hash("on_locc&"): [[fallthrough]];
|
||||
case hash("on_locc&"): // fallthrough
|
||||
case hash("start_locc&"):
|
||||
setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
|
||||
break;
|
||||
case hash("on_hicc&"): [[fallthrough]];
|
||||
case hash("on_hicc&"): // fallthrough
|
||||
case hash("start_hicc&"):
|
||||
setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
|
||||
break;
|
||||
|
|
@ -251,14 +251,14 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, volume, Default::volumeRange);
|
||||
break;
|
||||
case hash("gain_cc&"):
|
||||
case hash("gain_oncc&"): [[fallthrough]];
|
||||
case hash("gain_oncc&"): // fallthrough
|
||||
case hash("volume_oncc&"):
|
||||
setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange);
|
||||
break;
|
||||
case hash("amplitude"):
|
||||
setValueFromOpcode(opcode, amplitude, Default::amplitudeRange);
|
||||
break;
|
||||
case hash("amplitude_cc&"): [[fallthrough]];
|
||||
case hash("amplitude_cc&"): // fallthrough
|
||||
case hash("amplitude_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange);
|
||||
break;
|
||||
|
|
@ -377,7 +377,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
break;
|
||||
|
||||
// Performance parameters: filters
|
||||
case hash("cutoff"): [[fallthrough]];
|
||||
case hash("cutoff"): // fallthrough
|
||||
case hash("cutoff&"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
|
||||
|
|
@ -386,7 +386,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].cutoff, Default::filterCutoffRange);
|
||||
}
|
||||
break;
|
||||
case hash("resonance"): [[fallthrough]];
|
||||
case hash("resonance"): // fallthrough
|
||||
case hash("resonance&"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
|
||||
|
|
@ -397,7 +397,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
break;
|
||||
case hash("cutoff_oncc&"):
|
||||
case hash("cutoff_cc&"):
|
||||
case hash("cutoff&_oncc&"): [[fallthrough]];
|
||||
case hash("cutoff&_oncc&"): // fallthrough
|
||||
case hash("cutoff&_cc&"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -413,7 +413,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
break;
|
||||
case hash("resonance&_oncc&"):
|
||||
case hash("resonance&_cc&"):
|
||||
case hash("resonance_oncc&"): [[fallthrough]];
|
||||
case hash("resonance_oncc&"): // fallthrough
|
||||
case hash("resonance_cc&"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -427,7 +427,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
);
|
||||
}
|
||||
break;
|
||||
case hash("fil_keytrack"): [[fallthrough]];
|
||||
case hash("fil_keytrack"): // fallthrough
|
||||
case hash("fil&_keytrack"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -437,7 +437,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].keytrack, Default::filterKeytrackRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_keycenter"): [[fallthrough]];
|
||||
case hash("fil_keycenter"): // fallthrough
|
||||
case hash("fil&_keycenter"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -447,7 +447,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].keycenter, Default::keyRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_veltrack"): [[fallthrough]];
|
||||
case hash("fil_veltrack"): // fallthrough
|
||||
case hash("fil&_veltrack"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -457,7 +457,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].veltrack, Default::filterVeltrackRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_random"): [[fallthrough]];
|
||||
case hash("fil_random"): // fallthrough
|
||||
case hash("fil&_random"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -467,7 +467,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].random, Default::filterRandomRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_gain"): [[fallthrough]];
|
||||
case hash("fil_gain"): // fallthrough
|
||||
case hash("fil&_gain"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -477,7 +477,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, filters[filterIndex].gain, Default::filterGainRange);
|
||||
}
|
||||
break;
|
||||
case hash("fil_gaincc&"): [[fallthrough]];
|
||||
case hash("fil_gaincc&"): // fallthrough
|
||||
case hash("fil&_gaincc&"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -491,7 +491,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
);
|
||||
}
|
||||
break;
|
||||
case hash("fil_type"): [[fallthrough]];
|
||||
case hash("fil_type"): // fallthrough
|
||||
case hash("fil&_type"):
|
||||
{
|
||||
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1);
|
||||
|
|
@ -520,7 +520,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidth, Default::eqBandwidthRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq&_bw_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_bw_oncc&"): // fallthrough
|
||||
case hash("eq&_bwcc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
|
|
@ -542,7 +542,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequency, Default::eqFrequencyRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq&_freq_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_freq_oncc&"): // fallthrough
|
||||
case hash("eq&_freqcc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
|
|
@ -577,7 +577,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
setValueFromOpcode(opcode, equalizers[eqNumber - 1].gain, Default::eqGainRange);
|
||||
}
|
||||
break;
|
||||
case hash("eq&_gain_oncc&"): [[fallthrough]];
|
||||
case hash("eq&_gain_oncc&"): // fallthrough
|
||||
case hash("eq&_gaincc&"):
|
||||
{
|
||||
const auto eqNumber = opcode.parameters.front();
|
||||
|
|
@ -638,7 +638,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
case hash("transpose"):
|
||||
setValueFromOpcode(opcode, transpose, Default::transposeRange);
|
||||
break;
|
||||
case hash("tune"): [[fallthrough]];
|
||||
case hash("tune"): // fallthrough
|
||||
case hash("pitch"):
|
||||
setValueFromOpcode(opcode, tune, Default::tuneRange);
|
||||
break;
|
||||
|
|
@ -704,31 +704,31 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
|
|||
return false; // Was not vel2...
|
||||
setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange);
|
||||
break;
|
||||
case hash("ampeg_attackcc&"): [[fallthrough]];
|
||||
case hash("ampeg_attackcc&"): // fallthrough
|
||||
case hash("ampeg_attack_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_decaycc&"): [[fallthrough]];
|
||||
case hash("ampeg_decaycc&"): // fallthrough
|
||||
case hash("ampeg_decay_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_delaycc&"): [[fallthrough]];
|
||||
case hash("ampeg_delaycc&"): // fallthrough
|
||||
case hash("ampeg_delay_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_holdcc&"): [[fallthrough]];
|
||||
case hash("ampeg_holdcc&"): // fallthrough
|
||||
case hash("ampeg_hold_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_releasecc&"): [[fallthrough]];
|
||||
case hash("ampeg_releasecc&"): // fallthrough
|
||||
case hash("ampeg_release_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange);
|
||||
break;
|
||||
case hash("ampeg_startcc&"): [[fallthrough]];
|
||||
case hash("ampeg_startcc&"): // fallthrough
|
||||
case hash("ampeg_start_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange);
|
||||
break;
|
||||
case hash("ampeg_sustaincc&"): [[fallthrough]];
|
||||
case hash("ampeg_sustaincc&"): // fallthrough
|
||||
case hash("ampeg_sustain_oncc&"):
|
||||
setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange);
|
||||
break;
|
||||
|
|
|
|||
|
|
@ -163,20 +163,20 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
|
|||
{
|
||||
for (auto& member : members) {
|
||||
switch (member.lettersOnlyHash) {
|
||||
case hash("Set_cc&"): [[fallthrough]];
|
||||
case hash("Set_cc&"): // fallthrough
|
||||
case hash("set_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
|
||||
const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0);
|
||||
resources.midiState.ccEvent(0, member.parameters.back(), ccValue);
|
||||
}
|
||||
break;
|
||||
case hash("Label_cc&"): [[fallthrough]];
|
||||
case hash("Label_cc&"): // fallthrough
|
||||
case hash("label_cc&"):
|
||||
if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
|
||||
ccNames.emplace_back(member.parameters.back(), std::string(member.value));
|
||||
break;
|
||||
case hash("Default_path"):
|
||||
[[fallthrough]];
|
||||
// fallthrough
|
||||
case hash("default_path"):
|
||||
defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } });
|
||||
DBG("Changing default sample path to " << defaultPath);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue