Modifier loops can be const
This commit is contained in:
parent
ddeecf41b9
commit
7e8cdff407
3 changed files with 24 additions and 24 deletions
|
|
@ -29,17 +29,17 @@ void sfz::EQHolder::setup(const EQDescription& description, unsigned numChannels
|
|||
|
||||
// Setup the modulated values
|
||||
lastFrequency = baseFrequency;
|
||||
for (auto& mod : description.frequencyCC)
|
||||
for (const auto& mod : description.frequencyCC)
|
||||
lastFrequency += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastFrequency = Default::eqFrequencyRange.clamp(lastFrequency);
|
||||
|
||||
lastBandwidth = baseBandwidth;
|
||||
for (auto& mod : description.bandwidthCC)
|
||||
for (const auto& mod : description.bandwidthCC)
|
||||
lastBandwidth += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastBandwidth = Default::eqBandwidthRange.clamp(lastBandwidth);
|
||||
|
||||
lastGain = baseGain;
|
||||
for (auto& mod : description.gainCC)
|
||||
for (const auto& mod : description.gainCC)
|
||||
lastGain += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastGain = Default::filterGainRange.clamp(lastGain);
|
||||
|
||||
|
|
@ -62,17 +62,17 @@ void sfz::EQHolder::process(const float** inputs, float** outputs, unsigned numF
|
|||
// TODO: Once the midistate envelopes are done, add modulation in there!
|
||||
// For now we take the last value
|
||||
lastFrequency = baseFrequency;
|
||||
for (auto& mod : description->frequencyCC)
|
||||
for (const auto& mod : description->frequencyCC)
|
||||
lastFrequency += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastFrequency = Default::eqFrequencyRange.clamp(lastFrequency);
|
||||
|
||||
lastBandwidth = baseBandwidth;
|
||||
for (auto& mod : description->bandwidthCC)
|
||||
for (const auto& mod : description->bandwidthCC)
|
||||
lastBandwidth += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastBandwidth = Default::eqBandwidthRange.clamp(lastBandwidth);
|
||||
|
||||
lastGain = baseGain;
|
||||
for (auto& mod : description->gainCC)
|
||||
for (const auto& mod : description->gainCC)
|
||||
lastGain += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastGain = Default::filterGainRange.clamp(lastGain);
|
||||
|
||||
|
|
|
|||
|
|
@ -41,17 +41,17 @@ void sfz::FilterHolder::setup(const FilterDescription& description, unsigned num
|
|||
|
||||
// Setup the modulated values
|
||||
lastCutoff = baseCutoff;
|
||||
for (auto& mod : description.cutoffCC)
|
||||
for (const auto& mod : description.cutoffCC)
|
||||
lastCutoff *= centsFactor(midiState.getCCValue(mod.cc) * mod.value);
|
||||
lastCutoff = Default::filterCutoffRange.clamp(lastCutoff);
|
||||
|
||||
lastResonance = baseResonance;
|
||||
for (auto& mod : description.resonanceCC)
|
||||
for (const auto& mod : description.resonanceCC)
|
||||
lastResonance += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastResonance = Default::filterResonanceRange.clamp(lastResonance);
|
||||
|
||||
lastGain = baseGain;
|
||||
for (auto& mod : description.gainCC)
|
||||
for (const auto& mod : description.gainCC)
|
||||
lastGain += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastGain = Default::filterGainRange.clamp(lastGain);
|
||||
|
||||
|
|
@ -71,17 +71,17 @@ void sfz::FilterHolder::process(const float** inputs, float** outputs, unsigned
|
|||
// For now we take the last value
|
||||
// TODO: the template deduction could be automatic here?
|
||||
lastCutoff = baseCutoff;
|
||||
for (auto& mod : description->cutoffCC)
|
||||
for (const auto& mod : description->cutoffCC)
|
||||
lastCutoff *= centsFactor(midiState.getCCValue(mod.cc) * mod.value);
|
||||
lastCutoff = Default::filterCutoffRange.clamp(lastCutoff);
|
||||
|
||||
lastResonance = baseResonance;
|
||||
for (auto& mod : description->resonanceCC)
|
||||
for (const auto& mod : description->resonanceCC)
|
||||
lastResonance += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastResonance = Default::filterResonanceRange.clamp(lastResonance);
|
||||
|
||||
lastGain = baseGain;
|
||||
for (auto& mod : description->gainCC)
|
||||
for (const auto& mod : description->gainCC)
|
||||
lastGain += midiState.getCCValue(mod.cc) * mod.value;
|
||||
lastGain = Default::filterGainRange.clamp(lastGain);
|
||||
|
||||
|
|
|
|||
|
|
@ -250,7 +250,7 @@ void sfz::Voice::ampStageMono(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Amplitude envelope
|
||||
fill<float>(*modulationSpan, baseGain);
|
||||
for (auto& mod : region->amplitudeCC) {
|
||||
for (const auto& mod : region->amplitudeCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -259,12 +259,12 @@ void sfz::Voice::ampStageMono(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Crossfade envelopes
|
||||
fill<float>(*modulationSpan, 1.0f);
|
||||
for (auto& mod : region->crossfadeCCInRange) {
|
||||
for (const auto& mod : region->crossfadeCCInRange) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeIn(mod.value, x, xfCurve); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
}
|
||||
for (auto& mod : region->crossfadeCCOutRange) {
|
||||
for (const auto& mod : region->crossfadeCCOutRange) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeOut(mod.value, x, xfCurve); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -273,7 +273,7 @@ void sfz::Voice::ampStageMono(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Volume envelope
|
||||
fill<float>(*modulationSpan, db2mag(baseVolumedB));
|
||||
for (auto& mod : region->volumeCC) {
|
||||
for (const auto& mod : region->volumeCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
multiplicativeEnvelope(events, *tempSpan, [&](float x) { return db2mag(x * mod.value); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -300,7 +300,7 @@ void sfz::Voice::ampStageStereo(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Amplitude envelope
|
||||
fill<float>(*modulationSpan, baseGain);
|
||||
for (auto& mod : region->amplitudeCC) {
|
||||
for (const auto& mod : region->amplitudeCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -309,12 +309,12 @@ void sfz::Voice::ampStageStereo(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Crossfade envelopes
|
||||
fill<float>(*modulationSpan, 1.0f);
|
||||
for (auto& mod : region->crossfadeCCInRange) {
|
||||
for (const auto& mod : region->crossfadeCCInRange) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeIn(mod.value, x, xfCurve); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
}
|
||||
for (auto& mod : region->crossfadeCCOutRange) {
|
||||
for (const auto& mod : region->crossfadeCCOutRange) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&](float x) { return crossfadeOut(mod.value, x, xfCurve); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -323,7 +323,7 @@ void sfz::Voice::ampStageStereo(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Volume envelope
|
||||
fill<float>(*modulationSpan, db2mag(baseVolumedB));
|
||||
for (auto& mod : region->volumeCC) {
|
||||
for (const auto& mod : region->volumeCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
multiplicativeEnvelope(events, *tempSpan, [&](float x) { return db2mag(x * mod.value); });
|
||||
applyGain<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -353,7 +353,7 @@ void sfz::Voice::panStageMono(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// Apply panning
|
||||
fill<float>(*modulationSpan, region->pan);
|
||||
for (auto& mod : region->panCC) {
|
||||
for (const auto& mod : region->panCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
add<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -376,7 +376,7 @@ void sfz::Voice::panStageStereo(AudioSpan<float> buffer) noexcept
|
|||
// Apply panning
|
||||
// panningModulation(*modulationSpan);
|
||||
fill<float>(*modulationSpan, region->pan);
|
||||
for (auto& mod : region->panCC) {
|
||||
for (const auto& mod : region->panCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
add<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -386,7 +386,7 @@ void sfz::Voice::panStageStereo(AudioSpan<float> buffer) noexcept
|
|||
// Apply the width/position process
|
||||
// widthModulation(*modulationSpan);
|
||||
fill<float>(*modulationSpan, region->width);
|
||||
for (auto& mod : region->widthCC) {
|
||||
for (const auto& mod : region->widthCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
add<float>(*tempSpan, *modulationSpan);
|
||||
|
|
@ -395,7 +395,7 @@ void sfz::Voice::panStageStereo(AudioSpan<float> buffer) noexcept
|
|||
|
||||
// positionModulation(*modulationSpan);
|
||||
fill<float>(*modulationSpan, region->position);
|
||||
for (auto& mod : region->positionCC) {
|
||||
for (const auto& mod : region->positionCC) {
|
||||
const auto events = resources.midiState.getCCEvents(mod.cc);
|
||||
linearEnvelope(events, *tempSpan, [&mod](float x) { return x * mod.value; });
|
||||
add<float>(*tempSpan, *modulationSpan);
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue