|
LMMS
|
#include <juce_AudioProcessorGraph.h>
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 |
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< Node > | nodes |
| NodeID | lastNodeID = {} |
| std::unique_ptr< RenderSequenceFloat > | renderSequenceFloat |
| std::unique_ptr< RenderSequenceDouble > | renderSequenceDouble |
| 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< XmlElement > | getXmlFromBinary (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 } |
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}
| anonymous enum |
| juce::AudioProcessorGraph::AudioProcessorGraph | ( | ) |
Creates an empty graph.
|
override |
Destructor. Any processor objects that have been added to the graph will also be deleted.
|
overridevirtual |
Returns true if the processor wants MIDI messages.
Implements juce::AudioProcessor.
| 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.
| 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.
|
privatenoexcept |
|
private |
| bool juce::AudioProcessorGraph::canConnect | ( | const Connection & | c | ) | const |
Returns true if it would be legal to connect the specified points.
|
privatenoexcept |
|
inlineoverridevirtual |
Called by the host to rename a program.
Implements juce::AudioProcessor.
| void juce::AudioProcessorGraph::clear | ( | ) |
Deletes all nodes and connections from this graph. Any processor objects in the graph will be deleted.
|
private |
|
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:
Implements juce::AudioProcessor.
| bool juce::AudioProcessorGraph::disconnectNode | ( | NodeID | nodeID | ) |
Removes all connections from the specified node.
| std::vector< AudioProcessorGraph::Connection > juce::AudioProcessorGraph::getConnections | ( | ) | const |
Returns the list of connections in the graph.
|
inlineoverridevirtual |
Returns the number of the currently active program.
Implements juce::AudioProcessor.
Returns the name of this processor.
Implements juce::AudioProcessor.
Returns a pointer to one of the nodes in the graph. This will return nullptr if the index is out of range.
|
staticprivate |
| 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.
|
inlinenoexcept |
Returns the array of nodes in the graph.
|
inlinenoexcept |
Returns the number of nodes in the graph.
|
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.
Must return the name of a given program.
Implements juce::AudioProcessor.
|
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.
Implements juce::AudioProcessor.
|
overridevirtual |
Returns the length of the processor's tail, in seconds.
Implements juce::AudioProcessor.
|
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.
|
inlineoverridevirtual |
Your processor subclass must override this and return true if it can create an editor component.
Implements juce::AudioProcessor.
Does a recursive check to see if there's a direct or indirect series of connections between these two nodes.
|
privatenoexcept |
|
noexcept |
Returns true if the given connection exists.
|
privatenoexcept |
|
noexcept |
Returns true if there is a direct connection between any of the channels of two specified nodes.
| 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.
|
privatenoexcept |
|
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.
Implements juce::AudioProcessor.
|
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.
Reimplemented from juce::AudioProcessor.
|
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.
Implements juce::AudioProcessor.
|
overridevirtual |
Returns true if the processor produces MIDI messages.
Implements juce::AudioProcessor.
|
overridevirtual |
Called after playback has stopped, to let the object free up any resources it no longer needs.
Implements juce::AudioProcessor.
| bool juce::AudioProcessorGraph::removeConnection | ( | const Connection & | c | ) |
Deletes the given connection.
| 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.
| 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.
| 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.
|
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.
Called by the host to change the current program.
Implements juce::AudioProcessor.
|
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.
|
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.
Implements juce::AudioProcessor.
|
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.
Reimplemented from juce::AudioProcessor.
|
private |
|
private |
|
friend |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |