expyriment.stimuli.Tone

class expyriment.stimuli.Tone(duration, frequency=None, samplerate=None, bitdepth=None, amplitude=None)

A class implementing a tone stimulus.

Methods

__init__(duration, frequency=None, samplerate=None, bitdepth=None, amplitude=None)

Create a Tone.

Parameters :

duration : str

duration of the file in ms

frequency : int, optional

frequency of the sine tone

samplerate : int, optional

samplerate of the sine tone

bitdepth : int, optional

bitdeth of the sine tone

amplitude : int, optional

amplitude of the sine tone

amplitude

Getter for amplitude.

bitdepth

Getter for bitdepth.

copy()

Copy the stimulus.

Returns :

copy: stimulus.Audio :

Returned copy will NOT be is_preloaded!

duration

Getter for duration.

filename

Getter for filename

frequency

Getter for frequency.

id

Getter for id.

is_preloaded

Getter for is_preloaded

play(loops=0, maxtime=0, fade_ms=0)

Play the audio stimulus.

The function returns immediately after the sound started to play. A pygame.mixer.Channel object is returned.

Parameters :

loops : int, optional

how often to repeat (-1 = forever) (default = 0)

maxtime : int

stop after given amount of milliseconds (default = 0)

fade_ms : int, optional

fade in time in milliseconds (default = 0)

preload()

Preload stimulus to memory.

present()

Presents the sound.

The function is identical to Audio.play(loops=0, maxtime=0, fade_ms=0) and returns also immediately after the sound started to play.

Notes

See Audio.play for more information.

samplerate

Getter for samplerate.

save(filename)

Save the sine tone to a file.

Parameters :

filename : str

filename the sine tone should be saved to (str)

stop()

Stop the audio stimulus

unload()

Unload stimulus from memory.

This removes the reference to the object in memory. It is up to the garbage collector to actually remove it from memory.

Previous topic

expyriment.stimuli.TextScreen

Next topic

expyriment.stimuli.Video

This Page