YARP
Yet Another Robot Platform
yarp::dev::AudioPlayerDeviceBase Class Referenceabstract

AudioPlayerDeviceBase : a base class for all audio player devices More...

#include <yarp/dev/AudioPlayerDeviceBase.h>

+ Inheritance diagram for yarp::dev::AudioPlayerDeviceBase:

Public Member Functions

virtual bool renderSound (const yarp::sig::Sound &sound) override
 Render a sound using a device (i.e. More...
 
virtual bool startPlayback () override
 Start the playback. More...
 
virtual bool stopPlayback () override
 Stop the playback. More...
 
virtual bool isPlaying (bool &playback_enabled) override
 Check if the playback has been enabled (e.g. More...
 
virtual bool getPlaybackAudioBufferMaxSize (yarp::dev::AudioBufferSize &size) override
 
virtual bool getPlaybackAudioBufferCurrentSize (yarp::dev::AudioBufferSize &size) override
 
virtual bool resetPlaybackAudioBuffer () override
 
virtual bool setSWGain (double gain) override
 Sets a software gain for the played audio. More...
 
virtual ~AudioPlayerDeviceBase ()
 
- Public Member Functions inherited from yarp::dev::IAudioRender
virtual ~IAudioRender ()
 Destructor. More...
 
virtual bool setHWGain (double gain)=0
 Sets the hardware gain of the playback device (if supported by the hardware) More...
 

Protected Types

enum  {
  RENDER_APPEND = 0 ,
  RENDER_IMMEDIATE = 1
}
 

Protected Member Functions

virtual bool configureDeviceAndStart ()=0
 
virtual bool interruptDeviceAndClose ()=0
 
virtual void waitUntilPlaybackStreamIsComplete ()
 
virtual bool immediateSound (const yarp::sig::Sound &sound)
 
virtual bool appendSound (const yarp::sig::Sound &sound)
 
bool configurePlayerAudioDevice (yarp::os::Searchable &config, std::string device_name)
 

Protected Attributes

bool m_enable_buffer_autoclear = false
 
bool m_playback_enabled = false
 
std::recursive_mutex m_mutex
 
yarp::dev::CircularAudioBuffer_16tm_outputBuffer = nullptr
 
AudioDeviceDriverSettings m_audioplayer_cfg
 
double m_sw_gain = 1.0
 
double m_hw_gain = 1.0
 
bool m_audiobase_debug = false
 
enum yarp::dev::AudioPlayerDeviceBase:: { ... }  m_renderMode = RENDER_APPEND
 

Detailed Description

AudioPlayerDeviceBase : a base class for all audio player 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 render_mode_append bool - true No A new sound is appended to the playback buffer and reproduced accordingly -
AUDIO_BASE render_mode_immediate bool - false No Every new sound is immediately reproduced, stopping the current playback -
AUDIO_BASE buffer_autoclear bool - false No Automatically clear the buffer every time the devices is started/stopped If false, stop acts like a pause, and start allows to resume the playback
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 50 of file AudioPlayerDeviceBase.h.

Member Enumeration Documentation

◆ anonymous enum

anonymous enum
protected
Enumerator
RENDER_APPEND 
RENDER_IMMEDIATE 

Definition at line 61 of file AudioPlayerDeviceBase.h.

Constructor & Destructor Documentation

◆ ~AudioPlayerDeviceBase()

AudioPlayerDeviceBase::~AudioPlayerDeviceBase ( )
virtual

Definition at line 55 of file AudioPlayerDeviceBase.cpp.

Member Function Documentation

◆ appendSound()

bool AudioPlayerDeviceBase::appendSound ( const yarp::sig::Sound sound)
protectedvirtual

Definition at line 109 of file AudioPlayerDeviceBase.cpp.

◆ configureDeviceAndStart()

virtual bool yarp::dev::AudioPlayerDeviceBase::configureDeviceAndStart ( )
protectedpure virtual

Implemented in fakeSpeaker, and audioToFileDevice.

◆ configurePlayerAudioDevice()

bool AudioPlayerDeviceBase::configurePlayerAudioDevice ( yarp::os::Searchable config,
std::string  device_name 
)
protected

Definition at line 206 of file AudioPlayerDeviceBase.cpp.

◆ getPlaybackAudioBufferCurrentSize()

bool AudioPlayerDeviceBase::getPlaybackAudioBufferCurrentSize ( yarp::dev::AudioBufferSize size)
overridevirtual

Implements yarp::dev::IAudioRender.

Definition at line 31 of file AudioPlayerDeviceBase.cpp.

◆ getPlaybackAudioBufferMaxSize()

bool AudioPlayerDeviceBase::getPlaybackAudioBufferMaxSize ( yarp::dev::AudioBufferSize size)
overridevirtual

Implements yarp::dev::IAudioRender.

Definition at line 43 of file AudioPlayerDeviceBase.cpp.

◆ immediateSound()

bool AudioPlayerDeviceBase::immediateSound ( const yarp::sig::Sound sound)
protectedvirtual

Definition at line 124 of file AudioPlayerDeviceBase.cpp.

◆ interruptDeviceAndClose()

virtual bool yarp::dev::AudioPlayerDeviceBase::interruptDeviceAndClose ( )
protectedpure virtual

◆ isPlaying()

bool AudioPlayerDeviceBase::isPlaying ( bool &  playback_enabled)
overridevirtual

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

via startPlayback()/stopPlayback())

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

Implements yarp::dev::IAudioRender.

Definition at line 91 of file AudioPlayerDeviceBase.cpp.

◆ renderSound()

bool AudioPlayerDeviceBase::renderSound ( const yarp::sig::Sound sound)
overridevirtual

Render a sound using a device (i.e.

send it to the speakers).

Parameters
soundthe sound to be rendered
Returns
true/false upon success/failure

Implements yarp::dev::IAudioRender.

Reimplemented in audioToFileDevice.

Definition at line 141 of file AudioPlayerDeviceBase.cpp.

◆ resetPlaybackAudioBuffer()

bool AudioPlayerDeviceBase::resetPlaybackAudioBuffer ( )
overridevirtual

Implements yarp::dev::IAudioRender.

Definition at line 97 of file AudioPlayerDeviceBase.cpp.

◆ setSWGain()

bool AudioPlayerDeviceBase::setSWGain ( double  gain)
overridevirtual

Sets a software gain for the played audio.

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

Implements yarp::dev::IAudioRender.

Definition at line 60 of file AudioPlayerDeviceBase.cpp.

◆ startPlayback()

bool AudioPlayerDeviceBase::startPlayback ( )
overridevirtual

Start the playback.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioRender.

Reimplemented in PortAudioPlayerDeviceDriver, and audioToFileDevice.

Definition at line 71 of file AudioPlayerDeviceBase.cpp.

◆ stopPlayback()

bool AudioPlayerDeviceBase::stopPlayback ( )
overridevirtual

Stop the playback.

Returns
true/false upon success/failure

Implements yarp::dev::IAudioRender.

Reimplemented in PortAudioPlayerDeviceDriver, and audioToFileDevice.

Definition at line 81 of file AudioPlayerDeviceBase.cpp.

◆ waitUntilPlaybackStreamIsComplete()

void AudioPlayerDeviceBase::waitUntilPlaybackStreamIsComplete ( )
protectedvirtual

Reimplemented in PortAudioPlayerDeviceDriver, and audioToFileDevice.

Definition at line 256 of file AudioPlayerDeviceBase.cpp.

Member Data Documentation

◆ m_audiobase_debug

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

Definition at line 60 of file AudioPlayerDeviceBase.h.

◆ m_audioplayer_cfg

AudioDeviceDriverSettings yarp::dev::AudioPlayerDeviceBase::m_audioplayer_cfg
protected

Definition at line 57 of file AudioPlayerDeviceBase.h.

◆ m_enable_buffer_autoclear

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

Definition at line 53 of file AudioPlayerDeviceBase.h.

◆ m_hw_gain

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

Definition at line 59 of file AudioPlayerDeviceBase.h.

◆ m_mutex

std::recursive_mutex yarp::dev::AudioPlayerDeviceBase::m_mutex
protected

Definition at line 55 of file AudioPlayerDeviceBase.h.

◆ m_outputBuffer

yarp::dev::CircularAudioBuffer_16t* yarp::dev::AudioPlayerDeviceBase::m_outputBuffer = nullptr
protected

Definition at line 56 of file AudioPlayerDeviceBase.h.

◆ m_playback_enabled

bool yarp::dev::AudioPlayerDeviceBase::m_playback_enabled = false
protected

Definition at line 54 of file AudioPlayerDeviceBase.h.

◆ 

enum { ... } yarp::dev::AudioPlayerDeviceBase::m_renderMode

◆ m_sw_gain

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

Definition at line 58 of file AudioPlayerDeviceBase.h.


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