Data-types

This section contains the documentation for float_type, fvec, and cvec.

aubio.float_type

A string constant describing the floating-point representation used in fvec, cvec, and elsewhere in this module.

Defaults to “float32”.

If aubio was built specifically with the option –enable-double, this string will be defined to “float64”. See Double precision in Installing aubio for Python for more details on building aubio in double precision mode.

Examples

>>> aubio.float_type
'float32'
>>> numpy.zeros(10).dtype
'float64'
>>> aubio.fvec(10).dtype
'float32'
>>> np.arange(10, dtype=aubio.float_type).dtype
'float32'
class aubio.fvec(input_arg=1024)[source]

A vector holding float samples.

If input_arg is an int, a 1-dimensional vector of length input_arg will be created and filled with zeros. Otherwise, if input_arg is an array_like object, it will be converted to a 1-dimensional vector of type float_type.

Parameters:

input_arg (int or array_like) – Can be a positive integer, or any object that can be converted to a numpy array with numpy.array().

Examples

>>> aubio.fvec(10)
array([0., 0., 0., 0., 0., 0., 0., 0., 0., 0.], dtype=float32)
>>> aubio.fvec([0,1,2])
array([0., 1., 2.], dtype=float32)
>>> a = np.arange(10); type(a), type(aubio.fvec(a))
(<class 'numpy.ndarray'>, <class 'numpy.ndarray'>)
>>> a.dtype, aubio.fvec(a).dtype
(dtype('int64'), dtype('float32'))

Notes

In the Python world, fvec is simply a subclass of numpy.ndarray. In practice, any 1-dimensional numpy.ndarray of dtype float_type may be passed to methods accepting fvec as parameter. For instance, sink() or pvoc().

See also

cvec

a container holding spectral data

numpy.ndarray

parent class of fvec

numpy.zeros

create a numpy array filled with zeros

numpy.array

create a numpy array from an existing object

class aubio.cvec(size)

A container holding spectral data.

Create one cvec to store the spectral information of a window of size points. The data will be stored in two vectors, phas and norm, each of shape (length,), with length = size // 2 + 1.

Parameters:

size (int) – Size of spectrum to create.

Examples

>>> c = aubio.cvec(1024)
>>> c
aubio cvec of 513 elements
>>> c.length
513
>>> c.norm.dtype, c.phas.dtype
(dtype('float32'), dtype('float32'))
>>> c.norm.shape, c.phas.shape
((513,), (513,))

See also

fvec, fft, pvoc

length

Length of norm and phas vectors.

Type:

int

norm

Vector of shape (length,) containing the magnitude.

Type:

numpy.ndarray

phas

Vector of shape (length,) containing the phase.

Type:

numpy.ndarray