JUCE
Classes | Public Member Functions | Static Public Attributes | List of all members
AudioProcessorGraph Class Reference

A type of AudioProcessor which plays back a graph of other AudioProcessors. More...

+ Inheritance diagram for AudioProcessorGraph:

Classes

class  AudioGraphIOProcessor
 A special type of AudioProcessor that can live inside an AudioProcessorGraph in order to use the audio that comes into and out of the graph itself. More...
 
struct  Connection
 Represents a connection between two channels of two nodes in an AudioProcessorGraph. More...
 
class  Node
 Represents one of the nodes, or processors, in an AudioProcessorGraph. More...
 

Public Member Functions

 AudioProcessorGraph ()
 Creates an empty graph. More...
 
 ~AudioProcessorGraph ()
 Destructor. More...
 
void clear ()
 Deletes all nodes and connections from this graph. More...
 
int getNumNodes () const noexcept
 Returns the number of nodes in the graph. More...
 
NodegetNode (const int index) const noexcept
 Returns a pointer to one of the nodes in the graph. More...
 
NodegetNodeForId (const uint32 nodeId) const
 Searches the graph for a node with the given ID number and returns it. More...
 
NodeaddNode (AudioProcessor *newProcessor, uint32 nodeId=0)
 Adds a node to the graph. More...
 
bool removeNode (uint32 nodeId)
 Deletes a node within the graph which has the specified ID. More...
 
bool removeNode (Node *node)
 Deletes a node within the graph which has the specified ID. More...
 
int getNumConnections () const
 Returns the number of connections in the graph. More...
 
const ConnectiongetConnection (int index) const
 Returns a pointer to one of the connections in the graph. More...
 
const ConnectiongetConnectionBetween (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex) const
 Searches for a connection between some specified channels. More...
 
bool isConnected (uint32 possibleSourceNodeId, uint32 possibleDestNodeId) const
 Returns true if there is a connection between any of the channels of two specified nodes. More...
 
bool canConnect (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex) const
 Returns true if it would be legal to connect the specified points. More...
 
bool addConnection (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex)
 Attempts to connect two specified channels of two nodes. More...
 
void removeConnection (int index)
 Deletes the connection with the specified index. More...
 
bool removeConnection (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex)
 Deletes any connection between two specified points. More...
 
bool disconnectNode (uint32 nodeId)
 Removes all connections from the specified node. More...
 
bool isConnectionLegal (const Connection *connection) const
 Returns true if the given connection's channel numbers map on to valid channels at each end. More...
 
bool removeIllegalConnections ()
 Performs a sanity checks of all the connections. More...
 
const String getName () const override
 Returns the name of this processor. More...
 
void prepareToPlay (double, int) override
 Called before playback starts, to let the filter prepare itself. More...
 
void releaseResources () override
 Called after playback has stopped, to let the filter free up any resources it no longer needs. More...
 
void processBlock (AudioBuffer< float > &, MidiBuffer &) override
 Renders the next block. More...
 
void processBlock (AudioBuffer< double > &, MidiBuffer &) override
 Renders the next block. More...
 
bool supportsDoublePrecisionProcessing () const override
 Returns true if the Audio processor supports double precision floating point processing. More...
 
void reset () override
 A plugin can override this to be told when it should reset any playing voices. More...
 
void setNonRealtime (bool) noexceptoverride
 Called by the host to tell this processor whether it's being used in a non-realtime capacity for offline rendering or bouncing. More...
 
void setPlayHead (AudioPlayHead *) override
 Tells the processor to use this playhead object. More...
 
double getTailLengthSeconds () const override
 Returns the length of the filter's tail, in seconds. More...
 
bool acceptsMidi () const override
 Returns true if the processor wants midi messages. More...
 
bool producesMidi () const override
 Returns true if the processor produces midi messages. More...
 
bool hasEditor () const override
 Your filter must override this and return true if it can create an editor component. More...
 
AudioProcessorEditorcreateEditor () override
 Creates the filter's UI. More...
 
int getNumPrograms () override
 Returns the number of preset programs the filter supports. More...
 
int getCurrentProgram () override
 Returns the number of the currently active program. More...
 
void setCurrentProgram (int) override
 Called by the host to change the current program. More...
 
const String getProgramName (int) override
 Must return the name of a given program. More...
 
void changeProgramName (int, const String &) override
 Called by the host to rename a program. More...
 
void getStateInformation (juce::MemoryBlock &) override
 The host will call this method when it wants to save the filter's internal state. More...
 
void setStateInformation (const void *data, int sizeInBytes) override
 This must restore the filter's state from a block of data previously created using getStateInformation(). More...
 
- Public Member Functions inherited from AudioProcessor
virtual ~AudioProcessor ()
 Destructor. More...
 
virtual void processBlockBypassed (AudioBuffer< float > &buffer, MidiBuffer &midiMessages)
 Renders the next block when the processor is being bypassed. More...
 
virtual void processBlockBypassed (AudioBuffer< double > &buffer, MidiBuffer &midiMessages)
 Renders the next block when the processor is being bypassed. More...
 
virtual bool setPreferredBusArrangement (bool isInputBus, int busIndex, const AudioChannelSet &preferredSet)
 Called by the host, this attempts to change the plugin's channel layout on a particular bus. More...
 
ProcessingPrecision getProcessingPrecision () const noexcept
 Returns the precision-mode of the processor. More...
 
bool isUsingDoublePrecision () const noexcept
 Returns true if the current precision is set to doublePrecision. More...
 
void setProcessingPrecision (ProcessingPrecision precision) noexcept
 Changes the processing precision of the receiver. More...
 
AudioPlayHeadgetPlayHead () const noexcept
 Returns the current AudioPlayHead object that should be used to find out the state and position of the playhead. More...
 
int getTotalNumInputChannels () const noexcept
 Returns the total number of input channels. More...
 
int getTotalNumOutputChannels () const noexcept
 Returns the total number of output channels. More...
 
int getMainBusNumInputChannels () const noexcept
 Returns the number of input channels on the main bus. More...
 
int getMainBusNumOutputChannels () const noexcept
 Returns the number of output channels on the main bus. More...
 
double getSampleRate () const noexcept
 Returns the current sample rate. More...
 
int getBlockSize () const noexcept
 Returns the current typical block size that is being used. More...
 
int getLatencySamples () const noexcept
 This returns the number of samples delay that the filter imposes on the audio passing through it. More...
 
void setLatencySamples (int newLatency)
 The filter should call this to set the number of samples delay that it introduces. More...
 
virtual bool supportsMPE () const
 Returns true if the processor supports MPE. More...
 
const CriticalSectiongetCallbackLock () const noexcept
 This returns a critical section that will automatically be locked while the host is calling the processBlock() method. More...
 
void suspendProcessing (bool shouldBeSuspended)
 Enables and disables the processing callback. More...
 
bool isSuspended () const noexcept
 Returns true if processing is currently suspended. More...
 
bool isNonRealtime () const noexcept
 Returns true if the processor is being run in an offline mode for rendering. More...
 
AudioProcessorEditorgetActiveEditor () const noexcept
 Returns the active editor, if there is one. More...
 
AudioProcessorEditorcreateEditorIfNeeded ()
 Returns the active editor, or if there isn't one, it will create one. More...
 
virtual int getNumParameters ()
 This must return the correct value immediately after the object has been created, and mustn't change the number of parameters later. More...
 
virtual const String getParameterName (int parameterIndex)
 Returns the name of a particular parameter. More...
 
virtual float getParameter (int parameterIndex)
 Called by the host to find out the value of one of the filter's parameters. More...
 
virtual String getParameterName (int parameterIndex, int maximumStringLength)
 Returns the name of a parameter as a text string with a preferred maximum length. More...
 
virtual const String getParameterText (int parameterIndex)
 Returns the value of a parameter as a text string. More...
 
virtual String getParameterText (int parameterIndex, int maximumStringLength)
 Returns the value of a parameter as a text string with a preferred maximum length. More...
 
virtual int getParameterNumSteps (int parameterIndex)
 Returns the number of discrete steps that this parameter can represent. More...
 
virtual float getParameterDefaultValue (int parameterIndex)
 Returns the default value for the parameter. More...
 
virtual String getParameterLabel (int index) const
 Some plugin types may be able to return a label string for a parameter's units. More...
 
virtual bool isParameterOrientationInverted (int index) const
 This can be overridden to tell the host that particular parameters operate in the reverse direction. More...
 
virtual void setParameter (int parameterIndex, float newValue)
 The host will call this method to change the value of one of the filter's parameters. More...
 
void setParameterNotifyingHost (int parameterIndex, float newValue)
 Your filter can call this when it needs to change one of its parameters. More...
 
virtual bool isParameterAutomatable (int parameterIndex) const
 Returns true if the host can automate this parameter. More...
 
virtual bool isMetaParameter (int parameterIndex) const
 Should return true if this parameter is a "meta" parameter. More...
 
void beginParameterChangeGesture (int parameterIndex)
 Sends a signal to the host to tell it that the user is about to start changing this parameter. More...
 
void endParameterChangeGesture (int parameterIndex)
 Tells the host that the user has finished changing this parameter. More...
 
void updateHostDisplay ()
 The filter can call this when something (apart from a parameter value) has changed. More...
 
void addParameter (AudioProcessorParameter *)
 Adds a parameter to the list. More...
 
const OwnedArray< AudioProcessorParameter > & getParameters () const noexcept
 Returns the current list of parameters. More...
 
virtual void getCurrentProgramStateInformation (juce::MemoryBlock &destData)
 The host will call this method if it wants to save the state of just the filter's current program. More...
 
virtual void setCurrentProgramStateInformation (const void *data, int sizeInBytes)
 The host will call this method if it wants to restore the state of just the filter's current program. More...
 
virtual void numChannelsChanged ()
 This method is called when the number of input or output channels is changed. More...
 
virtual void addListener (AudioProcessorListener *newListener)
 Adds a listener that will be called when an aspect of this processor changes. More...
 
virtual void removeListener (AudioProcessorListener *listenerToRemove)
 Removes a previously added listener. More...
 
void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize)
 This is called by the processor to specify its details before being played. More...
 
void setRateAndBufferSizeDetails (double sampleRate, int blockSize) noexcept
 This is called by the processor to specify its details before being played. More...
 
void editorBeingDeleted (AudioProcessorEditor *) noexcept
 Not for public use - this is called before deleting an editor component. More...
 

Static Public Attributes

static const int midiChannelIndex
 A special number that represents the midi channel of a node. More...
 

Additional Inherited Members

- Public Types inherited from AudioProcessor
enum  ProcessingPrecision { singlePrecision, doublePrecision }
 
enum  WrapperType {
  wrapperType_Undefined = 0, wrapperType_VST, wrapperType_VST3, wrapperType_AudioUnit,
  wrapperType_AudioUnitv3, wrapperType_RTAS, wrapperType_AAX, wrapperType_Standalone
}
 Flags to indicate the type of plugin context in which a processor is being used. More...
 
- Static Public Member Functions inherited from AudioProcessor
static int getDefaultNumParameterSteps () noexcept
 Returns the default number of steps for a parameter. More...
 
static void copyXmlToBinary (const XmlElement &xml, juce::MemoryBlock &destData)
 Helper function that just converts an xml element into a binary blob. More...
 
static XmlElementgetXmlFromBinary (const void *data, int sizeInBytes)
 Retrieves an XML element that was stored as binary with the copyXmlToBinary() method. More...
 
static void JUCE_CALLTYPE setTypeOfNextNewPlugin (WrapperType)
 
- Public Attributes inherited from AudioProcessor
AudioBusArrangement busArrangement
 The processor's bus arrangement. More...
 
WrapperType wrapperType
 When loaded by a plugin wrapper, this flag will be set to indicate the type of plugin within which the processor is running. More...
 
- Protected Member Functions inherited from AudioProcessor
 AudioProcessor ()
 Constructor. More...
 
