Ejemplo n.º 1
0
def SDL_LoadWAV_RW(src, freesrc):
    """Load a WAVE from the data source.

    The source is automatically freed if `freesrc` is non-zero.  For
    example, to load a WAVE file, you could do::

        SDL_LoadWAV_RW(SDL_RWFromFile('sample.wav', 'rb'), 1)

    You need to free the returned buffer with `SDL_FreeWAV` when you
    are done with it.

    :Parameters:
     - `src`: `SDL_RWops`
     - `freesrc`: int

    :rtype: (`SDL_AudioSpec`, `SDL_array`)
    :return: a tuple (`spec`, `audio_buf`) where `spec` describes the data
        format and `audio_buf` is the buffer containing audio data.
    """
    spec = SDL_AudioSpec()
    audio_buf = POINTER(c_ubyte)()
    audio_len = c_uint()
    _SDL_LoadWAV_RW(src, freesrc, spec, byref(audio_buf), byref(audio_len))
    ctype = _ctype_audio_format(spec.format)
    return (spec,
            array.SDL_array(audio_buf, audio_len.value / sizeof(ctype), ctype))
Ejemplo n.º 2
0
 def cb(data, stream, len):
     ar = array.SDL_array(stream, len / sizeof(ctype[0]), ctype[0])
     callback(userdata, ar)
Ejemplo n.º 3
0
 def f(chan, stream, len, ignored):
     stream = array.SDL_array(stream, len, c_ubyte)
     func(chan, stream, udata)
Ejemplo n.º 4
0
 def __getattr__(self, attr):
     if attr == 'abuf':
         return array.SDL_array(self._abuf, self.alen, c_ubyte)
     raise AttributeError, attr
Ejemplo n.º 5
0
 def f(ignored, stream, len):
     # FIXME: getting a negative len value here sometimes
     if len < 0: return 
     stream = array.SDL_array(stream, len, c_ubyte)
     func(udata, stream)