gramods
Loading...
Searching...
No Matches
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
11namespace gramods {
12namespace gmSound {
13
18
19public:
20
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
69protected:
75 const std::vector<std::deque<float>> &getData();
76
77private:
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
virtual std::vector< std::vector< float > > detectSound()=0
Calls getData and applies the implementation specific algorithm to these data to detect sound in the ...
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
Gramods, short for Graphics Modules, is a collection of weakly inter dependent and useful APIs for Vi...
Definition config.hh:25