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, 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 toref
:20 * log10(S / ref)
. Zeros in the output correspond to positions whereS == ref
.If callable, the reference value is computed as
ref(S)
.- aminfloat > 0 [scalar]
minimum threshold for
S
andref
- top_dbfloat >= 0 [scalar]
threshold the output at
top_db
below the peak:max(20 * log10(S/ref)) - top_db
- Returns:
- S_dbnp.ndarray
S
measured in dB
See also
Notes
This function caches at level 30.