foleys_gui_magic
WYSWYG editor for JUCE GUIs including Visualisers
Public Member Functions | List of all members
MagicProcessorState Class Reference

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

+ 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. More...
 
juce::StringArray getParameterNames () const override
 Returns the IDs of AudioProcessorParameters for selection. More...
 
juce::PopupMenu createParameterMenu () const override
 Return a hierarchical menu of the AudioParameters. More...
 
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. More...
 
void setPlayheadUpdateFrequency (int frequency)
 Starts the timer to fetch the playhead values from the audio thread. More...
 
void setLastEditorSize (int width, int height)
 Allows the editor to set its last size to resore next time. More...
 
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. More...
 
void setStateInformation (const void *data, int sizeInBytes, juce::AudioProcessorEditor *editor=nullptr)
 This method restores the plugin state using the AudioProcessorValueTreeState. More...
 
juce::RangedAudioParameter * getParameter (const juce::String &paramID) override
 Returns a parameter for a parameter ID. More...
 
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. More...
 
void processMidiBuffer (juce::MidiBuffer &buffer, int numSamples, bool injectIndirectEvents=true)
 Send the midi data to the keyboard and to the MidiLearn mapper. More...
 
void mapMidiController (int cc, const juce::String &parameterID)
 Connects a midi controller CC to a parameter for MIDI learn. More...
 
int getLastController () const
 Returns the last moved controller for MIDI learn. More...
 
- Public Member Functions inherited from MagicGUIState
 MagicGUIState ()
 
virtual ~MagicGUIState ()
 
juce::ValueTree getPropertyRoot ()
 Returns the root node for exposed properties for the GUI. More...
 
juce::ValueTree getPropertyRoot () const
 
void setGuiValueTree (const juce::ValueTree &dom)
 Set the GUI DOM to create the GUI components from. More...
 
void setGuiValueTree (const char *data, int dataSize)
 
void setGuiValueTree (const juce::File &file)
 
juce::ValueTree & getGuiTree ()
 Grants access to the gui tree. More...
 
juce::ValueTree & getValueTree ()
 
void setApplicationSettingsFile (juce::File file)
 Set a file to save common settings for all instances. More...
 
juce::ValueTree & getSettings ()
 This is a settings ValueTree that is stored globally for all plugin instances. More...
 
void addTrigger (const juce::Identifier &triggerID, std::function< void()> function)
 You can store a lambda that can be called from e.g. More...
 
std::function< void()> getTrigger (const juce::Identifier &triggerID)
 Returns a lambda to be connected to your components. More...
 
juce::Value getPropertyAsValue (const juce::String &pathToProperty)
 Returns a property as value inside the ValueTreeState. More...
 
void populatePropertiesMenu (juce::ComboBox &comboBox) const
 Populates a menu with properties found in the persistent ValueTree. More...
 
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. More...
 
template<typename ObjectType >
juce::StringArray getObjectIDsByType () const
 Returns all identifiers of objects, that can be casted to the given type. More...
 
template<typename ObjectType >
ObjectType * getObjectWithType (juce::Identifier objectID)
 Return an object by objectID. More...
 
void prepareToPlay (double sampleRate, int samplesPerBlockExpected)
 Call this method in your prepareToPlay implementation, to allow th visualisers to be properly setup. More...
 
void addBackgroundProcessing (MagicPlotSource *source)
 Registers background processing. More...
 
juce::MidiKeyboardState & getKeyboardState ()
 

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.

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.

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 MagicGUIState::getValueTree(), and ParameterManager::loadParameterValues().

Referenced by MagicProcessor::setStateInformation().

◆ getParameter()

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

Returns a parameter for a parameter ID.

Reimplemented from MagicGUIState.

References ParameterManager::getParameter().

◆ updateParameterMap()

void updateParameterMap ( )

◆ createAttachment() [1/3]

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

Reimplemented from MagicGUIState.

◆ createAttachment() [2/3]

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

Reimplemented from MagicGUIState.

◆ createAttachment() [3/3]

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

Reimplemented from MagicGUIState.

◆ 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.

◆ getLastController()

int getLastController ( ) const

Returns the last moved controller for MIDI learn.

References MidiParameterMapper::getLastController().


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