Sign up ×
Music: Practice & Theory Stack Exchange is a question and answer site for musicians, students, and enthusiasts. It's 100% free, no registration required.

Parsons code is a notation of the overall shape of a melody. Wikipedia describes it thus:

The Parsons code, formally named the Parsons Code for Melodic Contours, is a simple notation used to identify a piece of music through melodic motion—the motion of the pitch up and down. Denys Parsons developed this system for his 1975 book, The Directory of Tunes and Musical Themes. Representing a melody in this manner makes it easy to index or search for particular pieces.

Given a sound file containing a melody, how would a program calculate its Parsons code?

share|improve this question
You should really specify what you mean by "sound file". The format of "sound file" will dictate to what extent it will be possible to extract salient lines, which is crucial to computing parsons code. For example, MusicXML - midi - Wave file are 3 kinds of "sound file" in descending order of feasibility for extracting/computing parsons code. – Roland Bouman Apr 10 '14 at 2:13
I am no sound expert, so I may very well be wrong. I assumed that the encoding is irrelevant. – elpadi Apr 10 '14 at 18:36
@RolandBouman I would have said that of the three file types you mentioned, only the WAV is a sound file. MusicXML and MIDI don't contain waveform data, i.e. sound. For the purposes of this question, as long as the file is indeed a sound file, (Mp3, aac, aiff, etc.) the encoding is irrelevant. – NReilingh Apr 10 '14 at 18:54
If we have a sound file, the problem may be effectively impossible. If we start with MIDI or MusicXML, it's relatively easy. – Kevin Apr 12 '14 at 7:31

1 Answer 1

up vote 7 down vote accepted

It depends.

For most music the answer is no, since this amounts to transcribing, which is still most accurately done by humans. There exist libraries of Parson's codes for existing known themes and songs.

For a sound file that consists of a single melody line in isolation, this becomes much more practical. All there is to do is generate an FFT for each point in time, find the peak Hz value, and then write some simple AI to track the upwards and downwards movements of that Hz value over time. This is how "theme recognition" websites work that allow you to find a melody using a computer microphone--the recorded sound is processed into a Parson's code, which is then compared with a database of known codes for various themes, which are returned as results.

share|improve this answer
just for clarity - what's "FFT" ? – user2808054 Jan 12 at 17:17
@user2808054 Fast Fourier Transform. Thanks for the note - I added a link. – NReilingh Jan 12 at 22:33
+1 for the link :-) – user2808054 Jan 13 at 12:34

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.