YARP
Yet Another Robot Platform
AudioRecorderDeviceBase.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2006-2021 Istituto Italiano di Tecnologia (IIT)
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 
6 #include <vector>
7 
8 #include <yarp/os/Searchable.h>
10 #include <yarp/dev/api.h>
12 #include <mutex>
13 
14 #ifndef YARP_DEV_AUDIORECORDERDEVICETEMPLATE_H
15 #define YARP_DEV_AUDIORECORDERDEVICETEMPLATE_H
16 
17 namespace yarp {
18 namespace dev {
19 
20 class AudioDeviceDriverSettings
21 {
22  public:
23  size_t numSamples = 0;
24  size_t numChannels = 0;
25  size_t frequency = 0;
26  size_t bytesPerSample = 2;
27 };
28 
48 {
49 protected:
50  bool m_enable_buffer_autoclear = false;
51  bool m_recording_enabled = false;
52  std::mutex m_mutex;
53  yarp::dev::CircularAudioBuffer_16t* m_inputBuffer = nullptr;
54  double m_sw_gain = 1.0;
55  double m_hw_gain = 1.0;
57  bool m_audiobase_debug = false;
58  int16_t m_cliptol = 3;
59 
60 public:
61  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;
62  virtual bool startRecording() override;
63  virtual bool stopRecording() override;
64  virtual bool isRecording(bool& recording_enabled) override;
65  virtual bool getRecordingAudioBufferMaxSize(yarp::dev::AudioBufferSize& size) override;
66  virtual bool getRecordingAudioBufferCurrentSize(yarp::dev::AudioBufferSize& size) override;
67  virtual bool resetRecordingAudioBuffer() override;
68  virtual bool setSWGain(double gain) override;
69 
70  virtual ~AudioRecorderDeviceBase();
71 
72 protected:
73  bool configureRecorderAudioDevice(yarp::os::Searchable& config, std::string device_name);
74 };
75 
76 } // namespace dev
77 } // namespace yarp
78 
79 #endif
AudioRecorderDeviceBase : a base class for all audio recorder devices
AudioDeviceDriverSettings m_audiorecorder_cfg
Read a YARP-format sound block from a device.
A base class for nested structures that can be searched.
Definition: Searchable.h:66
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition: Sound.h:26
The main, catch-all namespace for YARP.
Definition: dirs.h:16
#define YARP_dev_API
Definition: api.h:18