YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
yarp::dev::AudioRecorderDeviceBase Class Reference

AudioRecorderDeviceBase : a base class for all audio recorder devices More...

#include <yarp/dev/AudioRecorderDeviceBase.h>

+ Inheritance diagram for yarp::dev::AudioRecorderDeviceBase:

Public Member Functions

virtual bool getSound (yarp::sig::Sound &sound, size_t min_number_of_samples, size_t max_number_of_samples, double max_samples_timeout_s) override
 Get a sound from a device.
 
virtual bool startRecording () override
 Start the recording.
 
virtual bool stopRecording () override
 Stop the recording.
 
virtual bool isRecording (bool &recording_enabled) override
 Check if the recording has been enabled (e.g.
 
virtual bool getRecordingAudioBufferMaxSize (yarp::sig::AudioBufferSize &size) override
 
virtual bool getRecordingAudioBufferCurrentSize (yarp::sig::AudioBufferSize &size) override
 
virtual bool resetRecordingAudioBuffer () override
 
virtual bool setSWGain (double gain) override
 Sets a software gain for the grabbed audio.
 
virtual ~AudioRecorderDeviceBase ()
 
- Public Member Functions inherited from yarp::dev::IAudioGrabberSound
virtual ~IAudioGrabberSound ()
 Destructor.
 
virtual bool setHWGain (double gain)=0
 Sets the hardware gain of the grabbing device (if supported by the hardware)
 

Protected Member Functions

bool configureRecorderAudioDevice (yarp::os::Searchable &config, std::string device_name)
 

Protected Attributes

bool m_enable_buffer_autoclear = false
 
bool m_recording_enabled = false
 
std::mutex m_mutex
 
yarp::dev::CircularAudioBuffer_16tm_inputBuffer = nullptr
 
double m_sw_gain = 1.0
 
double m_hw_gain = 1.0
 
AudioDeviceDriverSettings m_audiorecorder_cfg
 
bool m_audiobase_debug = false
 
int16_t m_cliptol = 3
 

Detailed Description

AudioRecorderDeviceBase : a base class for all audio recorder devices

Parameters required by this device are:

Parameter name SubParameter Type Units Default Value Required Description Notes
AUDIO_BASE rate int Hz 44100 No The frequency of the audio device -
AUDIO_BASE samples int samples 44100 No The size of the internal buffer (in samples) A default value identical to device frequency implies a buffer length of 1s
AUDIO_BASE channels int - 2 No The number of channels -
AUDIO_BASE bits int - 16 No Not yet implemented -
AUDIO_BASE hw_gain double - 1.0 No The device audio gain. Its implementation is device dependent (and it may also be not implemented) -
AUDIO_BASE sw_gain double - 1.0 No A SW gain for audio waveform amplification -
AUDIO_BASE buffer_autoclear bool - true No Automatically clear the buffer every time the devices is started/stopped -
AUDIO_BASE debug bool - false No Enable debug mode The value is stored into variable m_audiobase_debug

See Audio in YARP for additional documentation on YARP audio.

Definition at line 46 of file AudioRecorderDeviceBase.h.

Constructor & Destructor Documentation

◆ ~AudioRecorderDeviceBase()

AudioRecorderDeviceBase::~AudioRecorderDeviceBase ( )
virtual

Definition at line 207 of file AudioRecorderDeviceBase.cpp.

Member Function Documentation

◆ configureRecorderAudioDevice()

bool AudioRecorderDeviceBase::configureRecorderAudioDevice ( yarp::os::Searchable config,
std::string  device_name 
)
protected

Definition at line 216 of file AudioRecorderDeviceBase.cpp.

◆ getRecordingAudioBufferCurrentSize()

bool AudioRecorderDeviceBase::getRecordingAudioBufferCurrentSize ( yarp::sig::AudioBufferSize size)
overridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 139 of file AudioRecorderDeviceBase.cpp.

◆ getRecordingAudioBufferMaxSize()

bool AudioRecorderDeviceBase::getRecordingAudioBufferMaxSize ( yarp::sig::AudioBufferSize size)
overridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 126 of file AudioRecorderDeviceBase.cpp.

◆ getSound()

bool AudioRecorderDeviceBase::getSound ( yarp::sig::Sound sound,
size_t  min_number_of_samples,
size_t  max_number_of_samples,
double  max_samples_timeout_s 
)
overridevirtual

Get a sound from a device.

Examples: getSound(s, 0, 100, 0.1); returns a sound whose size can vary between 0 and 100, with a maximum blocking time of 0.1 getSound(s, 100, 100, 0.0); returns a sound with exact size of 100. It may block forever (more specifically, until sound size is at least 100). getSound(s, 100, 100000, 0.0); returns a sound with a minimum size of 0, while trying to transfer all the internal buffer. It may block forever (more specifically, until sound size is at least 100).

Parameters
soundthe sound to be filled
min_number_of_samples.The function will block until the driver is able to collect at least min_number_of_samples. If set to zero, the function may return empty sounds.
max_number_of_samples.The function will block until the driver is either able to collect max_number_of_samples or the timeout expires.
max_samples_timeout_s.The timeout (in seconds) to retrieve max_number_of_samples.
Returns
true upon success, false for an invalid set of parameters, such as max_number_of_samples<min_number_of_samples, etc.

Implements yarp::dev::IAudioGrabberSound.

Definition at line 29 of file AudioRecorderDeviceBase.cpp.

◆ isRecording()

bool AudioRecorderDeviceBase::isRecording ( bool recording_enabled)
overridevirtual

Check if the recording has been enabled (e.g.

via startRecording()/stopRecording())

Parameters
recording_enabledthe status of the device
Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 201 of file AudioRecorderDeviceBase.cpp.

◆ resetRecordingAudioBuffer()

bool AudioRecorderDeviceBase::resetRecordingAudioBuffer ( )
overridevirtual

Implements yarp::dev::IAudioGrabberSound.

Definition at line 162 of file AudioRecorderDeviceBase.cpp.

◆ setSWGain()

bool AudioRecorderDeviceBase::setSWGain ( double  gain)
overridevirtual

Sets a software gain for the grabbed audio.

Parameters
gainthe audio gain (1.0 is the default value)
Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Definition at line 151 of file AudioRecorderDeviceBase.cpp.

◆ startRecording()

bool AudioRecorderDeviceBase::startRecording ( )
overridevirtual

Start the recording.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Reimplemented in PortAudioRecorderDeviceDriver.

Definition at line 175 of file AudioRecorderDeviceBase.cpp.

◆ stopRecording()

bool AudioRecorderDeviceBase::stopRecording ( )
overridevirtual

Stop the recording.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioGrabberSound.

Reimplemented in AudioFromFileDevice, and PortAudioRecorderDeviceDriver.

Definition at line 187 of file AudioRecorderDeviceBase.cpp.

Member Data Documentation

◆ m_audiobase_debug

bool yarp::dev::AudioRecorderDeviceBase::m_audiobase_debug = false
protected

Definition at line 56 of file AudioRecorderDeviceBase.h.

◆ m_audiorecorder_cfg

AudioDeviceDriverSettings yarp::dev::AudioRecorderDeviceBase::m_audiorecorder_cfg
protected

Definition at line 55 of file AudioRecorderDeviceBase.h.

◆ m_cliptol

int16_t yarp::dev::AudioRecorderDeviceBase::m_cliptol = 3
protected

Definition at line 57 of file AudioRecorderDeviceBase.h.

◆ m_enable_buffer_autoclear

bool yarp::dev::AudioRecorderDeviceBase::m_enable_buffer_autoclear = false
protected

Definition at line 49 of file AudioRecorderDeviceBase.h.

◆ m_hw_gain

double yarp::dev::AudioRecorderDeviceBase::m_hw_gain = 1.0
protected

Definition at line 54 of file AudioRecorderDeviceBase.h.

◆ m_inputBuffer

yarp::dev::CircularAudioBuffer_16t* yarp::dev::AudioRecorderDeviceBase::m_inputBuffer = nullptr
protected

Definition at line 52 of file AudioRecorderDeviceBase.h.

◆ m_mutex

std::mutex yarp::dev::AudioRecorderDeviceBase::m_mutex
protected

Definition at line 51 of file AudioRecorderDeviceBase.h.

◆ m_recording_enabled

bool yarp::dev::AudioRecorderDeviceBase::m_recording_enabled = false
protected

Definition at line 50 of file AudioRecorderDeviceBase.h.

◆ m_sw_gain

double yarp::dev::AudioRecorderDeviceBase::m_sw_gain = 1.0
protected

Definition at line 53 of file AudioRecorderDeviceBase.h.


The documentation for this class was generated from the following files: