Only init per-voice modulations which are of the region

This commit is contained in:
Jean Pierre Cimalando 2020-07-28 13:37:08 +02:00
parent 0507dab7c4
commit 4703b939ab
3 changed files with 4 additions and 4 deletions

View file

@ -141,7 +141,7 @@ void sfz::Voice::startVoice(Region* region, int delay, int number, float value,
bendSmoother.reset(centsFactor(region->getBendInCents(resources.midiState.getPitchBend())));
egEnvelope.reset(region->amplitudeEG, *region, resources.midiState, delay, value, sampleRate);
resources.modMatrix.initVoice(id);
resources.modMatrix.initVoice(id, region->getId());
}
int sfz::Voice::getCurrentSampleQuality() const noexcept

View file

@ -202,13 +202,13 @@ void ModMatrix::init()
}
}
void ModMatrix::initVoice(NumericId<Voice> voiceId)
void ModMatrix::initVoice(NumericId<Voice> voiceId, NumericId<Region> regionId)
{
Impl& impl = *impl_;
for (Impl::Source &source : impl.sources_) {
const int flags = source.key.flags();
if (flags & kModIsPerVoice)
if ((flags & kModIsPerVoice) && source.key.region() == regionId)
source.gen->init(source.key, voiceId);
}
}

View file

@ -104,7 +104,7 @@ public:
* @brief Reinitialize modulation source for a given voice.
* This must be called first after a voice enters active state.
*/
void initVoice(NumericId<Voice> voiceId);
void initVoice(NumericId<Voice> voiceId, NumericId<Region> regionId);
/**
* @brief Start modulation processing for the entire cycle.