33 namespace cinder {
namespace audio {
44 class Context :
public std::enable_shared_from_this<Context> {
61 template<
typename NodeT>
62 std::shared_ptr<NodeT>
makeNode( NodeT *node );
69 std::mutex&
getMutex()
const {
return mMutex; }
120 void disconnectRecursive(
const NodeRef &node, std::set<NodeRef> &traversedNodes );
121 void initRecursisve(
const NodeRef &node, std::set<NodeRef> &traversedNodes );
122 void uninitRecursisve(
const NodeRef &node, std::set<NodeRef> &traversedNodes );
123 const std::vector<Node *>& getAutoPulledNodes();
124 void processAutoPulledNodes();
125 void incrementFrameCount();
127 static void registerClearStatics();
129 std::atomic<uint64_t> mNumProcessedFrames;
133 std::set<NodeRef> mAutoPulledNodes;
134 std::vector<Node *> mAutoPullCache;
135 bool mAutoPullRequired, mAutoPullCacheDirty;
138 mutable std::mutex mMutex;
142 static std::shared_ptr<Context> sMasterContext;
143 static std::unique_ptr<DeviceManager> sDeviceManager;
146 template<
typename NodeT>
149 std::shared_ptr<NodeT> result( node );
150 result->setContext( shared_from_this() );
static Context * master()
Returns the master Context that manages hardware I/O and real-time processing, which is platform spec...
Definition: Context.cpp:72
void setEnabled(bool enable=true)
start / stop audio processing via boolean
Definition: Context.cpp:154
virtual void disconnectAllNodes()
Disconnect all Node's related by this Context.
Definition: Context.cpp:180
void enable(GLenum state)
Enables the OpenGL State state. Equivalent to calling to glEnable( state );.
Definition: dx.h:198
void removeAutoPulledNode(const NodeRef &node)
Definition: Context.cpp:262
RAII-style utility class to set a Context's enabled state and have it restored at the end of the curr...
Definition: Context.h:159
GLsizei const GLchar ** string
Definition: GLee.h:2427
Context * master()
Returns the master Context that manages hardware I/O and real-time processing, which is platform spec...
Definition: Context.h:155
double getNumProcessedSeconds()
Returns the total number of seconds that have been processed in the dsp loop.
Definition: Context.h:91
Manages the creation, connections, and lifecycle of audio::Node's.
Definition: Context.h:44
std::mutex & getMutex() const
Returns the mutex used to synchronize the audio thread. This is also used internally by the Node clas...
Definition: Context.h:69
Context()
Definition: Context.cpp:118
ScopedEnableContext(Context *context)
Constructs an object that will store context's enabled state and restore it at the end of the current...
Definition: Context.cpp:360
void postProcess()
OutputNode implmenentations should call this at the end of each rendering block.
Definition: Context.cpp:272
std::shared_ptr< NodeT > makeNode(NodeT *node)
Interface for creating new Node's of type NodeT, which are thereafter owned by this Context...
Definition: Context.h:147
std::shared_ptr< class OutputDeviceNode > OutputDeviceNodeRef
Definition: OutputNode.h:32
void uninitializeAllNodes()
Uninitialize all Node's related by this Context.
Definition: Context.cpp:171
virtual void connectionsDidChange(const NodeRef &node)
Called by node when it's connections have changed, default implementation is empty.
Definition: Context.h:81
static DeviceRef getDefaultOutput()
Returns a reference to the default output Device on your system.
Definition: Device.cpp:48
~ScopedEnableContext()
Definition: Context.cpp:377
Platform-specific Singleton for managing hardware devices. Applications normally should not need to u...
Definition: Device.h:110
virtual OutputDeviceNodeRef createOutputDeviceNode(const DeviceRef &device=Device::getDefaultOutput(), const Node::Format &format=Node::Format())=0
Creates and returns a platform-specific OutputDeviceNode, which delivers audio to the hardware output...
size_t getFramesPerBlock()
Returns the number of frames processed in one block by this Node, which is governed by the current Ou...
Definition: Context.h:86
uint64_t getNumProcessedFrames() const
Returns the total number of frames that have been processed in the dsp loop.
Definition: Context.h:89
std::shared_ptr< class Device > DeviceRef
Definition: Device.h:36
bool isEnabled() const
Returns whether or not this Context is current enabled and processing audio.
Definition: Context.h:78
virtual InputDeviceNodeRef createInputDeviceNode(const DeviceRef &device=Device::getDefaultInput(), const Node::Format &format=Node::Format())=0
Creates and returns a platform-specific InputDeviceNode, which captures audio from the hardware input...
void addAutoPulledNode(const NodeRef &node)
Definition: Context.cpp:250
static DeviceRef getDefaultInput()
Returns a reference to the default input Device on your system.
Definition: Device.cpp:53
virtual const OutputNodeRef & getOutput()
Returns the OutputNode for the Context (currently always an OutputDeviceNode that sends audio to your...
Definition: Context.cpp:194
GLXContext context
Definition: GLee.h:16985
std::shared_ptr< class InputDeviceNode > InputDeviceNodeRef
Definition: InputNode.h:33
GLenum GLsizei GLenum format
Definition: GLee.h:969
virtual void enable()
Enables audio processing. Effectively the same as calling getOutput()->enable()
Definition: Context.cpp:130
std::shared_ptr< class Node > NodeRef
Definition: Node.h:39
void uninitializeNode(const NodeRef &node)
Un-initializes node, ensuring that Node::uninitialze() gets called.
Definition: Context.cpp:206
virtual ~Context()
Definition: Context.cpp:123
void initializeNode(const NodeRef &node)
Initializes node, ensuring that Node::initialze() gets called and that its internal buffers are ready...
Definition: Context.cpp:201
std::string printGraphToString()
Returns a string representation of the Node graph for debugging purposes.
Definition: Context.cpp:340
std::shared_ptr< class OutputNode > OutputNodeRef
Definition: OutputNode.h:31
void initializeAllNodes()
Initialize all Node's related by this Context.
Definition: Context.cpp:162
static void setMaster(Context *masterContext, DeviceManager *deviceManager)
Allows the user to set the master Context and DeviceManager, overriding the defaults.
Definition: Context.cpp:112
virtual void setOutput(const OutputNodeRef &output)
Sets the new output of this Context to output. You should do this before making any connections becau...
Definition: Context.cpp:189
size_t getSampleRate()
Returns the samplerate of this Context, which is governed by the current OutputNode.
Definition: Context.h:84
virtual void disable()
Enables audio processing. Effectively the same as calling getOutput()->disable()
Definition: Context.cpp:145
static DeviceManager * deviceManager()
Returns the platform-specific DeviceManager singleton instance, which is platform specific...
Definition: Context.cpp:91