LMMS
Loading...
Searching...
No Matches
juce::AudioProcessorGraph Class Reference

#include <juce_AudioProcessorGraph.h>

Inheritance diagram for juce::AudioProcessorGraph:
juce::AudioProcessor juce::ChangeBroadcaster juce::AsyncUpdater

Classes

struct  NodeID
struct  NodeAndChannel
class  Node
struct  Connection
class  AudioGraphIOProcessor
struct  PrepareSettings
struct  RenderSequenceFloat
struct  RenderSequenceDouble

Public Types

enum  { midiChannelIndex = 0x1000 }
Public Types inherited from juce::AudioProcessor
enum  ProcessingPrecision { singlePrecision , doublePrecision }
enum class  Realtime { no , yes }
enum  WrapperType {
  wrapperType_Undefined = 0 , wrapperType_VST , wrapperType_VST3 , wrapperType_AudioUnit ,
  wrapperType_AudioUnitv3 , wrapperType_AAX , wrapperType_Standalone , wrapperType_Unity ,
  wrapperType_LV2
}
using ChangeDetails = AudioProcessorListener::ChangeDetails

Public Member Functions

 AudioProcessorGraph ()
 ~AudioProcessorGraph () override
void clear ()
const ReferenceCountedArray< Node > & getNodes () const noexcept
int getNumNodes () const noexcept
Node::Ptr getNode (int index) const noexcept
NodegetNodeForId (NodeID) const
Node::Ptr addNode (std::unique_ptr< AudioProcessor > newProcessor, NodeID nodeId={})
Node::Ptr removeNode (NodeID)
Node::Ptr removeNode (Node *)
std::vector< ConnectiongetConnections () const
bool isConnected (const Connection &) const noexcept
bool isConnected (NodeID possibleSourceNodeID, NodeID possibleDestNodeID) const noexcept
bool isAnInputTo (Node &source, Node &destination) const noexcept
bool canConnect (const Connection &) const
bool addConnection (const Connection &)
bool removeConnection (const Connection &)
bool disconnectNode (NodeID)
bool isConnectionLegal (const Connection &) const
bool removeIllegalConnections ()
const String getName () const override
void prepareToPlay (double, int) override
void releaseResources () override
void processBlock (AudioBuffer< float > &, MidiBuffer &) override
void processBlock (AudioBuffer< double > &, MidiBuffer &) override
bool supportsDoublePrecisionProcessing () const override
void reset () override
void setNonRealtime (bool) noexcept override
double getTailLengthSeconds () const override
bool acceptsMidi () const override
bool producesMidi () const override
bool hasEditor () const override
AudioProcessorEditorcreateEditor () override
int getNumPrograms () override
int getCurrentProgram () override
void setCurrentProgram (int) override
const String getProgramName (int) override
void changeProgramName (int, const String &) override
void getStateInformation (juce::MemoryBlock &) override
void setStateInformation (const void *data, int sizeInBytes) override
Public Member Functions inherited from juce::AudioProcessor
virtual ~AudioProcessor ()
virtual StringArray getAlternateDisplayNames () const
virtual void memoryWarningReceived ()
virtual void processBlockBypassed (AudioBuffer< float > &buffer, MidiBuffer &midiMessages)
virtual void processBlockBypassed (AudioBuffer< double > &buffer, MidiBuffer &midiMessages)
int getBusCount (bool isInput) const noexcept
BusgetBus (bool isInput, int busIndex) noexcept
const BusgetBus (bool isInput, int busIndex) const noexcept
virtual bool canAddBus (bool isInput) const
virtual bool canRemoveBus (bool isInput) const
bool addBus (bool isInput)
bool removeBus (bool isInput)
bool setBusesLayout (const BusesLayout &)
bool setBusesLayoutWithoutEnabling (const BusesLayout &)
BusesLayout getBusesLayout () const
AudioChannelSet getChannelLayoutOfBus (bool isInput, int busIndex) const noexcept
bool setChannelLayoutOfBus (bool isInput, int busIndex, const AudioChannelSet &layout)
int getChannelCountOfBus (bool isInput, int busIndex) const noexcept
bool enableAllBuses ()
bool disableNonMainBuses ()
int getChannelIndexInProcessBlockBuffer (bool isInput, int busIndex, int channelIndex) const noexcept
int getOffsetInBusBufferForAbsoluteChannelIndex (bool isInput, int absoluteChannelIndex, int &busIndex) const noexcept
template<typename FloatType>
AudioBuffer< FloatType > getBusBuffer (AudioBuffer< FloatType > &processBlockBuffer, bool isInput, int busIndex) const
bool checkBusesLayoutSupported (const BusesLayout &) const
ProcessingPrecision getProcessingPrecision () const noexcept
bool isUsingDoublePrecision () const noexcept
void setProcessingPrecision (ProcessingPrecision newPrecision) noexcept
AudioPlayHeadgetPlayHead () const noexcept
int getTotalNumInputChannels () const noexcept
int getTotalNumOutputChannels () const noexcept
int getMainBusNumInputChannels () const noexcept
int getMainBusNumOutputChannels () const noexcept
template<size_t numLayouts>
BusesLayout getNextBestLayoutInLayoutList (const BusesLayout &layouts, const short(&channelLayoutList)[numLayouts][2])
double getSampleRate () const noexcept
int getBlockSize () const noexcept
int getLatencySamples () const noexcept
void setLatencySamples (int newLatency)
virtual bool supportsMPE () const
virtual bool isMidiEffect () const
const CriticalSectiongetCallbackLock () const noexcept
void suspendProcessing (bool shouldBeSuspended)
bool isSuspended () const noexcept
virtual AudioProcessorParametergetBypassParameter () const
bool isNonRealtime () const noexcept
Realtime isRealtime () const noexcept
AudioProcessorEditorgetActiveEditor () const noexcept
AudioProcessorEditorcreateEditorIfNeeded ()
void updateHostDisplay (const ChangeDetails &details=ChangeDetails::getDefaultFlags())
void addParameter (AudioProcessorParameter *)
void addParameterGroup (std::unique_ptr< AudioProcessorParameterGroup >)
const AudioProcessorParameterGroupgetParameterTree () const
void setParameterTree (AudioProcessorParameterGroup &&newTree)
virtual void refreshParameterList ()
const Array< AudioProcessorParameter * > & getParameters () const
virtual void getCurrentProgramStateInformation (juce::MemoryBlock &destData)
virtual void setCurrentProgramStateInformation (const void *data, int sizeInBytes)
virtual void numChannelsChanged ()
virtual void numBusesChanged ()
virtual void processorLayoutsChanged ()
virtual void addListener (AudioProcessorListener *newListener)
virtual void removeListener (AudioProcessorListener *listenerToRemove)
virtual void setPlayHead (AudioPlayHead *newPlayHead)
void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize)
void setRateAndBufferSizeDetails (double sampleRate, int blockSize) noexcept
virtual int32 getAAXPluginIDForMainBusConfig (const AudioChannelSet &mainInputLayout, const AudioChannelSet &mainOutputLayout, bool idForAudioSuite) const
virtual CurveData getResponseCurve (CurveData::Type) const
void editorBeingDeleted (AudioProcessorEditor *) noexcept
virtual void updateTrackProperties (const TrackProperties &properties)
virtual int getNumParameters ()
virtual const String getParameterName (int parameterIndex)
virtual String getParameterID (int index)
virtual float getParameter (int parameterIndex)
virtual String getParameterName (int parameterIndex, int maximumStringLength)
virtual const String getParameterText (int parameterIndex)
virtual String getParameterText (int parameterIndex, int maximumStringLength)
virtual int getParameterNumSteps (int parameterIndex)
virtual bool isParameterDiscrete (int parameterIndex) const
virtual float getParameterDefaultValue (int parameterIndex)
virtual String getParameterLabel (int index) const
virtual bool isParameterOrientationInverted (int index) const
virtual void setParameter (int parameterIndex, float newValue)
virtual bool isParameterAutomatable (int parameterIndex) const
virtual bool isMetaParameter (int parameterIndex) const
virtual AudioProcessorParameter::Category getParameterCategory (int parameterIndex) const
void beginParameterChangeGesture (int parameterIndex)
void endParameterChangeGesture (int parameterIndex)
void setParameterNotifyingHost (int parameterIndex, float newValue)
int getNumInputChannels () const noexcept
int getNumOutputChannels () const noexcept
const String getInputSpeakerArrangement () const noexcept
const String getOutputSpeakerArrangement () const noexcept
virtual const String getInputChannelName (int channelIndex) const
virtual const String getOutputChannelName (int channelIndex) const
virtual bool isInputChannelStereoPair (int index) const
virtual bool isOutputChannelStereoPair (int index) const
Public Member Functions inherited from juce::ChangeBroadcaster
 ChangeBroadcaster () noexcept
