gramods
Classes | Public Member Functions | Public Attributes | Protected Member Functions | List of all members
gramods::gmSound::SoundDetector Class Referenceabstract

The interface for an algorithm detecting sound in an audio stream. More...

#include <SoundDetector.hh>

Inheritance diagram for gramods::gmSound::SoundDetector:
Inheritance graph
[legend]
Collaboration diagram for gramods::gmSound::SoundDetector:
Collaboration graph
[legend]

Classes

struct  Impl
 

Public Member Functions

size_t getSampleRate ()
 Returns the sample rate. More...
 
size_t getChannelCount ()
 Sets the number of channels to attempt to open for the capture device. More...
 
void setCapture (std::shared_ptr< Capture > c)
 Sets the capture object to read audio sample data from. More...
 
void setWindow (float t)
 Sets the time window (in seconds) over which to search for matching events. More...
 
virtual std::vector< std::vector< float > > detectSound ()=0
 Calls getData and applies the implementation specific algorithm to these data to detect sound in the stream, estimating how long ago the sound appeared in each channel. More...
 
std::string getDefaultKey () override
 Returns the default key for the Object when automatically instantiated in a Configuration, i.e. More...
 
- Public Member Functions inherited from gramods::gmCore::Object
 Object ()
 Initializes internal data. More...
 
virtual ~Object ()
 Cleaning up internal data. More...
 
virtual void initialize ()
 Called to initialize the Object. More...
 
virtual void accept (Visitor *visitor)
 Calls the visitors apply method with this as argument. More...
 
virtual void traverse (Visitor *visitor)
 Calls the child Object's accept method, if such exist. More...
 
bool isInitialized ()
 Returns true if the Object is initialized. More...
 

Public Attributes

 GM_OFI_DECLARE
 

Protected Member Functions

const std::vector< std::deque< float > > & getData ()
 Fetches the current data that span the specified window. More...
 

Detailed Description

The interface for an algorithm detecting sound in an audio stream.

Member Function Documentation

◆ detectSound()

virtual std::vector<std::vector<float> > gramods::gmSound::SoundDetector::detectSound ( )
pure virtual

Calls getData and applies the implementation specific algorithm to these data to detect sound in the stream, estimating how long ago the sound appeared in each channel.

Returns
The time offset, in seconds, of the t0 of all detected sounds, per channel. Zero equals now and positive values represent back in time. The outer vector should always have size equal to the number of channels, even if no sound was detected.

Implemented in gramods::gmSound::SoundBurstDetector.

◆ getChannelCount()

size_t gramods::gmSound::SoundDetector::getChannelCount ( )

Sets the number of channels to attempt to open for the capture device.

◆ getData()

const std::vector< std::deque< float > > & gramods::gmSound::SoundDetector::getData ( )
protected

Fetches the current data that span the specified window.

The referenced object is valid at least until the getData method is called again.

◆ getDefaultKey()

std::string gramods::gmSound::SoundDetector::getDefaultKey ( )
inlineoverridevirtual

Returns the default key for the Object when automatically instantiated in a Configuration, i.e.

where it ends up in a parent Object. Default is "object", but this should be overriden by sub classes and can also be overridden in XML by using the attribute KEY, as in KEY="view".

The key can also be used to extract a specific object from a Configuration instance:

gmCore::Configuration config(argc, argv);
std::shared_ptr<MyClass> my_object;
if (! config.getObjectByKey("view", my_object)) {
GM_ERR("MyCode", "Cannot run without MyClass instance");
exit(-1);
}

Reimplemented from gramods::gmCore::Object.

◆ getSampleRate()

size_t gramods::gmSound::SoundDetector::getSampleRate ( )

Returns the sample rate.

◆ setCapture()

void gramods::gmSound::SoundDetector::setCapture ( std::shared_ptr< Capture c)

Sets the capture object to read audio sample data from.

The number of microphone positions should match the number of channels in the capture.

XML-attribute: capture

◆ setWindow()

void gramods::gmSound::SoundDetector::setWindow ( float  t)

Sets the time window (in seconds) over which to search for matching events.

Default is 0.029 seconds, which corresponds to approximately 10 meters with the default speed of sound.

XML-attribute: window


The documentation for this class was generated from the following files: