YARP
Yet Another Robot Platform
 
Loading...
Searching...
No Matches
AudioToFileDevice Class Reference

audioToFileDevice : This device driver, wrapped by default by AudioPlayerWrapper, is used to save to an audio stream to a file on disk. More...

#include <audioToFileDevice/AudioToFileDevice.h>

+ Inheritance diagram for AudioToFileDevice:

Public Member Functions

 AudioToFileDevice ()
 
 AudioToFileDevice (const AudioToFileDevice &)=delete
 
 AudioToFileDevice (AudioToFileDevice &&)=delete
 
AudioToFileDeviceoperator= (const AudioToFileDevice &)=delete
 
AudioToFileDeviceoperator= (AudioToFileDevice &&)=delete
 
 ~AudioToFileDevice () override
 
bool open (yarp::os::Searchable &config) override
 Open the DeviceDriver.
 
bool close () override
 Close the DeviceDriver.
 
virtual yarp::dev::ReturnValue renderSound (const yarp::sig::Sound &sound) override
 Render a sound using a device (i.e.
 
virtual yarp::dev::ReturnValue startPlayback () override
 Start the playback.
 
virtual yarp::dev::ReturnValue stopPlayback () override
 Stop the playback.
 
virtual yarp::dev::ReturnValue setHWGain (double gain) override
 Sets the hardware gain of the playback device (if supported by the hardware)
 
virtual bool configureDeviceAndStart () override
 
virtual bool interruptDeviceAndClose () override
 
virtual void waitUntilPlaybackStreamIsComplete () override
 
- Public Member Functions inherited from yarp::dev::DeviceDriver
 DeviceDriver ()
 
 DeviceDriver (const DeviceDriver &other)=delete
 
 DeviceDriver (DeviceDriver &&other) noexcept=delete
 
DeviceDriveroperator= (const DeviceDriver &other)=delete
 
DeviceDriveroperator= (DeviceDriver &&other) noexcept=delete
 
virtual ~DeviceDriver ()
 
virtual std::string id () const
 Return the id assigned to the PolyDriver.
 
virtual void setId (const std::string &id)
 Set the id for this device.
 
template<class T >
bool view (T *&x)
 Get an interface to the device driver.
 
virtual DeviceDrivergetImplementation ()
 Some drivers are bureaucrats, pointing at others.
 
- Public Member Functions inherited from yarp::dev::AudioPlayerDeviceBase
virtual yarp::dev::ReturnValue isPlaying (bool &playback_enabled) override
 Check if the playback has been enabled (e.g.
 
virtual yarp::dev::ReturnValue getPlaybackAudioBufferMaxSize (yarp::sig::AudioBufferSize &size) override
 
virtual yarp::dev::ReturnValue getPlaybackAudioBufferCurrentSize (yarp::sig::AudioBufferSize &size) override
 
virtual yarp::dev::ReturnValue resetPlaybackAudioBuffer () override
 
virtual yarp::dev::ReturnValue setSWGain (double gain) override
 Sets a software gain for the played audio.
 
virtual ~AudioPlayerDeviceBase ()
 
- Public Member Functions inherited from yarp::dev::IAudioRender
virtual ~IAudioRender ()
 Destructor.
 
- Public Member Functions inherited from AudioToFileDevice_ParamsParser
 AudioToFileDevice_ParamsParser ()
 
 ~AudioToFileDevice_ParamsParser () override=default
 
bool parseParams (const yarp::os::Searchable &config) override
 Parse the DeviceDriver parameters.
 
std::string getDeviceClassName () const override
 Get the name of the DeviceDriver class.
 
std::string getDeviceName () const override
 Get the name of the device (i.e.
 
std::string getDocumentationOfDeviceParams () const override
 Get the documentation of the DeviceDriver's parameters.
 
std::vector< std::string > getListOfParams () const override
 Return a list of all params used by the device.
 
- Public Member Functions inherited from yarp::dev::IDeviceDriverParams
virtual ~IDeviceDriverParams ()
 

Additional Inherited Members

- Public Attributes inherited from AudioToFileDevice_ParamsParser
const std::string m_device_classname = {"AudioToFileDevice"}
 
const std::string m_device_name = {"audioToFileDevice"}
 
bool m_parser_is_strict = false
 
const parser_version_type m_parser_version = {}
 
const std::string m_file_name_defaultValue = {"audio_out.wav"}
 
const std::string m_save_mode_defaultValue = {"overwrite_file"}
 
const std::string m_add_marker_defaultValue = {"false"}
 
std::string m_file_name = {"audio_out.wav"}
 
std::string m_save_mode = {"overwrite_file"}
 
bool m_add_marker = {false}
 
- Protected Types inherited from yarp::dev::AudioPlayerDeviceBase
enum  {
  RENDER_APPEND = 0 ,
  RENDER_IMMEDIATE = 1
}
 
- Protected Member Functions inherited from yarp::dev::AudioPlayerDeviceBase
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 inherited from yarp::dev::AudioPlayerDeviceBase
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

audioToFileDevice : This device driver, wrapped by default by AudioPlayerWrapper, is used to save to an audio stream to a file on disk.

This device driver derives from yarp::dev::AudioPlayerDeviceBase base class. Please check its documentation for additional configuration parameters.

Parameters required by this device are shown in class: AudioToFileDevice_ParamsParser and AudioRecorderDeviceBase

Three different operating modes are available, defined by the optional string parameter save_mode: if save_mode == "append_data", the file is written only when the module terminates. Every start/stop operation just pauses the module. On resume, the new data is concatenated at the end of the file.

if save_mode == "overwrite_file", the output file is written every time the stop() method is called or when the module terminates. If the file already exists, it will be overwritten with the new data.

if save_mode = "rename_file", the output file is written to a NEW file every time the stop() method is called or when the module terminates. The file name is modified, using an incremental counter appended at the end of the file name.

if save_mode = "break_file", the output file is written to a NEW file every time a yarp::sig::sound is received or when the module terminates. The file name is modified, using an incremental counter appended at the end of the file name.

See Audio in YARP for additional documentation on YARP audio.

Definition at line 45 of file AudioToFileDevice.h.

Constructor & Destructor Documentation

◆ AudioToFileDevice() [1/3]

AudioToFileDevice::AudioToFileDevice ( )

Definition at line 26 of file AudioToFileDevice.cpp.

◆ AudioToFileDevice() [2/3]

AudioToFileDevice::AudioToFileDevice ( const AudioToFileDevice )
delete

◆ AudioToFileDevice() [3/3]

AudioToFileDevice::AudioToFileDevice ( AudioToFileDevice &&  )
delete

◆ ~AudioToFileDevice()

AudioToFileDevice::~AudioToFileDevice ( )
override

Definition at line 30 of file AudioToFileDevice.cpp.

Member Function Documentation

◆ close()

bool AudioToFileDevice::close ( )
overridevirtual

Close the DeviceDriver.

Returns
true/false on success/failure.

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 124 of file AudioToFileDevice.cpp.

◆ configureDeviceAndStart()

bool AudioToFileDevice::configureDeviceAndStart ( )
overridevirtual

Implements yarp::dev::AudioPlayerDeviceBase.

Definition at line 181 of file AudioToFileDevice.cpp.

◆ interruptDeviceAndClose()

bool AudioToFileDevice::interruptDeviceAndClose ( )
overridevirtual

Implements yarp::dev::AudioPlayerDeviceBase.

Definition at line 187 of file AudioToFileDevice.cpp.

◆ open()

bool AudioToFileDevice::open ( yarp::os::Searchable config)
overridevirtual

Open the DeviceDriver.

Parameters
configis a list of parameters for the device. Which parameters are effective for your device can vary. See device invocation examples. If there is no example for your device, you can run the "yarpdev" program with the verbose flag set to probe what parameters the device is checking. If that fails too, you'll need to read the source code (please nag one of the yarp developers to add documentation for your device).
Returns
true/false upon success/failure

Reimplemented from yarp::dev::DeviceDriver.

Definition at line 35 of file AudioToFileDevice.cpp.

◆ operator=() [1/2]

AudioToFileDevice & AudioToFileDevice::operator= ( AudioToFileDevice &&  )
delete

◆ operator=() [2/2]

AudioToFileDevice & AudioToFileDevice::operator= ( const AudioToFileDevice )
delete

◆ renderSound()

ReturnValue AudioToFileDevice::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
a ReturnValue, convertible to true/false

Reimplemented from yarp::dev::AudioPlayerDeviceBase.

Definition at line 154 of file AudioToFileDevice.cpp.

◆ setHWGain()

ReturnValue AudioToFileDevice::setHWGain ( double  gain)
overridevirtual

Sets the hardware gain of the playback device (if supported by the hardware)

Parameters
gainthe audio gain (1.0 is the default value)
Returns
a ReturnValue, convertible to true/false

Implements yarp::dev::IAudioRender.

Definition at line 170 of file AudioToFileDevice.cpp.

◆ startPlayback()

ReturnValue AudioToFileDevice::startPlayback ( )
overridevirtual

Start the playback.

Returns
a ReturnValue, convertible to true/false

Reimplemented from yarp::dev::AudioPlayerDeviceBase.

Definition at line 130 of file AudioToFileDevice.cpp.

◆ stopPlayback()

ReturnValue AudioToFileDevice::stopPlayback ( )
overridevirtual

Stop the playback.

Returns
a ReturnValue, convertible to true/false

Reimplemented from yarp::dev::AudioPlayerDeviceBase.

Definition at line 142 of file AudioToFileDevice.cpp.

◆ waitUntilPlaybackStreamIsComplete()

void AudioToFileDevice::waitUntilPlaybackStreamIsComplete ( )
overridevirtual

Reimplemented from yarp::dev::AudioPlayerDeviceBase.

Definition at line 193 of file AudioToFileDevice.cpp.


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