@@ -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()
721694void AmbiCreatorAudioProcessor::setAbLayer (int desiredLayer)
722695{
723696 if (desiredLayer != abLayerState)
724- {
725697 changeAbLayerState (desiredLayer);
726- }
727698}
728699
729700// ==============================================================================
0 commit comments