Beispiel #1
0
def SDL_MixAudio(dst, src, length, volume):
    """Mix two audio buffers.

    This takes two audio buffers of the playing audio format and mixes
    them, performing addition, volume adjustment, and overflow clipping.
    The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
    for full audio volume.  Note this does not change hardware volume.
    This is provided for convenience -- you can mix your own audio data.

    :note: SDL-ctypes doesn't know the current play format, so you must
        always pass in byte buffers (SDL_array or sequence) to this function,
        rather than of the native data type.

    :Parameters:
     - `dst`: `SDL_array`
     - `src`: `SDL_array`
     - `length`: int
     - `volume`: int

    """
    dstref, dst = array.to_ctypes(dst, len(dst), c_ubyte)
    srcref, src = array.to_ctypes(src, len(src), c_ubyte)
    if len(dst) < length:
        raise TypeError('Destination buffer too small')
    elif len(src) < length:
        raise TypeError('Source buffer too small')
    _SDL_MixAudio(dst, src, length, volume)
Beispiel #2
0
def SDL_MixAudio(dst, src, length, volume):
    """Mix two audio buffers.

    This takes two audio buffers of the playing audio format and mixes
    them, performing addition, volume adjustment, and overflow clipping.
    The volume ranges from 0 - 128, and should be set to SDL_MIX_MAXVOLUME
    for full audio volume.  Note this does not change hardware volume.
    This is provided for convenience -- you can mix your own audio data.

    :note: SDL-ctypes doesn't know the current play format, so you must
        always pass in byte buffers (SDL_array or sequence) to this function,
        rather than of the native data type.

    :Parameters:
     - `dst`: `SDL_array`
     - `src`: `SDL_array`
     - `length`: int
     - `volume`: int

    """
    dstref, dst = array.to_ctypes(dst, len(dst), c_ubyte)
    srcref, src = array.to_ctypes(src, len(src), c_ubyte)
    if len(dst) < length:
        raise TypeError, "Destination buffer too small"
    elif len(src) < length:
        raise TypeError, "Source buffer too small"
    _SDL_MixAudio(dst, src, length, volume)
Beispiel #3
0
def Mix_QuickLoad_WAV(mem):
    '''Load a wave file of the mixer format from a sequence or SDL_array.

    :Parameters:
     - `mem`: sequence or `SDL_array`

    :rtype: `Mix_Chunk`
    '''
    ref, mem = array.to_ctypes(mem, len(mem), c_ubyte)
    return _Mix_QuickLoad_WAV(mem)