the generative music blog #01 – a simple melody

So what’s the purpose here?

I would like to invite to take part in my generative music journey.

I have been generating music for many years now using various methods and utilizing a wide range of tools and algorithms. It is a fun approach to music composition which allows me to experiment and have fun with materials during the process.

It is important to note that when it comes to generative music (as with non-generative music) the possibilities are literally endless.

Our first melody

To get things going, I’ll start with a simple algorithm and manually translate it into musical notation.

Let’s take an extremely simplistic example – I would like to write a short melody (let’s limit it to 8-16 tones) with an upwards trajectory. The range should not exceed a single octave (we’ll use middle C as our base tone). That’s hardly an algorithm, but these limitations will force us to be creative. Nevertheless, it’s enough for us to generate the following melody:

Melody #1, a diatonic C major scale

Some of you might recognize that it’s not a melody per-se, it’s basically just the C major scale. We will need to add some complexity to our algorithm in order to make it musically more interesting. There are a few elements we could play around with, for today’s experiment – let’s focus on the following elements: pitch, duration and melodic intervals/steps.

Pitch

Let’s first define pitch – pitch refers to the height of the tone. In western classical notation, we indicate pitch by placing a note-head on a specific line in a music Staff. Currently, we only use tones from the C major diatonic scale (all white keys on the piano). So we could add more spice to our melody by introducing the chromatic tones as well:

Melody #2, a chromatic scale

This already allows us to create some more interesting melodic patterns. For example, an octatonic scale, where we have alternating melodic intervals – every semi-tone is followed by a whole-tone:

Melody #3, an octatonic scale

We will explore these intervals further later on.

Duration

You are probably not very impressed with these musical examples so far. That’s because they are not very, well… musical. We are still missing a very important element – the rhythm. The rhythm is going to be determined by the duration of the different pitches we use in our melody.

For example, we could use eighth notes instead of quarter notes for a faster melody. (depending on tempo of course, but let’s assume all of the examples are performed in the same tempo).

Melody #4, a C major scale in eighth notes

Like we did with the tone intervals, we could also come up with a simple alternating pattern between quarter and eighth notes:

Melody #5, a C major scale with an alternating rhythmic pattern

When combining this with spicier pitch patterns, we can already come up with a melody that is musically interesting. So let’s say we use the following pitch pattern: whole-tone, semi-tone, semi-tone. Coupled with the following duration pattern: quarter note, eighth note, eighth note. This would produce the following melody:

Melody #6, a pitch pattern + a duration pattern

Intervals

Now, let’s add the final element in today’s experiment and play around with the intervals we employ between the tones. So far, we have only used the two smallest intervals allowed by standard western notation (yes, I know quarter tone chromatic notation has been semi-standardized, but we are trying to keep this post as simple as possible).

Let’s introduce some larger intervals, such as major and minor thirds and perfect fourths.

Melody #7, a C major chord arpeggio

This results in a very nice C major arpeggio, but it violates the rule we have defined in the beginning of minimum 8 notes in the melody. To resolve this issue, I would use intervals going down in pitch as well. Meaning, the general trajectory of the melody would be going up, but it won’t be a perfect linear movement. (you can compare this melodic contour to the S&P 500 if you’d like).

Melody #8, 2 pitch patterns + a duration pattern

So here we have the same rhythmic pattern we introduced in melody #6 repeating 3 times. Pitch wise – we have two very similar patterns – one used with the first repetition of the rhythmic pattern (major third up, minor second down, perfect fourth up) and the other with the second and third repetitions (minor second down, major second down, perfect forth up).

We can also decide that that patterns do not have to match, for example:

Melody #9, non-matching pitch and duration patterns

The result is a melodic pattern appearing in different rhythmic contexts. This is due to the duration pattern containing 4 tones (quarter note, eighth note and 2 sixteenth notes) while the pitch pattern contains only 3 (two descending tones followed by a jump up by a perfect fourth).

Conclusion

And so, without employing any other musical elements, such as dynamics, articulation, harmony or instrumentation, we have already managed to generate a relatively interesting melody. The algorithm for generating such melody is quite simple and not very sophisticated. It is so simple, in fact, that I have produced all musical examples manually, because writing code that will generate such simple musical examples will take longer then writing them down manually.

Nevertheless, this simple example proved quite useful in the context of an actual piece of music. Adding a simple beat created with LMMS and using the extensive MIDI capabilities of Ardour, I managed to produce a nice sounding track featuring our simple melody.

You can check it out by following this link: https://shufu.bandcamp.com/track/a-simple-melody

Leave a Reply

Your email address will not be published. Required fields are marked *