An important and practical aspect of mathematics is that it can be used to describe (technically model ) arbitrary processes, making it possible to analyse and understand them in a formal, quantitative way.

Use the tools below to compose a tune, or alternatively let the computer compose it for you, and see how a simple mathematical model of composition allows us to generate interesting tunes.

But it also allows us to study mathematically the diversity of tunes that can result, and, in the light of discussions about plagiarism, copyright and originality in popular music, we can consider questions like "How many different songs can there be?" This application is discussed in detail in my associated blog entry: How many tunes?

Loading instruments...

Computer Composer
Exploring how mathematics can be used to describe and create music
This activity involves mathematically representing music and the process of composition by modelling it as a three step process — build a rhythm, add a melody, then harmonise. Follow the below to work through these three steps to compose a tune, or alternatively let the computer compose it for you. You might be surprised at what comes out.

Step 1: Make the rhythm

The first step is to choose the timing of your song, and the rhythm of your melody. There are two choices for the timing: #4 (i.e. three beats in a bar), or $4 (four beats in a bar).

The song will be two bars in total, and each note duration is counted in half beats. This means you need to fill the 12 or 16 counts in the two bars by choosing from the note durations:

  • 1    for a half beat (a quaver) — e
  • 2    for a whole beat (a crotchet) — q
  • 3    for one and a half beats (a dotted crotchet) — q.
  • 4    for two whole beats (a minim) — h
Notes joined by a tie have their durations combined, so, for example, the note q-q lasts for 2 whole beats. Ties are used when the timing means a note crosses a barline or an important internal beat.

Specify your chosen rhythm by entering a string of digits from 1 to 4 in the text box below (just like the example values shown), finishing when you have the required total sum.

Alternatively, you can ask the computer to compose a rhythm for you by hitting the Random button.

Enter rhythm:      
Step 2: Make the melody
For the melody, you can use any of the notes from A below middle C to E an octave above by typing the corresponding letter as follows:

Once again, hitting Random will cause the computer to randomly assign notes to the given rhythm. The melody will always finish on middle C, and any randomly generated melody will start on middle C as well.

Enter melody:      
Step 3: Make the harmony
To complete the composition, enter a harmony based on the three major chords:

C = [C,E,G], F = [F,A,C], and G = [G,B,D],

and their relative minors:

Am = [A,C,E], Dm = [D,F,A], and Em = [E,G,B].

Two chords are used to harmonise each bar, applied on the 1st and 3rd beats respectively, and hitting Random will cause the computer to match a chord to the associated notes of the melody. Because frequently more than one chord will match, there are several possible harmonies that the computer will randomly choose between. However, it will avoid clear disharmonies.

If a fifth chord is not specified, the computer will add a final C chord, except when the starting chord is Am, in which case it may end on either a C or an Am.

Enter harmony:  
Perform the finished product
Finally, choose an instrument for the melody, and both an instrument and playing style for the harmony, then listen to your music by hitting the hitting Play button. Save and print your favourites.



Saved Music

Loading instruments...