def read(self): """ Retrieve the samples contained inside the Buffer object. returns: type=bytearray An array containing the samples """ start = _buffer_start(self._buffer) end = _buffer_end(self._buffer) array = bytearray(end - start) mytype = c_char * len(array) c_array = mytype.from_buffer(array) _memmove(c_array, start, len(array)) return array
def write(self, array): """ Copy the given array of samples inside the Buffer object. :param array: type=bytearray The array containing the samples to copy returns: type=int The number of bytes written into the buffer """ start = _buffer_start(self._buffer) end = _buffer_end(self._buffer) length = end - start if length > len(array): length = len(array) mytype = c_char * len(array) c_array = mytype.from_buffer(array) _memmove(start, c_array, length) return length
def write(self, array): """ Copy the given array of samples inside the Buffer object. parameters: array: type=bytearray The array containing the samples to copy returns: type=int The number of bytes written into the buffer """ start = _buffer_start(self._buffer) end = _buffer_end(self._buffer) length = end - start if length > len(array): length = len(array) mytype = c_char * len(array) c_array = mytype.from_buffer(array) _memmove(start, c_array, length) return length