openshot-audio  0.1.4
Classes | Public Member Functions | Static Public Attributes | Friends | List of all members
juce::AudioProcessorGraph Class Reference

#include <juce_audio_processors.h>

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

Classes

class  AudioGraphIOProcessor
 
struct  Connection
 
class  Node
 

Public Member Functions

 AudioProcessorGraph ()
 
 ~AudioProcessorGraph ()
 
void clear ()
 
int getNumNodes () const noexcept
 
NodegetNode (const int index) const noexcept
 
NodegetNodeForId (const uint32 nodeId) const
 
NodeaddNode (AudioProcessor *newProcessor, uint32 nodeId=0)
 
bool removeNode (uint32 nodeId)
 
int getNumConnections () const
 
const ConnectiongetConnection (int index) const
 
const ConnectiongetConnectionBetween (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex) const
 
bool isConnected (uint32 possibleSourceNodeId, uint32 possibleDestNodeId) const
 
bool canConnect (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex) const
 
bool addConnection (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex)
 
void removeConnection (int index)
 
bool removeConnection (uint32 sourceNodeId, int sourceChannelIndex, uint32 destNodeId, int destChannelIndex)
 
bool disconnectNode (uint32 nodeId)
 
bool isConnectionLegal (const Connection *connection) const
 
bool removeIllegalConnections ()
 
const String getName () const override
 
void prepareToPlay (double, int) override
 
void releaseResources () override
 
void processBlock (AudioSampleBuffer &, MidiBuffer &) override
 
void reset () override
 
void setNonRealtime (bool) noexcept override
 
void setPlayHead (AudioPlayHead *) override
 
const String getInputChannelName (int) const override
 
const String getOutputChannelName (int) const override
 
bool isInputChannelStereoPair (int) const override
 
bool isOutputChannelStereoPair (int) const override
 
bool silenceInProducesSilenceOut () const 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 void processBlockBypassed (AudioSampleBuffer &buffer, MidiBuffer &midiMessages)
 
AudioPlayHeadgetPlayHead () const noexcept
 
double getSampleRate () const noexcept
 
int getBlockSize () const noexcept
 
int getNumInputChannels () const noexcept
 
int getNumOutputChannels () const noexcept
 
const StringgetInputSpeakerArrangement () const noexcept
 
const StringgetOutputSpeakerArrangement () const noexcept
 
int getLatencySamples () const noexcept
 
void setLatencySamples (int newLatency)
 
const CriticalSectiongetCallbackLock () const noexcept
 
void suspendProcessing (bool shouldBeSuspended)
 
bool isSuspended () const noexcept
 
bool isNonRealtime () const noexcept
 
AudioProcessorEditorgetActiveEditor () const noexcept
 
AudioProcessorEditorcreateEditorIfNeeded ()
 
virtual int getNumParameters ()
 
virtual const String getParameterName (int parameterIndex)
 
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 float getParameterDefaultValue (int parameterIndex)
 
virtual String getParameterLabel (int index) const
 
virtual bool isParameterOrientationInverted (int index) const
 
virtual void setParameter (int parameterIndex, float newValue)
 
void setParameterNotifyingHost (int parameterIndex, float newValue)
 
virtual bool isParameterAutomatable (int parameterIndex) const
 
virtual bool isMetaParameter (int parameterIndex) const
 
void beginParameterChangeGesture (int parameterIndex)
 
void endParameterChangeGesture (int parameterIndex)
 
void updateHostDisplay ()
 
void addParameter (AudioProcessorParameter *)
 
const OwnedArray< AudioProcessorParameter > & getParameters () const noexcept
 
virtual void getCurrentProgramStateInformation (juce::MemoryBlock &destData)
 
virtual void setCurrentProgramStateInformation (const void *data, int sizeInBytes)
 
virtual void numChannelsChanged ()
 
virtual void addListener (AudioProcessorListener *newListener)
 
virtual void removeListener (AudioProcessorListener *listenerToRemove)
 
void setPlayConfigDetails (int numIns, int numOuts, double sampleRate, int blockSize) noexcept
 
void editorBeingDeleted (AudioProcessorEditor *) noexcept
 
void setSpeakerArrangement (const String &inputs, const String &outputs)
 

Static Public Attributes

static const int midiChannelIndex = 0x1000
 

Friends

class AudioGraphIOProcessor
 

Additional Inherited Members

- Public Types inherited from juce::AudioProcessor
enum  WrapperType {
  wrapperType_Undefined = 0, wrapperType_VST, wrapperType_VST3, wrapperType_AudioUnit,
  wrapperType_RTAS, wrapperType_AAX, wrapperType_Standalone
}
 
- Static Public Member Functions inherited from juce::AudioProcessor
static int getDefaultNumParameterSteps () noexcept
 
static void copyXmlToBinary (const XmlElement &xml, juce::MemoryBlock &destData)
 
static XmlElementgetXmlFromBinary (const void *data, int sizeInBytes)
 
static void JUCE_CALLTYPE setTypeOfNextNewPlugin (WrapperType)
 
- Public Attributes inherited from juce::AudioProcessor
WrapperType wrapperType
 
