Skip to content

Commit

Permalink
Modify our UI display vs Processor strategy (#77)
Browse files Browse the repository at this point in the history
Use the display processor copy for more things in the UI
and the audio thread one for less. This means that problems
with not switching whtn the UI thread is in various uncalled
states are all fixed, it seems.
  • Loading branch information
baconpaul authored May 6, 2024
1 parent 8f9eaad commit 149450b
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 10 deletions.
33 changes: 23 additions & 10 deletions src-juce/AWConsolidatedProcessor.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -225,14 +225,33 @@ void AWConsolidatedAudioProcessor::setAWProcessorTo(int registryIndex, bool init
if (awProcessor)
{
awProcessor->setSampleRate(getSampleRate());
}

if (initDisplay)
{
std::lock_guard<std::mutex> g(displayProcessorMutex);
awDisplayProcessor = rg.generator();
awDisplayProcessor->setSampleRate(getSampleRate());
}

setupParamDisplaysFromDisplayProcessor(registryIndex);
}

void AWConsolidatedAudioProcessor::setupParamDisplaysFromDisplayProcessor(int index)
{
{
std::lock_guard<std::mutex> g(displayProcessorMutex);

auto rg = AirwinRegistry::registry[index];

nProcessorParams = rg.nParams;
for (int i = 0; i < rg.nParams; ++i)
{
char txt[kVstMaxParamStrLen];
awProcessor->getParameterName(i, txt);
awDisplayProcessor->getParameterName(i, txt);
fxParams[i]->mutableName = txt;
fxParams[i]->setValueNotifyingHost(awProcessor->getParameter(i));
defaultValues[i] = awProcessor->getParameter(i);
fxParams[i]->setValueNotifyingHost(awDisplayProcessor->getParameter(i));
defaultValues[i] = awDisplayProcessor->getParameter(i);
active[i] = true;
}
for (int i = rg.nParams; i < nAWParams; ++i)
Expand All @@ -243,16 +262,10 @@ void AWConsolidatedAudioProcessor::setAWProcessorTo(int registryIndex, bool init
}
}

if (initDisplay)
{
std::lock_guard<std::mutex> g(displayProcessorMutex);
awDisplayProcessor = rg.generator();
awDisplayProcessor->setSampleRate(getSampleRate());
}

updateHostDisplay(juce::AudioProcessor::ChangeDetails().withParameterInfoChanged(true));
rebuildUI = true;
}

//==============================================================================
void AWConsolidatedAudioProcessor::getStateInformation(juce::MemoryBlock &destData)
{
Expand Down
5 changes: 5 additions & 0 deletions src-juce/AWConsolidatedProcessor.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,15 +114,20 @@ class AWConsolidatedAudioProcessor : public juce::AudioProcessor,
awDisplayProcessor = rg.generator();
awDisplayProcessor->setSampleRate(getSampleRate());
}
setupParamDisplaysFromDisplayProcessor(index);

if (isPlaying)
{
curentProcessorIndex = index;
resetType.push({-1, index, 0.f});
}
else
{
setAWProcessorTo(index, false);
}
}
void setupParamDisplaysFromDisplayProcessor(int index);

std::atomic<bool> refreshUI{false},
rebuildUI{false}; // repaint vs re-setup everything. Value vs type

Expand Down

0 comments on commit 149450b

Please sign in to comment.