Example #1
0
    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
Example #2
0
	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
Example #3
0
    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
Example #4
0
	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