WYSWYG editor for JUCE GUIs including Visualisers
Loading...
Searching...
No Matches
MagicProcessorState Class Reference

The MagicProcessorState is a subclass of MagicGUIState, that adds AudioProcessor specific functionality. More...

#include <foleys_MagicProcessorState.h>

+ Inheritance diagram for MagicProcessorState:

Public Member Functions

 MagicProcessorState (juce::AudioProcessor &processorToUse)
 Create a MagicProcessorState to let the generated GUI communicate with the processor and it's internals.
 
 ~MagicProcessorState () override
 
juce::StringArray getParameterNames () const override
 Returns the IDs of AudioProcessorParameters for selection.
 
juce::PopupMenu createParameterMenu () const override
 Return a hierarchical menu of the AudioParameters.
 
void updatePlayheadInformation (juce::AudioPlayHead *playhead)
 Calling this in the processBlock() will store the values from AudioPlayHead into the state, so it can be used in the GUI.
 
void setPlayheadUpdateFrequency (int frequency)
 Starts the timer to fetch the playhead values from the audio thread.
 
void setLastEditorSize (int width, int height)
 Allows the editor to set its last size to resore next time.
 
bool getLastEditorSize (int &width, int &height)
 
void getStateInformation (juce::MemoryBlock &destData)
 This method will serialise the plugin state from AudioProcessorValueTreeState for the host to save in the session.
 
void setStateInformation (const void *data, int sizeInBytes, juce::AudioProcessorEditor *editor=nullptr)
 This method restores the plugin state using the AudioProcessorValueTreeState.
 
juce::RangedAudioParameter * getParameter (const juce::String &paramID) override
 Returns a parameter for a parameter ID.
 
void updateParameterMap ()
 
std::unique_ptr< juce::SliderParameterAttachment > createAttachment (const juce::String &paramID, juce::Slider &slider) override
 
std::unique_ptr< juce::ComboBoxParameterAttachment > createAttachment (const juce::String &paramID, juce::ComboBox &combobox) override
 
std::unique_ptr< juce::ButtonParameterAttachment > createAttachment (const juce::String &paramID, juce::Button &button) override
 
juce::AudioProcessor * getProcessor () override
 Return the referenced AudioProcessor, if this state can provide one.
 
void processMidiBuffer (juce::MidiBuffer &buffer, int numSamples, bool injectIndirectEvents=true)
 Send the midi data to the keyboard and to the MidiLearn mapper.
 
void mapMidiController (int cc, const juce::String &parameterID)
 Connects a midi controller CC to a parameter for MIDI learn.
 
int getLastController () const
 Returns the last moved controller for MIDI learn.
 
- Public Member Functions inherited from MagicGUIState
 MagicGUIState ()
 
virtual ~MagicGUIState ()
 
juce::ValueTree getPropertyRoot ()
 Returns the root node for exposed properties for the GUI.
 
juce::ValueTree getPropertyRoot () const
 
void setGuiValueTree (const juce::ValueTree &dom)
 Set the GUI DOM to create the GUI components from.
 
void setGuiValueTree (const char *data, int dataSize)
 
void setGuiValueTree (const juce::File &file)
 
juce::ValueTree & getGuiTree ()
 Grants access to the gui tree.
 
juce::ValueTree & getValueTree ()
 
void setApplicationSettingsFile (juce::File file)
 Set a file to save common settings for all instances.
 
juce::ValueTree & getSettings ()
 This is a settings ValueTree that is stored globally for all plugin instances.
 
void addTrigger (const juce::Identifier &triggerID, std::function< void()> function)
 You can store a lambda that can be called from e.g.
 
std::function< void()> getTrigger (const juce::Identifier &triggerID)
 Returns a lambda to be connected to your components.
 
juce::Value getPropertyAsValue (const juce::String &pathToProperty)
 Returns a property as value inside the ValueTreeState.
 
void populatePropertiesMenu (juce::ComboBox &comboBox) const
 Populates a menu with properties found in the persistent ValueTree.
 
juce::PopupMenu createPropertiesMenu (juce::ComboBox &combo) const
 
juce::PopupMenu createTriggerMenu () const
 
juce::PopupMenu createAssetFilesMenu () const
 
template<typename T , typename... Ts>
T * createAndAddObject (const juce::Identifier &objectID, Ts &&... t)
 Create and add an object.
 
template<typename ObjectType >
juce::StringArray getObjectIDsByType () const
 Returns all identifiers of objects, that can be casted to the given type.
 
template<typename ObjectType >
ObjectType * getObjectWithType (juce::Identifier objectID)
 Return an object by objectID.
 
void clearAllObjects ()
 This removes all objects managed by the MagicGuiState.
 
void prepareToPlay (double sampleRate, int samplesPerBlockExpected)
 Call this method in your prepareToPlay implementation, to allow th visualisers to be properly setup.
 
void addBackgroundProcessing (MagicPlotSource *source)
 Registers background processing.
 
juce::MidiKeyboardState & getKeyboardState ()
 