void sendParamChangeMessageToListeners (int parameterIndex, float newValue)
 
- Protected Attributes inherited from AudioProcessor
AudioPlayHeadplayHead
 

Detailed Description

A type of AudioProcessor which plays back a graph of other AudioProcessors.

Use one of these objects if you want to wire-up a set of AudioProcessors and play back the result.

Processors can be added to the graph as "nodes" using addNode(), and once added, you can connect any of their input or output channels to other nodes using addConnection().

To play back a graph through an audio device, you might want to use an AudioProcessorPlayer object.

Constructor & Destructor Documentation

AudioProcessorGraph::AudioProcessorGraph ( )

Creates an empty graph.

AudioProcessorGraph::~AudioProcessorGraph ( )

Destructor.

Any processor objects that have been added to the graph will also be deleted.

Member Function Documentation

void AudioProcessorGraph::clear ( )

Deletes all nodes and connections from this graph.

Any processor objects in the graph will be deleted.

int AudioProcessorGraph::getNumNodes ( ) const
noexcept

Returns the number of nodes in the graph.

Node* AudioProcessorGraph::getNode ( const int  index) const
noexcept

Returns a pointer to one of the nodes in the graph.

This will return nullptr if the index is out of range.

See also
getNodeForId

References addNode(), getNodeForId(), and removeNode().

Node* AudioProcessorGraph::getNodeForId ( const uint32  nodeId) const

Searches the graph for a node with the given ID number and returns it.

If no such node was found, this returns nullptr.

See also
getNode

Referenced by getNode().

Node* AudioProcessorGraph::addNode ( AudioProcessor newProcessor,
uint32  nodeId = 0 
)

Adds a node to the graph.

This creates a new node in the graph, for the specified processor. Once you have added a processor to the graph, the graph owns it and will delete it later when it is no longer needed.

The optional nodeId parameter lets you specify an ID to use for the node, but if the value is already in use, this new node will overwrite the old one.

If this succeeds, it returns a pointer to the newly-created node.

Referenced by getNode().

bool AudioProcessorGraph::removeNode ( uint32  nodeId)

Deletes a node within the graph which has the specified ID.

This will also delete any connections that are attached to this node.

Referenced by getNode().

bool AudioProcessorGraph::removeNode ( Node node)

Deletes a node within the graph which has the specified ID.

This will also delete any connections that are attached to this node.

int AudioProcessorGraph::getNumConnections ( ) const

Returns the number of connections in the graph.

const Connection* AudioProcessorGraph::getConnection ( int  index) const
const Connection* AudioProcessorGraph::getConnectionBetween ( uint32  sourceNodeId,
int  sourceChannelIndex,
uint32  destNodeId,
int  destChannelIndex 
) const

Searches for a connection between some specified channels.

If no such connection is found, this returns nullptr.

Referenced by getConnection().

bool AudioProcessorGraph::isConnected ( uint32  possibleSourceNodeId,
uint32  possibleDestNodeId 
) const

Returns true if there is a connection between any of the channels of two specified nodes.

Referenced by getConnection().

bool AudioProcessorGraph::canConnect ( uint32  sourceNodeId,
int  sourceChannelIndex,
uint32  destNodeId,
int  destChannelIndex 
) const

Returns true if it would be legal to connect the specified points.

Referenced by getConnection().

bool AudioProcessorGraph::addConnection ( uint32  sourceNodeId,
int  sourceChannelIndex,
uint32  destNodeId,
int  destChannelIndex 
)

Attempts to connect two specified channels of two nodes.

If this isn't allowed (e.g. because you're trying to connect a midi channel to an audio one or other such nonsense), then it'll return false.

Referenced by getConnection().

void AudioProcessorGraph::removeConnection ( int  index)

Deletes the connection with the specified index.

Referenced by getConnection().

bool AudioProcessorGraph::removeConnection ( uint32  sourceNodeId,
int  sourceChannelIndex,
uint32  destNodeId,
int  destChannelIndex 
)

Deletes any connection between two specified points.

Returns true if a connection was actually deleted.

