Keep voice settings and restore them after polyphony change

This commit is contained in:
Jean Pierre Cimalando 2020-06-21 16:54:37 +02:00
parent a0a7116cf0
commit 07961287be
2 changed files with 28 additions and 5 deletions

View file

@ -491,11 +491,11 @@ void sfz::Synth::finalizeSfzLoad()
regions.resize(currentRegionCount); regions.resize(currentRegionCount);
modificationTime = checkModificationTime(); modificationTime = checkModificationTime();
for (auto& voice : voices) { settingsPerVoice.maxFilters = maxFilters;
voice->setMaxFiltersPerVoice(maxFilters); settingsPerVoice.maxEQs = maxEQs;
voice->setMaxEQsPerVoice(maxEQs); settingsPerVoice.maxModifiers = maxModifiers;
voice->prepareSmoothers(maxModifiers);
} applySettingsPerVoice();
} }
bool sfz::Synth::loadScalaFile(const fs::path& path) bool sfz::Synth::loadScalaFile(const fs::path& path)
@ -1205,6 +1205,17 @@ void sfz::Synth::resetVoices(int numVoices)
} }
this->numVoices = numVoices; this->numVoices = numVoices;
applySettingsPerVoice();
}
void sfz::Synth::applySettingsPerVoice()
{
for (auto& voice : voices) {
voice->setMaxFiltersPerVoice(settingsPerVoice.maxFilters);
voice->setMaxEQsPerVoice(settingsPerVoice.maxEQs);
voice->prepareSmoothers(settingsPerVoice.maxModifiers);
}
} }
void sfz::Synth::setOversamplingFactor(sfz::Oversampling factor) noexcept void sfz::Synth::setOversamplingFactor(sfz::Oversampling factor) noexcept

View file

@ -631,6 +631,10 @@ private:
* @param numVoices * @param numVoices
*/ */
void resetVoices(int numVoices); void resetVoices(int numVoices);
/**
* @brief Make the stored settings take effect in all the voices
*/
void applySettingsPerVoice();
/** /**
* @brief Render the voice to its designated outputs and effect busses. * @brief Render the voice to its designated outputs and effect busses.
@ -702,6 +706,14 @@ private:
int noteOffset { 0 }; int noteOffset { 0 };
int octaveOffset { 0 }; int octaveOffset { 0 };
// Settings per voice
struct SettingsPerVoice {
size_t maxFilters { 0 };
size_t maxEQs { 0 };
ModifierArray<size_t> maxModifiers { 0 };
};
SettingsPerVoice settingsPerVoice;
Duration dispatchDuration { 0 }; Duration dispatchDuration { 0 };
Parser parser; Parser parser;