- Introduced by
- Anssi Klapuri
- Year
- 2008
- Type
- Polyphonic audio analysis
- Family
- Feature extraction
What does it do?
Melody extraction is the task of automatically recovering the main melodic pitch contour from polyphonic music recordings, in which several sources sound at once.
It is closely related to pitch detection but adds a step that decides which of the candidate pitches belongs to the melody. The task emerged from music transcription research in the 2000s and is used in applications such as cover song detection and music-to-lyrics alignment.
The intuition behind the method
Listeners usually hear one main line even in a dense texture, and melody extraction tries to reproduce that judgement. The method relies on the observation that the melody often differs from the accompaniment in measurable ways: it may be louder, have longer notes, sit in the lead vocal or lead instrument, or occupy a particular pitch range. The algorithm scores each candidate pitch track for salience and then selects a trajectory that is both salient and temporally continuous. In this sense it is a polyphonic pitch tracking problem with an added ranking step.
History
Melody extraction research developed in the 2000s out of automatic music transcription, which provides the wider context for estimating pitches from polyphonic audio. Klapuri's work on automatic music transcription (Klapuri, 2008) gives background on that field. Salamon and Gómez (2014) address melody extraction from polyphonic music signals using pitch contour characteristics. Bittner et al. (2017) study lead and accompaniment separation, a related problem in which the lead voice is separated from the accompaniment.
When to use it
Choose melody extraction when the question concerns the main line of a polyphonic recording, for example in cover song identification, melodic analysis, or singing voice analysis, and when the material has a dominant voice or lead instrument. It suits music with a clear melody and moderate polyphony. Do not use it when every pitch in the signal is needed, since pitch detection or transcription is the appropriate tool. It is also a poor choice for ensemble music with no dominant voice, for purely accompaniment tracks, and for monophonic recordings, where simple pitch tracking already gives the melody. The approach assumes a dominant, reasonably continuous melodic line whose presence can be judged frame by frame; evaluation additionally assumes a consistent definition of voiced frames in the reference annotation.
Limitations and considerations
- Defining the melody is ambiguous in dense orchestration. When two lines have similar salience, the selected trajectory can switch between voices, and the signal alone does not settle which line is the melody.
- Learning-based systems need annotated melodies for training. Annotation is labour-intensive, and learned salience and transition behaviour reflects the conventions of the annotated training data.
- Octave errors and fast melismatic passages are known failure cases. The continuity constraint that suppresses implausible jumps can also smooth over genuine rapid pitch changes.
- Performance can vary strongly across genres. Models trained mainly on pop vocals may transfer poorly to instrumental jazz or classical music.
Source conditions do not replace independent scientific review or validation by an analysis engine.
Strengths
- It targets a single melodic line rather than every pitch present, so its output suits tasks that need one theme, such as cover song identification.
- Salience ranking and a continuity constraint can help follow a lead voice through moderately dense accompaniment, where a frame-by-frame pitch tracker would report many competing pitches. Success depends on the lead voice being the most salient line.
- The output is a time-aligned pitch contour, which can feed music-to-lyrics alignment and singing voice analysis.
Applications
- Cover song detection and music recommendation based on melodic similarity.
- Automatic music-to-lyrics alignment and karaoke synchronization.
- Singing voice separation for music remixing and production.
- Music transcription and optical music recognition, where a melodic contour can serve as an additional cue.
- Musicological analysis of melodic contour and thematic variation across compositions.
How it works
How it works
Compute a time-frequency representation of the audio, such as a constant-Q transform or mel-spectrogram, and extract several pitch candidates in each frame. These candidates are the material that the later ranking step chooses from.
Systems differ in how they score the salience of candidate pitches and how they link pitches across neighbouring frames. Some learn these behaviours from annotated melodies, for example with recurrent networks or hidden Markov models that capture pitch continuity, and the annotated melodies serve as training targets. Others rely on pitch contour characteristics, as in the approach of Salamon and Gómez (2014).
Select one pitch trajectory across frames by combining the salience scores with dynamic programming. The objective typically sums a per-frame salience term over the chosen trajectory and subtracts a penalty for pitch jumps between neighbouring frames, which favours smooth transitions over implausible jumps. Exact formulations differ between systems. Frames in which no melody is judged to be present are left unvoiced.
Compare the predicted contour with ground-truth annotations using frame-level measures. Raw pitch accuracy is the fraction of reference voiced frames whose estimated pitch lies within a stated pitch tolerance of the reference pitch. Raw chroma accuracy applies the same test with octave differences ignored, which separates octave errors from wrong pitch classes. Voicing recall is the fraction of reference voiced frames that the method also marks as voiced, and voicing false alarm is the fraction of reference unvoiced frames that the method marks as voiced. Because the scores are computed per frame, the result depends on how voiced frames are defined in the reference annotation, so results are comparable only when the same annotation and pitch tolerance are used.
Common pitfalls
- Confusing melody extraction with pitch detection. Pitch detection finds the pitches present in each frame; melody extraction ranks them and selects one trajectory. Treating the two as equivalent discards the ranking step that defines the task.
- Ignoring voicing. A melody is meaningful only where a line is actually sung or played, so pitch values reported during rests or silences are noise. Voicing decisions must be evaluated separately from pitch accuracy.
- Overgeneralising from benchmark results. Evaluation test sets such as those used in MIREX are curated, and real-world recordings are often harder, so benchmark scores may overstate performance on new material.
Frequently asked questions
Is melody extraction the same as pitch tracking?
No. Pitch tracking finds the pitches present in the audio; melody extraction identifies the single perceptually dominant pitch trajectory. Melody extraction uses pitch tracking as an input and adds salience ranking and temporal coherence.
Can melody extraction work on instrumental music?
Yes, if there is a clear lead instrument such as a solo violin or trumpet. It struggles with orchestral ensemble music in which no single voice dominates, or with purely rhythmic accompaniment.
What is the difference between melody and harmony?
Melody is the single top pitch contour perceived as the main line. Harmony is the simultaneous arrangement of multiple pitches forming chords. Melody extraction recovers one line, while harmonic analysis must infer the rest.
How accurate must melody extraction be for real-world use?
The required accuracy depends on the application. Music analysis may tolerate more error than music matching or transcription, and tolerance to small octave errors also varies by use.
Related methods
Sources
Salamon, J., & Gómez, E. (2014). Melody extraction from polyphonic music signals using pitch contour characteristics. IEEE Transactions on Audio, Speech, and Language Processing, 20(6), 1759-1770.
Open publication referenceKlapuri, A. (2008). Automatic music transcription as we know it today. Journal of New Music Research, 33(3), 323-337.
Open DOI referenceBittner, R. M., McVicar, M., Salamon, J., & Ellis, D. P. (2017). An analysis of lead and accompaniment separation in polyphonic music. In Proceedings of the International Society for Music Information Retrieval Conference.
Open publication reference