top of page

Sound (PE.sound)

PE.sound.MusicList

play list of sounds in a loop, can be used for background music

class usage:

object in space that emit particles.

MusicList.__init__(self, sounds: list, vol=1, fade_out=0, fade_in=0)

function actions:

initializing the music list. 

​

parameters:

sounds - a list of pygame.mixer.Sound objects (list/tuple)

vol  - music volume (from 0 to 1) (float)

fade_out - the duration of the fade transition when a music ends(float)

fade_in - the duration of the fade transition when a music starts (float)

​

​

MusicList.play(self)

function actions:

a tick function, updates the playlist.​

​

recommended place on script:

at the main loop. (this is a tick fundction)

​

PE.sound.sound(sound: pygame.mixer.Sound, vol=1, fade_out=0, fade_in=0, one_time=False)

function actions:

improvement for pygame.mixer.Sound.play(). plays a pygame mixer sound, with some settings in one line.​

​

parameters:

sound - the sound object you want to play (pygame.mixer.Sound)

vol - sound volume (float)

fade_out - fade out effect duration (float)

fade_in - fade in effect duration (float)

one_time - determines whether this sound can overlap itself. True means it cannot, False means it can be played several times at once.(bool)

​

PE.sound.music(sound: pygame.mixer.Sound, vol=1, fade_out=0, fade_in=0)

function actions:

equivalent to PE.sound.sound with the one_time parameter set to True. warning: this function exists because initially, the one_time parameter did not exist, and this was the way to achieve a one-time sound effect. this function may be removed in the future.

​

parameters:

sound - the sound object you want to play (pygame.mixer.Sound)

vol - sound volume (float)

fade_out - fade out effect duration (float)

fade_in - fade in effect duration (float)

​

​

​

Powered and secured by Wix © 2035

bottom of page