librosax.amplitude_to_db¶
- amplitude_to_db(S: Array, *, ref: float | Callable = 1.0, amin: float = 1e-05, top_db: float | None = 80.0, axes: str | int | tuple | None = 'auto') floating[Any] | Array[source]¶
Convert an amplitude spectrogram to decibel (dB) units.
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:
S – Input amplitude spectrogram. Any shape; applied element-wise.
ref – Reference value for scaling. If scalar, the amplitude
abs(S)is scaled relative toref:20 * log10(S / ref). If callable, the reference value is computed asref(abs(S), axis=axes, keepdims=True). Default is 1.0.amin – Minimum threshold for input values. Default is 1e-5.
top_db – Threshold the output at
top_dbbelow the peak of each slice alongaxes. Default is 80.0.axes – Axis or axes over which
refandtop_dbare reduced. Seepower_to_db.
- Returns:
dB-scaled spectrogram with same shape as input.
See also
power_to_db, db_to_amplitude