stimuli.audio.SoundAM

class stimuli.audio.SoundAM(volume, sample_rate=44100, duration=1, frequency_carrier=1000, frequency_modulation=40, method='conventional')

Amplitude modulated sound.

Composed of a carrier frequency fc which is amplitude modulated at fm. By default, an Auditory Steady State Response stimuli composed of a 1000 Hz carrier frequency modulated at 40 Hz through conventional modulation is created.

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.

frequency_carrierint

Carrier frequency in Hz.

frequency_modulationint

Modulatiom frequency in Hz.

method'conventional' | 'dsbsc'

'conventional' is also called classical AM, the eq. used is:

signal = (1 - M(t)) * cos(2*pi*fc*t)
M(t) = cos(2*pi*fm*t)

'dsbsc' is also called double side band suppressed carrier, the eq. used is:

signal = M(t)*cos(2*pi*fc*t)
M(t) = sin(2*pi*fm*t)

Attributes

duration

Sound's duration [seconds].

frequency_carrier

Sound's carrier frequency [Hz].

frequency_modulation

Sound's modulation frequency [Hz].

method

Sound's modulation method.

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_carrier

Sound’s carrier frequency [Hz].

property frequency_modulation

Sound’s modulation frequency [Hz].

property method

Sound’s modulation method.

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.