PyGaze - documentation - libsound
The sound library is used to create Sound objects, which may be used to play sounds (who would've thought, right?). Sounds may be created by specifying oscillation type, frequency, sound length, attack ('fade in') and decay ('fade out'), or they may be loaded from a file.
contents
SoundSound.pan
Sound.play
Sound.stop
Sound.set_volume
Sound
Sound object for auditive stimuli
arguments | |
---|---|
None | |
keyword arguments | |
osc | type of oscillator; allowed: 'sine', 'saw', 'square', 'whitenoise' (default = SOUNDOSCILLATOR) |
freq | sound frequency in Herz, either float or integer (default = SOUNDFREQUENCY) |
length | sound length in milliseconds (default = SOUNDLENGTH) |
attack | sound attack ('fade in') in milliseconds (default = SOUNDATTACK) |
decay | sound decay ('fade out') in milliseconds (default = SOUNDDECAY) |
soundfile | full path to soundfile with .ogg or .wav extension or None for no file; if a file is specified, all other keyword arguments will be ignored (default = None) |
Sets the panning of a sound (the volume of the 'unpanned' channel decreases, while the other channel remaines the same)
arguments | |||||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|---|---|
panning | either a float between -1 and 1, 'left' or 'right':
|
||||||||||||
keyword arguments | |||||||||||||
None | |||||||||||||
returns | |||||||||||||
None | alters self.sound |
Plays specified sound (keyword argument loops specifies how many repeats after being played once, -1 is infinite); function does not wait for playback end, but returns immediately
arguments | |
---|---|
None | |
keyword arguments | |
repeats | specifies the amount of repeats after being played once (-1 is infinite) (default = 0) |
returns | |
None | self.sound is played |
Immediately stops sound playback
arguments | |
---|---|
None | |
keyword arguments | |
None | |
returns | |
None | self.sound stops playing |
Set the playback volume (loudness) to specified value
arguments | |
---|---|
None | |
keyword arguments | |
volume | float between 0 (silent) and 1 (maximal volume) |
returns | |
None | sets self.sound volume to specified value |
full source
You can find the full source code for libsound.py on GitHub.