bool AudioProcessorGraph::disconnectNode ( uint32  nodeId)

Removes all connections from the specified node.

Referenced by getConnection().

bool AudioProcessorGraph::isConnectionLegal ( const Connection connection) const

Returns true if the given connection's channel numbers map on to valid channels at each end.

Even if a connection is valid when created, its status could change if a node changes its channel config.

Referenced by getConnection().

bool AudioProcessorGraph::removeIllegalConnections ( )

Performs a sanity checks of all the connections.

This might be useful if some of the processors are doing things like changing their channel counts, which could render some connections obsolete.

Referenced by getConnection().

const String AudioProcessorGraph::getName ( ) const
overridevirtual

Returns the name of this processor.

Implements AudioProcessor.

void AudioProcessorGraph::prepareToPlay ( double  sampleRate,
int  maximumExpectedSamplesPerBlock 
)
overridevirtual

Called before playback starts, to let the filter prepare itself.

The sample rate is the target sample rate, and will remain constant until playback stops.

You can call getTotalNumInputChannels and getTotalNumOutputChannels or query the busArrangement member variable to find out the number of channels your processBlock callback must process.

The maximumExpectedSamplesPerBlock value is a strong hint about the maximum number of samples that will be provided in each block. You may want to use this value to resize internal buffers. You should program defensively in case a buggy host exceeds this value. The actual block sizes that the host uses may be different each time the callback happens: completely variable block sizes can be expected from some hosts.

See also
busArrangement, getTotalNumInputChannels, getTotalNumOutputChannels

Implements AudioProcessor.

void AudioProcessorGraph::releaseResources ( )
overridevirtual

Called after playback has stopped, to let the filter free up any resources it no longer needs.

Implements AudioProcessor.

void AudioProcessorGraph::processBlock ( AudioBuffer< float > &  buffer,
MidiBuffer midiMessages 
)
overridevirtual

Renders the next block.

When this method is called, the buffer contains a number of channels which is at least as great as the maximum number of input and output channels that this filter is using. It will be filled with the filter's input data and should be replaced with the filter's output.

So for example if your filter has a total of 2 input channels and 4 output channels, then the buffer will contain 4 channels, the first two being filled with the input data. Your filter should read these, do its processing, and replace the contents of all 4 channels with its output.

Or if your filter has a total of 5 inputs and 2 outputs, the buffer will have 5 channels, all filled with data, and your filter should overwrite the first 2 of these with its output. But be VERY careful not to write anything to the last 3 channels, as these might be mapped to memory that the host assumes is read-only!

If your plug-in has more than one input or output buses then the buffer passed to the processBlock methods will contain a bundle of all channels of each bus. Use AudioBusArrangement::getBusBuffer to obtain an audio buffer for a particular bus.

Note that if you have more outputs than inputs, then only those channels that correspond to an input channel are guaranteed to contain sensible data - e.g. in the case of 2 inputs and 4 outputs, the first two channels contain the input, but the last two channels may contain garbage, so you should be careful not to let this pass through without being overwritten or cleared.

Also note that the buffer may have more channels than are strictly necessary, but you should only read/write from the ones that your filter is supposed to be using.

The number of samples in these buffers is NOT guaranteed to be the same for every callback, and may be more or less than the estimated value given to prepareToPlay(). Your code must be able to cope with variable-sized blocks, or you're going to get clicks and crashes!

Also note that some hosts will occasionally decide to pass a buffer containing zero samples, so make sure that your algorithm can deal with that!

If the filter is receiving a midi input, then the midiMessages array will be filled with the midi messages for this block. Each message's timestamp will indicate the message's time, as a number of samples from the start of the block.

Any messages left in the midi buffer when this method has finished are assumed to be the filter's midi output. This means that your filter should be careful to clear any incoming messages from the array if it doesn't want them to be passed-on.

Be very careful about what you do in this callback - it's going to be called by the audio thread, so any kind of interaction with the UI is absolutely out of the question. If you change a parameter in here and need to tell your UI to update itself, the best way is probably to inherit from a ChangeBroadcaster, let the UI components register as listeners, and then call sendChangeMessage() inside the processBlock() method to send out an asynchronous message. You could also use the AsyncUpdater class in a similar way.

See also
AudioBusArrangement::getBusBuffer

Implements AudioProcessor.

void AudioProcessorGraph::processBlock ( AudioBuffer< double > &  buffer,
MidiBuffer midiMessages 
)
overridevirtual

Renders the next block.

When this method is called, the buffer contains a number of channels which is at least as great as the maximum number of input and output channels that this filter is using. It will be filled with the filter's input data and should be replaced with the filter's output.

So for example if your filter has a combined total of 2 input channels and 4 output channels, then the buffer will contain 4 channels, the first two being filled with the input data. Your filter should read these, do its processing, and replace the contents of all 4 channels with its output.

Or if your filter has 5 inputs and 2 outputs, the buffer will have 5 channels, all filled with data, and your filter should overwrite the first 2 of these with its output. But be VERY careful not to write anything to the last 3 channels, as these might be mapped to memory that the host assumes is read-only!

If your plug-in has more than one input or output buses then the buffer passed to the processBlock methods will contain a bundle of all channels of each bus. Use AudioBusArrangement::getBusBuffer to obtain a audio buffer for a particular bus.

Note that if you have more outputs than inputs, then only those channels that correspond to an input channel are guaranteed to contain sensible data - e.g. in the case of 2 inputs and 4 outputs, the first two channels contain the input, but the last two channels may contain garbage, so you should be careful not to let this pass through without being overwritten or cleared.

Also note that the buffer may have more channels than are strictly necessary, but you should only read/write from the ones that your filter is supposed to be using.

If your plugin uses buses, then you should use AudioBusArrangement::getBusBuffer() or AudioBusArrangement::getChannelIndexInProcessBlockBuffer() to find out which of the input and output channels correspond to which of the buses.

The number of samples in these buffers is NOT guaranteed to be the same for every callback, and may be more or less than the estimated value given to prepareToPlay(). Your code must be able to cope with variable-sized blocks, or you're going to get clicks and crashes!

Also note that some hosts will occasionally decide to pass a buffer containing zero samples, so make sure that your algorithm can deal with that!

If the filter is receiving a midi input, then the midiMessages array will be filled with the midi messages for this block. Each message's timestamp will indicate the message's time, as a number of samples from the start of the block.

Any messages left in the midi buffer when this method has finished are assumed to be the filter's midi output. This means that your filter should be careful to clear any incoming messages from the array if it doesn't want them to be passed-on.

Be very careful about what you do in this callback - it's going to be called by the audio thread, so any kind of interaction with the UI is absolutely out of the question. If you change a parameter in here and need to tell your UI to update itself, the best way is probably to inherit from a ChangeBroadcaster, let the UI components register as listeners, and then call sendChangeMessage() inside the processBlock() method to send out an asynchronous message. You could also use the AsyncUpdater class in a similar way.

See also
AudioBusArrangement::getBusBuffer

Reimplemented from AudioProcessor.

bool AudioProcessorGraph::supportsDoublePrecisionProcessing ( ) const
overridevirtual

Returns true if the Audio processor supports double precision floating point processing.

The default implementation will always return false. If you return true here then you must override the double precision versions of processBlock. Additionally, you must call getProcessingPrecision() in your prepareToPlay method to determine the precision with which you need to allocate your internal buffers.

See also
getProcessingPrecision, setProcessingPrecision

Reimplemented from AudioProcessor.

void AudioProcessorGraph::reset ( )
overridevirtual

A plugin can override this to be told when it should reset any playing voices.

The default implementation does nothing, but a host may call this to tell the plugin that it should stop any tails or sounds that have been left running.

Reimplemented from AudioProcessor.

void AudioProcessorGraph::setNonRealtime ( bool  isNonRealtime)
overridevirtualnoexcept

Called by the host to tell this processor whether it's being used in a non-realtime capacity for offline rendering or bouncing.

Reimplemented from AudioProcessor.

