librosa.effects.harmonic

librosa.effects.harmonic(y, **kwargs)[source]

Extract harmonic elements from an audio time-series.

Parameters:
y : np.ndarray [shape=(n,)]

audio time series

kwargs : additional keyword arguments.

See librosa.decompose.hpss for details.

Returns:
y_harmonic : np.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.util.example_audio_file())
>>> y_harmonic = librosa.effects.harmonic(y)
>>> # Use a margin > 1.0 for greater harmonic separation
>>> y_harmonic = librosa.effects.harmonic(y, margin=3.0)