void setResourcesFolder (const juce::String &name)
 
juce::File getResourcesFolder () const
 

Detailed Description

The MagicProcessorState is a subclass of MagicGUIState, that adds AudioProcessor specific functionality.

It allows for instance connecting to AudioProcessorParameters and supplies a default XML tree* of components built from the getParameterTree() from the AudioProcessor.

Constructor & Destructor Documentation

◆ MagicProcessorState()

MagicProcessorState ( juce::AudioProcessor & processorToUse)

Create a MagicProcessorState to let the generated GUI communicate with the processor and it's internals.

◆ ~MagicProcessorState()

~MagicProcessorState ( )
override

Member Function Documentation

◆ getParameterNames()

juce::StringArray getParameterNames ( ) const
overridevirtual

Returns the IDs of AudioProcessorParameters for selection.

Reimplemented from MagicGUIState.

References ParameterManager::getParameterNames().

◆ createParameterMenu()

juce::PopupMenu createParameterMenu ( ) const
overridevirtual

Return a hierarchical menu of the AudioParameters.

Reimplemented from MagicGUIState.

◆ updatePlayheadInformation()

void updatePlayheadInformation ( juce::AudioPlayHead * playhead)

Calling this in the processBlock() will store the values from AudioPlayHead into the state, so it can be used in the GUI.

To enable this call setPlayheadUpdateFrequency (frequency) with an appropriate value

◆ setPlayheadUpdateFrequency()

void setPlayheadUpdateFrequency ( int frequency)

Starts the timer to fetch the playhead values from the audio thread.

◆ setLastEditorSize()

void setLastEditorSize ( int width,
int height )

Allows the editor to set its last size to resore next time.

References MagicGUIState::getValueTree().

Referenced by MagicPluginEditor::resized().

◆ getLastEditorSize()

bool getLastEditorSize ( int & width,
int & height )

◆ getStateInformation()

void getStateInformation ( juce::MemoryBlock & destData)

This method will serialise the plugin state from AudioProcessorValueTreeState for the host to save in the session.

Parameters
destDatais the memory block to fill

References MagicGUIState::getValueTree(), and ParameterManager::saveParameterValues().

Referenced by MagicProcessor::getStateInformation().

◆ setStateInformation()

void setStateInformation ( const void * data,
int sizeInBytes,
juce::AudioProcessorEditor * editor = nullptr )

This method restores the plugin state using the AudioProcessorValueTreeState.

If you supply a pointer to the editor (using getActiveEditor()) the last size is automatically restored.

Parameters
datais a pointer to the original data
sizeInBytesis the length of the data
editoris an optional pointer to the editor to apply the last size to

References MagicProcessorState::getLastEditorSize(), MagicGUIState::getValueTree(), and ParameterManager::loadParameterValues().

Referenced by MagicProcessor::setStateInformation().

◆ getParameter()

juce::RangedAudioParameter * getParameter ( const juce::String & paramID)
overridevirtual

◆ updateParameterMap()

void updateParameterMap ( )

◆ createAttachment() [1/3]

std::unique_ptr< juce::SliderParameterAttachment > createAttachment ( const juce::String & paramID,
juce::Slider & slider )
overridevirtual

Reimplemented from MagicGUIState.

References MagicProcessorState::getParameter().

◆ createAttachment() [2/3]

std::unique_ptr< juce::ComboBoxParameterAttachment > createAttachment ( const juce::String & paramID,
juce::ComboBox & combobox )
overridevirtual

Reimplemented from MagicGUIState.

References MagicProcessorState::getParameter().

◆ createAttachment() [3/3]

std::unique_ptr< juce::ButtonParameterAttachment > createAttachment ( const juce::String & paramID,
juce::Button & button )
overridevirtual

Reimplemented from MagicGUIState.

References MagicProcessorState::getParameter().

◆ getProcessor()

juce::AudioProcessor * getProcessor ( )
overridevirtual

Return the referenced AudioProcessor, if this state can provide one.

Reimplemented from MagicGUIState.

◆ processMidiBuffer()

void processMidiBuffer ( juce::MidiBuffer & buffer,
int numSamples,
bool injectIndirectEvents = true )

Send the midi data to the keyboard and to the MidiLearn mapper.

Parameters
bufferthe midi buffer from processBlock
numSamplesthe number of samples in the corresponding audio buffer
injectIndirectEventsif true key presses from the GUI are added to the midi stream

References MagicGUIState::getKeyboardState(), and MidiParameterMapper::processMidiBuffer().

◆ mapMidiController()

void mapMidiController ( int cc,
const juce::String & parameterID )

Connects a midi controller CC to a parameter for MIDI learn.

References MidiParameterMapper::mapMidiController().

◆ getLastController()

int getLastController ( ) const

Returns the last moved controller for MIDI learn.

References MidiParameterMapper::getLastController().

Referenced by MidiLearnComponent::mouseDrag(), and MidiLearnComponent::paint().


The documentation for this class was generated from the following files: