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:
x : np.ndarray [dtype=int]

The integer-valued data buffer

n_bytes : int [1, 2, 4]

The number of bytes per sample in x

dtype : numeric type

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

Returns:
x_float : np.ndarray [dtype=float]

The input data buffer cast to floating point

See also

buf_to_float