Module AggiEngine.sound

Expand source code
import simpleaudio as sa
from typing import Any


class Sound:

    def __init__(self) -> None:
        self.sounds = dict()
    
    def load(self, key: Any, filestr: str) -> None:
        """
        loads a wav file for future playback  
        ``key:`` A key you will use to access the audio playback  
        ``filestr:`` The file path for a wav file to play  
        """
        self.sounds[key] = sa.WaveObject.from_wave_file(filestr)
    
    def play(self, key: Any) -> sa.PlayObject:
        """
        Plays your sound
        ``key:`` The key used when loading the sound  
        """
        return self.sounds[key].play()
    
    def stop_all(self) -> None:
        """
        Stops all sounds from playing
        """
        sa.stop_all()

Classes

class Sound
Expand source code
class Sound:

    def __init__(self) -> None:
        self.sounds = dict()
    
    def load(self, key: Any, filestr: str) -> None:
        """
        loads a wav file for future playback  
        ``key:`` A key you will use to access the audio playback  
        ``filestr:`` The file path for a wav file to play  
        """
        self.sounds[key] = sa.WaveObject.from_wave_file(filestr)
    
    def play(self, key: Any) -> sa.PlayObject:
        """
        Plays your sound
        ``key:`` The key used when loading the sound  
        """
        return self.sounds[key].play()
    
    def stop_all(self) -> None:
        """
        Stops all sounds from playing
        """
        sa.stop_all()

Methods

def load(self, key: typing.Any, filestr: str) ‑> NoneType

loads a wav file for future playback
key: A key you will use to access the audio playback
filestr: The file path for a wav file to play

Expand source code
def load(self, key: Any, filestr: str) -> None:
    """
    loads a wav file for future playback  
    ``key:`` A key you will use to access the audio playback  
    ``filestr:`` The file path for a wav file to play  
    """
    self.sounds[key] = sa.WaveObject.from_wave_file(filestr)
def play(self, key: typing.Any) ‑> simpleaudio.shiny.PlayObject

Plays your sound key: The key used when loading the sound

Expand source code
def play(self, key: Any) -> sa.PlayObject:
    """
    Plays your sound
    ``key:`` The key used when loading the sound  
    """
    return self.sounds[key].play()
def stop_all(self) ‑> NoneType

Stops all sounds from playing

Expand source code
def stop_all(self) -> None:
    """
    Stops all sounds from playing
    """
    sa.stop_all()