Records its inputs to a Buffer. The Buffer record size should be specified by the user (the default size is 44100 frames). Also supports writing the recorded samples to file. More...
#include <SampleRecorderNode.h>
Public Types | |
enum | ChannelMode { ChannelMode::SPECIFIED, ChannelMode::MATCHES_INPUT, ChannelMode::MATCHES_OUTPUT } |
Public Member Functions | |
BufferRecorderNode (const Format &format=Format()) | |
BufferRecorderNode (size_t numFrames, const Format &format=Format()) | |
Constructs a BufferRecordNode and initializes its buffer to be large enough to hold numFrames frames. More... | |
void | start () |
Starts recording. Resets the write position to zero (call disable() to pause recording). More... | |
void | stop () |
Stops recording. Same as calling disable(). More... | |
void | setNumFrames (size_t numFrames, bool shrinkToFit=false) |
Sets the length of the recording buffer in frames. More... | |
void | setNumSeconds (double numSeconds, bool shrinkToFit=false) |
Sets the length of the recording buffer in seconds. More... | |
size_t | getNumFrames () const |
Returns the length of the recording buffer in frames. More... | |
double | getNumSeconds () const |
Returns the length of the recording buffer in seconds. More... | |
BufferRef | getRecordedCopy () const |
Returns a copy of the recored samples, up to the current write position. More... | |
void | writeToFile (const ci::fs::path &filePath, SampleType sampleType=SampleType::INT_16) |
Writes the currently recorded samples to a file at filePath. More... | |
uint64_t | getLastOverrun () |
Returns the frame of the last buffer overrun or 0 if none since the last time this method was called. When this happens, it means the recorded buffer probably has skipped some frames. More... | |
size_t | getWritePosition () const |
Returns the current write position, which represents how many samples are currently recorded. More... | |
virtual void | connect (const NodeRef &output) override |
Connects this Node to output. More... | |
virtual void | connectInput (const NodeRef &input) override |
virtual void | disconnectInput (const NodeRef &input) override |
virtual void | disconnectAllOutputs () override |
Overridden to also remove from Context's auto-pulled list. More... | |
void | enable () |
Enables this Node for processing. Same as setEnabled( true ) . More... | |
void | disable () |
Disables this Node for processing. Same as setEnabled( false ) . More... | |
void | setEnabled (bool b=true) |
Sets whether this Node is enabled for processing or not. More... | |
bool | isEnabled () const |
Returns whether this Node is enabled for processing or not. More... | |
virtual void | disconnect (const NodeRef &output) |
Disconnects this Node from output. More... | |
virtual void | disconnectAll () |
Disconnects this Node from all inputs and outputs. More... | |
virtual void | disconnectAllInputs () |
Disconnects all of this Node's inputs. More... | |
size_t | getNumConnectedInputs () const |
Returns the number of inputs connected to this Node. More... | |
size_t | getNumConnectedOutputs () const |
Returns the number of outputs this Node is connected to. More... | |
bool | isConnectedToInput (const NodeRef &input) const |
Returns true if input is connected to this Node as an input, false otherwise. More... | |
bool | isConnectedToOutput (const NodeRef &output) const |
Returns true if output is connected to this Node as an output, false otherwise. More... | |
ContextRef | getContext () const |
Returns the Context associated with this Node. More... | |
size_t | getNumChannels () const |
Returns the number of channels this Node will process. More... | |
ChannelMode | getChannelMode () const |
Returns the channel mode. More... | |
size_t | getMaxNumInputChannels () const |
Returns the maximum number of channels any input has. More... | |
size_t | getSampleRate () const |
Returns the samplerate of this Node, which is governed by the Context's OutputNode. More... | |
size_t | getFramesPerBlock () const |
Returns the number of frames processed in one block by this Node, which is governed by the Context's OutputNode. More... | |
bool | isAutoEnabled () const |
Returns whether this Node is automatically enabled / disabled when connected. More... | |
void | setAutoEnabled (bool b=true) |
Sets whether this Node is automatically enabled / disabled when connected. More... | |
bool | isInitialized () const |
Returns whether this Node is in an initialized state and is capable of processing audio. More... | |
bool | getProcessesInPlace () const |
Returns whether this Node will process audio with an in-place Buffer. More... | |
bool | canConnectToInput (const NodeRef &input) |
Returns whether it is possible to connect to input, example reasons of failure would be this == Node, or Node is already an input. More... | |
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 traversal returns true for supportsCycles(), this method will return false. More... | |
const std::set< NodeRef > & | getInputs () const |
Returns an immutable reference to the inputs container. More... | |
std::vector< NodeRef > | 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. More... | |
virtual std::string | getName () |
Returns a string representing the name of this Node type. Default returns a demangled, compiler-specific class name. More... | |
void | setName (const std::string &name) |
Sets this Node's name to a user-specified string. More... | |
Buffer * | getInternalBuffer () |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage. More... | |
const Buffer * | getInternalBuffer () const |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage. More... | |
void | pullInputs (Buffer *inPlaceBuffer) |
Usually called internally by the Node, in special cases sub-classes may need to call this on other Node's. More... | |
Protected Member Functions | |
virtual void | initialize () override |
Called before audio buffers need to be used. There is always a valid Context at this point. More... | |
virtual void | process (Buffer *buffer) override |
Override to perform audio processing on buffer. More... | |
void | initBuffers (size_t numFrames) |
void | updatePullMethod () |
virtual void | uninitialize () |
Called once the contents of initialize are no longer relevant, i.e. connections have changed. More... | |
virtual void | enableProcessing () |
Callled when this Node should enable processing. Initiated from Node::enable(). More... | |
virtual void | disableProcessing () |
Callled when this Node should disable processing. Initiated from Node::disable(). More... | |
virtual void | sumInputs () |
virtual bool | supportsInputNumChannels (size_t numChannels) const |
Default implementation returns true if numChannels matches our format. More... | |
virtual bool | supportsCycles () const |
Default implementation returns false, return true if it makes sense for the Node to be processed in a cycle (eg. Delay). More... | |
virtual bool | supportsProcessInPlace () const |
Default implementation returns true, subclasses should return false if they must process out-of-place (summing). More... | |
virtual void | disconnectOutput (const NodeRef &output) |
virtual void | configureConnections () |
void | setupProcessWithSumming () |
void | notifyConnectionsDidChange () |
bool | inputChannelsAreUnequal () const |
void | setNumChannels (size_t numChannels) |
Only Node subclasses can specify num channels directly - users specify via Format at construction time. More... | |
void | setChannelMode (ChannelMode mode) |
Only Node subclasses can specify channel mode directly - users specify via Format at construction time. More... | |
void | initializeImpl () |
void | uninitializeImpl () |
BufferDynamic * | getSummingBuffer () |
const BufferDynamic * | getSummingBuffer () const |
Protected Attributes | |
BufferDynamic | mRecorderBuffer |
BufferDynamicRef | mCopiedBuffer |
std::atomic< uint64_t > | mLastOverrun |
std::atomic< size_t > | mWritePos |
bool | mIsPulledByContext |
Records its inputs to a Buffer. The Buffer record size should be specified by the user (the default size is 44100 frames). Also supports writing the recorded samples to file.
|
stronginherited |
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::BufferRecorderNode::BufferRecorderNode | ( | size_t | numFrames, |
const Format & | format = Format() |
||
) |
Constructs a BufferRecordNode and initializes its buffer to be large enough to hold numFrames frames.
void cinder::audio::BufferRecorderNode::start | ( | ) |
Starts recording. Resets the write position to zero (call disable() to pause recording).
void cinder::audio::BufferRecorderNode::setNumFrames | ( | size_t | numFrames, |
bool | shrinkToFit = false |
||
) |
Sets the length of the recording buffer in frames.
If the write position is non-zero, the old contents will be preserved (by copying it to the newly allocated Buffer). If shrinkToFit is set to true
, the internal Buffer will be down-sized if necessary, otherwise it will only re-allocate when growing while changing its dimensions to match numFrames (default shrinkToFit = false).
void cinder::audio::BufferRecorderNode::setNumSeconds | ( | double | numSeconds, |
bool | shrinkToFit = false |
||
) |
Sets the length of the recording buffer in seconds.
size_t cinder::audio::BufferRecorderNode::getNumFrames | ( | ) | const |
Returns the length of the recording buffer in frames.
double cinder::audio::BufferRecorderNode::getNumSeconds | ( | ) | const |
Returns the length of the recording buffer in seconds.
BufferRef cinder::audio::BufferRecorderNode::getRecordedCopy | ( | ) | const |
Returns a copy of the recored samples, up to the current write position.
This method is non locking, and as such any resizing calls must be performed on the same thread or be otherwise synchronized.
void cinder::audio::BufferRecorderNode::writeToFile | ( | const ci::fs::path & | filePath, |
SampleType | sampleType = SampleType::INT_16 |
||
) |
Writes the currently recorded samples to a file at filePath.
The encoding format is derived from filePath's extension and sampleType (default = SampleType::INT_16).
uint64_t cinder::audio::BufferRecorderNode::getLastOverrun | ( | ) |
Returns the frame of the last buffer overrun or 0 if none since the last time this method was called. When this happens, it means the recorded buffer probably has skipped some frames.
|
overrideprotectedvirtual |
Called before audio buffers need to be used. There is always a valid Context at this point.
Reimplemented from cinder::audio::Node.
Override to perform audio processing on buffer.
Reimplemented from cinder::audio::Node.
|
protected |
|
inherited |
Returns the current write position, which represents how many samples are currently recorded.
Connects this Node to output.
Reimplemented from cinder::audio::Node.
|
overridevirtualinherited |
Reimplemented from cinder::audio::Node.
|
overridevirtualinherited |
Reimplemented from cinder::audio::Node.
|
overridevirtualinherited |
Overridden to also remove from Context's auto-pulled list.
Reimplemented from cinder::audio::Node.
|
protectedinherited |
|
inherited |
Enables this Node for processing. Same as setEnabled( true )
.
|
inherited |
Disables this Node for processing. Same as setEnabled( false )
.
|
inherited |
Sets whether this Node is enabled for processing or not.
|
inherited |
Returns whether this Node is enabled for processing or not.
Disconnects this Node from output.
|
virtualinherited |
Disconnects this Node from all inputs and outputs.
|
virtualinherited |
Disconnects all of this Node's inputs.
Reimplemented in cinder::audio::ChannelRouterNode.
|
inherited |
Returns the number of inputs connected to this Node.
|
inherited |
Returns the number of outputs this Node is connected to.
|
inherited |
Returns true if input is connected to this Node as an input, false otherwise.
|
inherited |
Returns true if output is connected to this Node as an output, false otherwise.
|
inherited |
|
inherited |
Returns the number of channels this Node will process.
|
inherited |
Returns the channel mode.
|
inherited |
Returns the maximum number of channels any input has.
|
inherited |
Returns the samplerate of this Node, which is governed by the Context's OutputNode.
|
inherited |
Returns the number of frames processed in one block by this Node, which is governed by the Context's OutputNode.
|
inherited |
Returns whether this Node is automatically enabled / disabled when connected.
|
inherited |
Sets whether this Node is automatically enabled / disabled when connected.
|
inherited |
Returns whether this Node is in an initialized state and is capable of processing audio.
|
inherited |
|
inherited |
|
inherited |
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.
|
inherited |
Returns an immutable reference to the inputs container.
|
inherited |
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.
|
virtualinherited |
Returns a string representing the name of this Node type. Default returns a demangled, compiler-specific class name.
|
inherited |
Sets this Node's name to a user-specified string.
|
inherited |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage.
|
inherited |
Usually used internally by a Node subclass, returns a pointer to the internal buffer storage.
|
protectedvirtualinherited |
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.
|
protectedvirtualinherited |
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.
|
protectedvirtualinherited |
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.
|
protectedvirtualinherited |
Reimplemented in cinder::audio::ChannelRouterNode.
|
protectedvirtualinherited |
Default implementation returns true if numChannels matches our format.
Reimplemented in cinder::audio::ChannelRouterNode.
|
protectedvirtualinherited |
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.
|
protectedvirtualinherited |
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.
|
protectedvirtualinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protectedinherited |
|
protected |
|
protected |
|
protected |
|
protectedinherited |
|
protectedinherited |