Sound#
arcade.Sound#
- class arcade.Sound(file_name: str | Path, streaming: bool = False)[source]#
This class represents a sound you can play.
- get_stream_position(player: Player) float [source]#
Return where we are in the stream. This will reset back to zero when it is done playing.
- Parameters:
player (pyglet.media.Player) – Player returned from
play_sound()
.
- get_volume(player: Player) float [source]#
Get the current volume.
- Parameters:
player (pyglet.media.Player) – Player returned from
play_sound()
.- Returns:
A float, 0 for volume off, 1 for full volume.
- Return type:
- is_playing(player: Player) bool [source]#
Return if the sound is currently playing or not
- Parameters:
player (pyglet.media.Player) – Player returned from
play_sound()
.- Returns:
A boolean,
True
if the sound is playing.- Return type:
- play(volume: float = 1.0, pan: float = 0.0, loop: bool = False, speed: float = 1.0) Player [source]#
Play the sound.
arcade.load_sound#
- arcade.load_sound(path: str | Path, streaming: bool = False) Sound | None [source]#
Load a sound.
- Parameters:
path (Path) – Name of the sound file to load.
streaming (bool) – Boolean for determining if we stream the sound or load it all into memory. Set to
True
for long sounds to save memory,False
for short sounds to speed playback.
- Returns:
Sound object which can be used by the
play_sound()
function.- Return type:
arcade.play_sound#
- arcade.play_sound(sound: Sound, volume: float = 1.0, pan: float = 0.0, looping: bool = False, speed: float = 1.0) Player [source]#
Play a sound.
- Parameters:
sound (Sound) – Sound loaded by
load_sound()
. Do NOT use a string here for the filename.volume (float) – Volume, from 0=quiet to 1=loud
pan (float) – Pan, from -1=left to 0=centered to 1=right
looping (bool) – Should we loop the sound over and over?
speed (float) – Change the speed of the sound which also changes pitch, default 1.0
arcade.stop_sound#
- arcade.stop_sound(player: Player)[source]#
Stop a sound that is currently playing.
- Parameters:
player (pyglet.media.Player) – Player returned from
play_sound()
.