virtual ~ChangeBroadcaster ()
void addChangeListener (ChangeListener *listener)
void removeChangeListener (ChangeListener *listener)
void removeAllChangeListeners ()
void sendChangeMessage ()
void sendSynchronousChangeMessage ()
void dispatchPendingMessages ()

Private Member Functions

void topologyChanged ()
void unprepare ()
void handleAsyncUpdate () override
void clearRenderingSequence ()
void buildRenderingSequence ()
bool anyNodesNeedPreparing () const noexcept
bool isConnected (Node *src, int sourceChannel, Node *dest, int destChannel) const noexcept
bool isAnInputTo (Node &src, Node &dst, int recursionCheck) const noexcept
bool canConnect (Node *src, int sourceChannel, Node *dest, int destChannel) const noexcept
bool isLegal (Node *src, int sourceChannel, Node *dest, int destChannel) const noexcept
Private Member Functions inherited from juce::AsyncUpdater
 AsyncUpdater ()
virtual ~AsyncUpdater ()
void triggerAsyncUpdate ()
void cancelPendingUpdate () noexcept
void handleUpdateNowIfNeeded ()
bool isUpdatePending () const noexcept

Static Private Member Functions

static void getNodeConnections (Node &, std::vector< Connection > &)

Private Attributes

ReferenceCountedArray< Nodenodes
NodeID lastNodeID = {}
std::unique_ptr< RenderSequenceFloatrenderSequenceFloat
std::unique_ptr< RenderSequenceDoublerenderSequenceDouble
PrepareSettings prepareSettings
std::atomic< bool > isPrepared { false }

