gramods
SoundDetector.hh
1 
2 #ifndef GRAMODS_SOUND_SOUNDDETECTOR
3 #define GRAMODS_SOUND_SOUNDDETECTOR
4 
5 #include <gmSound/config.hh>
6 
7 #include <gmSound/Capture.hh>
8 
9 #include <deque>
10 
11 namespace gramods {
12 namespace gmSound {
13 
17 class SoundDetector : public gmCore::Object {
18 
19 public:
20 
21  SoundDetector();
22  ~SoundDetector();
23 
27  size_t getSampleRate();
28 
33  size_t getChannelCount();
34 
42  void setCapture(std::shared_ptr<Capture> c);
43 
51  void setWindow(float t);
52 
63  virtual std::vector<std::vector<float>> detectSound() = 0;
64 
65  std::string getDefaultKey() override { return "soundDetector"; }
66 
67  GM_OFI_DECLARE;
68 
69 protected:
75  const std::vector<std::deque<float>> &getData();
76 
77 private:
78  struct Impl;
79  std::unique_ptr<Impl> _impl;
80 };
81 
82 }}
83 
84 #endif
Base type for objects in the Gramods package for standardized handling of construction,...
Definition: Object.hh:42
The interface for an algorithm detecting sound in an audio stream.
Definition: SoundDetector.hh:17
size_t getChannelCount()
Sets the number of channels to attempt to open for the capture device.
Definition: SoundDetector.cpp:35
std::string getDefaultKey() override
Returns the default key for the Object when automatically instantiated in a Configuration,...
Definition: SoundDetector.hh:65
void setCapture(std::shared_ptr< Capture > c)
Sets the capture object to read audio sample data from.
Definition: SoundDetector.cpp:40
const std::vector< std::deque< float > > & getData()
Fetches the current data that span the specified window.
Definition: SoundDetector.cpp:53
size_t getSampleRate()
Returns the sample rate.
Definition: SoundDetector.cpp:30
void setWindow(float t)
Sets the time window (in seconds) over which to search for matching events.
Definition: SoundDetector.cpp:47
virtual std::vector< std::vector< float > > detectSound()=0
Calls getData and applies the implementation specific algorithm to these data to detect sound in the ...
Gramods, short for Graphics Modules, is a collection of weakly inter dependent and useful APIs for Vi...
Definition: config.hh:25