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