YARP
Yet Another Robot Platform
audioToFileDevice.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  * All rights reserved.
4  *
5  * This software may be modified and distributed under the terms of the
6  * BSD-3-Clause license. See the accompanying LICENSE file for details.
7  */
8 
10 #include <yarp/dev/IAudioRender.h>
11 #include <yarp/sig/Sound.h>
12 #include <yarp/sig/SoundFile.h>
13 
14 #include <string>
15 #include <mutex>
16 #include <deque>
17 
44 {
45 public:
51  ~audioToFileDevice() override;
52 
53  // Device Driver interface
54  bool open(yarp::os::Searchable &config) override;
55  bool close() override;
56 
57 public:
58  virtual bool renderSound(const yarp::sig::Sound& sound) override;
59  virtual bool startPlayback() override;
60  virtual bool stopPlayback()override;
61  virtual bool getPlaybackAudioBufferMaxSize(yarp::dev::AudioBufferSize& size) override;
63  virtual bool resetPlaybackAudioBuffer() override;
64 
65 private:
66  yarp::sig::Sound m_audioFile;
67  std::string m_audio_filename = "audio_out.wav";
68  std::mutex m_mutex;
69  bool m_playback_running = false;
70  std::deque<yarp::sig::Sound> m_sounds;
71  size_t m_filename_counter = 0;
72  enum save_mode_t
73  {
74  save_overwrite_file = 0,
75  save_append_data =1,
76  save_rename_file =2
77  } m_save_mode = save_overwrite_file;
78 
79  void save_to_file();
80 };
audioToFileDevice
audioToFileDevice : This device driver, wrapped by default by AudioPlayerWrapper, is used to save to ...
Definition: audioToFileDevice.h:44
audioToFileDevice::startPlayback
virtual bool startPlayback() override
Start the playback.
Definition: audioToFileDevice.cpp:124
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
audioToFileDevice::resetPlaybackAudioBuffer
virtual bool resetPlaybackAudioBuffer() override
Definition: audioToFileDevice.cpp:117
yarp::dev::AudioBufferSize
Definition: AudioBufferSize.h:26
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
audioToFileDevice::operator=
audioToFileDevice & operator=(audioToFileDevice &&)=delete
audioToFileDevice::getPlaybackAudioBufferMaxSize
virtual bool getPlaybackAudioBufferMaxSize(yarp::dev::AudioBufferSize &size) override
Definition: audioToFileDevice.cpp:110
audioToFileDevice::getPlaybackAudioBufferCurrentSize
virtual bool getPlaybackAudioBufferCurrentSize(yarp::dev::AudioBufferSize &size) override
Definition: audioToFileDevice.cpp:103
yarp::dev::IAudioRender
Definition: IAudioRender.h:21
audioToFileDevice::close
bool close() override
Close the DeviceDriver.
Definition: audioToFileDevice.cpp:97
audioToFileDevice::stopPlayback
virtual bool stopPlayback() override
Stop the playback.
Definition: audioToFileDevice.cpp:136
audioToFileDevice::audioToFileDevice
audioToFileDevice(const audioToFileDevice &)=delete
audioToFileDevice::renderSound
virtual bool renderSound(const yarp::sig::Sound &sound) override
Render a sound using a device (i.e.
Definition: audioToFileDevice.cpp:148
IAudioRender.h
audioToFileDevice::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: audioToFileDevice.cpp:41
audioToFileDevice::audioToFileDevice
audioToFileDevice(audioToFileDevice &&)=delete
yarp::sig::Sound
Class for storing sounds.
Definition: Sound.h:28
SoundFile.h
audioToFileDevice::audioToFileDevice
audioToFileDevice()
Definition: audioToFileDevice.cpp:31
audioToFileDevice::~audioToFileDevice
~audioToFileDevice() override
Definition: audioToFileDevice.cpp:36
Sound.h
DeviceDriver.h
audioToFileDevice::operator=
audioToFileDevice & operator=(const audioToFileDevice &)=delete