Skip to content

Commit

Permalink
Merge pull request #11424 from Swiftb0y/fix/gh11376
Browse files Browse the repository at this point in the history
Properly Handle mismatch between Presets and EffectUnits with different amount of Effect slots
  • Loading branch information
daschuer authored Apr 3, 2023
2 parents e370f30 + dbbb854 commit c7a4bd5
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 10 deletions.
9 changes: 9 additions & 0 deletions src/effects/chains/equalizereffectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,15 @@ EqualizerEffectChain::EqualizerEffectChain(
addEffectSlot(formatEffectSlotGroup(handleAndGroup.name()));
enableForInputChannel(handleAndGroup);
m_effectSlots[0]->setEnabled(true);

QObject::connect(this,
&EffectChain::chainPresetChanged,
this,
[this](const QString& presetname) {
Q_UNUSED(presetname);
setFilterWaveform(
m_effectSlots.at(0)->getManifest()->isMixingEQ());
});
// DlgPrefEq loads the Effect with loadEffectToGroup

setupLegacyAliasesForGroup(handleAndGroup.name());
Expand Down
26 changes: 16 additions & 10 deletions src/effects/effectchain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -200,23 +200,29 @@ const QString& EffectChain::presetName() const {
return m_presetName;
}

void EffectChain::loadChainPreset(EffectChainPresetPointer pPreset) {
void EffectChain::loadChainPreset(EffectChainPresetPointer pChainPreset) {
slotControlClear(1);
VERIFY_OR_DEBUG_ASSERT(pPreset) {
VERIFY_OR_DEBUG_ASSERT(pChainPreset) {
return;
}

int effectSlotIndex = 0;
for (const auto& pEffectPreset : pPreset->effectPresets()) {
EffectSlotPointer pEffectSlot = m_effectSlots.at(effectSlotIndex);
pEffectSlot->loadEffectFromPreset(pEffectPreset);
effectSlotIndex++;
const QList effectPresets = pChainPreset->effectPresets();

// TODO: use C++23 std::ranges::views::zip instead
// `EffectChain`s can create arbitrary amounts of effectslots and chain presets
// can contain an arbitrary number of effects. This ensures we only load
// as many effects as we have slots available.
const int validPresetSlotCount = std::min(effectPresets.count(), m_effectSlots.count());
for (int presetSlotIndex = 0;
presetSlotIndex < validPresetSlotCount;
presetSlotIndex++) {
m_effectSlots[presetSlotIndex]->loadEffectFromPreset(effectPresets[presetSlotIndex]);
}

setMixMode(pPreset->mixMode());
m_pControlChainSuperParameter->setDefaultValue(pPreset->superKnob());
setMixMode(pChainPreset->mixMode());
m_pControlChainSuperParameter->setDefaultValue(pChainPreset->superKnob());

m_presetName = pPreset->name();
m_presetName = pChainPreset->name();
emit chainPresetChanged(m_presetName);

setControlLoadedPresetIndex(presetIndex());
Expand Down

0 comments on commit c7a4bd5

Please sign in to comment.