World > Sound#

API Reference#

class miniworlds.worlds.manager.sound_manager.SoundManager(app)[source]#

Manages short sound-effect playback for a world.

Access via world.sound.

Unlike world.music, sounds can overlap and are designed for short in-game effects.

Examples

world.sound.play("assets/explosion.wav")
world.sound.play("assets/jump.wav", volume=80)
is_playing(path)[source]#

Return whether the given sound is currently playing.

Return type:

bool

Parameters:

path – Path to the sound.

Returns:

True if the sound is playing.

Raises:

ValueError – If path is empty.

Examples

if world.sound.is_playing("sounds/explosion.wav"):
    world.sound.stop("sounds/explosion.wav")
is_registered(path)[source]#

Return whether a sound is already registered.

Return type:

bool

Parameters:

path – Path to the sound.

Returns:

True if the sound is registered.

Raises:

ValueError – If path is empty.

Examples

if not world.sound.is_registered("sounds/explosion.wav"):
    world.sound.register("sounds/explosion.wav")
play(path, volume=100)[source]#

Play a sound.

Return type:

None

Parameters:
  • path – Path to the sound.

  • volume – Volume between 0 and 100.

Raises:

ValueError – If path is empty or volume is out of range.

Examples

world.sound.play("sounds/explosion.wav", volume=80)
register(path)[source]#

Register a sound for later use.

Return type:

None

Parameters:

path – Path to the sound.

Raises:

ValueError – If path is empty.

Examples

world.sound.register("sounds/explosion.wav")
stop(path)[source]#

Stop a playing sound.

Return type:

None

Parameters:

path – Path to the sound to stop.

Raises:

ValueError – If path is empty.

Examples

world.sound.stop("sounds/explosion.wav")