stimuli.audio.Sound

class stimuli.audio.Sound(fname)

Auditory stimulus loaded from a file.

Parameters:
fnamestr | Path

Path to the supported audio file to load.

Attributes

duration

Sound's duration [seconds].

fname

The sound's original file name.

n_samples

Number of samples.

sample_rate

Sound's sampling rate [Hz].

signal

Sound's signal.

times

Times array.

tmax

Right-edge of the signal crop [seconds].

tmin

Left-edge of the signal crop [seconds].

volume

Sound's volume(s) [AU].

window

Window applied to the signal.

Methods

copy([deep])

Copy the sound.

crop([tmin, tmax])

Crop the sound between tmin and tmax.

play([blocking])

Play the sound.

reset()

Reset the signal to the original loaded signal.

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().

crop(tmin=None, tmax=None)

Crop the sound between tmin and tmax.

Parameters:
tminfloat | None

Left-edge of the crop. If None, the beginning of the sound.

tmaxfloat | None

Right-edge of the crop. If None, the end of the sound.

Notes

The time-based selection selects the samples in the closed interval [tmin, tmax].

play(blocking=False)

Play the sound.

This function creates and terminates an audio stream.

Parameters:
blockingbool

If True, playing the sounds blocks the interpreter.

reset()

Reset the signal to the original loaded signal.

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 duration

Sound’s duration [seconds].

property fname

The sound’s original file name.

property n_samples

Number of samples.

property sample_rate

Sound’s sampling rate [Hz].

property signal

Sound’s signal.

property times

Times array.

property tmax

Right-edge of the signal crop [seconds].

property tmin

Left-edge of the signal crop [seconds].

property volume

Sound’s volume(s) [AU].

property window

Window applied to the signal.

Examples using stimuli.audio.Sound

Base sounds

Base sounds