Skip to content

Commit 6dd86c7

Browse files
fix: A/B layer switching should not affect legacy mode
1 parent e220aab commit 6dd86c7

File tree

2 files changed

+11
-40
lines changed

2 files changed

+11
-40
lines changed

source/PluginEditor.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -356,7 +356,7 @@ void AmbiCreatorAudioProcessorEditor::buttonClicked (juce::Button* button)
356356
bool isToggled = button->getToggleState();
357357
DBG ("tbLegacyMode clicked: Setting legacyMode to " << (isToggled ? "ON" : "OFF"));
358358
valueTreeState.getParameter ("legacyMode")->setValueNotifyingHost (isToggled ? 1.0f : 0.0f);
359-
setModeDisplay (ambiCreatorProcessor.getLegacyModeActive());
359+
setModeDisplay (isToggled);
360360
}
361361
else if (button == &abComponent[0] && ! button->getToggleState())
362362
{

source/PluginProcessor.cpp

Lines changed: 10 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -339,12 +339,12 @@ void AmbiCreatorAudioProcessor::processBlock (juce::AudioBuffer<float>& buffer,
339339
auto totalNumInputChannels = getTotalNumInputChannels();
340340
auto totalNumOutputChannels = getTotalNumOutputChannels();
341341

342-
AudioPlayHead* playHead = getPlayHead();
342+
AudioPlayHead* localPlayHead = getPlayHead();
343343
AudioPlayHead::PositionInfo playHeadPosition;
344344

345-
if (playHead != nullptr)
345+
if (localPlayHead != nullptr)
346346
{
347-
if (auto position = playHead->getPosition())
347+
if (auto position = localPlayHead->getPosition())
348348
{
349349
playHeadPosition = *position;
350350
}
@@ -551,23 +551,6 @@ void AmbiCreatorAudioProcessor::setStateInformation (const void* data, int sizeI
551551
layerB = params.copyState();
552552
abLayerState = eCurrentActiveLayer::layerA;
553553
}
554-
555-
MessageManager::callAsync (
556-
[this]
557-
{
558-
static const StringArray paramIDs = { "outGainDb",
559-
"horRotation",
560-
"zGainDb",
561-
"channelOrder",
562-
"legacyMode" };
563-
for (const auto& id : paramIDs)
564-
{
565-
if (auto* param = params.getParameter (id))
566-
{
567-
param->setValueNotifyingHost (param->getValue());
568-
}
569-
}
570-
});
571554
}
572555
}
573556

@@ -578,37 +561,27 @@ void AmbiCreatorAudioProcessor::changeAbLayerState (int desiredLayer)
578561
ScopedLock lock (stateLock); // Protect ValueTree operations
579562
DBG ("Switching to layer: " << (desiredLayer == eCurrentActiveLayer::layerA ? "A" : "B"));
580563

564+
// legacyMode property is not affected by layer switching
565+
const auto legacyMode = getLegacyModeActive();
566+
581567
if (desiredLayer == eCurrentActiveLayer::layerA)
582568
{
583569
layerB = params.copyState();
570+
// legacy mode is exempt from A/B switching
571+
layerA.getChildWithProperty ("id", "legacyMode").setProperty ("value", legacyMode, nullptr);
584572
params.replaceState (layerA.createCopy());
585573
abLayerState = eCurrentActiveLayer::layerA;
586574
DBG ("Layer A loaded: legacyMode=" << (getLegacyModeActive() ? "ON" : "OFF"));
587575
}
588576
else
589577
{
590578
layerA = params.copyState();
579+
// legacy mode is exempt from A/B switching
580+
layerB.getChildWithProperty ("id", "legacyMode").setProperty ("value", legacyMode, nullptr);
591581
params.replaceState (layerB.createCopy());
592582
abLayerState = eCurrentActiveLayer::layerB;
593583
DBG ("Layer B loaded: legacyMode=" << (getLegacyModeActive() ? "ON" : "OFF"));
594584
}
595-
596-
MessageManager::callAsync (
597-
[this]
598-
{
599-
static const StringArray paramIDs = { "outGainDb",
600-
"horRotation",
601-
"zGainDb",
602-
"channelOrder",
603-
"legacyMode" };
604-
for (const auto& id : paramIDs)
605-
{
606-
if (auto* param = params.getParameter (id))
607-
{
608-
param->setValueNotifyingHost (param->getValue());
609-
}
610-
}
611-
});
612585
}
613586

614587
//==============================================================================
@@ -721,9 +694,7 @@ void AmbiCreatorAudioProcessor::updateLatency()
721694
void AmbiCreatorAudioProcessor::setAbLayer (int desiredLayer)
722695
{
723696
if (desiredLayer != abLayerState)
724-
{
725697
changeAbLayerState (desiredLayer);
726-
}
727698
}
728699

729700
//==============================================================================

0 commit comments

Comments
 (0)