YARP
Yet Another Robot Platform
fakeMicrophone.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/os/PeriodicThread.h>
13 #include <yarp/sig/Sound.h>
14 #include <yarp/sig/SoundFile.h>
15 
16 #include <string>
17 #include <mutex>
18 
19 #define DEFAULT_PERIOD 0.01 //s
20 
41 {
42 public:
44  fakeMicrophone(const fakeMicrophone&) = delete;
48  ~fakeMicrophone() override;
49 
50 public: // DeviceDriver
51  bool open(yarp::os::Searchable &config) override;
52  bool close() override;
53 
54 private:
55  //thread
56  bool threadInit() override;
57  void run() override;
58 
59 private:
60  std::vector<size_t> m_counter;
61  std::vector<size_t> m_max_count;
62  size_t m_wave_amplitude = 32000;
63  double m_sig_freq=440; //Hz
64 
65  enum waveform_t
66  {
67  sine = 0,
68  sawtooth = 1,
69  square = 2,
70  constant = 3
71  } m_waveform = sine;
72 };
yarp::os::Searchable
A base class for nested structures that can be searched.
Definition: Searchable.h:69
fakeMicrophone::operator=
fakeMicrophone & operator=(fakeMicrophone &&)=delete
yarp::dev::DeviceDriver
Interface implemented by all device drivers.
Definition: DeviceDriver.h:38
fakeMicrophone::open
bool open(yarp::os::Searchable &config) override
Open the DeviceDriver.
Definition: fakeMicrophone.cpp:47
yarp::dev::AudioRecorderDeviceBase
Definition: AudioRecorderDeviceBase.h:34
fakeMicrophone
fakeMicrophone : fake microphone device implementing the IAudioGrabberSound interface to generate a t...
Definition: fakeMicrophone.h:41
fakeMicrophone::operator=
fakeMicrophone & operator=(const fakeMicrophone &)=delete
fakeMicrophone::fakeMicrophone
fakeMicrophone()
Definition: fakeMicrophone.cpp:37
fakeMicrophone::fakeMicrophone
fakeMicrophone(fakeMicrophone &&)=delete
yarp::os::PeriodicThread
An abstraction for a periodic thread.
Definition: PeriodicThread.h:25
PeriodicThread.h
fakeMicrophone::fakeMicrophone
fakeMicrophone(const fakeMicrophone &)=delete
SoundFile.h
IGenericSensor.h
AudioRecorderDeviceBase.h
fakeMicrophone::~fakeMicrophone
~fakeMicrophone() override
Definition: fakeMicrophone.cpp:42
Sound.h
fakeMicrophone::close
bool close() override
Close the DeviceDriver.
Definition: fakeMicrophone.cpp:110
DeviceDriver.h