FROM AGPEDIA — AGENCY THROUGH KNOWLEDGE

Harmonic–percussive source separation

Harmonic–percussive source separation (HPSS) splits a music recording into a harmonic part, the pitched sounds that carry melodies and chords, and a percussive part, the clicks, knocks and strikes, rather than into particular instruments.[1:1][2:1] It rests on how the two look in a spectrogram: sustained pitched sounds form horizontal lines, short percussive sounds vertical ones.[2:1][1:1] It is used as an effect for remixing and as a preprocessing step: removing the drums helps the transcription of pitched instruments and chord detection, and removing pitched instruments helps drum transcription and beat tracking.[2:2] Other uses include improving chroma features, tempo estimation and time-scale modification.[3:1]

Harmonic and percussive sounds

In Meinard Müller's definitions, a harmonic sound is what is heard as pitched; its prototype is a sinusoid, a horizontal line in a spectrogram, and the sound of a violin is a typical example. A percussive sound is heard as a clash, knock, clap or click; its prototype is an impulse, a vertical line, and examples include a drum stroke and the transient in the attack of a musical tone. Some sounds, such as white noise or applause, are neither.[1:1] By this definition the transient at the start of a note counts as percussive, even when the rest of the note is harmonic.[1:1]

Methods

Diffusion

Ono and colleagues based their method on the observation that stable harmonic sounds form horizontal ridges in the spectrogram and percussive sounds vertical, broadband ones.[2:1] Their method is iterative, typically needing 30 to 50 iterations to converge.[2:3]

Median filtering

Derry FitzGerald (2010) restated the idea in terms of outliers: within one time frame, harmonic peaks are outliers in the spectrum; within one frequency bin, percussive events are outliers across time.[2:4] Median filters, which remove outliers, therefore do the job. Filtering each frequency bin along time keeps the horizontal lines and suppresses the vertical; filtering each frame along frequency does the reverse. The two filtered spectrograms are turned into masks that are applied to the original spectrogram.[2:5]

The method needs only two passes through the spectrogram and ran about twice as fast as Ono and colleagues', with quality comparable in informal listening. FitzGerald found separation better with longer FFTs, and little difference among median filter lengths between 15 and 30. Soft masks gave fewer artifacts than binary masks, at the cost of slightly more interference between the parts.[2:3]

A third, residual component

The two parts often contain noise-like sounds that are neither harmonic nor percussive, and depending on the settings, harmonic sounds can leak into the percussive part and vice versa. Jonathan Driedger, Müller and Sascha Disch (2014) added a separation factor β: a time–frequency bin is assigned to the harmonic part only if it stands out from the percussive part by at least a factor of β, and vice versa. Whatever is assigned to neither forms a third, residual component, an idea inspired by the sines, transients and noise model of audio.[3:2][3:3] The three components always add up to the original signal.[3:3]

Parameters

Driedger and colleagues found that the median filter lengths matter little unless extreme values are chosen. The frame size matters more, because it shifts energy towards one part. Large frames blur short percussive sounds, which then leak into the harmonic part; small frames have low frequency resolution, blurring horizontal structures, so harmonic sounds leak into the percussive part. A larger separation factor makes both parts more clearly harmonic or percussive, but sends more of the signal to the residual.[3:4]

Implementations

The librosa library's hpss function implements median-filtering separation following FitzGerald and Driedger and colleagues. With its margin parameter at 1 it splits a spectrogram into harmonic and percussive parts; with a larger margin it leaves a residual as well. Its soft masks are built with a Wiener-filter exponent.[4:1]

Limitations

Masking methods leave the phase of the original mixture in both parts. Müller notes that this ignores phase interference between the components, that estimating coherent phase for separate components is very hard or even intractable, and that a masked spectrogram may not correspond to a coherent signal when it is turned back into audio.[1:2] The split also depends on the frame size: large frames let percussive sounds leak into the harmonic part, and small frames the reverse.[3:4]

  1. ^a ^b ^c ^d ↗ fh-definitions ^ ↗ fh-phase Müller, Meinard. Harmonic–Percussive Separation (HPS). FMP Notebooks (companion to Fundamentals of Music Processing), International Audio Laboratories Erlangen. https://www.audiolabs-erlangen.de/resources/MIR/FMP/C8/C8S1_HPS.html.
  2. ^a ^b ^c ↗ ridges ^ ↗ preprocessing ^a ^b ↗ fz-speed-quality ^ ↗ fz-outliers ^ ↗ median-filtering FitzGerald, Derry (2010-09). Harmonic/Percussive Separation Using Median Filtering. Proceedings of the 13th International Conference on Digital Audio Effects (DAFx-10). Graz. https://dafx10.iem.at/proceedings/papers/DerryFitzGerald_DAFx10_P15.pdf.
  3. ^ ↗ dr-applications ^ ↗ dr-abstract ^a ^b ↗ dr-beta ^a ^b ↗ dr-params Driedger, Jonathan; Müller, Meinard; Disch, Sascha (2014). Extending Harmonic-Percussive Separation of Audio Signals. Proceedings of the 15th International Society for Music Information Retrieval Conference (ISMIR 2014). https://doi.org/10.5281/zenodo.1415226 https://zenodo.org/records/1415226.
  4. ^ ↗ lh-hpss librosa development team. librosa.decompose.hpss. librosa 0.11.0 documentation. https://librosa.org/doc/0.11.0/generated/librosa.decompose.hpss.html.
Available in