expyriment.stimuli.Tone

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

A class implementing a tone stimulus.

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

Create a Tone.

Parameters:
durationstr

duration of the file in ms

frequencyint, optional

frequency of the sine tone

samplerateint, optional

samplerate of the sine tone

bitdepthint, optional

bitdeth of the sine tone

amplitudeint, optional

amplitude of the sine tone

property amplitude

Getter for amplitude.

property bitdepth

Getter for bitdepth.

copy()

Copy the stimulus.

Returns:
copy: expyriment.stimuli.Audio

Returned copy will NOT be is_preloaded!

property duration

Getter for duration.

property filename

Getter for filename.

property frequency

Getter for frequency.

property id

Getter for id.

property is_preloaded

Getter for is_preloaded.

property logging

Getter for logging.

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

Play the audio stimulus.

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

Parameters:
loopsint, optional

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

maxtimeint

stop after given amount of milliseconds (default = 0)

fade_msint, optional

fade in time in milliseconds (default = 0)

log_event_tagnumeral or string, optional

if log_event_tag is defined and if logging is switched on for this stimulus (default), a summary of the inter-event-intervalls are appended at the end of the event file

preload()

Preload stimulus to memory.

present(log_event_tag=None)

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.

property samplerate

Getter for samplerate.

save(filename)

Save the sine tone to a file.

Parameters:
filenamestr

filename the sine tone should be saved to (str)

set_logging(onoff)

Set logging of this object on or off

Parameters:
onoffbool

set logging on (True) or off (False)

stop()

Stop the audio stimulus

unload(**kwargs)

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.