## Melodic Dissonance

Now I will take a shot at defining melodic dissonance.

The general idea is that we want notes to be in coherent lines. Big jumps are dissonant; small jumps (e.g. whole tones and semitones) are consonant. So dissonance increases with interval; but after a while, the notes start sounding like they are part of separate lines, and the dissonance starts decreasing with interval.

Melodic dissonance is measured between each non-simultaneous note pair of the phrase; so we measure it separately for each combination of two non-simultaneous notes in the phrase, and then take the sum of that. For efficiency we may only measure notes that are sufficiently close to each other. The metric should be defined such that melodic dissonance decreases with the distance between note beginnings. For now we give the general definition which measures the melodic dissonance between two arbitrary notes.

First let us ignore the distance, and pay attention only to the interval. The dissonance is lowest with notes that are very close (a semitone or two). Then it increases as the notes increase in distance, then it decreases as the distance increases further (because the notes are perceived as being part of separate melodic lines). We will say that the melodic dissonance is greatest at a distance of half an octave (a diminished fifth, or six semitones).

Let i be the interval between the two notes. Let p = 6 be the point of peak dissonance. Then the melodic dissonance is:

D1 = k1^i if i

p

k1 is a constant calibrating the speed of dissonance increase before the peak. k2 is a constant calibrating the speed of dissonance decrease after the peak. Reasonable values would be:

k1 = 1.5
k2 = 1.2

This would yield the following dissonance values:

i D1
0 1
1 1.5
2 2.3
3 3.4
4 5
5 7.6
6 11.4
7 7.9
8 6.6
9 6.6
10 5.5
11 4.6
12 3.8

So that is two notes, without taking temporal distance into account. Now let us add temporal distance. Dissonance decreases with distance. So if the temporal distance (in ticks) between the beginnings of two notes is d, then:

D2 = D1 / (k3^d).

k3 is a constant calibrating the speed of dissonance decrease with temporal distance. Reasonable values would be slightly larger than 1.

To calculate the melodic dissonance of the whole phrase, we calculate D2 for every combination of non-simultaneous notes, take the average, and multiply by the length of the phrase. This gives us a result similar to the result we got with harmonic dissonance, where adding complexity to the phrase does not necessarily make it more dissonant, but the dissonance is still proportional to the phrase length.

Alternatively, maybe longer phrases should not be more dissonant. Then the melodic dissonance is the average of all of the D2s, and the harmonic dissonance is not the integral of the instantaneous harmonic dissonances, but the integral over the phrase length.