Caution

You're reading the documentation for a development version. For the latest released version, please have a look at 0.11.0.

librosa.amplitude_to_db

librosa.amplitude_to_db(S, *, ref=1.0, amin=1e-05, top_db=80.0, axes='auto')[source]

Convert an amplitude spectrogram to dB-scaled spectrogram.

This is equivalent to power_to_db(S**2, ref=ref**2, amin=amin**2, top_db=top_db), but is provided for convenience.

Parameters:
Snp.ndarray

input amplitude

refscalar or callable

If scalar, the amplitude abs(S) is scaled relative to ref: 20 * log10(S / ref). Zeros in the output correspond to positions where S == ref.

If callable, the reference value is computed as ref(S, axis=axes, keepdims=True).

aminfloat > 0 [scalar]

minimum threshold for S and ref

top_dbfloat >= 0 [scalar]

threshold the output at top_db below the peak: max(20 * log10(S/ref)) - top_db For multi-channel inputs, with axes=’auto’, peaks are calculated independently for each channel.

axesNone, “auto”, int, or tuple of int

Axis or axes along which to compute the reference value (if ref is callable). If auto, then axes will be inferred as the trailing dimensions of S:

  • If S is scalar, then axes=None

  • If S is 1D, then axes=(-1,)

  • If S is >=2D, then axes=(-2, -1)

Returns:
S_dbnp.ndarray

S measured in dB

Notes

This function caches at level 30.