Skip to content

Commit

Permalink
Fix Visualizer parameter editor not updating when stream changed
Browse files Browse the repository at this point in the history
  • Loading branch information
anjaldoshi committed Mar 7, 2024
1 parent 71f0f76 commit 528ec76
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 15 deletions.
20 changes: 11 additions & 9 deletions Source/Processors/Visualization/Visualizer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -61,10 +61,12 @@ void Visualizer::update()
}
}

Array<ParameterEditor*> allParamEditors;

allParamEditors.addArray(parameterEditors);
allParamEditors.clear();

// Add the visualizer's parameter editors
allParamEditors.addArray(getParameterEditors());

// Add the parameter editors of all the parameter editor owners for this visualizer
for(auto editorOwner : parameterEditorOwners)
allParamEditors.addArray(editorOwner->getParameterEditors());

Expand Down Expand Up @@ -105,21 +107,21 @@ void Visualizer::startCallbacks()
{
startTimer(1/float(refreshRate)*1000.0f);

for (int n = 0; n < parameterEditors.size(); n++)
for (auto ed: allParamEditors)
{
if (parameterEditors[n]->shouldDeactivateDuringAcquisition())
parameterEditors[n]->setEnabled(false);
if (ed->shouldDeactivateDuringAcquisition())
ed->setEnabled(false);
}
}

void Visualizer::stopCallbacks()
{
stopTimer();

for (int n = 0; n < parameterEditors.size(); n++)
for (auto ed : allParamEditors)
{
if (parameterEditors[n]->shouldDeactivateDuringAcquisition())
parameterEditors[n]->setEnabled(true);
if (ed->shouldDeactivateDuringAcquisition())
ed->setEnabled(true);
}
}

Expand Down
11 changes: 5 additions & 6 deletions Source/Processors/Visualization/Visualizer.h
Original file line number Diff line number Diff line change
Expand Up @@ -114,6 +114,9 @@ class PLUGIN_API Visualizer : public Component,
the parameters of the underlying processor are changed. */
void update();

/** Called by the update() method to allow the visualizer to update its custom settings.*/
virtual void updateSettings() { }

/** Starts animation callbacks at refreshRate Hz. */
void startCallbacks();

Expand All @@ -130,9 +133,6 @@ class PLUGIN_API Visualizer : public Component,

GenericProcessor* getProcessor() { return processor; }

/** An array of pointers to ParameterEditors created based on the Parameters of an editor's underlying processor. */
OwnedArray<ParameterEditor> parameterEditors;

protected:

// --------------------------------------------
Expand Down Expand Up @@ -208,15 +208,14 @@ class PLUGIN_API Visualizer : public Component,
const String& description,
bool deactivateDuringAcquisition = false);

/** Called by the update() method to allow the visualizer to update its custom settings.*/
virtual void updateSettings() { }

private:

GenericProcessor* processor;

OwnedArray<ParameterEditorOwner> parameterEditorOwners;

Array<ParameterEditor*> allParamEditors;

JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR (Visualizer);
};

Expand Down

0 comments on commit 528ec76

Please sign in to comment.