def _array_io(self, action, array, frames):
        """Check array and call low-level IO function."""
        if (array.ndim not in (1, 2) or
                array.ndim == 1 and self.channels != 1 or
                array.ndim == 2 and array.shape[1] != self.channels):
            raise ValueError("Invalid shape: {0!r}".format(array.shape))
        if not array.flags.c_contiguous:
            raise ValueError("Data must be C-contiguous")
        try:
            ctype = _ffi_types[array.dtype.name]
        except KeyError:
            raise TypeError("dtype must be one of {0!r}".format(
                sorted(_ffi_types.keys())))
        assert array.dtype.itemsize == _ffi.sizeof(ctype)
        cdata = _ffi.cast(ctype + '*', array.__array_interface__['data'][0])
        return self._cdata_io(action, cdata, ctype, frames)
dataset/ETHPy150Open bastibe/PySoundFile/soundfile.py/SoundFile._array_io/original