Caution

You're reading an old version of this documentation. If you want up-to-date information, please have a look at 0.10.1.

librosa.amplitude_to_db

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

Convert an amplitude spectrogram to dB-scaled spectrogram.

This is equivalent to power_to_db(S**2), 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).

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)) - top_db

Returns:
S_dbnp.ndarray

S measured in dB

Notes

This function caches at level 30.