Audio🔗

The audio module provides classes for generating standard audio stimuli and for loading existing files.

Sound generation🔗

Standard sounds can be generated like noise, amplitude modulated sounds or pure tones.

Noise(color, volume, duration[, ...])

Colored noise stimulus.

SoundAM(frequency_carrier, ...[, ...])

Amplitude modulated sound.

Tone(frequency, volume, duration[, ...])

Pure tone stimulus at a given frequency.

Example usage:

from stimuli.audio import Noise

sound = Noise(color="pink", volume=50, duration=1)
sound.play(when=0.2)  # schedule in 200 ms

Sound files🔗

For more complex stimuli, the sounds can be loaded from files.

Sound(fname[, device, backend, clock])

Auditory stimulus loaded from a file.

Example usage:

from stimuli.audio import Sound

sound = Sound("path/to/sound.wav")
sound.play(when=0.2)  # schedule in 200 ms

Backend🔗

The audio module uses the sounddevice library with a callback function to play the sounds.

SoundSD(device, sample_rate, *[, clock])

Sounddevice backend for audio playback.