D♭ Tutorial: SCALES, KEYS AND MODES

In the previous tutorials we introduced melodies and harmonies. The actual tone is not determined only by harmony + degree. An important role plays the musical key and its mode. This tutorial shows how to deal with the key and mode attributes and how to define own scales.

Major keys

Let us start with a very simple example of a scale.

0
C-1
Code Editor
0.000

Each entity has its own key attribute, so changing the key anytime is straightforward. It defines the base tone of the current key as a chromatic distance to C. So key = 0 corresponds to C major, key = 1 corresponds to D♭ major, key = 2 corresponds to D major, etc. (assuming we did not touch the default mode yet, hence the major mode). The following example plays all the 12 major keys.

0
C-1
Code Editor
0.000

Based on what you have learned about chords in the tutorial on harmonies, you can try to change the previous example to play triads or other chords instead of plain tones.

Modes

The keys are by default major (ionian). Other modes introduce a different sequence of semitones that can help to enrich your compositions. The second most prominent mode is of course the minor mode (aeolian). Just like keys, harmonies and degrees, mode is also a native entity attribute. By default, mode == 0, or using a different notation, mode == Mode.Ionian. In order to switch to a minor key, we need to take Mode.Aeolian instead.

0
C-1
Code Editor
0.000

Important: With constants like Mode.Aeolian you can directly set the absolute mode value. D♭ also offers relative changes. These are not ordered in the same way as it is common in basic music theory: ionian, dorian, phrygian, ... The ordering goes from dark to bright, adding a sharp sign towards bright and a flat sign towards dark. These steps correspond to intervals of fourths:

  • next brighter: ionian (I) → lydian (IV)

  • next darker: ionian (I) → mixolydian (-IV i.e. V)

The full progression from the darkest to the brightest goes as:

  • locrian (VII) → phrygian (III) → aeolian (VI) → dorian (II) → mixolydian (V) → ionian (I) → lydian (IV).

0
C-1
Code Editor
0.000

Edge cases when mode would overflow are handled by increasing or decreasing the key as well:

  • next brighter: C lydian → C# locrian

  • next darker: C# locrian → C lydian

This way, relative mode changes are consistent in both notation and musical color.

0
C-1
Code Editor
0.000

Let us enrich the melody example from the melody tutorial by a little bit of modal variation. Note the dedicated Rnd.Mode random generator that returns a Mode from the given range.

0
C-1
Code Editor
0.000

Accidentals

When changing between modes, sharps and flats are added following the circle of fourths. E.g., after adding a ♭ on D, the next lower mode will add a ♭ to G. Such build-up limits the combinations considerably.

It is also possible to add accidentals that are out of any key-mode combination. The alter attribute adds a chromatic offset to an entity. So the final formula for a tone is: octave * 12 + key + harmony(mode) + degree(mode) + alter.

The next example converts the first D into a D♭ and G into G♯.

0
C-1
Code Editor
0.000

Scales

Up to now all examples used the default diatonic scale and its modes. It consists of 7 out of 12 possible tones. That 7 tones are distributed rather equally. In the major mode the set is 0,2,4,5,7,9,11 which corresponds to C,D,E,F,G,A,B.

If expressed as a sequence of interval differences, this is equivallent to 2-2-1-2-2-2-1. With 7 tones there are 7 modes. Each mode is just a rotation of the differences sequence. For example rotating one to the right yields 1-2-2-1-2-2-2 which corresponds to 0,1,3,5,6,8,10 or C,D♭,E♭,F,G♭,A♭,B♭ being the locrian mode (in D♭ denoted as -5). Modes add accidentals in a strict order (circle of fourths). With just 7 rotation options they cover just a little portion of possibilites.

Defining a custom scale allows to overcome that limitation. The following examples show how to define the two alternate minor scales: harmonic minor and melodic minor scales.

0
C-1
Code Editor
0.000

Scales are not limited to just 7 notes. It can be less or more. Let us try out a hexatonic augmented scale.

0
C-1
Code Editor
0.000
0
C-1
Code Editor
0.000

Scales are implemented similar to chords, they are sets. So it is possible to add or remove tones by one or combine scales.

0
C-1
Code Editor
0.000

Try out to change the sift of the second chord that builds the scale. Shifting a scale moves its tones during the script evaluation so that the scale root may be larger than 0. But at the end when the exact tones are determined, all scales are rotated back so that the first tone is always at 0. In order to apply a permanent shift, use key instead.

Also feel free to experiment with other scales like pentatonic or octatonic.

Since modes only rotate the sequence of differences, they apply to arbitrary scales. The naming is, however, not valid anymore. The ordering of modes also does not follow the circle of fourths. It rather tries to order them ascending by minimal change so that the perception from darkest to the lightest stays. For sparse scales this is not recognizable anymore.

Many scales do not contain less modes than expected if they exhibit repeating patterns in the difference sequence rotations. The augmented scale is one of them. Instead of the maximum of 6 modes, it only offers 2 distinct modes: 3-1-3-1-3-1 and 1-3-1-3-1-3

0
C-1
Code Editor
0.000

Atonal music

Basic structures of D♭ are built around the traditional western tonal system where harmonic functions decide about the quality of a chord. So even with modulations, there is no way to legaly create an augmented triad chord without slicing it first and then raising the top note.

0
C-1
Code Editor
0.000

Another solution would be to switch to another scale. Atonal music is all built around the chromatic scale and it is right straight forward to enter chords of arbitrary qualities in a chromatic scale. The Chromatic command transforms all entitiy data to the chromatic scale and even accepts chord qualities as an optional parameter.

0
C-1
Code Editor
0.000

Non-standard scales, transitions between keys and modal changes form a large block of songwriing theory. Both are closely related to harmonies and will be furhter explored in more advanced tutorials.

The next tutorial introduces dynmanics and smooth transitions like crescendo. We already introduced it partially with the velocity attribute.