### Navigation

- index
- modules |
- next |
- previous |
- cocos »
- cocos package »
- cocos.audio package »
- cocos.audio.SDL package »

# cocos.audio.SDL.array module

class `SDL_array`(ptr, count, ctype)
  `as_bytes`()

    Access the array as raw bytes, regardless of the underlying data type.

    This can be useful, for example, in accessing a 32-bit colour buffer by individual components rather than the encoded pixel.

    Return type: | SDL_array

  `as_ctypes`()

    Access the array as a ctypes array.

    Return type: | ctypes.Array

  `as_int16`()

    Access the array as 16-bit integers, regardless of the underlying data type.

    Return type: | SDL_array

  `as_int32`()

    Access the array as 32-bit integers, regardless of the underlying data type.

    Return type: | SDL_array

  `as_numpy`(shape=None)

    Access the array as a numpy array.

    The numpy array shares the same underlying memory buffer, so changes are immediate, and you can use the numpy array as you would normally. To set the entire contents of the array at once, use a `[:]` slice.

    If numpy is not installed, an ImportError will be raised.

    Return type: | numpy.ndarray

  `from_string`(data)

    Copy string data into this array.

    The string must have exactly the same length of this array (in bytes). No size checking is performed.

    Parameters: | data : str String data to copy.

  `have_numpy`()

    Determine if the numpy array module is available.

    Return type: | bool

  `to_string`()

    Return a string with the contents of this array.

    Return type: | string

`to_ctypes`(values, count, ctype)

  Create a ctypes array of the given count and type, with the contents of sequence values.

  Parameters: | values: sequence of length count, or SDL_array instance, or ctypes.Array, or POINTER(ctypes.Array) count: int ctype: type
  Return type: | object, ctypes.Array
  Returns: | (ref, array), where ref is an object that must be retained by the caller for as long as the array is used.

### Navigation

- index
- modules |
- next |
- previous |
- cocos »
- cocos package »
- cocos.audio package »
- cocos.audio.SDL package »