![]() |
Cinder
0.9.1
|
#include <Node.h>
Inherits enable_shared_from_this< Node >, and cinder::Noncopyable.
Inherited by cinder::audio::ChannelRouterNode, cinder::audio::cocoa::EffectAudioUnitNode, cinder::audio::DelayNode, cinder::audio::FilterBiquadNode, cinder::audio::InputNode, cinder::audio::MathNode, cinder::audio::NodeAutoPullable, cinder::audio::OutputNode, and cinder::audio::Pan2dNode.
Classes | |
struct | Format |
Public Types | |
enum | ChannelMode { ChannelMode::SPECIFIED, ChannelMode::MATCHES_INPUT, ChannelMode::MATCHES_OUTPUT } |
Public Member Functions | |
Node (const Format &format) | |
virtual | ~Node () |
void | enable () |
void | enable (double when) |
void | disable () |
void | disable (double when) |
void | setEnabled (bool b) |
void | setEnabled (bool b, double when) |
bool | isEnabled () const |
virtual void | connect (const NodeRef &output) |
virtual void | disconnect (const NodeRef &output) |
virtual void | disconnectAll () |
virtual void | disconnectAllOutputs () |
virtual void | disconnectAllInputs () |
size_t | getNumConnectedInputs () const |
size_t | getNumConnectedOutputs () const |
bool | isConnectedToInput (const NodeRef &input) const |
bool | isConnectedToOutput (const NodeRef &output) const |
ContextRef | getContext () const |
size_t | getNumChannels () const |
ChannelMode | getChannelMode () const |
size_t | getMaxNumInputChannels () const |
size_t | getSampleRate () const |
size_t | getFramesPerBlock () const |
bool | isAutoEnabled () const |
void | setAutoEnabled (bool b=true) |
bool | isInitialized () const |
bool | getProcessesInPlace () const |
bool | canConnectToInput (const NodeRef &input) |
bool | checkCycle (const NodeRef &sourceNode, const NodeRef &destNode) const |
const std::set< NodeRef > & | getInputs () const |
std::vector< NodeRef > | getOutputs () const |
virtual std::string | getName () |
void | setName (const std::string &name) |
Buffer * | getInternalBuffer () |
const Buffer * | getInternalBuffer () const |
void | pullInputs (Buffer *inPlaceBuffer) |
Protected Member Functions | |
virtual void | initialize () |
virtual void | uninitialize () |
virtual void | enableProcessing () |
virtual void | disableProcessing () |
virtual void | process (Buffer *buffer) |
virtual void | sumInputs () |
virtual bool | supportsInputNumChannels (size_t numChannels) const |
virtual bool | supportsCycles () const |
virtual bool | supportsProcessInPlace () const |
virtual void | connectInput (const NodeRef &input) |
virtual void | disconnectInput (const NodeRef &input) |
virtual void | disconnectOutput (const NodeRef &output) |
virtual void | configureConnections () |
void | setupProcessWithSumming () |
void | notifyConnectionsDidChange () |
bool | inputChannelsAreUnequal () const |
void | setNumChannels (size_t numChannels) |
void | setChannelMode (ChannelMode mode) |
const std::pair< size_t, size_t > & | getProcessFramesRange () const |
void | initializeImpl () |
void | uninitializeImpl () |
BufferDynamic * | getSummingBuffer () |
const BufferDynamic * | getSummingBuffer () const |
Friends | |
class | Context |
class | Param |
Fundamental building block for creating an audio processing graph.
Node's allow for flexible combinations of synthesis, analysis, effects, file reading/writing, etc, and are designed so that that it is easy for users to add their own custom subclasses to a processing graph.
A Node is owned by a Context, and as such must by created using its makeNode() method, or one of the specializations for platform specific Node's.
Audio Node's are designed to operate on two different threads: a 'user' thread (i.e. main / UI) and an audio thread. Specifically, methods for connecting and disconnecting are expected to come from the 'user' thread, while the Node's process() and internal pulling methods are called from a hard real-time thread. A mutex is used (Context::getMutex()) to synchronize connection changes and pulling the audio graph. Note that if the Node's initialize() method is heavy, it can be called before connected to anything, so as to not block the audio graph. This must be done throught the Context::initializeNode() interface.
Subclassing: implement process( Buffer *buffer ) to perform audio processing. A Node does not have access to its owning Context until initialize() is called, uninitialize() is called before a Node is deallocated or channel counts change.
|
strong |
Used to specifiy how the corresponding channels are to be resolved between two connected Node's, based on either a Node's input (the default), it's output, or specified by user.
Enumerator | |
---|---|
SPECIFIED |
Number of channels has been specified by user or is non-settable. |
MATCHES_INPUT |
This Node matches it's channels with it's input. |
MATCHES_OUTPUT |
This Node matches it's channels with it's output. |
cinder::audio::Node::Node | ( | const Format & | format | ) |
|
virtual |
void cinder::audio::Node::enable | ( | ) |
Enables this Node for processing. Same as setEnabled( true )
.
void cinder::audio::Node::enable | ( | double | when | ) |
Enables this Node for processing at when seconds, measured against Context::getNumProcessedSeconds(). Same as setEnabled( true, when )
.
void cinder::audio::Node::disable | ( | ) |
Disables this Node for processing. Same as setEnabled( false )
.
void cinder::audio::Node::disable | ( | double | when | ) |
Disables this Node for processing at when seconds, measured against Context::getNumProcessedSeconds(). Same as setEnabled( false, when )
.
void cinder::audio::Node::setEnabled | ( | bool | b | ) |
Sets whether this Node is enabled for processing or not.
void cinder::audio::Node::setEnabled | ( | bool | b, |
double | when | ||
) |
Sets whether this Node is enabled for processing or not at when seconds, measured against Context::getNumProcessedSeconds().
bool cinder::audio::Node::isEnabled | ( | ) | const |
Returns whether this Node is enabled for processing or not.
|
virtual |
Connects this Node to output.
Reimplemented in cinder::audio::NodeAutoPullable.
|
virtual |
Disconnects this Node from output.
|
virtual |
Disconnects this Node from all inputs and outputs.
|
virtual |
Disconnects this Node from all outputs.
Reimplemented in cinder::audio::NodeAutoPullable.
|
virtual |
Disconnects all of this Node's inputs.
Reimplemented in cinder::audio::ChannelRouterNode.
size_t cinder::audio::Node::getNumConnectedInputs | ( | ) | const |
Returns the number of inputs connected to this Node.
size_t cinder::audio::Node::getNumConnectedOutputs | ( | ) | const |
Returns the number of outputs this Node is connected to.
bool cinder::audio::Node::isConnectedToInput | ( | const NodeRef & | input | ) | const |
Returns true if input is connected to this Node as an input, false otherwise.
bool cinder::audio::Node::isConnectedToOutput | ( | const NodeRef & | output | ) | const |
Returns true if output is connected to this Node as an output, false otherwise.
ContextRef cinder::audio::Node::getContext | ( | ) | const |
size_t cinder::audio::Node::getNumChannels | ( | ) | const |
Returns the number of channels this Node will process.
ChannelMode cinder::audio::Node::getChannelMode | ( | ) | const |
Returns the channel mode.
size_t cinder::audio::Node::getMaxNumInputChannels | ( | ) | const |
Returns the maximum number of channels any input has.
size_t cinder::audio::Node::getSampleRate | ( | ) | const |
Returns the samplerate of this Node, which is governed by the Context's OutputNode.
size_t cinder::audio::Node::getFramesPerBlock | ( | ) | const |
Returns the number of frames processed in one block by this Node, which is governed by the Context's OutputNode.
bool cinder::audio::Node::isAutoEnabled | ( | ) | const |
Returns whether this Node is automatically enabled / disabled when connected.
void cinder::audio::Node::setAutoEnabled | ( | bool | b = true | ) |
Sets whether this Node is automatically enabled / disabled when connected.
bool cinder::audio::Node::isInitialized | ( | ) | const |
Returns whether this Node is in an initialized state and is capable of processing audio.
bool cinder::audio::Node::getProcessesInPlace | ( | ) | const |
bool cinder::audio::Node::canConnectToInput | ( | const NodeRef & | input | ) |
Returns true if there is an unmanageable cycle betweeen sourceNode and destNode. If any Node's in the traversal returns true for supportsCycles(), this method will return false.
const std::set<NodeRef>& cinder::audio::Node::getInputs | ( | ) | const |
Returns an immutable reference to the inputs container.
vector< NodeRef > cinder::audio::Node::getOutputs | ( | ) | const |
Returns a copy of the NodeRef's referenced by the this Node as outputs. The copy is necessary because outputs are stored internally with weak_ptr's.
|
virtual |
Returns a string representing the name of this Node type. Default returns a demangled, compiler-specific class name.
void cinder::audio::Node::setName | ( | const std::string & | name | ) |
Sets this Node's name to a user-specified string.
Buffer* cinder::audio::Node::getInternalBuffer | ( | ) |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage.
const Buffer* cinder::audio::Node::getInternalBuffer | ( | ) | const |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage.
void cinder::audio::Node::pullInputs | ( | Buffer * | inPlaceBuffer | ) |
|
protectedvirtual |
Called before audio buffers need to be used. There is always a valid Context at this point.
Reimplemented in cinder::audio::GenPulseNode, cinder::audio::GenOscNode, cinder::audio::FilePlayerNode, cinder::audio::MonitorSpectralNode, cinder::audio::GenTableNode, cinder::audio::cocoa::EffectAudioUnitNode, cinder::audio::cocoa::InputDeviceNodeAudioUnit, cinder::audio::BufferRecorderNode, cinder::audio::MonitorNode, cinder::audio::cocoa::OutputDeviceNodeAudioUnit, cinder::audio::FilterBiquadNode, cinder::audio::DelayNode, and cinder::audio::GenNode.
|
protectedvirtual |
Called once the contents of initialize are no longer relevant, i.e. connections have changed.
Reimplemented in cinder::audio::FilePlayerNode, cinder::audio::cocoa::EffectAudioUnitNode, cinder::audio::cocoa::InputDeviceNodeAudioUnit, cinder::audio::cocoa::OutputDeviceNodeAudioUnit, and cinder::audio::FilterBiquadNode.
|
protectedvirtual |
Callled when this Node should enable processing. Initiated from Node::enable().
Reimplemented in cinder::audio::FilePlayerNode, cinder::audio::BufferPlayerNode, cinder::audio::cocoa::InputDeviceNodeAudioUnit, and cinder::audio::cocoa::OutputDeviceNodeAudioUnit.
|
protectedvirtual |
Callled when this Node should disable processing. Initiated from Node::disable().
Reimplemented in cinder::audio::FilePlayerNode, cinder::audio::cocoa::InputDeviceNodeAudioUnit, and cinder::audio::cocoa::OutputDeviceNodeAudioUnit.
|
protectedvirtual |
Override to perform audio processing on buffer.
Reimplemented in cinder::audio::GenPulseNode, cinder::audio::FilePlayerNode, cinder::audio::GenOscNode, cinder::audio::GenTableNode, cinder::audio::BufferPlayerNode, cinder::audio::cocoa::EffectAudioUnitNode, cinder::audio::GenTriangleNode, cinder::audio::GenSineNode, cinder::audio::cocoa::InputDeviceNodeAudioUnit, cinder::audio::DivideNode, cinder::audio::CallbackProcessorNode, cinder::audio::BufferRecorderNode, cinder::audio::GenPhasorNode, cinder::audio::MonitorNode, cinder::audio::MultiplyNode, cinder::audio::GenNoiseNode, cinder::audio::SubtractNode, cinder::audio::FilterBiquadNode, cinder::audio::AddNode, cinder::audio::DelayNode, and cinder::audio::Pan2dNode.
|
protectedvirtual |
Reimplemented in cinder::audio::ChannelRouterNode.
|
protectedvirtual |
Default implementation returns true if numChannels matches our format.
Reimplemented in cinder::audio::ChannelRouterNode.
|
protectedvirtual |
Default implementation returns false, return true if it makes sense for the Node to be processed in a cycle (eg. Delay).
Reimplemented in cinder::audio::DelayNode.
|
protectedvirtual |
Default implementation returns true, subclasses should return false if they must process out-of-place (summing).
Reimplemented in cinder::audio::ChannelRouterNode, and cinder::audio::cocoa::OutputDeviceNodeAudioUnit.
|
protectedvirtual |
Reimplemented in cinder::audio::NodeAutoPullable.
|
protectedvirtual |
Reimplemented in cinder::audio::NodeAutoPullable, and cinder::audio::ChannelRouterNode.
|
protectedvirtual |
Reimplemented in cinder::audio::NodeAutoPullable.
|
protectedvirtual |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
|
protected |
Returns a pair of frame indices for Nodes that wish to support sample accurate enable and disable.
The first index is where processing should start, the second is where it should end. Should only be called on the audio thread from within a Node's process() method. Unless scheduled (with Context::schedule()), this will be [0, getFramesPerBlock()]
|
protected |
|
protected |
|
protected |
|
protected |
|
friend |
|
friend |