February 25, 2019

Inventions: The Algorithm

The algorithm that I wrote to generate the monophonic improvisations used in Inventions is based on a simple abstraction of one possible principle of composition: invention, repetition and variation.

It generates “micro-motifs” of the length of a half note (corresponding to half a bar in four-four time). I chose this length because I find it an ideal time scale with respect to auditory memory—or at least with respect to engrained listening habits.

A micro-motif is generated as follows. First, the rhythmic pattern is laid out. The half bar is filled with a set of note values that add up to the total length. This is done by randomly concatenating note values from a set of smaller sets, e.g., two demiquavers or a quaver triplet. I choose this procedure instead of just randomly adding single note values of different length to preserve a certain rhythmical integrity; for instance, single demiquavers followed by a crotchet lead to a form of rhythmic incoherence which I intended to avoid (after trying and finding the outcome uninteresting).

Now that the rhythm is laid out, the pitch of the notes is determined. First, a scale (i.e. major or minor, Dorian or Phrygian) is set globally for the entire piece. Starting from a randomly chosen note within that scale (e.g., an A), the algorithm stochastically selects the pitch of the subsequent note by randomly choosing from a predefined set of intervals (e.g., one, two and four steps but not three or more than four steps within the chosen scale) and adding it to the current note. Only allowing such a restricted set of intervals enables a certain melodic coherence which, again, may be interesting to break in other circumstances.

Now the micro-motif is complete and is added to the improvisation.

In the next step, the algorithm determines stochastically whether (i) a new motif is generated from scratch or (ii) the same micro-motif is used as a basis for the next micro-motif. If (i), the process starts over. If (ii), the algorithm decides for each note of the current micro-motif whether it is varied. The same basic principles as above apply—variations are determined stochastically using a set of allowed intervals. Sometimes, additional rules are imposed, e.g., to avoid doubling of notes which may randomly occur.

This process is repeated until the desired length of the improvisation is reached. Finally, note values and timings are loosened by adding noise on the respective variables.

Clearly, the algorithm has many parameters that determine the “style” of the outcome: probabilities for stochastic decisions, interval sets etc. Importantly, the algorithm does not just concatenate predefined melodic micro-sequences but creates, varies and overthrows them.

As an output, the algorithm creates a control file that can be read by music production systems. This is what you hear as the piano part. Everything else is added by myself (non-algorithmically).