Sound

Sounds

serge.sound.Sounds

The registry of all sounds (is an AudioRegistry)

Music

serge.sound.Music

The registry of all music (is a MusicStore)

AudioRegistry

class serge.sound.AudioRegistry[source]

Bases: serge.registry.GeneralStore, serge.common.EventAware

Registry for audio

isPaused()[source]

Return True if we are paused

isPlaying()[source]

Return True if we are playing

pause()[source]

Pause all sounds

play(name, loops=0)[source]

Play a sound

Parameters:
  • name – the name of the sound to play
  • loops – the number of times to loop the sound (0=do not loop, -1=loop forever)
playSequence(sequence)[source]

Play a sequence of sounds

toggle()[source]

Toggle whether music or sound is playing or not

unpause()[source]

Unpause all sounds

update(interval)[source]

Update the registry looking for events

The method is called automatically by the engine.

SoundItem

class serge.sound.SoundItem(path=None, sound=None)[source]

Bases: object

Represents a sound item

Parameters:path – the path to the sound file
fadeout(time)[source]

Fadeout the sound

Parameters:time – the time over which the sound fades out in seconds (0=immediate)
getChannel()[source]

Return the underlying pygame channel object

getSound()[source]

Return the underlying pygame sound object

get_volume()[source]

Return the volume that the sound is playing at (0=silent, 1=full volume)

isPlaying()[source]

Return True if the sound is currently playing

pause()[source]

Pause the sound

play(loops=0)[source]

Play the music

Parameters:loops – the number of times to loop the sound (0=do not loop, -1=loop forever)
set_volume(volume)[source]

Set the volume of the sound

Parameters:volume – the volume of the sound (0=silent, 1=full volume)
stop()[source]

Stop the sound

unpause()[source]

Pause the sound

MusicStore

class serge.sound.MusicStore[source]

Bases: serge.sound.AudioRegistry

Stores music

fadeout(time)[source]

Fadeout the currently playing track

Parameters:time – the time over which the music fades out in seconds (0=immediate)
getVolume()[source]

Returns the volume (0=silent, 1=full volume)

isPlaying()[source]

Return True if we are playing

isPlayingSong(name)[source]

Return True if the named song is playing

Parameters:name – the name of the music item
setPlaylist(item_list)[source]

Set a playlist

setVolume(volume)[source]

Set the volume

Parameters:volume – the volume of the music (0=silent, 1=full volume)
update(interval)[source]

Update the registry looking for events

The method is called automatically by the engine.

MusicItem

class serge.sound.MusicItem(path)[source]

Bases: object

Represents a music item

pause()[source]

Pause the music

play(loops=0)[source]

Play the music

Parameters:loops – the number of times to loop the music (0=do not loop, -1=loop forever)
stop()[source]

Stop the music

unpause()[source]

Pause the music