- Protected Member Functions inherited from juce::AudioProcessor
 AudioProcessor ()
 
void sendParamChangeMessageToListeners (int parameterIndex, float newValue)
 
- Protected Attributes inherited from juce::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::AudioProcessorGraph ( )

Creates an empty graph.

◆ ~AudioProcessorGraph()

AudioProcessorGraph::~AudioProcessorGraph ( )

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

Member Function Documentation

◆ acceptsMidi()

bool AudioProcessorGraph::acceptsMidi ( ) const
overridevirtual

Returns true if the processor wants midi messages.

Implements juce::AudioProcessor.

◆ addConnection()

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.

◆ addNode()

AudioProcessorGraph::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.

◆ canConnect()

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

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

◆ changeProgramName()

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

Called by the host to rename a program.

Implements juce::AudioProcessor.

◆ clear()

void AudioProcessorGraph::clear ( )

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

◆ createEditor()

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

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

◆ disconnectNode()

bool AudioProcessorGraph::disconnectNode ( uint32  nodeId)

Removes all connections from the specified node.

◆ getConnection()

const Connection* juce::AudioProcessorGraph::getConnection ( int  index) const
inline

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

◆ getConnectionBetween()

const AudioProcessorGraph::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.

◆ getCurrentProgram()

int juce::AudioProcessorGraph::getCurrentProgram ( )
inlineoverridevirtual

Returns the number of the currently active program.

Implements juce::AudioProcessor.

◆ getInputChannelName()

const String AudioProcessorGraph::getInputChannelName ( int  channelIndex) const
overridevirtual

Returns the name of one of the processor's input channels.

The processor might not supply very useful names for channels, and this might be something like "1", "2", "left", "right", etc.

Implements juce::AudioProcessor.

◆ getName()

const String AudioProcessorGraph::getName ( ) const
overridevirtual

Returns the name of this processor.

Implements juce::AudioProcessor.

◆ getNode()

Node* juce::AudioProcessorGraph::getNode ( const 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

◆ getNodeForId()

AudioProcessorGraph::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

◆ getNumConnections()

int juce::AudioProcessorGraph::getNumConnections ( ) const
inline

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

◆ getOutputChannelName()

const String AudioProcessorGraph::getOutputChannelName ( int  channelIndex) const
overridevirtual

Returns the name of one of the processor's output channels.

The processor might not supply very useful names for channels, and this might be something like "1", "2", "left", "right", etc.

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

◆ getTailLengthSeconds()

double AudioProcessorGraph::getTailLengthSeconds ( ) const
overridevirtual

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

Implements juce::AudioProcessor.

◆ hasEditor()

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

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

See also
createEditor

Implements juce::AudioProcessor.

◆ isConnected()

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

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

◆ isConnectionLegal()

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.

◆ isInputChannelStereoPair()

bool AudioProcessorGraph::isInputChannelStereoPair ( int  index) const
overridevirtual

Returns true if the specified channel is part of a stereo pair with its neighbour.

Implements juce::AudioProcessor.

◆ isOutputChannelStereoPair()

bool AudioProcessorGraph::isOutputChannelStereoPair ( int  index) const
overridevirtual

Returns true if the specified channel is part of a stereo pair with its neighbour.

Implements juce::AudioProcessor.

◆ prepareToPlay()

void AudioProcessorGraph::prepareToPlay ( double  sampleRate,
int  estimatedSamplesPerBlock 
)
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.

The estimatedSamplesPerBlock value is a HINT about the typical number of samples that will be processed for each callback, but isn't any kind of guarantee. The actual block sizes that the host uses may be different each time the callback happens, and may be more or less than this value.

Implements juce::AudioProcessor.

◆ processBlock()

void AudioProcessorGraph::processBlock ( AudioSampleBuffer 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 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!

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!

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.

Implements juce::AudioProcessor.

◆ producesMidi()

bool AudioProcessorGraph::producesMidi ( ) const
overridevirtual

Returns true if the processor produces midi messages.

Implements juce::AudioProcessor.

◆ releaseResources()

void AudioProcessorGraph::releaseResources ( )
overridevirtual

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

Implements juce::AudioProcessor.

◆ removeConnection() [1/2]

void AudioProcessorGraph::removeConnection ( int  index)

Deletes the connection with the specified index.

◆ removeConnection() [2/2]

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.

◆ removeIllegalConnections()

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.

◆ removeNode()

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.

◆ reset()

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

◆ setCurrentProgram()

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

Called by the host to change the current program.

Implements juce::AudioProcessor.

◆ setNonRealtime()

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

◆ setPlayHead()

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

◆ setStateInformation()

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

◆ silenceInProducesSilenceOut()

bool AudioProcessorGraph::silenceInProducesSilenceOut ( ) const
overridevirtual

Returns true if a silent input always produces a silent output.

Implements juce::AudioProcessor.

Friends And Related Function Documentation

◆ AudioGraphIOProcessor

friend class AudioGraphIOProcessor
friend

Member Data Documentation

◆ midiChannelIndex

const int AudioProcessorGraph::midiChannelIndex = 0x1000
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 files: