Exploring Inherent Properties of the Monophonic Melody of Songs

Melody is one of the most important components in music. Unlike other components in music theory, such as harmony and counterpoint, computable features for melody is urgently in need. These features are highly demanded as data-driven methods dominating the fields such as musical information retrieval and automatic music composition. To boost the performance of deep-learning-related musical tasks, we propose a set of interpretable features on monophonic melody for computational purposes. These features are defined not only in mathematical form, but also with some considerations on composers 'intuition. For example, the Melodic Center of Gravity can reflect the sentence-wise contour of the melody, the local / global melody dynamics quantifies the dynamics of a melody that couples pitch and time in a sentence. We found that these features are considered by people universally in many genres of songs, even for atonal composition practices. Hopefully, these melodic features can provide nov el inspiration for future researchers as a tool in the field of MIR and automatic composition.


page 1

page 2

page 3

page 4


Neural Translation of Musical Style

Music is an expressive form of communication often used to convey emotio...

Music Composition with Deep Learning: A Review

Generating a complex work of art such as a musical composition requires ...

Exploring Exotic Counterpoint Compositions

In this paper, first musical compositions are presented, which are creat...

BacHMMachine: An Interpretable and Scalable Model for Algorithmic Harmonization for Four-part Baroque Chorales

Algorithmic harmonization - the automated harmonization of a musical pie...

Interplay between musical practices and tuning in the marimba de chonta music

In the Pacific Coast of Colombia there is a type of marimba called marim...

A Tutorial on Deep Learning for Music Information Retrieval

Following their success in Computer Vision and other areas, deep learnin...

A Statistical Model for Melody Reduction

A commonly-cited reason for the poor performance of automatic chord esti...

1 Introduction

In recent years, with the improvement of technology, especially machine learning and deep learning technology, the music industry has undergone tremendous changes, and interdisciplinary research fields such as automatic music generation, music recommendation systems, and automatic music evaluation have gradually developed. All most all the current state-of-the-art methods in these fields are closely related to deep learning.

As we know, in modern deep learning technology, the super large amount of high-dimensional data and effective feature extraction are the keys to success. However, unlike the image, audio or natural language, the popular deep learning technology is not easy to perform feature engineering on very low-dimensional music information, especially the monophonic melody. Here, we only discuss the music of Midi / Sheet Music or similar format, without considering the audio after recording and mixing. The main difficulties are the following.

  • First, it is difficult for music to obtain a very large dataset or corpus with a uniform format and complete labeling, like image and natural language, and it is necessary to have professionally trained personnel to organize such a music dataset.

  • Second, unlike audio, music data (for example in Midi format) is very low-dimensional, and multi-track music always can be highly structured, existing deep learning technologies does not perform well on such data.

  • Third, for image, some mathematicians have used the methods of partial differential equations and inverse problems to establish a set of rigorous theories; for audio, digital signal processing provides a number of interpretable feature extraction methods; for natural language, there is computational linguistics based on linguistics which provides an interpretable research method.

In some branches of music theory, such as Harmony, Counterpoint and Orchestration, there are some self-consistent theories for music creation and evaluation, and even theoretical explanations based on mathematics, physics, etc. Except for theoretical explanations based on audio or acoustics, for music data based on Sheet Music or Midi format, some of the existing methods use more abstract mathematical theories, such as Abstract Algebra and Topology, to try to explain some of the underlying phenomena. Their common problem is that they are mathematically beautiful, but because they take high computational complexity or cannot be computed by machine at all, we cannot use it to help us design algorithms. Other existing methods are more like statistics of midi events, such as counting their histograms, without touching composition theory or human perception (whether in the perspective of creation or appreciation). These low-level semantic features are rigid and difficult to use flexibly. For example, if we directly intervene in the automatic generation algorithm with a given melodic interval sequence and rhythm sequence as conditions, this is rigid and inconsistent with the way humans compose music, and maybe the melody will be, and even the generated melody will be a mess. But if we don’t put any conditions on the generation algorithm, they will become uncontrollable, and even the generated melody will still be a mess.

Therefore, for the music data we are discussing here, there is still a lack of a set of high/intermediate-level semantic, human-perception related, interpretable and computable feature extraction methods, such as Melspectrogram in audio, to enable existing deep learning-based algorithms for automatic music generation or automatic music evaluation more interpretable or controllable, or they can be used to design corresponding rule-based algorithms.

In this paper, we focus on the monophonic melody of songs, explore its inherent properties. This means that, we only study the monophonic melody, no matter which temperaments, scale modes, even whether tonal or atonal they are, and we do not consider the relationship between melody & harmony or melody & lyrics, only focus on the inherent properties of the monophonic melody of songs. Inspired from Psychology and Musicology/Composition Theory, we propose some coarse-grained features of melody mathematically from a macro perspective, like

  • Melodic Center of Gravity/Melody Center: Used to demonstrate the sentence-wise contour of the melody flow.

  • Local/Global Melody Dynamic: Used to study the dynamic inside a sentence (mainly about the melody which couples the pitch series and rhythm).

  • Rhythm Dynamic: Used to study the dynamic inside a sentence (mainly about the rhythm).

All the above features are designed based on human perception and human composition process, and all have their specific musical significance. The framework we propose is flexible, and some of these modules can be adjusted or other quantities constructed in accordance with the assumptions in the framework to solve different problems. To the best of our knowledge, this is the first work to study the inherent properties of the melody in this novel and rigorous way. Since images, audio, and natural languages have all experienced interpretable feature extraction research based on human perception before entering the era of deep learning, they also designed the corresponding most advanced deep learning technologies based on the work of these predecessors. The lack of similar work in music may be the biggest reason for the poor performance of existing deep learning methods. Therefore, we think that similar work needs to be done on music, so this article may be one of the pioneers.

2 Background and Preliminaries

First of all, we must deeply understand how people write melody, what people think about when writing a melody, and the general characteristics of melody written by pros.

2.1 How do people write melody?

When pros write melody, they always start with the Motif111In music, a motif About this sound(pronunciation) (also motive) is a short musical phrase, a salient recurring figure, musical fragment or succession of notes that has some special importance in or is characteristic of a composition: ”The motive is the smallest structural unit possessing thematic identity”. —-From Wikipedia–the basic module in a song/music. Then they use some composition techniques, which they may call transformation222such as translation, rotation, and scaling, sometimes they may use modulation and tonicization, to make a song logically and not boring from their basic motifs. But these are not enough. In order to write a complete song, we also need to consider about the structure, which is called Musical Form333In pop music, people always use verse, pre-chorus, chorus as the notations of structure. In classical music, we have some concept of forms such as sonota, rondo. In Chinese, we also use Qi Cheng Zhuan He to denote similar meanings..

Here we take a famous song, I will wait for you by Michel Legrand444http://michellegrandofficial.com/, as an example to demonstrate these concepts mentioned above. It is shown in Fig. 1. All the analyses is in the caption of Fig. 1.

Figure 1: Brief analysis of this song: Motif: The yellow box is the motif for this song, the green one is a translation of the motif, the pink one is an inverse(rotation) of it, the red one is scaling of the motif, and the purple one is inverse(rotation)+scaling of it. Musical Form: A denotes the verse, B denotes the chorus, and C denotes the Recapitulation. Number above the slur means the index of this sentence. Three figures in the second column denote sentence-wise MCG, GMD and RD respectively. Their x-axis is the index of sentences. And we choose non-normalized L-GMD for this song (choosing non-normalized is because the sentences in this song are neat).

From the example above, we can see/hear that the composer will design the undulations between different parts, in other words the overall melody contour; then within each part, the sentences are also related each other; the dynamic/tension contrast of the sentences between different parts is distinct.

2.2 General Characteristics of Good Melodies

Regardless of composer’s personal characteristics and different genres/styles, here we only talk about the general characteristics of good melodies.

First of all, a good melody should be easy and comfortable to sing. In other words, it should have smooth rhythm and melody line, match the range of human voice, and last but not least, it should have no ridiculous oversized jumps.

Then, a good melody should be melodious. It means the melody should match the chord of the corresponding accompany, and it has catchy chord progression555like chord progression of Canon in D by Pachelbel, or IV-V-III-VI-II-V-I which is very popular in C-pop and old J-pop.. In addition to the relationship between melody and chord, it should also have reasonable melody dynamic in different parts of it, such as the contrast between verse and chorus.

Some of the famous melodies written by pros always have unexpected surprises, such as reharmonization in their own way, or personal melody lines. These characteristics are why we can easily distinguish them from thousands of songs, or we can say why these pros are called pros and they are famous.

2.3 Related Works

As we said above, there are some explanatory works on music theory, some of them such as [tymoczko2010geometry][mazzola2012topos] are explained based on the theory of mathematics or physics, theories they used are abstract and difficult to understand and calculate, or even can not be computed by computer.

Some studies, such as [mckay2006jsymbolic][mckay2018jsymbolic], directly perform some statistics on midi events (such as histograms of pitch and duration), and then use these statistical quantities as features for machine learning algorithms to use. But the limitation of this method is too low-level semantics, far from human perception, and even their feature dimensions are higher than midi or symbolic music itself, so it is difficult to perform well for deep learning algorithms in some tasks such as automatic music generation and objective evaluation.

There is also some work from a psychological perspective, such as [quinto2013emotional][thomassen1982melodic][condit2019deconstructing][toussaint2012pairwise][temperley2004cognition]. They have proposed some useful quantities like nPVI to measure the dynamic of rhythm, and used these quantities as tools to study the rhythm relationship between speech and music, also proved that these quantities are consistent with human perception from the perspective of psychological experiments. However, their common problem is that they ignore the logical considerations of human composition process. In other words, they ignore the inherent logical structure of music and do not propose a rigorous framework for music research.

Although some studies on music using very abstract mathematical theories may seem to clarify its internal structure, they can hardly be calculated, so that it is hardly to be used for algorithm design.

Some existing music generation algorithms using deep learning technology, such as [huang2018music][huang2020pop][yang2017midinet][dong2018musegan], some of them which seem to use advanced technology, are controlled directly using a fixed harmony progression or melody interval relationship, but their generated music is neither illogical, unmelodious, or even unstructured. These rigid and low-level semantic features do not fit well with human perception and composition. As we said before, it enlightens us to start with the human composition process, design some feature extraction methods that are consistent with human perception, and control the automatic music generation process with these coarse-grained features.

3 Study Melody in a Rigorous Mathematical Way

In this section, we will define some quantities mathematically with perceptual and musical explanations from different aspects of the melody, and give some calculation and visualization examples in 3.3.

First we give a mathematical definition for note, rest and melody.

Definition. Given a Note , it has two basic components: (relative) pitch and (relative) duration . A Rest only has duration components, so we use to represent its duration. A monophonic Melody is defined as where is a note or a rest .

Here we only consider pitch and duration aspects of the note, and note series of the melody, which means we do not consider the bar. And notice that we write relative pitch and relative duration above, it means in some features we need to choose the units of pitch and duration, we will discuss it later.

3.1 Sentence-wise Contour of Melody

When people listen to a song, it is easy to feel whether the tone of the sentence is high or low, or that they can easily feel which of the two sentences has a higher tone (the tone here represents the macro perception of all the pitches of a whole sentence). But in a sentence, there may be a lot of fragmented notes, and even they may produce poly-words on one note or poly-note on one word due to the problem of lyrics language. Even in such complex sentences, people can still perceive the sentence-wise movement process. So we need some tools to help machines get the quantitative measurements of this phenomena. For this purpose, here we will introduce the Melody Center of Gravity.

Definition. Given a monophonic melody without rest, we formalize it as , where , and use to denote its length . Then we define , the Melodic Center of Gravity (MCG) of this given melody as follows,


Due to the homogeneity of in the above formula, we don not need to consider its unit.

As for the relative position of the pitch, we may adjust the weights of the internal and external tones (both for harmony and scale), not simply use semitone as the basic unit.

Note that this definition is only about melodies without rest. Considering the sense of listening to the whole sentence and the expression way of people playing or singing, if the rest is in a musical sentence, we can ignore it and add its duration to the previous note during the calculation of this sentence.

Although we have been emphasizing the sentence-wise MCG calculation here, we can also calculate MCG of each bar or full song to measure the corresponding perceptual features.

Remark: If we set all durations to be 1, then we have a special type of MCG, which is called Melody Center, in some literature ([mckay2006jsymbolic][mckay2018jsymbolic]) they also call it Mean Pitch.


However, we do not recommend this. We can see the following example in Fig. 2. MCs of these two melody are the same, but it ’s clear that the latter is higher overall. So from this, we can see the need to propose MCG which is more flexible and couples pitch and time666In practice, we can choose proper pitch unit and duration unit to change to adjust the weight of different notes according to factors such as different scales or chords..

Figure 2: Example for MCG and MC

3.2 Dynamic inside a Sentence

Let us begin with a famous film music – Shark Theme from ”Jaws” by John Williams. We only consider its bass melody line shown in the first column of Fig. 3. It’s very simple, that is, two fixed different pitches jumping back and forth according to the given simple groove777In music, groove is the sense of propulsive rhythmic ”feel” or sense of ”swing”. In jazz, it can be felt as a persistently repeated pattern. It can be created by the interaction of the music played by a band’s rhythm section (e.g. drums, electric bass or double bass, guitar, and keyboards)..

Figure 3: Bass melody line of Shark Theme from ”Jaws” by John Williams

We can easily find that from the perspective of human perception and experience, this melody is not so flat (even if only considering this melody), maybe we can compare to another melody in the second column of Fig. 3. which has only one single pitch following this groove to get that the previous melody is not so flat, but its rhythm pattern/groove is very flat. So, how to characterize these feelings more rigorous?

3.2.1 Local/Global Melody Dynamic

The first thing we should pay attention to is the Melody Dynamic. As we said above, we need a quantity to help us measure the Melody Dynamic which couples pitch and duration. Before we give the mathematical definition, let us see some examples first.

We show some pairs of melody pieces in Fig. 4. Both intuitively and experimentally (the experiment result is shown in 4.1, melody pieces in the first column of Fig. 4 are more flat than the second column, except for the first and fourth row (these are equally flat).

Figure 4: Examples for Local Melody Dynamic

Next, we formalize the above description and give some rigorous definitions in a mathematical way. Before all that, we assume that for a fixed system, its units of (relative) pitch and duration are fixed888Note that due to the setting of , these two units cannot be specified at will. They need to be set according to the actual situation. Here we set a semitone as the pitch unit and a quarter length as a duration unit (experiments in 4 will discuss about the rationality of this setting)..

Definition. Define as the

Pitch Moment

of a given note , which is a quantity that couples pitch and duration. Empirically, it should be monotonic about both and . Here we choose


for simplicity.

In some literature of psychological research (such as [temperley2004cognition]), people have studied that for a melody/rhythm, people have a better perception of two adjacent terms which is called pairwise. So here we will introduce a very important concept for the melody dynamic between two successive notes, which we call Local Melody Dynamic.

Definition. Given two successive notes , we use


to measure their dynamic difference, where are derived from , where should allow some basic perceptual assumptions as follows. It’s called Local Melody Dynamic(LMD) induced by between and .

Perceptual Assumptions of 999The order of these five assumptions is consistent with the column order of Fig. 4.:
Symmetry of notes:

Decay over time: , where
Convexity in time: , where
Translation invariance in pitch: , where
Monotonicity of pitch interval: , where , and

In order to illustrate that these assumptions are not contradictory to each other and to facilitate subsequent computations, we directly give a possible as follows which satisfies all the assumptions,



Finally, we give some quantities of the global dynamic of a whole sentence through the above Local Melody Dynamic.

Definition. Given a monophonic melody without rest, we denote


as ’s Local Melody Dynamic Sequence(LMDS). Then we can define


to measure the melody dynamic of the whole sentence, where is a kind of norm. It’s called Global Melody Dynamic(GMD) induced by of . Accordingly we can define the normalized GMD(nGMD) as follows,


where is the length of Local Melody Dynamic Sequence of .


  • If here we use L1 norm, it’s a bit like total variation101010a mathematical concept from Real Analysis of a given function.

  • If here we use L norm, it means we use the maximum local melody dynamic to measure the given melody’s global melody dynamic.

  • Different norms measure different types of dynamic:

    • L-GMD irregularity

    • L1-(n)GMD time-dependent dynamic

The calculation and visualization demo is shown in 3.3.

Alternative LMD/GMD

Here we also propose an alternative version of LMD and GMD, which is more easy to understand but does not perfectly satisfy the perceptual assumptions required by LMD.

The Alternative LMD/GMD is inspired by Complex Number. We consider the pitch and duration of a note as two orthogonal dimensions, that is, the real and imaginary parts of a complex number. Then we can use the angle between two complex numbers to measure the difference between the two notes, in other words, to measure how much effort it takes to move from one note to another (rotation angle). The mathematical definition of Alternative LMD is as follows.

Definition. Given two successive notes , we use


to measure their dynamic difference alternatively, where . It is called Alternative Local Melody Dynamic111111The units of pitch and duration here also need to be considered carefully..

The definition of Alternative Global Melody Dynamic is similar to before.

3.2.2 Melody Dynamic Range

Above we studied the pairwise melody dynamic in a sentence. But when people listen to music, they can also perceive the difference between the highest and lowest pitch in a sentence or whole music([temperley2004cognition]), here we call it Melody Dynamic Range.

Definition. Given a monophonic melody where is a note or a rest , then we define its Melody Dynamic Range(DR) as follows,


where is the pitch sequence extracted from in order.

It can be known from the definition and human perception that, the larger the melody dynamic range, the wider the (voice) range of this sentence, and the greater the tension/expression in some senses.

3.2.3 Rhythm Dynamic

As we said before, the melody is composed of notes, and the notes are composed of pitch and duration, then the melody is composed of a pitch sequence and a corresponding duration sequence. Considering only the pitch sequence of melody is missing its musical meaning, that is, it cannot be called music. But considering only the duration sequence of melody has its own musical meaning—-it is called rhythm. Above we have delved into the properties of the melody, next we will focus on the rhythm.

In some literatures ([toussaint2012pairwise][condit2019deconstructing]), people use PVI (Pairwise Variability Index) or nPVI (Normalized Pairwise Variability Index) (defined in 11) to measure the variability of specific time series like rhythm of speech or music. Due to the limitation of these quantities(can not work across style/genre and other things), we design a new framework to analyze the dynamic/variability of the rhythm.

Definition. For a given time series , its nPVI is defined as follows,


First, we expanded the definition and framework of PVI and nPVI like LMD and GMD, to study the rhythm in more detail.

Definition. Given a monophonic melody where is a note or a rest , then we use to denote its rhythm, which means only take the duration of notes and rests in .

Let , where , we call it PV Sequence. Then we have


But even the refined/expanded PVI has limitations. Let’s see an example in Fig. 5.

Figure 5: The first measure’s nPVI is 0, and the second measure’s nPVI is 66.66.

Here we don’t discuss the definition of style/genre too much. We only assert that,
If we only changed the groove (such as making a song swing), the rhythm dynamic of the melody itself will not be changed. In other words, the Rhythm Dynamic of a given melody should be a property that is style/genre-agnostic and inherent in itself. As for how to distinguish the two melodies in Fig. 5, the previously defined melody dynamics are enough (the melody dynamics of the two melody are 42.64 and 182.57 respectively).

So we need to define a style/genre-agnostic Rhythm Dynamic. In other words, the Rhythm Dynamics of the two melodies in the above example should be the same. Next we give a mathematical definition of Rhythm Dynamic.

Definition. (All notations are the same as PV Series.) Let , where 121212If the denominator in one of the above functions is equal to , the value of the function is taken as ., it requires ,131313This is consistent with human perception. Because it ’s hard to say what the inherent rhythmic dynamic of the two successive notes is, because they do not move forward. we call this quantity as Rhythm Dynamic Series, and call its norm


as Rhythm Dynamic (no Global),


as Normalized Rhythm Dynamic.

We calculate the rhythm dynamics of the two melodies in Fig. 5 by the above definition, after that we can get that they are both .

3.3 Examples

The second column of Fig. 1 shows our analysis of a complete song in the first column, we plot sentence-wise MCG, GMD and RD of it. We can see from these figures that when the chorus part (B) is reached, although the RD is very small (which means the rhythm is relatively flat), both MCG and GMD are bigger than those in verse (A& C). This shows that although it is relatively flat compared to verse from the perspective of rhythm, the melody dynamic in chorus are still bigger than verse. In line with human perception, it illustrates the rationality of our definition of Melody Dynamic and Rhythm Dynamic.

Here we show three more songs and their analyses in Fig. 6, 7 and 8. In these 3 song we choose normalized L-GMD, because the sentences in these songs are not so neat, normalized GMD would be more appropriate.

Figure 6: Autumn Leaves
Figure 7: Fly Me to the Moon
Figure 8: Love Yourself (part)

4 Experiments

4.1 Choice of the pitch and time duration units

Here we briefly describe the experimental process and results. We have 10 participants (2 pros, 3 enthusiasts and 5 ordinary people) in this experiment. For each participant, we let them listen to 10 music from the real-world music dataset mentioned in 4.2, and plot 9 versions of pictures which are similar to the second column of Fig. 1. The difference between these nine versions is the choice of the pitch and time duration units. Each participant selects a set of pictures (MCG, GMD and RD) that he thinks best represent his perception of the song, and the final score is the cumulative number of votes for each version. Before the experiment, each participant was explained in detail what these three quantities (MCG, GMD and RD) should represent. Details are in the table 1.

From this table, we can conclude that (1, 1) is the most consistent with human perception among the nine choices.

Version Pitch unit Duration unit Score
1 0.5 0.5 3
2 0.5 1 5
3 0.5 2 4
4 1 0.5 7
5 1 1 56
6 1 2 8
7 2 0.5 2
8 2 1 3
9 2 2 2
Table 1: Pitch unit/semitone, Duration unit/quarterlength

4.2 Extract these features in real-world music dataset

We have two real-world music dataset, one is Hooktheorytab (lead sheet) dataset141414https://github.com/wayne391/lead-sheet-dataset, the other is a C-pop dataset which is made by ourselves. We selected some data on the two data sets for experiments, and all the experimental data are in our github repo151515https://github.com/water45wzh/exploring_melody. All the code and useful data are shown in this repo.

5 Conclusion and Future Work

The importance of studying the inherent properties of melody is self-evident, whether for objective evaluation of a melody or creating melodies by machine based on rules or deep learning. Due to the low-dimensionality of highly structured music data, it’s difficult to use deep learning or other dimensionality reduction method to do feature engineering to extract inherent interpretable properties for it. In this paper, we focus on the inherent properties of the monophonic melody of songs. First, we define the melody mathematically. Then we define some coarse-grained quantities based on melody composition technique and human perception (such as Melodic Center of Gravity, Local/Global Melody Dynamic, etc.) to study the inherent properties of melody, we noticed that in a sense, some of these quantities are style/genre-agnostic, and can work across different temperaments or tonality/atonality. Finally, we take some real-world songs as examples to study the meaning of these quantities. Although we have not proposed criteria for evaluating whether a melody is good or bad, just propose some novel interpretable quantities to characterize some of the inherent properties of the melody. We believe, and try to apply these features to promote research on the objective evaluation or automatic generation of melody based on rules or deep learning in the future.