Dispatch and record pitch bends in the Voice

This commit is contained in:
Paul Ferrand 2019-12-13 10:20:31 +01:00
parent b9bee27ef3
commit cc04f21a05
2 changed files with 16 additions and 1 deletions

View file

@ -95,6 +95,13 @@ void sfz::Voice::startVoice(Region* region, int delay, int channel, int number,
width += normalizeCC(midiState.cc[region->widthCC->first]) * normalizeNegativePercents(region->widthCC->second);
widthEnvelope.reset(width);
pitchBendEnvelope.setFunction([region](float pitchValue){
const auto normalizedBend = normalizeBend(pitchValue);
const auto bendInCents = normalizedBend > 0 ? normalizedBend * region->bendUp : normalizedBend * region->bendDown;
return centsFactor(bendInCents);
});
pitchBendEnvelope.reset(midiState.pitchBend);
sourcePosition = region->getOffset();
initialDelay = delay + static_cast<uint32_t>(region->getDelay() * sampleRate);
baseFrequency = midiNoteFrequency(number) * pitchRatio;
@ -183,8 +190,15 @@ void sfz::Voice::registerCC(int delay, int channel [[maybe_unused]], int ccNumbe
}
}
void sfz::Voice::registerPitchWheel(int delay [[maybe_unused]], int channel [[maybe_unused]], int pitch [[maybe_unused]]) noexcept
void sfz::Voice::registerPitchWheel(int delay, int channel, int pitch) noexcept
{
if (!channel == triggerChannel)
return;
if (state == State::idle)
return;
pitchBendEnvelope.registerEvent(delay, pitch);
// TODO
}

View file

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