Friends

class AudioGraphIOProcessor

Additional Inherited Members

Static Public Member Functions inherited from juce::AudioProcessor
static bool containsLayout (const BusesLayout &layouts, const std::initializer_list< const short[2]> &channelLayoutList)
template<size_t numLayouts>
static bool containsLayout (const BusesLayout &layouts, const short(&channelLayoutList)[numLayouts][2])
static int getDefaultNumParameterSteps () noexcept
static const char * getWrapperTypeDescription (AudioProcessor::WrapperType) noexcept
static void copyXmlToBinary (const XmlElement &xml, juce::MemoryBlock &destData)
static std::unique_ptr< XmlElementgetXmlFromBinary (const void *data, int sizeInBytes)
static void JUCE_CALLTYPE setTypeOfNextNewPlugin (WrapperType)
Public Attributes inherited from juce::AudioProcessor
const WrapperType wrapperType
Protected Member Functions inherited from juce::AudioProcessor
 AudioProcessor ()
 AudioProcessor (const BusesProperties &ioLayouts)
 AudioProcessor (const std::initializer_list< const short[2]> &channelLayoutList)
virtual bool isBusesLayoutSupported (const BusesLayout &) const
virtual bool canApplyBusesLayout (const BusesLayout &layouts) const
virtual bool applyBusLayouts (const BusesLayout &layouts)
virtual bool canApplyBusCountChange (bool isInput, bool isAddingBuses, BusProperties &outNewBusProperties)
void sendParamChangeMessageToListeners (int parameterIndex, float newValue)
Protected Attributes inherited from juce::AudioProcessor
std::atomic< AudioPlayHead * > playHead { nullptr }

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.

@tags{Audio}

Member Enumeration Documentation

◆ anonymous enum

anonymous enum

A special index 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.

Enumerator
midiChannelIndex 

Constructor & Destructor Documentation

◆ AudioProcessorGraph()

juce::AudioProcessorGraph::AudioProcessorGraph ( )

Creates an empty graph.

◆ ~AudioProcessorGraph()

juce::AudioProcessorGraph::~AudioProcessorGraph ( )
override

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

Member Function Documentation

◆ acceptsMidi()

bool juce::AudioProcessorGraph::acceptsMidi ( ) const
overridevirtual

Returns true if the processor wants MIDI messages.

Implements juce::AudioProcessor.

◆ addConnection()

bool juce::AudioProcessorGraph::addConnection ( const Connection & c)

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.

◆ addNode()

AudioProcessorGraph::Node::Ptr juce::AudioProcessorGraph::addNode ( std::unique_ptr< AudioProcessor > newProcessor,
NodeID nodeId = {} )

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 a unique ID to use for the node. If the value is already in use, this method will fail and return an empty node.

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

◆ anyNodesNeedPreparing()

bool juce::AudioProcessorGraph::anyNodesNeedPreparing ( ) const
privatenoexcept

◆ buildRenderingSequence()

void juce::AudioProcessorGraph::buildRenderingSequence ( )
private

◆ canConnect() [1/2]

bool juce::AudioProcessorGraph::canConnect ( const Connection & c) const

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

◆ canConnect() [2/2]

bool juce::AudioProcessorGraph::canConnect ( Node * src,
int sourceChannel,
Node * dest,
int destChannel ) const
privatenoexcept

