29 #include <boost/noncopyable.hpp>
30 #include <boost/logic/tribool.hpp>
36 namespace cinder {
namespace audio {
39 typedef std::shared_ptr<class Node>
NodeRef;
59 class Node :
public std::enable_shared_from_this<Node>,
public boost::noncopyable {
73 Format() : mChannels( 0 ), mChannelMode(
ChannelMode::MATCHES_INPUT ), mAutoEnable( boost::logic::indeterminate ) {}
93 boost::tribool mAutoEnable;
153 const std::set<NodeRef>&
getInputs()
const {
return mInputs; }
216 std::weak_ptr<Context> mContext;
217 std::atomic<bool> mEnabled;
220 bool mProcessInPlace;
223 uint64_t mLastProcessedFrame;
227 std::set<std::shared_ptr<Node> > mInputs;
228 std::vector<std::weak_ptr<Node> > mOutputs;
237 input->connect( output );
size_t getFramesPerBlock() const
Returns the number of frames processed in one block by this Node, which is governed by the Context's ...
Definition: Node.cpp:281
size_t getSampleRate() const
Returns the samplerate of this Node, which is governed by the Context's OutputNode.
Definition: Node.cpp:276
void setNumChannels(size_t numChannels)
Only Node subclasses can specify num channels directly - users specify via Format at construction tim...
Definition: Node.cpp:248
NodeAutoPullable(const Format &format)
Definition: Node.cpp:475
void setAutoEnabled(bool b=true)
Sets whether this Node is automatically enabled / disabled when connected.
Definition: Node.h:142
GLenum mode
Definition: GLee.h:3042
virtual void uninitialize()
Called once the contents of initialize are no longer relevant, i.e. connections have changed...
Definition: Node.h:174
This Node matches it's channels with it's input.
virtual void disconnect(const NodeRef &output)
Disconnects this Node from output.
Definition: Node.cpp:79
GLenum GLenum GLenum input
Definition: GLee.h:8931
ChannelMode
Definition: Node.h:63
virtual std::string getName()
Returns a string representing the name of this Node type. Default returns a demangled, compiler-specific class name.
Definition: Node.cpp:466
void pullInputs(Buffer *inPlaceBuffer)
Usually called internally by the Node, in special cases sub-classes may need to call this on other No...
Definition: Node.cpp:369
Number of channels has been specified by user or is non-settable.
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: dx.h:198
std::vector< NodeRef > getOutputs() const
Returns a copy of the NodeRef's referenced by the this Node as outputs. The copy is necessary because...
Definition: Node.cpp:153
~ScopedEnableNode()
Definition: Node.cpp:546
size_t getMaxNumInputChannels() const
Returns the maximum number of channels any input has.
Definition: Node.cpp:267
GLsizei const GLchar ** string
Definition: GLee.h:2427
void notifyConnectionsDidChange()
Definition: Node.cpp:450
virtual bool supportsProcessInPlace() const
Default implementation returns true, subclasses should return false if they must process out-of-place...
Definition: Node.h:189
bool isAutoEnabled() const
Returns whether this Node is automatically enabled / disabled when connected.
Definition: Node.h:140
virtual void connect(const NodeRef &output) override
Connects this Node to output.
Definition: Node.cpp:484
ScopedEnableNode(const NodeRef &node)
Constructs an object that will store node's enabled state and restore it at the end of the current sc...
Definition: Node.cpp:529
virtual void connectInput(const NodeRef &input) override
Definition: Node.cpp:490
size_t getNumConnectedOutputs() const
Returns the number of outputs this Node is connected to.
Definition: Node.cpp:199
General Audio exception.
Definition: Exception.h:34
void updatePullMethod()
Definition: Node.cpp:512
virtual void process(Buffer *buffer)
Override to perform audio processing on buffer.
Definition: Node.h:180
Manages the creation, connections, and lifecycle of audio::Node's.
Definition: Context.h:44
BufferDynamic * getSummingBuffer()
Definition: Node.h:209
virtual void disconnectAllInputs()
Disconnects all of this Node's inputs.
Definition: Node.cpp:110
ChannelMode getChannelMode() const
Returns the channel mode.
Definition: Node.h:132
const ChannelRouterNodeRef & operator>>(const NodeRef &input, const ChannelRouterNode::RouteConnector &route)
Enable routing connection syntax:
Definition: ChannelRouterNode.cpp:55
BufferDynamicT< Buffer > BufferDynamic
Definition: Buffer.h:289
bool isConnectedToOutput(const NodeRef &output) const
Returns true if output is connected to this Node as an output, false otherwise.
Definition: Node.cpp:209
bool inputChannelsAreUnequal() const
Definition: Node.cpp:286
bool isInitialized() const
Returns whether this Node is in an initialized state and is capable of processing audio...
Definition: Node.h:144
virtual ~NodeAutoPullable()
Definition: Node.cpp:480
virtual void connectInput(const NodeRef &input)
Definition: Node.cpp:121
bool mIsPulledByContext
Definition: Node.h:256
virtual void enableProcessing()
Callled when this Node should enable processing. Initiated from Node::enable().
Definition: Node.h:176
virtual void disconnectAllOutputs()
Disconnects this Node from all outputs.
Definition: Node.cpp:101
void initializeImpl()
Definition: Node.cpp:220
virtual bool supportsCycles() const
Default implementation returns false, return true if it makes sense for the Node to be processed in a...
Definition: Node.h:187
bool isEnabled() const
Returns whether this Node is enabled for processing or not.
Definition: Node.h:106
void setEnabled(bool b=true)
Sets whether this Node is enabled for processing or not.
Definition: Node.cpp:186
virtual bool supportsInputNumChannels(size_t numChannels) const
Default implementation returns true if numChannels matches our format.
Definition: Node.h:185
RAII-style utility class to set a Node's enabled state and have it restored at the end of the current...
Definition: Node.h:260
virtual void disconnectInput(const NodeRef &input)
Definition: Node.cpp:129
std::shared_ptr< class Context > ContextRef
Definition: Node.h:38
bool getProcessesInPlace() const
Returns whether this Node will process audio with an in-place Buffer.
Definition: Node.h:146
virtual void disconnectOutput(const NodeRef &output)
Definition: Node.cpp:141
void uninitializeImpl()
Definition: Node.cpp:236
virtual void connect(const NodeRef &output)
Connects this Node to output.
Definition: Node.cpp:61
GLuint buffer
Definition: GLee.h:2065
bool canConnectToInput(const NodeRef &input)
Returns whether it is possible to connect to input, example reasons of failure would be this == Node...
Definition: Node.cpp:455
virtual void configureConnections()
Definition: Node.cpp:302
const BufferDynamic * getSummingBuffer() const
Definition: Node.h:210
ContextRef getContext() const
Returns the Context associated with this Node.
Definition: Node.h:128
a Node that can be pulled without being connected to any outputs.
Definition: Node.h:242
const std::set< NodeRef > & getInputs() const
Returns an immutable reference to the inputs container.
Definition: Node.h:153
GLboolean GLboolean GLboolean b
Definition: GLee.h:2964
virtual void disconnectAll()
Disconnects this Node from all inputs and outputs.
Definition: Node.cpp:95
Fundamental building block for creating an audio processing graph.
Definition: Node.h:59
bool checkCycle(const NodeRef &sourceNode, const NodeRef &destNode) const
Returns true if there is an unmanageable cycle betweeen sourceNode and destNode. If any Node's in the...
Definition: Node.cpp:434
virtual void initialize()
Called before audio buffers need to be used. There is always a valid Context at this point...
Definition: Node.h:172
GLuint const GLchar * name
Definition: GLee.h:2259
NodeCycleExc(const NodeRef &sourceNode, const NodeRef &destNode)
Definition: Node.cpp:556
void setupProcessWithSumming()
Definition: Node.cpp:423
virtual void disconnectInput(const NodeRef &input) override
Definition: Node.cpp:496
Buffer * getInternalBuffer()
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage...
Definition: Node.h:163
void enable()
Enables this Node for processing. Same as setEnabled( true ).
Definition: Node.cpp:165
GLXContext context
Definition: GLee.h:16985
GLenum GLsizei GLenum format
Definition: GLee.h:969
const Buffer * getInternalBuffer() const
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage...
Definition: Node.h:165
virtual void sumInputs()
Definition: Node.cpp:405
void setName(const std::string &name)
Sets this Node's name to a user-specified string.
Definition: Node.h:160
std::shared_ptr< class Node > NodeRef
Definition: Node.h:39
void disable()
Disables this Node for processing. Same as setEnabled( false ).
Definition: Node.cpp:177
void setChannelMode(ChannelMode mode)
Only Node subclasses can specify channel mode directly - users specify via Format at construction tim...
Definition: Node.cpp:257
size_t getNumConnectedInputs() const
Returns the number of inputs connected to this Node.
Definition: Node.cpp:194
Allows an audio parameter to be controlled over time with sample accuracate curves.
Definition: Param.h:81
size_t getNumChannels() const
Returns the number of channels this Node will process.
Definition: Node.h:130
Node(const Format &format)
Definition: Node.cpp:44
virtual ~Node()
Definition: Node.cpp:57
bool isConnectedToInput(const NodeRef &input) const
Returns true if input is connected to this Node as an input, false otherwise.
Definition: Node.cpp:204
This Node matches it's channels with it's output.
virtual void disconnectAllOutputs() override
Overridden to also remove from Context's auto-pulled list.
Definition: Node.cpp:502
virtual void disableProcessing()
Callled when this Node should disable processing. Initiated from Node::disable(). ...
Definition: Node.h:178