Add a bend step factor in the voice

This commit is contained in:
Paul Ferrand 2019-12-13 13:59:49 +01:00
parent 5d94521af9
commit c763e819bb
2 changed files with 10 additions and 4 deletions

View file

@ -105,6 +105,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int channel, int number,
sourcePosition = region->getOffset();
initialDelay = delay + static_cast<uint32_t>(region->getDelay() * sampleRate);
baseFrequency = midiNoteFrequency(number);
bendStepFactor = centsFactor(region->bendStep);
prepareEGEnvelope(initialDelay, value);
}
@ -371,8 +372,10 @@ void sfz::Voice::fillWithData(AudioSpan<float> buffer) noexcept
auto rightCoeffs = tempSpan2.first(buffer.getNumFrames());
fill<float>(jumps, pitchRatio * speedRatio);
if (region->bendStep > 1)
pitchBendEnvelope.getQuantizedBlock(bends, region->bendStep);
if (region->bendStep > 1){
pitchBendEnvelope.getQuantizedBlock(bends, bendStepFactor);
DBG("Last bend value " << bends.back());
}
else
pitchBendEnvelope.getBlock(bends);
@ -459,8 +462,10 @@ void sfz::Voice::fillWithGenerator(AudioSpan<float> buffer) noexcept
const float step = baseFrequency * twoPi<float> / sampleRate;
fill<float>(jumps, step);
if (region->bendStep > 1)
pitchBendEnvelope.getQuantizedBlock(bends, region->bendStep);
if (region->bendStep > 1){
pitchBendEnvelope.getQuantizedBlock(bends, bendStepFactor);
DBG("Last bend value " << bends.back());
}
else
pitchBendEnvelope.getBlock(bends);

View file

@ -318,6 +318,7 @@ private:
LinearEnvelope<float> positionEnvelope;
LinearEnvelope<float> widthEnvelope;
MultiplicativeEnvelope<float> pitchBendEnvelope;
float bendStepFactor { centsFactor(1) };
HistoricalBuffer<float> powerHistory { config::powerHistoryLength };
LEAK_DETECTOR(Voice);