Skip to content

brian.sensors.NXT.SoundSensorNXT

brian.sensors.NXT

SoundSensorNXT class objects

class SoundSensorNXT(Sensor)

Class for interacting with NXT sound sensor.

Sensor is automatically registered in the constructor of the base class and un-registered in its destructor. It can also be unregistered with the SoundSensorNXT.close_sensor() function.

There can be at most one instance at any given time, of any sensor class per port in the entire program.

__init__

def __init__(port: SensorPort)

Initialize an NXT sound sensor at the given port.

Arguments:

  • port: Sensor port to which the sensor is attached.

sound_intensity

def sound_intensity() -> float

Measures incoming sound.

Raises:

  • brian.sensors.SensorIsNotReadyError: If the sensor is not ready.

Returns:

Value in range 0-1, with 0 being the quietest and 1 being the loudest.

sound_intensity_raw

def sound_intensity_raw() -> int

Measures incoming sound. Raw measurement is inverted, meaning lower values correspond to louder sounds.

Raises:

  • brian.sensors.SensorIsNotReadyError: If the sensor is not ready.

Returns:

Value in range 0-4095, with 4095 being the quietest and 0 being the loudest.