Fallthroughs

This commit is contained in:
Paul Ferrand 2020-03-11 00:00:52 +01:00 committed by Paul Fd
parent d1706c4df4
commit 0b90ab722f
4 changed files with 47 additions and 47 deletions

View file

@ -54,7 +54,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Attack; currentState = State::Attack;
step = (peak - currentValue) / (attack > 0 ? attack : 1); step = (peak - currentValue) / (attack > 0 ? attack : 1);
[[fallthrough]]; // fallthrough
case State::Attack: case State::Attack:
if (attack-- > 0) { if (attack-- > 0) {
currentValue += step; currentValue += step;
@ -63,14 +63,14 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Hold; currentState = State::Hold;
currentValue = peak; currentValue = peak;
[[fallthrough]]; // fallthrough
case State::Hold: case State::Hold:
if (hold-- > 0) if (hold-- > 0)
return currentValue; return currentValue;
step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1)); step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
currentState = State::Decay; currentState = State::Decay;
[[fallthrough]]; // fallthrough
case State::Decay: case State::Decay:
if (decay-- > 0) { if (decay-- > 0) {
currentValue *= step; currentValue *= step;
@ -79,7 +79,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Sustain; currentState = State::Sustain;
currentValue = sustain; currentValue = sustain;
[[fallthrough]]; // fallthrough
case State::Sustain: case State::Sustain:
if (freeRunning) if (freeRunning)
shouldRelease = true; shouldRelease = true;
@ -92,7 +92,7 @@ Type ADSREnvelope<Type>::getNextValue() noexcept
currentState = State::Done; currentState = State::Done;
currentValue = 0.0; currentValue = 0.0;
[[fallthrough]]; // fallthrough
default: default:
return 0.0; return 0.0;
} }
@ -116,7 +116,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentState = State::Attack; currentState = State::Attack;
step = (peak - start) / (attack > 0 ? attack : 1); step = (peak - start) / (attack > 0 ? attack : 1);
[[fallthrough]]; // fallthrough
case State::Attack: case State::Attack:
length = min(remainingSamples, attack); length = min(remainingSamples, attack);
currentValue = linearRamp<Type>(output, currentValue, step); currentValue = linearRamp<Type>(output, currentValue, step);
@ -128,7 +128,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = peak; currentValue = peak;
currentState = State::Hold; currentState = State::Hold;
[[fallthrough]]; // fallthrough
case State::Hold: case State::Hold:
length = min(remainingSamples, hold); length = min(remainingSamples, hold);
fill<Type>(output, currentValue); 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)); step = std::exp(std::log(sustain + config::virtuallyZero) / (decay > 0 ? decay : 1));
currentState = State::Decay; currentState = State::Decay;
[[fallthrough]]; // fallthrough
case State::Decay: case State::Decay:
length = min(remainingSamples, decay); length = min(remainingSamples, decay);
currentValue = multiplicativeRamp<Type>(output, currentValue, step); currentValue = multiplicativeRamp<Type>(output, currentValue, step);
@ -152,7 +152,7 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = sustain; currentValue = sustain;
currentState = State::Sustain; currentState = State::Sustain;
[[fallthrough]]; // fallthrough
case State::Sustain: case State::Sustain:
if (freeRunning) if (freeRunning)
shouldRelease = true; shouldRelease = true;
@ -168,9 +168,9 @@ void ADSREnvelope<Type>::getBlock(absl::Span<Type> output) noexcept
currentValue = 0.0; currentValue = 0.0;
currentState = State::Done; currentState = State::Done;
[[fallthrough]]; // fallthrough
case State::Done: case State::Done:
[[fallthrough]]; // fallthrough
default: default:
break; break;
} }

View file

@ -78,11 +78,11 @@ void sfz::Oversampler::stream(const sfz::AudioBuffer<float>& input, sfz::AudioBu
case Oversampling::x8: case Oversampling::x8:
for (auto& upsampler: upsampler8x) for (auto& upsampler: upsampler8x)
upsampler.set_coefs(coeffsStage8x.data()); upsampler.set_coefs(coeffsStage8x.data());
[[fallthrough]]; // fallthrough
case Oversampling::x4: case Oversampling::x4:
for (auto& upsampler: upsampler4x) for (auto& upsampler: upsampler4x)
upsampler.set_coefs(coeffsStage4x.data()); upsampler.set_coefs(coeffsStage4x.data());
[[fallthrough]]; // fallthrough
case Oversampling::x2: case Oversampling::x2:
for (auto& upsampler: upsampler2x) for (auto& upsampler: upsampler2x)
upsampler.set_coefs(coeffsStage2x.data()); upsampler.set_coefs(coeffsStage2x.data());

View file

@ -66,7 +66,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
case hash("count"): case hash("count"):
setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange); setValueFromOpcode(opcode, sampleCount, Default::sampleCountRange);
break; break;
case hash("loopmode"): [[fallthrough]]; case hash("loopmode"): // fallthrough
case hash("loop_mode"): case hash("loop_mode"):
switch (hash(opcode.value)) { switch (hash(opcode.value)) {
case hash("no_loop"): case hash("no_loop"):
@ -85,21 +85,21 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
DBG("Unkown loop mode:" << std::string(opcode.value)); DBG("Unkown loop mode:" << std::string(opcode.value));
} }
break; break;
case hash("loopend"): [[fallthrough]]; case hash("loopend"): // fallthrough
case hash("loop_end"): case hash("loop_end"):
setRangeEndFromOpcode(opcode, loopRange, Default::loopRange); setRangeEndFromOpcode(opcode, loopRange, Default::loopRange);
break; break;
case hash("loopstart"): [[fallthrough]]; case hash("loopstart"): // fallthrough
case hash("loop_start"): case hash("loop_start"):
setRangeStartFromOpcode(opcode, loopRange, Default::loopRange); setRangeStartFromOpcode(opcode, loopRange, Default::loopRange);
break; break;
// Instrument settings: voice lifecycle // Instrument settings: voice lifecycle
case hash("group"): [[fallthrough]]; case hash("group"): // fallthrough
case hash("polyphony_group"): case hash("polyphony_group"):
setValueFromOpcode(opcode, group, Default::groupRange); setValueFromOpcode(opcode, group, Default::groupRange);
break; break;
case hash("offby"): [[fallthrough]]; case hash("offby"): // fallthrough
case hash("off_by"): case hash("off_by"):
setValueFromOpcode(opcode, offBy, Default::groupRange); setValueFromOpcode(opcode, offBy, Default::groupRange);
break; break;
@ -237,11 +237,11 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
DBG("Unknown trigger mode: " << std::string(opcode.value)); DBG("Unknown trigger mode: " << std::string(opcode.value));
} }
break; break;
case hash("on_locc&"): [[fallthrough]]; case hash("on_locc&"): // fallthrough
case hash("start_locc&"): case hash("start_locc&"):
setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange); setRangeStartFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
break; break;
case hash("on_hicc&"): [[fallthrough]]; case hash("on_hicc&"): // fallthrough
case hash("start_hicc&"): case hash("start_hicc&"):
setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange); setRangeEndFromOpcode(opcode, ccTriggers[opcode.parameters.back()], Default::ccTriggerValueRange);
break; break;
@ -251,14 +251,14 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
setValueFromOpcode(opcode, volume, Default::volumeRange); setValueFromOpcode(opcode, volume, Default::volumeRange);
break; break;
case hash("gain_cc&"): case hash("gain_cc&"):
case hash("gain_oncc&"): [[fallthrough]]; case hash("gain_oncc&"): // fallthrough
case hash("volume_oncc&"): case hash("volume_oncc&"):
setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange); setCCPairFromOpcode(opcode, volumeCC, Default::volumeCCRange);
break; break;
case hash("amplitude"): case hash("amplitude"):
setValueFromOpcode(opcode, amplitude, Default::amplitudeRange); setValueFromOpcode(opcode, amplitude, Default::amplitudeRange);
break; break;
case hash("amplitude_cc&"): [[fallthrough]]; case hash("amplitude_cc&"): // fallthrough
case hash("amplitude_oncc&"): case hash("amplitude_oncc&"):
setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange); setCCPairFromOpcode(opcode, amplitudeCC, Default::amplitudeRange);
break; break;
@ -377,7 +377,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
// Performance parameters: filters // Performance parameters: filters
case hash("cutoff"): [[fallthrough]]; case hash("cutoff"): // fallthrough
case hash("cutoff&"): case hash("cutoff&"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].cutoff, Default::filterCutoffRange);
} }
break; break;
case hash("resonance"): [[fallthrough]]; case hash("resonance"): // fallthrough
case hash("resonance&"): case hash("resonance&"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1); const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.back() - 1);
@ -397,7 +397,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
case hash("cutoff_oncc&"): case hash("cutoff_oncc&"):
case hash("cutoff_cc&"): case hash("cutoff_cc&"):
case hash("cutoff&_oncc&"): [[fallthrough]]; case hash("cutoff&_oncc&"): // fallthrough
case hash("cutoff&_cc&"): case hash("cutoff&_cc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -413,7 +413,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
break; break;
case hash("resonance&_oncc&"): case hash("resonance&_oncc&"):
case hash("resonance&_cc&"): case hash("resonance&_cc&"):
case hash("resonance_oncc&"): [[fallthrough]]; case hash("resonance_oncc&"): // fallthrough
case hash("resonance_cc&"): case hash("resonance_cc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -427,7 +427,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
); );
} }
break; break;
case hash("fil_keytrack"): [[fallthrough]]; case hash("fil_keytrack"): // fallthrough
case hash("fil&_keytrack"): case hash("fil&_keytrack"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].keytrack, Default::filterKeytrackRange);
} }
break; break;
case hash("fil_keycenter"): [[fallthrough]]; case hash("fil_keycenter"): // fallthrough
case hash("fil&_keycenter"): case hash("fil&_keycenter"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].keycenter, Default::keyRange);
} }
break; break;
case hash("fil_veltrack"): [[fallthrough]]; case hash("fil_veltrack"): // fallthrough
case hash("fil&_veltrack"): case hash("fil&_veltrack"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].veltrack, Default::filterVeltrackRange);
} }
break; break;
case hash("fil_random"): [[fallthrough]]; case hash("fil_random"): // fallthrough
case hash("fil&_random"): case hash("fil&_random"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].random, Default::filterRandomRange);
} }
break; break;
case hash("fil_gain"): [[fallthrough]]; case hash("fil_gain"): // fallthrough
case hash("fil&_gain"): case hash("fil&_gain"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, filters[filterIndex].gain, Default::filterGainRange);
} }
break; break;
case hash("fil_gaincc&"): [[fallthrough]]; case hash("fil_gaincc&"): // fallthrough
case hash("fil&_gaincc&"): case hash("fil&_gaincc&"):
{ {
const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1); const auto filterIndex = opcode.parameters.size() == 1 ? 0 : (opcode.parameters.front() - 1);
@ -491,7 +491,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
); );
} }
break; break;
case hash("fil_type"): [[fallthrough]]; case hash("fil_type"): // fallthrough
case hash("fil&_type"): case hash("fil&_type"):
{ {
const auto filterIndex = opcode.parameters.empty() ? 0 : (opcode.parameters.front() - 1); 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); setValueFromOpcode(opcode, equalizers[eqNumber - 1].bandwidth, Default::eqBandwidthRange);
} }
break; break;
case hash("eq&_bw_oncc&"): [[fallthrough]]; case hash("eq&_bw_oncc&"): // fallthrough
case hash("eq&_bwcc&"): case hash("eq&_bwcc&"):
{ {
const auto eqNumber = opcode.parameters.front(); 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); setValueFromOpcode(opcode, equalizers[eqNumber - 1].frequency, Default::eqFrequencyRange);
} }
break; break;
case hash("eq&_freq_oncc&"): [[fallthrough]]; case hash("eq&_freq_oncc&"): // fallthrough
case hash("eq&_freqcc&"): case hash("eq&_freqcc&"):
{ {
const auto eqNumber = opcode.parameters.front(); 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); setValueFromOpcode(opcode, equalizers[eqNumber - 1].gain, Default::eqGainRange);
} }
break; break;
case hash("eq&_gain_oncc&"): [[fallthrough]]; case hash("eq&_gain_oncc&"): // fallthrough
case hash("eq&_gaincc&"): case hash("eq&_gaincc&"):
{ {
const auto eqNumber = opcode.parameters.front(); const auto eqNumber = opcode.parameters.front();
@ -638,7 +638,7 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
case hash("transpose"): case hash("transpose"):
setValueFromOpcode(opcode, transpose, Default::transposeRange); setValueFromOpcode(opcode, transpose, Default::transposeRange);
break; break;
case hash("tune"): [[fallthrough]]; case hash("tune"): // fallthrough
case hash("pitch"): case hash("pitch"):
setValueFromOpcode(opcode, tune, Default::tuneRange); setValueFromOpcode(opcode, tune, Default::tuneRange);
break; break;
@ -704,31 +704,31 @@ bool sfz::Region::parseOpcode(const Opcode& opcode)
return false; // Was not vel2... return false; // Was not vel2...
setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange); setValueFromOpcode(opcode, amplitudeEG.vel2sustain, Default::egOnCCPercentRange);
break; break;
case hash("ampeg_attackcc&"): [[fallthrough]]; case hash("ampeg_attackcc&"): // fallthrough
case hash("ampeg_attack_oncc&"): case hash("ampeg_attack_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccAttack, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_decaycc&"): [[fallthrough]]; case hash("ampeg_decaycc&"): // fallthrough
case hash("ampeg_decay_oncc&"): case hash("ampeg_decay_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccDecay, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_delaycc&"): [[fallthrough]]; case hash("ampeg_delaycc&"): // fallthrough
case hash("ampeg_delay_oncc&"): case hash("ampeg_delay_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccDelay, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_holdcc&"): [[fallthrough]]; case hash("ampeg_holdcc&"): // fallthrough
case hash("ampeg_hold_oncc&"): case hash("ampeg_hold_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccHold, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_releasecc&"): [[fallthrough]]; case hash("ampeg_releasecc&"): // fallthrough
case hash("ampeg_release_oncc&"): case hash("ampeg_release_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange); setCCPairFromOpcode(opcode, amplitudeEG.ccRelease, Default::egOnCCTimeRange);
break; break;
case hash("ampeg_startcc&"): [[fallthrough]]; case hash("ampeg_startcc&"): // fallthrough
case hash("ampeg_start_oncc&"): case hash("ampeg_start_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange); setCCPairFromOpcode(opcode, amplitudeEG.ccStart, Default::egOnCCPercentRange);
break; break;
case hash("ampeg_sustaincc&"): [[fallthrough]]; case hash("ampeg_sustaincc&"): // fallthrough
case hash("ampeg_sustain_oncc&"): case hash("ampeg_sustain_oncc&"):
setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange); setCCPairFromOpcode(opcode, amplitudeEG.ccSustain, Default::egOnCCPercentRange);
break; break;

View file

@ -163,20 +163,20 @@ void sfz::Synth::handleControlOpcodes(const std::vector<Opcode>& members)
{ {
for (auto& member : members) { for (auto& member : members) {
switch (member.lettersOnlyHash) { switch (member.lettersOnlyHash) {
case hash("Set_cc&"): [[fallthrough]]; case hash("Set_cc&"): // fallthrough
case hash("set_cc&"): case hash("set_cc&"):
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) { if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) {
const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0); const auto ccValue = readOpcode(member.value, Default::ccValueRange).value_or(0);
resources.midiState.ccEvent(0, member.parameters.back(), ccValue); resources.midiState.ccEvent(0, member.parameters.back(), ccValue);
} }
break; break;
case hash("Label_cc&"): [[fallthrough]]; case hash("Label_cc&"): // fallthrough
case hash("label_cc&"): case hash("label_cc&"):
if (Default::ccNumberRange.containsWithEnd(member.parameters.back())) if (Default::ccNumberRange.containsWithEnd(member.parameters.back()))
ccNames.emplace_back(member.parameters.back(), std::string(member.value)); ccNames.emplace_back(member.parameters.back(), std::string(member.value));
break; break;
case hash("Default_path"): case hash("Default_path"):
[[fallthrough]]; // fallthrough
case hash("default_path"): case hash("default_path"):
defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } }); defaultPath = absl::StrReplaceAll(trim(member.value), { { "\\", "/" } });
DBG("Changing default sample path to " << defaultPath); DBG("Changing default sample path to " << defaultPath);