stimuli.audio.Noise

class stimuli.audio.Noise(volume, sample_rate=44100, duration=1, color='white')

Colored noise stimulus.

Parameters:
volumefloat | tuple

If an int or a float is provided, the sound will use only one channel (mono). If a 2-length tuple is provided, the sound will use 2 channels (stereo). The volume of each channel is given between 0 and 100. For stereo, the volume is given as (L, R).

sample_ratefloat

Sampling frequency of the sound. The default is 44100 Hz.

durationfloat

Duration of the sound. The default is 1 second.

colorstr

The noise color. Available colors are: 'white', 'pink', 'blue', 'violet' and 'brown'.

Attributes

color

The noise color.

duration

Sound's duration [seconds].

n_samples

Number of samples.

sample_rate

Sound's sampling rate [Hz].

signal

Sound's signal.

times

Times array.

volume

Sound's volume(s) [AU].

window

Window applied to the signal.

Methods

copy([deep])

Copy the sound.

play([blocking])

Play the sound.

save(fname[, overwrite])

Save a sound signal into a .wav file.

stop()

Stop the sounds played on the active audio stream.

copy(deep=True)

Copy the sound.

Parameters:
deepbool

If True, deepcopy() is used instead of copy().

play(blocking=False)

Play the sound.

This function creates and terminates an audio stream.

Parameters:
blockingbool

If True, playing the sounds blocks the interpreter.

save(fname, overwrite=False)

Save a sound signal into a .wav file.

The saving is handled by scipy.io.wavfile.write().

Parameters:
fnamestr | Path

Path to the file where the sound signal is saved. The extension should be ‘.wav’.

overwritebool

If True, file with the same name are overwritten.

stop()

Stop the sounds played on the active audio stream.

property color

The noise color.

property duration

Sound’s duration [seconds].

property n_samples

Number of samples.

property sample_rate

Sound’s sampling rate [Hz].

property signal

Sound’s signal.

property times

Times array.

property volume

Sound’s volume(s) [AU].

property window

Window applied to the signal.

Examples using stimuli.audio.Noise

Colored noise

Colored noise