void AudioProcessorGraph::setPlayHead ( AudioPlayHead newPlayHead)
overridevirtual

Tells the processor to use this playhead object.

The processor will not take ownership of the object, so the caller must delete it when it is no longer being used.

Reimplemented from AudioProcessor.

double AudioProcessorGraph::getTailLengthSeconds ( ) const
overridevirtual

Returns the length of the filter's tail, in seconds.

Implements AudioProcessor.

bool AudioProcessorGraph::acceptsMidi ( ) const
overridevirtual

Returns true if the processor wants midi messages.

Implements AudioProcessor.

bool AudioProcessorGraph::producesMidi ( ) const
overridevirtual

Returns true if the processor produces midi messages.

Implements AudioProcessor.

bool AudioProcessorGraph::hasEditor ( ) const
overridevirtual

Your filter must override this and return true if it can create an editor component.

See also
createEditor

Implements AudioProcessor.

AudioProcessorEditor* AudioProcessorGraph::createEditor ( )
overridevirtual

Creates the filter's UI.

This can return nullptr if you want a UI-less filter, in which case the host may create a generic UI that lets the user twiddle the parameters directly.

If you do want to pass back a component, the component should be created and set to the correct size before returning it. If you implement this method, you must also implement the hasEditor() method and make it return true.

Remember not to do anything silly like allowing your filter to keep a pointer to the component that gets created - it could be deleted later without any warning, which would make your pointer into a dangler. Use the getActiveEditor() method instead.

The correct way to handle the connection between an editor component and its filter is to use something like a ChangeBroadcaster so that the editor can register itself as a listener, and be told when a change occurs. This lets them safely unregister themselves when they are deleted.

Here are a few things to bear in mind when writing an editor:

  • Initially there won't be an editor, until the user opens one, or they might not open one at all. Your filter mustn't rely on it being there.
  • An editor object may be deleted and a replacement one created again at any time.
  • It's safe to assume that an editor will be deleted before its filter.
See also
hasEditor

Implements AudioProcessor.

int AudioProcessorGraph::getNumPrograms ( )
overridevirtual

Returns the number of preset programs the filter supports.

The value returned must be valid as soon as this object is created, and must not change over its lifetime.

This value shouldn't be less than 1.

Implements AudioProcessor.

int AudioProcessorGraph::getCurrentProgram ( )
overridevirtual

Returns the number of the currently active program.

Implements AudioProcessor.

void AudioProcessorGraph::setCurrentProgram ( int  index)
overridevirtual

Called by the host to change the current program.

Implements AudioProcessor.

const String AudioProcessorGraph::getProgramName ( int  index)
overridevirtual

Must return the name of a given program.

Implements AudioProcessor.

void AudioProcessorGraph::changeProgramName ( int  index,
const String newName 
)
overridevirtual

Called by the host to rename a program.

Implements AudioProcessor.

References AudioProcessor::getStateInformation(), and AudioProcessor::setStateInformation().

void AudioProcessorGraph::getStateInformation ( juce::MemoryBlock &  destData)
overridevirtual

The host will call this method when it wants to save the filter's internal state.

This must copy any info about the filter's state into the block of memory provided, so that the host can store this and later restore it using setStateInformation().

Note that there's also a getCurrentProgramStateInformation() method, which only stores the current program, not the state of the entire filter.

See also the helper function copyXmlToBinary() for storing settings as XML.

See also
getCurrentProgramStateInformation

Implements AudioProcessor.

void AudioProcessorGraph::setStateInformation ( const void *  data,
int  sizeInBytes 
)
overridevirtual

This must restore the filter's state from a block of data previously created using getStateInformation().

Note that there's also a setCurrentProgramStateInformation() method, which tries to restore just the current program, not the state of the entire filter.

See also the helper function getXmlFromBinary() for loading settings as XML.

See also
setCurrentProgramStateInformation

Implements AudioProcessor.

Member Data Documentation

const int AudioProcessorGraph::midiChannelIndex
static

A special number that represents the midi channel of a node.

This is used as a channel index value if you want to refer to the midi input or output instead of an audio channel.


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