Sound Effects

Sound effects can be triggered by sending an event:

def on_button_pressed(self, event, signal):
    signal(PlaySound(sound=ppb.Sound('toot.ogg')))

Both Ogg/Vorbis and WAV are supported audio formats.

Note

As is usual with assets, you should instantiate your ppb.Sound as soon as possible, such as at the class level.

Note

PyGame has fairly limited codec support. “Complex WAVE files” are not supported. Ogg/Opus appears to be unsupported. Additional formats and codecs might be supported but undocumented.

Reference

class ppb.events.PlaySound(sound: ppb.assets.Asset)[source]

Fire to start a sound playing.

class ppb.Sound(name)[source]

The asset to use for sounds. WAV and Ogg/Vorbis are supported.