stimuli.audio.Tone

class stimuli.audio.Tone(volume, sample_rate=44100, duration=1, frequency=440)

Pure tone stimulus at the frequency f (Hz).

The equation is:

sin(2*pi*f*time).

Example: A 440 - La 440 - Tone(f=440)

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.

frequencyfloat

Pure tone frequency. The default is 440 Hz (La - A440).

Examples

A 440, also called La 440, corresponds to a pure tone at a frequency of 440 Hz.

Attributes

duration

Sound's duration [seconds].

frequency

Sound's pure tone frequency [Hz].

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 duration

Sound’s duration [seconds].

property frequency

Sound’s pure tone frequency [Hz].

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.Tone

Base sounds

Base sounds

Apply a window

Apply a window