librosa.util.buf_to_float

librosa.util.buf_to_float(x, *, n_bytes=2, dtype=<class 'numpy.float32'>)[source]

Convert an integer buffer to floating point values. This is primarily useful when loading integer-valued wav data into numpy arrays.

Parameters:
xnp.ndarray [dtype=int]

The integer-valued data buffer

n_bytesint [1, 2, 4]

The number of bytes per sample in x

dtypenumeric type

The target output type (default: 32-bit float)

Returns:
x_floatnp.ndarray [dtype=float]

The input data buffer cast to floating point