Classes (extension) | UGens > Analysis | UGens > FFT

MedianSeparation : MultiOutUGen : UGen : AbstractFunction : Object

Separate harmonic and percussive parts of a signal


Implementation of source separation model outlined in:

Derry FitzGerald (2010) "Harmonic/Percussive Separation using Median Filtering" International Conference on Digital Audio Effects (DAFx)

The algorithm can work quite effectively, though you may hear spectral artefacts in the reconstruction depending on the nature of your input signal. Try it on piano sounds to hear really beautiful separation. There are various parameters to the analysis, and I've generalised the original algorithm a little, allowing mean separation as well as median (which is much cheaper CPU cost). Higher quality separation necessarily requires greater latency in calculation.

Class Methods, fftharmonic, fftpercussive, fftsize: 1024, mediansize: 17, hardorsoft: 0, p: 2, medianormax: 0)

fft, fftharmonic, fftpercussive, fftsize=1024, mediansize=17, hardorsoft=0, p=2, medianormax=0



Audio input to track, which has been pre-analysed by the FFT UGen; see examples below


Output FFT buffer for writing the harmonic part


Output FFT buffer for writing the percussive part


The algorithm needs to know the FFT size at constructor time, so pass it in here (all of the buffers for the previous three input arguments should have this size).


How many FFT frames and bands to take a median over. The median in the horizontal direction (strength of tonal consistency, harmonic element) is compared to that in the vertical (percussiveness) to determine if a particular spectral bin will belong to the harmonic or percussive reconstruction.


A flag, 0 for hard, 1 for soft. Hard separation is an either/or for allocation; soft allows a blended sound based on the relative levels of horizontal versus vertical. Each may lead to artefacts, experiment.


A factor from the paper for the soft assignment. Default of 2 is the paper default; 1 would be a linear proportional assignment.


Defaults to using median algorithm, but a lower CPU cost mean (average) can be used via this argument.

Inherited class methods

Instance Methods

Inherited instance methods