librosa.envelope#
- librosa.envelope(y, *, frame_length=2048, hop_length=512, kind='max', mode='reflect', center=True, percentile=100.0, axis=-1)[source]#
Compute a time-domain amplitude envelope using 1D filtering operations.
- Parameters:
- ynp.ndarray
Audio time series. Multi-channel is supported.
- frame_lengthint > 0
The size of the filtering window in samples.
- hop_lengthint > 0
The number of samples to advance between decimated output samples.
- kindstr
The type of filtering operation: -
'max': maximum filter -'max_abs': maximum of absolute value -'min': minimum filter -'median': median filter -'percentile': percentile filter (usingpercentileargument)- modestr
Padding mode passed to
scipy.ndimagefilter functions (e.g.'reflect','constant','nearest','mirror','wrap').- centerbool
If
True, the filtering window is centered on each sample. IfFalse, the window is left-aligned.- percentilefloat
Percentile value (between 0 and 100) used when
kind='percentile'.- axisint
Axis along which to compute the envelope.
- Returns:
- y_envnp.ndarray
Decimated amplitude envelope computed along
axis.
- Raises:
- ParameterShapeError
If
yis not valid audio.
- ParameterValueError
If
frame_lengthorhop_lengthare not positive integers.If
kindis unrecognized.
Notes
This function caches at level 20.
Examples
>>> y, sr = librosa.loadx("trumpet") >>> env = librosa.envelope(y, frame_length=2048, hop_length=512, kind="max") >>> env.shape (230,)