In the previous tutorial on melody we created a simple melody. Now we will learn to combine it with harmonies.
For this we will learn how to use harmony
, chord
and inversion
attributes of the entities.
Each entity has the chord
attribute which controls how many notes are actually played.
So instead of playing the default single note, you may play the whole triad.
D♭ offers a finer control of the notes played. Similarly as in the previous examples,
they are indexed relative to the base tone of this entity. So you can write the triad as
[0, 2, 4]
. Integer arrays can be implicitly casted to chords and interact with them.
A single integer n
behaves like an array [n]
. Collection expressions (new in C# 12)
make the notation short and simple.
The default chord for each entity is [0]
. You can freely add and remove single or multiple tones from the chord using +
and -
.
Chords can be inverted in both directions. Positive inversions increase the lowest chord note (bass)
by an octave so that it becomes the top note of the chord. For larger chords several octave steps may be necessary.
Positive inversions can be imagined on a keyboard like rotations to the right.
Vice versa, a negative inversion decreases the top note of the chord by one or more octave steps
so that it becomes the lowest tone of the chord. Negative inversions imagined on a keyboard
are like rotations to the left. The default value of inversion
is 0
.
The most trivial harmonic progression in western music would switch between the tonic and the dominant back and forth.
We can easily create such a progression with the help of the modulo operator %
to distinguish between even and odd entites.
We may use a random choice to place the dominant either above or below the tonic.
Notice that the two dominat options are in fact three inversions away. We can also include the two inversions inbetween that are not in the root form.
Note that you could exchange harmony
for degree
and the result would sound just the same.
This is because in fact degree stands for a degree in a harmonic function.
So in C major @harmony = 0; @degree = 2;
stands for E but @harmony = 4; @degree = 2;
is interpreted as B.
You see that if one of them is zero, the other one fully takes over.
D♭ put no restrictions on the pair of attributes.
It is up to the composer to deal with them in a semantically correct way.
The following example shows a combination of harmony
and degree
.
The result is a simple ostinato build on top of the harmony. The relative
degrees of the ostinato always stay the same, but the harmonic progression
shifts them according to the current harmonic function.
We may also develop the ostinato idea using chords. It is better to increase the overal duration as playing chords as fast as in the previous example would be very difficult.
Arpeggio
is a nice function to decompose a chord into entities with single tones.
Each chord note lands in a single degree. An arpeggion on a triad (0,2,4)
results
in three entities (0),(2),(4)
. In fact they all become (0)
with degree
attributes
adjusted accordingly.
The arpeggio portion can be specified to be shorter so that the chord sounds longer.
A similar effect can be also achieved with a Split
but there the tones will not overlap anymore.
A parameterless Split
divides notes in a chord
so that they will be played
as in ostinato one after each other. If the chord
contains less than two notes,
no operation is performed.
Let us now repeat the progression example with the Arpeggio
added. Note that it must be
applied as last, as it breaks the chords into single tones and inversions would have no effect on single tones.
We can now create a more complex progression randomly. We will still start on the tonic and end on the dominant.
Random generation of harmonies can easily get out of control when too much of randomness is involved. Maybe some of the examples you just heard sounded awkward every now and then. Chords of a progression usually obey several rules, or better said constraints. D♭ supports generation of melodies, harmonies and rhythms by means of constraint programming. These advanced topics will be discussed in a later chapter.
Harmonies presented here are composed only of diatonic tones from the current key. In the next tutorial you will learn how to switch between keys and modes to gain access to the full range of chromas.