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::dev {
18 
19 class AudioDeviceDriverSettings
20 {
21  public:
22  size_t numSamples = 0;
23  size_t numChannels = 0;
24  size_t frequency = 0;
25  size_t bytesPerSample = 2;
26 };
27 
47 {
48 protected:
49  bool m_enable_buffer_autoclear = false;
50  bool m_recording_enabled = false;
51  std::mutex m_mutex;
52  yarp::dev::CircularAudioBuffer_16t* m_inputBuffer = nullptr;
53  double m_sw_gain = 1.0;
54  double m_hw_gain = 1.0;
56  bool m_audiobase_debug = false;
57  int16_t m_cliptol = 3;
58 
59 public:
60  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;
61  virtual bool startRecording() override;
62  virtual bool stopRecording() override;
63  virtual bool isRecording(bool& recording_enabled) override;
64  virtual bool getRecordingAudioBufferMaxSize(yarp::dev::AudioBufferSize& size) override;
65  virtual bool getRecordingAudioBufferCurrentSize(yarp::dev::AudioBufferSize& size) override;
66  virtual bool resetRecordingAudioBuffer() override;
67  virtual bool setSWGain(double gain) override;
68 
69  virtual ~AudioRecorderDeviceBase();
70 
71 protected:
72  bool configureRecorderAudioDevice(yarp::os::Searchable& config, std::string device_name);
73 };
74 
75 } // namespace yarp::dev
76 
77 #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:63
Class for storing sounds See Audio in YARP for additional documentation on YARP audio.
Definition: Sound.h:25
For streams capable of holding different kinds of content, check what they actually have.
#define YARP_dev_API
Definition: api.h:18