Switchboard SDK
Loading...
Searching...
No Matches
switchboard::RecorderNode Class Reference

Records the incoming audio data to a file. More...

#include <RecorderNode.hpp>

Inheritance diagram for switchboard::RecorderNode:
switchboard::SingleBusAudioSinkNode switchboard::AudioSinkNode switchboard::AudioNode

Public Member Functions

 RecorderNode (const uint recordingSampleRate=constants::SAMPLE_RATE_UNDEFINED, const uint numberOfRecordedChannels=constants::STEREO)
 Creates a RecorderNode instance.
 
 ~RecorderNode ()
 RecorderNode destructor.
 
void start ()
 Start recording the incoming audio.
 
bool stop (const std::string &recordingFilePath, Codec format)
 Stop recording the incoming audio and write it to file.
 
bool getIsRecording () const
 Check whether the RecorderNode is recording.
 
void setIsRealtime (const bool isRealtime)
 Set whether the RecorderNode should run in realtime mode.
 
bool getIsRealtime () const
 Check whether the RecorderNode is running in realtime mode.
 
bool setBusFormat (AudioBusFormat &busFormat) override
 Sets bus format.
 
bool consume (AudioBus &bus) override
 Consumes audio data from the given bus.
 
- Public Member Functions inherited from switchboard::SingleBusAudioSinkNode
bool setNumberOfBuses (const uint numberOfBuses) override
 Sets number of buses.
 
bool setBusFormats (AudioBusFormatList &busFormats) override
 Sets bus formats.
 
bool consume (AudioBusList &buses) override
 Consumes audio data from the given buses.
 
- Public Member Functions inherited from switchboard::AudioSinkNode
- Public Member Functions inherited from switchboard::AudioNode
 AudioNode ()
 AudioNode constructor.
 
virtual ~AudioNode ()=default
 AudioNode virtual destructor.
 
const std::string & getType () const
 Gets the type of the audio node.
 
virtual const std::string getDisplayName () const
 Gets the display name of the audio node.
 
virtual std::vector< std::unique_ptr< Parameter > > & getParameters ()
 Gets the parameters of the audio node.
 
virtual ParametergetParameter (const std::string &id)
 Gets the parameter with the given name.
 

Additional Inherited Members

- Public Attributes inherited from switchboard::AudioNode
std::string name
 The name of the audio node.
 
- Protected Member Functions inherited from switchboard::AudioNode
void initParameters (std::map< std::string, std::any > config)
 Initializes the node parameters from the given configuration values.
 
- Protected Attributes inherited from switchboard::AudioNode
std::string type
 
std::vector< std::unique_ptr< Parameter > > parameters
 

Detailed Description

Records the incoming audio data to a file.

RecorderNode class

Constructor & Destructor Documentation

◆ RecorderNode()

switchboard::RecorderNode::RecorderNode ( const uint recordingSampleRate = constants::SAMPLE_RATE_UNDEFINED,
const uint numberOfRecordedChannels = constants::STEREO )

Creates a RecorderNode instance.

Parameters
recordingSampleRateThe sample rate which the output file will be saved with. SAMPLE_RATE_UNDEFINED (0) means, sample rate will be set to the first received bus sample rate in setBusFormat.
numberOfRecordedChannelsNumber of channels to record. Must match the number of channels of the incoming audio buffer.

Member Function Documentation

◆ consume()

bool switchboard::RecorderNode::consume ( AudioBus & bus)
overridevirtual

Consumes audio data from the given bus.

Should be overridden by subclasses.

Parameters
busThe bus that contain the audio data.
Returns
True if audio was consumed successfully, false otherwise.

Implements switchboard::SingleBusAudioSinkNode.

◆ getIsRealtime()

bool switchboard::RecorderNode::getIsRealtime ( ) const

Check whether the RecorderNode is running in realtime mode.

Returns
True if the RecorderNode is running in realtime mode.

◆ getIsRecording()

bool switchboard::RecorderNode::getIsRecording ( ) const

Check whether the RecorderNode is recording.

Returns
True if the RecorderNode is recording.

◆ setBusFormat()

bool switchboard::RecorderNode::setBusFormat ( AudioBusFormat & busFormat)
overridevirtual

Sets bus format.

Should be overridden by subclasses.

Parameters
busFormatThe bus format to set.
Returns
True if the bus format was set successfully, false otherwise.

Implements switchboard::SingleBusAudioSinkNode.

◆ setIsRealtime()

void switchboard::RecorderNode::setIsRealtime ( const bool isRealtime)

Set whether the RecorderNode should run in realtime mode.

Parameters
isRealtimeTrue if the RecorderNode should run in realtime mode.

◆ stop()

bool switchboard::RecorderNode::stop ( const std::string & recordingFilePath,
Codec format )

Stop recording the incoming audio and write it to file.

Parameters
recordingFilePathFinal recording file path.
formatFinal recording file format.