librosa.effects.harmonic

librosa.effects.harmonic(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]

Extract harmonic elements from an audio time-series.

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 just the harmonic portion

See also

hpss

Separate harmonic and percussive components

percussive

Extract only the percussive component

librosa.decompose.hpss

HPSS for spectrograms

Examples

>>> # Extract harmonic component
>>> y, sr = librosa.load(librosa.ex('choice'))
>>> y_harmonic = librosa.effects.harmonic(y)
>>> # Use a margin > 1.0 for greater harmonic separation
>>> y_harmonic = librosa.effects.harmonic(y, margin=3.0)