Caution

You're reading the documentation for a development version. For the latest released version, please have a look at 0.10.1.

librosa.effects.hpss

librosa.effects.hpss(y, *, kernel_size=31, power=2.0, mask=False, margin=1.0, n_fft=2048, hop_length=None, win_length=None, window='hann', center=True, pad_mode='constant')[source]

Decompose an audio time series into harmonic and percussive components.

This function automates the STFT->HPSS->ISTFT pipeline, and ensures that the output waveforms have equal length to the input waveform y.

Parameters:
ynp.ndarray [shape=(…, n)]

audio time series. Multi-channel is supported.

kernel_size
power
mask
margin

See librosa.deocmpose.hpss

n_fft
hop_length
win_length
window
center
pad_mode

See librosa.stft

Returns:
y_harmonicnp.ndarray [shape=(…, n)]

audio time series of the harmonic elements

y_percussivenp.ndarray [shape=(…, n)]

audio time series of the percussive elements

See also

harmonic

Extract only the harmonic component

percussive

Extract only the percussive component

librosa.decompose.hpss

HPSS on spectrograms

Examples

>>> # Extract harmonic and percussive components
>>> y, sr = librosa.load(librosa.ex('choice'))
>>> y_harmonic, y_percussive = librosa.effects.hpss(y)
>>> # Get a more isolated percussive component by widening its margin
>>> y_harmonic, y_percussive = librosa.effects.hpss(y, margin=(1.0,5.0))