Sound#
arcade.Sound#
- class arcade.Sound(file_name: Union[str, pathlib.Path], streaming: bool = False)[source]#
This class represents a sound you can play.
- get_stream_position(player: pyglet.media.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: pyglet.media.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_complete(player: pyglet.media.player.Player) bool [source]#
Return true if the sound is done playing.
- is_playing(player: pyglet.media.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) pyglet.media.player.Player [source]#
Play the sound.
- set_volume(volume, player: pyglet.media.player.Player) None [source]#
Set the volume of a sound as it is playing.
- Parameters
volume (float) – Floating point volume. 0 is silent, 1 is full.
player (pyglet.media.Player) – Player returned from
play_sound()
.
- stop(player: pyglet.media.player.Player) None [source]#
Stop a currently playing sound.
arcade.load_sound#
- arcade.load_sound(path: Union[str, pathlib.Path], streaming: bool = False) Optional[arcade.sound.Sound] [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: arcade.sound.Sound, volume: float = 1.0, pan: float = 0.0, looping: bool = False, speed: float = 1.0) pyglet.media.player.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: pyglet.media.player.Player)[source]#
Stop a sound that is currently playing.
- Parameters
player (pyglet.media.Player) – Player returned from
play_sound()
.