39 if (!b) {
return false;}
42 if (!b) {
return false; }
46 if (
m_save_mode ==
"overwrite_file") { m_save_mode_enum = save_mode_t::save_overwrite_file;
yCInfo(
AUDIOTOFILE) <<
"overwrite_file mode selected. File will be saved both on exit and on stop";}
47 else if (
m_save_mode ==
"append_data") { m_save_mode_enum = save_mode_t::save_append_data;
yCInfo(
AUDIOTOFILE) <<
"append_data mode selected. File will be saved on exit only";}
48 else if (
m_save_mode ==
"rename_file") { m_save_mode_enum = save_mode_t::save_rename_file;
yCInfo(
AUDIOTOFILE) <<
"rename_file mode selected. File will be saved both on exit and on stop";}
49 else if (
m_save_mode ==
"break_file") { m_save_mode_enum = save_mode_t::save_break_file;
yCInfo(
AUDIOTOFILE) <<
"break_file mode selected.";}
50 else {
yError() <<
"Unsupported value for save_mode parameter";
return false; }
55void AudioToFileDevice::save_to_file()
58 if (m_sounds.size() == 0) {
64 m_audioFile.
setFrequency(m_sounds.front().getFrequency());
65 m_audioFile.
resize(0, m_sounds.front().getChannels());
66 while (!m_sounds.empty())
85 for (
size_t i = 0; i <
ss_size; i++)
110 if (m_save_mode_enum == save_mode_t::save_rename_file ||
111 m_save_mode_enum == save_mode_t::save_break_file)
132 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
135 if (m_save_mode_enum != save_mode_t::save_append_data)
144 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
147 if (m_save_mode_enum != save_mode_t::save_append_data)
156 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
157 if (m_save_mode_enum == save_break_file)
159 m_sounds.push_back(sound);
165 m_sounds.push_back(sound);
172 std::lock_guard<std::recursive_mutex> lock(
m_mutex);
178 return ReturnValue::return_code::return_value_error_method_failed;
bool parseParams(const yarp::os::Searchable &config) override
Parse the DeviceDriver parameters.
bool close() override
Close the DeviceDriver.
virtual yarp::dev::ReturnValue setHWGain(double gain) override
Sets the hardware gain of the playback device (if supported by the hardware)
virtual yarp::dev::ReturnValue startPlayback() override
Start the playback.
virtual bool configureDeviceAndStart() override
virtual void waitUntilPlaybackStreamIsComplete() override
virtual yarp::dev::ReturnValue stopPlayback() override
Stop the playback.
virtual yarp::dev::ReturnValue renderSound(const yarp::sig::Sound &sound) override
Render a sound using a device (i.e.
virtual bool interruptDeviceAndClose() override
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
~AudioToFileDevice() override
std::recursive_mutex m_mutex
bool configurePlayerAudioDevice(yarp::os::Searchable &config, std::string device_name)
A mini-server for performing network communication in the background.
A base class for nested structures that can be searched.
virtual Bottle & findGroup(const std::string &key) const =0
Gets a list corresponding to a given keyword.
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
void setFrequency(int freq)
Set the frequency of the sound (i.e.
void resize(size_t samples, size_t channels=1)
Set the sound size.
#define yCInfo(component,...)
#define yCError(component,...)
#define yCDebug(component,...)
#define YARP_LOG_COMPONENT(name,...)
For streams capable of holding different kinds of content, check what they actually have.
An interface to the operating system, including Port based communication.
bool write(const ImageOf< PixelRgb > &src, const std::string &dest, image_fileformat format=FORMAT_PPM)