ALSoundDetection API

NAOqi Audio - Overview | API


Namespace : AL

#include <alproxies/alsounddetectionproxy.h>

Method list

As any module, this module inherits methods from ALModule API. It also has the following specific methods:

class ALSoundDetectionProxy

Event list

Methods

void ALSoundDetection::setParameter(const std::string& parameter, const float& value)

Use it to set the sensitivity of the detection.

Parameters:
  • parameter – Name of the parameter
  • value – Value of the parameter

Available parameters:

  • “Sensibility”: DEPRECATED, use “Sensitivity” instead.
  • “Sensitivity” between 0 and 1 to adjust the detection threshold. At 0, the robot does not detect any sound. At 1, it reacts to the slightest sound.

So the sensitivity of the detection can be set by calling this function as follows:

import sys
from naoqi import ALProxy

if (len(sys.argv) < 2):
    print "Usage: 'python sounddetection_setparameter.py IP [PORT]'"
    sys.exit(1)

IP = sys.argv[1]
PORT = 9559
if (len(sys.argv) > 2):
    PORT = sys.argv[2]
try:
    sd = ALProxy("ALSoundDetection", IP, PORT)
except Exception,e:
    print "Could not create proxy to ALSoundDetection"
    print "Error was: ",e
    sys.exit(1)

# Sets the sensitivity of the detection to 0.3 (less sensitive than default).
# The default value is 0.9.
sd.setParameter("Sensitivity", 0.3)
print "Sensitivity set to 0.3"
void ALSoundDetection::subscribe(const std::string& name)

Subscribes to ALSoundDetection. This causes the module to start writing information to ALMemory in “SoundDetected”. This can be accessed in ALMemory using ALMemoryProxy::getData().

Parameters:
  • name – Name to identify the subscriber
void ALSoundDetection::unsubscribe(const std::string& name)

Unsubscribes to ALSoundDetection. This causes the module to stop writing information to ALMemory in “SoundDetected”.

Parameters:

Events

Event: "SoundDetected"
callback(std::string eventName, AL::ALValue value, std::string subscriberIdentifier)

Raised when a significant sound has been detected.

Parameters:
  • eventName (std::string) – “SoundDetected”
  • value – Detected sound informations. Please refer to ALSoundDetection for details.
  • subscriberIdentifier (std::string) –