◆ changeProgramName()

void juce::AudioProcessorGraph::changeProgramName ( int index,
const String & newName )
inlineoverridevirtual

Called by the host to rename a program.

Implements juce::AudioProcessor.

◆ clear()

void juce::AudioProcessorGraph::clear ( )

Deletes all nodes and connections from this graph. Any processor objects in the graph will be deleted.

◆ clearRenderingSequence()

void juce::AudioProcessorGraph::clearRenderingSequence ( )
private

◆ createEditor()

AudioProcessorEditor * juce::AudioProcessorGraph::createEditor ( )
inlineoverridevirtual

Creates the processor's GUI.

This can return nullptr if you want a GUI-less processor, 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 processor 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 processor 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 processor 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 processor.
See also
hasEditor

Implements juce::AudioProcessor.

◆ disconnectNode()

bool juce::AudioProcessorGraph::disconnectNode ( NodeID nodeID)

Removes all connections from the specified node.

◆ getConnections()

std::vector< AudioProcessorGraph::Connection > juce::AudioProcessorGraph::getConnections ( ) const

Returns the list of connections in the graph.

◆ getCurrentProgram()

int juce::AudioProcessorGraph::getCurrentProgram ( )
inlineoverridevirtual

Returns the number of the currently active program.

Implements juce::AudioProcessor.

◆ getName()

const String juce::AudioProcessorGraph::getName ( ) const
overridevirtual

Returns the name of this processor.

Implements juce::AudioProcessor.

◆ getNode()

Node::Ptr juce::AudioProcessorGraph::getNode ( int index) const
inlinenoexcept

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

◆ getNodeConnections()

void juce::AudioProcessorGraph::getNodeConnections ( Node & node,
std::vector< Connection > & connections )
staticprivate

◆ getNodeForId()

AudioProcessorGraph::Node * juce::AudioProcessorGraph::getNodeForId ( NodeID 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

◆ getNodes()

const ReferenceCountedArray< Node > & juce::AudioProcessorGraph::getNodes ( ) const
inlinenoexcept

Returns the array of nodes in the graph.

◆ getNumNodes()

int juce::AudioProcessorGraph::getNumNodes ( ) const
inlinenoexcept

Returns the number of nodes in the graph.

◆ getNumPrograms()

int juce::AudioProcessorGraph::getNumPrograms ( )
inlineoverridevirtual

Returns the number of preset programs the processor 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 juce::AudioProcessor.

◆ getProgramName()

const String juce::AudioProcessorGraph::getProgramName ( int index)
inlineoverridevirtual

Must return the name of a given program.

Implements juce::AudioProcessor.

◆ getStateInformation()

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

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

This must copy any info about the processor'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 processor.

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

See also
getCurrentProgramStateInformation

Implements juce::AudioProcessor.

◆ getTailLengthSeconds()

double juce::AudioProcessorGraph::getTailLengthSeconds ( ) const
overridevirtual

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

Implements juce::AudioProcessor.

◆ handleAsyncUpdate()

void juce::AudioProcessorGraph::handleAsyncUpdate ( )
overrideprivatevirtual

Called back to do whatever your class needs to do.

This method is called by the message thread at the next convenient time after the triggerAsyncUpdate() method has been called.

Implements juce::AsyncUpdater.

◆ hasEditor()

bool juce::AudioProcessorGraph::hasEditor ( ) const
inlineoverridevirtual

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

See also
createEditor

Implements juce::AudioProcessor.

◆ isAnInputTo() [1/2]

bool juce::AudioProcessorGraph::isAnInputTo ( Node & source,
Node & destination ) const
noexcept

Does a recursive check to see if there's a direct or indirect series of connections between these two nodes.

◆ isAnInputTo() [2/2]

bool juce::AudioProcessorGraph::isAnInputTo ( Node & src,
Node & dst,
int recursionCheck ) const
privatenoexcept

◆ isConnected() [1/3]

bool juce::AudioProcessorGraph::isConnected ( const Connection & c) const
noexcept

Returns true if the given connection exists.

◆ isConnected() [2/3]

bool juce::AudioProcessorGraph::isConnected ( Node * src,
int sourceChannel,
Node * dest,
int destChannel ) const
privatenoexcept

◆ isConnected() [3/3]

bool juce::AudioProcessorGraph::isConnected ( NodeID possibleSourceNodeID,
NodeID possibleDestNodeID ) const
noexcept

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

◆ isConnectionLegal()

bool juce::AudioProcessorGraph::isConnectionLegal ( const Connection & c) 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.

◆ isLegal()

bool juce::AudioProcessorGraph::isLegal ( Node * src,
int sourceChannel,
Node * dest,
int destChannel ) const
privatenoexcept

◆ prepareToPlay()

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

Called before playback starts, to let the processor 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 busLayout 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
busLayout, getTotalNumInputChannels, getTotalNumOutputChannels

Implements juce::AudioProcessor.

◆ processBlock() [1/2]

void juce::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 processor is using. It will be filled with the processor's input data and should be replaced with the processor's output.

So for example if your processor 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 processor should read these, do its processing, and replace the contents of all 4 channels with its output.

Or if your processor has 5 inputs and 2 outputs, the buffer will have 5 channels, all filled with data, and your processor 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 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 processor is supposed to be using.

If your plugin uses buses, then you should use getBusBuffer() or 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 processor 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 processor's MIDI output. This means that your processor should be careful to clear any incoming messages from the array if it doesn't want them to be passed-on.

If you have implemented the getBypassParameter method, then you need to check the value of this parameter in this callback and bypass your processing if the parameter has a non-zero value.

Note that when calling this method as a host, the result may still be bypassed as the parameter that controls the bypass may be non-zero.

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
getBusBuffer

Reimplemented from juce::AudioProcessor.

◆ processBlock() [2/2]

void juce::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 processor is using. It will be filled with the processor's input data and should be replaced with the processor's output.

So for example if your processor 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 processor should read these, do its processing, and replace the contents of all 4 channels with its output.

Or if your processor has a total of 5 inputs and 2 outputs, the buffer will have 5 channels, all filled with data, and your processor 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 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 processor 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 processor 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 processor's MIDI output. This means that your processor should be careful to clear any incoming messages from the array if it doesn't want them to be passed-on.

If you have implemented the getBypassParameter method, then you need to check the value of this parameter in this callback and bypass your processing if the parameter has a non-zero value.

Note that when calling this method as a host, the result may still be bypassed as the parameter that controls the bypass may be non-zero.

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
getBusBuffer

Implements juce::AudioProcessor.

◆ producesMidi()

bool juce::AudioProcessorGraph::producesMidi ( ) const
overridevirtual

Returns true if the processor produces MIDI messages.

Implements juce::AudioProcessor.

◆ releaseResources()

void juce::AudioProcessorGraph::releaseResources ( )
overridevirtual

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

Implements juce::AudioProcessor.

◆ removeConnection()

bool juce::AudioProcessorGraph::removeConnection ( const Connection & c)

Deletes the given connection.

◆ removeIllegalConnections()

bool juce::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.

◆ removeNode() [1/2]

AudioProcessorGraph::Node::Ptr juce::AudioProcessorGraph::removeNode ( Node * node)

Deletes a node within the graph. This will also delete any connections that are attached to this node.

◆ removeNode() [2/2]

AudioProcessorGraph::Node::Ptr juce::AudioProcessorGraph::removeNode ( NodeID nodeId)

Deletes a node within the graph which has the specified ID. This will also delete any connections that are attached to this node.

◆ reset()

void juce::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 juce::AudioProcessor.

◆ setCurrentProgram()

void juce::AudioProcessorGraph::setCurrentProgram ( int index)
inlineoverridevirtual

Called by the host to change the current program.

Implements juce::AudioProcessor.

◆ setNonRealtime()

void juce::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 juce::AudioProcessor.

◆ setStateInformation()

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

This must restore the processor'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 processor.

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

See also
setCurrentProgramStateInformation

Implements juce::AudioProcessor.

◆ supportsDoublePrecisionProcessing()

bool juce::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 juce::AudioProcessor.

◆ topologyChanged()

void juce::AudioProcessorGraph::topologyChanged ( )
private

◆ unprepare()

void juce::AudioProcessorGraph::unprepare ( )
private

◆ AudioGraphIOProcessor

friend class AudioGraphIOProcessor
friend

Member Data Documentation

◆ isPrepared

std::atomic<bool> juce::AudioProcessorGraph::isPrepared { false }
private

◆ lastNodeID

NodeID juce::AudioProcessorGraph::lastNodeID = {}
private

◆ nodes

ReferenceCountedArray<Node> juce::AudioProcessorGraph::nodes
private

◆ prepareSettings

PrepareSettings juce::AudioProcessorGraph::prepareSettings
private

◆ renderSequenceDouble

std::unique_ptr<RenderSequenceDouble> juce::AudioProcessorGraph::renderSequenceDouble
private

◆ renderSequenceFloat

std::unique_ptr<RenderSequenceFloat> juce::AudioProcessorGraph::renderSequenceFloat
private

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