# Path: vulk/exception.py
# class SDL2Error(VulkError):
#     pass
# 
# class SoundError(VulkError):
#     pass


import logging
import sdl2
from sdl2 import sdlmixer as mixer
from sdl2.ext.compat import byteify
from vulk.exception import SDL2Error, SoundError

    def close(self):
        '''Close the audio system'''
        mixer.Mix_CloseAudio()
        sdl2.SDL_Quit(sdl2.SDL_INIT_AUDIO)
        logger.info("Audio stopped")


class Sound():
    '''
    Sound effects are small audio samples, usually no longer than a few
    seconds, that are played back on specific game events such as a character
    jumping or shooting a gun.

    Sound effects can be stored in various formats. Vulk is based on SDL2 and
    thus supports WAVE, AIFF, RIFF, OGG, and VOC files.
    '''

    def __init__(self, path):
        '''Load the sound file

        *Parameters:*

        - `path`: Path to the sound file
        '''
        self.sample = mixer.Mix_LoadWAV(byteify(path, "utf-8"))

        if not self.sample:
            msg = "Cannot load file %s" % path
            logger.error(msg)

# Path: vulk/exception.py
# class SDL2Error(VulkError):
#     pass
# 
# class SoundError(VulkError):
#     pass


# Path: vulk/audio.py
import logging
import sdl2
from sdl2 import sdlmixer as mixer
from sdl2.ext.compat import byteify
from vulk.exception import SDL2Error, SoundError


    def close(self):
        '''Close the audio system'''
        mixer.Mix_CloseAudio()
        sdl2.SDL_Quit(sdl2.SDL_INIT_AUDIO)
        logger.info("Audio stopped")


class Sound():
    '''
    Sound effects are small audio samples, usually no longer than a few
    seconds, that are played back on specific game events such as a character
    jumping or shooting a gun.

    Sound effects can be stored in various formats. Vulk is based on SDL2 and
    thus supports WAVE, AIFF, RIFF, OGG, and VOC files.
    '''

    def __init__(self, path):
        '''Load the sound file

        *Parameters:*

        - `path`: Path to the sound file
        '''
        self.sample = mixer.Mix_LoadWAV(byteify(path, "utf-8"))

        if not self.sample:
            msg = "Cannot load file %s" % path
            logger.error(msg)

            raise SoundError(msg)