librosa.core.amplitude_to_db

librosa.core.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:
S : np.ndarray

input amplitude

ref : scalar 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).

amin : float > 0 [scalar]

minimum threshold for S and ref

top_db : float >= 0 [scalar]

threshold the output at top_db below the peak: max(20 * log10(S)) - top_db

Returns:
S_db : np.ndarray

S measured in dB

Notes

This function caches at level 30.