Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Keep voice settings and restore them after polyphony change #285

Merged
merged 1 commit into from
Jun 21, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 16 additions & 5 deletions src/sfizz/Synth.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -491,11 +491,11 @@ void sfz::Synth::finalizeSfzLoad()
regions.resize(currentRegionCount);
modificationTime = checkModificationTime();

for (auto& voice : voices) {
voice->setMaxFiltersPerVoice(maxFilters);
voice->setMaxEQsPerVoice(maxEQs);
voice->prepareSmoothers(maxModifiers);
}
settingsPerVoice.maxFilters = maxFilters;
settingsPerVoice.maxEQs = maxEQs;
settingsPerVoice.maxModifiers = maxModifiers;

applySettingsPerVoice();
}

bool sfz::Synth::loadScalaFile(const fs::path& path)
Expand Down Expand Up @@ -1205,6 +1205,17 @@ void sfz::Synth::resetVoices(int 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
Expand Down
12 changes: 12 additions & 0 deletions src/sfizz/Synth.h
Original file line number Diff line number Diff line change
Expand Up @@ -631,6 +631,10 @@ class Synth final : public Voice::StateListener, public Parser::Listener {
* @param 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.
Expand Down Expand Up @@ -702,6 +706,14 @@ class Synth final : public Voice::StateListener, public Parser::Listener {
int noteOffset { 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 };

Parser parser;
Expand Down