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

#include <AudioProcessorGraph.h>

Inheritance diagram for water::AudioProcessorGraph:
water::AudioProcessor

Classes

class  Node
struct  Connection
class  AudioGraphIOProcessor
struct  AudioProcessorGraphBufferHelpers

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)
bool removeNode (Node *node)
size_t getNumConnections () const
const ConnectiongetConnection (size_t index) const
const ConnectiongetConnectionBetween (ChannelType channelType, uint32 sourceNodeId, uint sourceChannelIndex, uint32 destNodeId, uint destChannelIndex) const
bool isConnected (uint32 possibleSourceNodeId, uint32 possibleDestNodeId) const
bool canConnect (ChannelType channelType, uint32 sourceNodeId, uint sourceChannelIndex, uint32 destNodeId, uint destChannelIndex) const
bool addConnection (ChannelType channelType, uint32 sourceNodeId, uint sourceChannelIndex, uint32 destNodeId, uint destChannelIndex)
void removeConnection (int index)
bool removeConnection (ChannelType channelType, uint32 sourceNodeId, uint sourceChannelIndex, uint32 destNodeId, uint 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 processBlockWithCV (AudioSampleBuffer &audioBuffer, const AudioSampleBuffer &cvInBuffer, AudioSampleBuffer &cvOutBuffer, MidiBuffer &midiMessages) override
void reset () override
void setNonRealtime (bool) noexcept override
bool acceptsMidi () const override
bool producesMidi () const override
void reorderNowIfNeeded ()
const CarlaRecursiveMutex & getReorderMutex () const
void clearRenderingSequence ()
void buildRenderingSequence ()
bool isAnInputTo (uint32 possibleInputId, uint32 possibleDestinationId, int recursionCheck) const
Public Member Functions inherited from water::AudioProcessor
virtual ~AudioProcessor ()
uint getTotalNumInputChannels (ChannelType t) const noexcept
uint getTotalNumOutputChannels (ChannelType t) const noexcept
double getSampleRate () const noexcept
int getBlockSize () const noexcept
int getLatencySamples () const noexcept
void setLatencySamples (int newLatency)
virtual bool supportsMPE () const
virtual const String getInputChannelName (ChannelType, uint) const
virtual const String getOutputChannelName (ChannelType, uint) const
const CarlaRecursiveMutex & getCallbackLock () const noexcept
void suspendProcessing (bool shouldBeSuspended)
bool isSuspended () const noexcept
virtual void reconfigure ()
bool isNonRealtime () const noexcept
void setPlayConfigDetails (uint numAudioIns, uint numAudioOuts, uint numCVIns, uint numCVOuts, uint numMIDIIns, uint numMIDIOuts, double sampleRate, int blockSize)
void setRateAndBufferSizeDetails (double sampleRate, int blockSize) noexcept

Static Public Attributes

static const uint midiChannelIndex

Private Member Functions

void processAudioAndCV (AudioSampleBuffer &audioBuffer, const AudioSampleBuffer &cvInBuffer, AudioSampleBuffer &cvOutBuffer, MidiBuffer &midiMessages)

Private Attributes

ReferenceCountedArray< Nodenodes
OwnedArray< Connectionconnections
uint32 lastNodeId
OwnedArray< MidiBuffermidiBuffers
Array< void * > renderingOps
CarlaScopedPointer< AudioProcessorGraphBufferHelpersaudioAndCVBuffers
MidiBuffercurrentMidiInputBuffer
MidiBuffer currentMidiOutputBuffer
bool isPrepared
bool needsReorder
CarlaRecursiveMutex reorderMutex

Friends

class AudioGraphIOProcessor

Additional Inherited Members

Public Types inherited from water::AudioProcessor
enum  ChannelType { ChannelTypeAudio , ChannelTypeCV , ChannelTypeMIDI }
Protected Member Functions inherited from water::AudioProcessor
 AudioProcessor ()

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()

water::AudioProcessorGraph::AudioProcessorGraph ( )

Creates an empty graph.

◆ ~AudioProcessorGraph()

water::AudioProcessorGraph::~AudioProcessorGraph ( )

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

Member Function Documentation

◆ acceptsMidi()

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

Returns true if the processor wants midi messages.

Implements water::AudioProcessor.

◆ addConnection()

bool water::AudioProcessorGraph::addConnection ( ChannelType channelType,
uint32 sourceNodeId,
uint sourceChannelIndex,
uint32 destNodeId,
uint 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 * water::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.

◆ buildRenderingSequence()

void water::AudioProcessorGraph::buildRenderingSequence ( )

◆ canConnect()

bool water::AudioProcessorGraph::canConnect ( ChannelType channelType,
uint32 sourceNodeId,
uint sourceChannelIndex,
uint32 destNodeId,
uint destChannelIndex ) const

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

◆ clear()

void water::AudioProcessorGraph::clear ( )

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

◆ clearRenderingSequence()

void water::AudioProcessorGraph::clearRenderingSequence ( )

◆ disconnectNode()

bool water::AudioProcessorGraph::disconnectNode ( uint32 nodeId)

Removes all connections from the specified node.

◆ getConnection()

const Connection * water::AudioProcessorGraph::getConnection ( size_t index) const
inline

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

◆ getConnectionBetween()

const AudioProcessorGraph::Connection * water::AudioProcessorGraph::getConnectionBetween ( ChannelType channelType,
uint32 sourceNodeId,
uint sourceChannelIndex,
uint32 destNodeId,
uint destChannelIndex ) const

Searches for a connection between some specified channels. If no such connection is found, this returns nullptr.

◆ getName()

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

Returns the name of this processor.

Implements water::AudioProcessor.

◆ getNode()

Node * water::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 * water::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()

size_t water::AudioProcessorGraph::getNumConnections ( ) const
inline

Returns the number of connections in the graph.

◆ getNumNodes()

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

Returns the number of nodes in the graph.

◆ getReorderMutex()

const CarlaRecursiveMutex & water::AudioProcessorGraph::getReorderMutex ( ) const

◆ isAnInputTo()

bool water::AudioProcessorGraph::isAnInputTo ( uint32 possibleInputId,
uint32 possibleDestinationId,
int recursionCheck ) const

◆ isConnected()

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

◆ prepareToPlay()

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

◆ processAudioAndCV()

void water::AudioProcessorGraph::processAudioAndCV ( AudioSampleBuffer & audioBuffer,
const AudioSampleBuffer & cvInBuffer,
AudioSampleBuffer & cvOutBuffer,
MidiBuffer & midiMessages )
private

◆ processBlockWithCV()

void water::AudioProcessorGraph::processBlockWithCV ( AudioSampleBuffer & audioBuffer,
const AudioSampleBuffer & cvInBuffer,
AudioSampleBuffer & cvOutBuffer,
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 AudiobusLayout::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
AudiobusLayout::getBusBuffer

Implements water::AudioProcessor.

◆ producesMidi()

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

Returns true if the processor produces midi messages.

Implements water::AudioProcessor.

◆ releaseResources()

void water::AudioProcessorGraph::releaseResources ( )
overridevirtual

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

Implements water::AudioProcessor.

◆ removeConnection() [1/2]

bool water::AudioProcessorGraph::removeConnection ( ChannelType channelType,
uint32 sourceNodeId,
uint sourceChannelIndex,
uint32 destNodeId,
uint destChannelIndex )

Deletes any connection between two specified points. Returns true if a connection was actually deleted.

◆ removeConnection() [2/2]

void water::AudioProcessorGraph::removeConnection ( int index)

Deletes the connection with the specified index.

◆ removeIllegalConnections()

bool water::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]

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

◆ removeNode() [2/2]

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

◆ reorderNowIfNeeded()

void water::AudioProcessorGraph::reorderNowIfNeeded ( )

◆ reset()

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

◆ setNonRealtime()

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

◆ AudioGraphIOProcessor

friend class AudioGraphIOProcessor
friend

Member Data Documentation

◆ audioAndCVBuffers

CarlaScopedPointer<AudioProcessorGraphBufferHelpers> water::AudioProcessorGraph::audioAndCVBuffers
private

◆ connections

OwnedArray<Connection> water::AudioProcessorGraph::connections
private

◆ currentMidiInputBuffer

MidiBuffer* water::AudioProcessorGraph::currentMidiInputBuffer
private

◆ currentMidiOutputBuffer

MidiBuffer water::AudioProcessorGraph::currentMidiOutputBuffer
private

◆ isPrepared

bool water::AudioProcessorGraph::isPrepared
private

◆ lastNodeId

uint32 water::AudioProcessorGraph::lastNodeId
private

◆ midiBuffers

OwnedArray<MidiBuffer> water::AudioProcessorGraph::midiBuffers
private

◆ midiChannelIndex

const uint water::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.

◆ needsReorder

bool water::AudioProcessorGraph::needsReorder
private

◆ nodes

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

◆ renderingOps

Array<void*> water::AudioProcessorGraph::renderingOps
private

◆ reorderMutex

CarlaRecursiveMutex water::AudioProcessorGraph::reorderMutex
private

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