top of page
  • Peter Ivan Edwards

Coding Clapping Music

In this next series of posts, I will recreate 2 minimalist classics: Steve Reich's Clapping Music and Philip Glass's 1+1. These are not algorithmically generated compositions, but they can be generated algorithmically. My goal is to show examples of how algorithms can be used to generate compositional designs. First, I will create code to generate Steve Reich's Clapping Music and generalize it in a simple program called Clapping Machine that automatically creates multiple versions of Clapping Music. Then, I'll move on to Philip Glass's 1+1. I will also create 2 original works using the same code developed for the Reich and Glass pieces. One work will be for Balinese Gong Kebyar and the other will be the worst rock song you've ever heard.

I admit that I'm working with low hanging fruit, avoiding more complicated compositional systems that might already have been algorithmically generated to some degree, for instance, works by Xenakis, Ligeti, or Messiaen. But simple will be complicated enough for this first venture.

Clapping Music

While short and simple, Clapping Music is arguably Steve Reich's most famous composition. It has achieved canon status, that is, nearly every undergraduate music major learns about it as a quintessential minimalist work. It demonstrates Reich's phasing technique in which two instruments play the same musical line, one continually repeating it and the other rhythmically rotating it in stages. In Reich's other phase pieces, a unique effect is created by accelerating the rotating part and then resynchronizing with the fixed one, at which point the rotating line is one beat ahead of the fixed one. This doesn't happen in Clapping Music.

The work is, as the title suggests, for 2 clapping performers. The base rhythm is as follows:

From this rhythm, the entire work can be generated. First, the rhythm needs to be converted into a list of 12 rational values representing the 1/8-note attacks and rests. Attacks are represented with positive values, while rests are represented with negative ones.

(setf orig-rhythm '(1/8 1/8 1/8 -1/8 1/8 1/8 -1/8 1/8 -1/8 1/8 1/8 -1/8))

Create a field called orig-rhythm and set it to the list '(1/8 1/8 1/8 -1/8 1/8 1/8 -1/8 1/8 -1/8 1/8 1/8 -1/8).

Once this field is created, the next step is to create a field that includes all of the rotations of orig-rhythm. For this, the loop macro can be used.

(setf rotated-rhythm (loop for r from 0 downto -12 collecting (gen-rotate r orig-rhythm)))

Create a field called rotated-rhythm and set it to the result of looping for a variable r from 0 down to -12. For each iteration collect the result of r applied to the function gen-rotate, in which r is the amount of rotation and the field orig-rhythm is the list being rotated.

A few things to note here. If r is 0, then there is no rotation. If r is -1, then the 2nd value in orig-rhythm become the first and the first is shifted to the end. If r is -12, then orig-rhythm is unchanged because there are 12 values in this list and rotating it by 12 values just yields the original, unrotated version. What results from this loop is a list of lists with all of the rhythms used in Clapping Music.

Each of these rotated rhythms needs to be repeated 8 times before moving to the next. To create these repetitions, the function gen-repeat can be used. The fixed rhythm needs to be repeated 8 times over the 13 stages of the rhythmic rotation.

(gen-repeat (* 8 13) orig-rhythm)

Generate a repetition of orig-rhythm (8 x 13) times, or 104 times. 

The rotated rhythms need to be iterated through so that each can be repeated 8 times. A loop macro can be used for this.

(loop for r-list in rotated-rhythm collecting 
  (gen-repeat 8 r-list))

Loop for a variable r-list which represents each sublist in the field rotated-rhythm. With each iteration collect the result of repeating r-list 8 times.

There are 8 attacks and 4 rests in each bar, which means that there are 832 (8 x 104) attacks in the piece because the work is a total of 104 bars. If the clap is notated with the pitch F4, then the code for generating all of the pitches for the score is as follows.

(gen-repeat 832 'f4)

Generate a repetition of the value f4 832 times.

In OpusModus, there is a music notation script called OMN, which stands for OpusModus Notation. With pitch and rhythm information, a representation of the music is generated in OMN. This can be exported as MIDI or MusicXML data for use in a music notation program or DAW. To achieve this, one uses the make-omn function.

  :pitch (gen-repeat 832 'f4)
  :length (gen-repeat 108 orig-rhythm))

The make-omn function accepts several keyword arguments, the two used here are pitch and length with which the pitch and rhythmic information is inputted. The above code generates notation for the fixed rhythm part. Below is the code for the rotating rhythm part. Both largely involve cutting and pasting previous code.

  :pitch (gen-repeat 832 'f4)
  :length (loop for r-list in rotated-rhythm collecting (gen-repeat 8 r-list)))

A score with both parts can be generated with the def-score macro. Here this macro takes the name clapping-music. Some requisite score information concerning title, key signature, time signature, and tempo is inputted. Then, each instrumental part is inputted in OMN. Each part must be named. In the code below the first is the rotating-clapper and the second the fixed clapper. When this is evaluated a score is generated that includes both parts. This can be exported as either MIDI or MusicXML data.

(def-score clapping-music
  (:title "Clapping Music"
   :key-signature 'atonal
   :time-signature '(12 8)
   :tempo 168)
   :omn (make-omn
          :pitch (gen-repeat 832 'f4)
          :length (loop for r-list in rotated-rhythm collecting (gen-repeat 8 r-list))))
   :omn (make-omn
          :pitch (gen-repeat 832 'f4)
          :length (gen-repeat 104 orig-rhythm))))

Who knew so little code could produce such an important work?

Below is a dystopian MIDI version generated with the code above. I'm going to skip sharing the notation for two reasons. First, there are other places on the web to illegally download the original, which will look exactly the same. Second, while I'm not 100% sure that algorithmically generating this piece and then putting it into Sibelius for distribution on the internet is illegal, I'm going to play it safe and assume that it is.

10 views0 comments
bottom of page