# Composing with fractals: an introduction

# Introduction

One of the consequences of the Second World War -at least in the European music scene- was the decline of faith in the human factor. The creative mind of the composer, whose inspiration and personal taste feature within the music, became heavily disputed. The aesthetic choices that previous composers made during the process of writing their music were stigmatised as carrying the stamp of a culture that, regardless of its past achievements, was responsible for some of the biggest atrocities in modern history. The expressive devices the composers were using were part of a civilisation that failed to contribute to the course of *historical progress*, a concept that started during the Enlightenment and flourished throughout the French Revolution and 19th century (Hegel, Marx). Instead, it almost collapsed under the weight of two wars in less than thirty years, with a death toll of unimaginable scale. There was also a new threat, hanging hanging over people’s heads like an invisible sword: the prospect of an all-out nuclear war that could eliminate human race (Philosopher *Theodor Adorno* famously declared that no poetry could be written after the Second World War).

In addition to this lack of faith for the traditional compositional forms and expressive devices, the collapse of the traditional tonal system which had already started with the *Second Viennese School, *prompted composers to seek other ways of giving their music a structure. It is not a coincidence that *total serialism* became popular among young composers in the immediate aftermath of the war. They seemed to be looking for “objective” systems that would enable them to write music, without resolving to techniques of the past that they no longer wanted to be associated with.

Another development of the period was the advancement of computational systems and applied mathematics, which contributed towards the use of mathematics in the compositional process, as they fitted into what the composers were looking for. With such composers as *Iannis Xenakis*, the use of mathematics in music became popular and today algorithmic composition features as a separate music field, with its own set of techniques and terms. Those techniques involve computer programming, as well as extensive use of mathematics, from basic to advanced. One of those mathematical concepts of particular importance in this tutorial is the *fractal*. Therefore, we could say that composing with fractals is a form of algorithmic composition.

# Fractals

Although that there is still no formal definition of what a *fractal* is, two widely used definitions are presented here. The first comes from *B. Mandelbrot*, the mathematician that was among the first to use the term. He was also the first to realise fractals as computer images. So, according to him:

…A Fractal is a rough or fragmented geometric shape that can be subdivided in parts, each of which is (at least approximately) a reduced/size copy of the whole…

In more formal mathematical terms, a fractal can be defined as:

…A fractal is a set of points whose fractal dimension exceeds its topological dimension…

Fractals have been used in many movies and computer games, in order to model trees, clouds and mountains. They have the ability to simulate the asymmetrical but not random behaviour that occurs in many natural phenomena (chaotic behaviour). One simple example of creating a fractal is displayed below. The method of creating the fractal shape is to repeatedly replace each line segment with the following four line segments (figure 1):

The process starts with a single line segment and continues ad lib. The first few iterations of this process are shown below (figure 2):

It is mainly this feature of *self-similarity* that has prompted composers to use fractals in their music, applying their properties in the time domain. One possible way of doing that comes next.

Figures 3 and 4 show some more complex examples of fractals:

# Application to music – example

For this example, we will take one of the simplest fractal equations and use its output in order to control a number of music parameters. The result will be a short music segment for a violin and cello duet. Of course the same process can be applied to a number of different configurations, depending of what the composer wants.

The equation that we are using was proposed by *Lorenz* in 1976, as part of his research in climate change. It is defined as follows:

X(n+1) = a(3*X(n) – 4*X(n)^3)

This means that, the output of the system that has been described by the equation at time T=n, is being used as an input, in order for the output at time T=n+1 to be calculated. In other words, we use the current output of our system as its input to calculate the next output. Such systems like the above are called systems with *feedback*. In this particular system, there is one parameter that can be changed according to composer’s wish, and this is the value of *a*. The range is any number between 0 and 1. It must be noted (from personal experience) that values under 0.5 tend to produce monotonous and uninteresting results (die-hard minimalist fans might disagree). So the practical range for music applications ranges from 0.6 to 1. In general, as the value of *a* increases, the unpredictability of the system increases accordingly. For values near 1, the output of the system becomes almost random, whereas for values in the range 0.78 to 0.98 there is some kind of complex periodicity, with patterns that are very similar but not identical. This happens due to the special nature of the fractals that is reflected upon the output of the equation, especially for the range of *a* that has been mentioned above. Therefore, that range tends to produce the results that seem more musically interesting. Of course, *a* does not need to remain static throughout a composition. It can be changed to add more variety to the result.

As mentioned above, we will use the Lorenz equation to determine *pitch*, *duration* and *dynamics* for our duet.

## Pitch:

An integer, including 0 (zero), is assigned to each one of the twelve pitches, starting from the note C, as shown in figure 5. This is called *pitch-class* representation.

The choice of the octave for every note is left to the composer, instead of being determined by the equation. The overall process that we will follow here is the same for the other parameters (duration and dynamics) and needs some explanation first. Let’s say, for example, that we want to create a pitch set consisting of six notes: C, D flat, D, F, G, and B flat. Their correspondent integer numbers (pitch class representation) would be 0, 1, 2, 5, 7 and 10. It must be noted that, although somewhat obvious, in pitch class terminology *enharmonic* notes have the same representative integer number. For example C sharp has the same number with D flat, C double sharp and so on. Therefore, our pitch set is as shown in figure 6:

The next step is to use a data structure that is called *array*. Without being too technical, we could say that an array is a way of keeping objects in a particular order. Our array will be called, for no particular reason, *Pericleus*. Henceforth, Pericleus will contain the pitch set that has already been created with the following order: Pericleus = {C, D flat, D, F, G, B flat}, or {0, 1, 2, 5, 7, 10}. When data objects are stored in an array, individual objects are selected by an index that is usually a non-negative scalar integer. An index maps the array value to a stored object. For example, G is the fifth object of the array. If we use *0-based indexing* (that is we start counting from 0 instead of 1), then we can use the following expression to identify the object: Pericleus[4] = G. Another example would be Pericleus[0] which is C, or number 0 (pitch-class representation). In a similar manner we have: Pericleus[1] = 1, Pericleus[2] = 2, Pericleus[3] = 5, Pericleus[4] = 7 and Pericleus[5] = 10.

Once the pitch array has been defined, a value needs to be set for *a*. A value that has been proved empirically to lead to interesting results is 0.887. Then, for the given value of *a*, we run the equation and we pick up the first ten numbers. In reality the process is slightly more complicated because it includes the right choice of the initial value of *n* (time) and the normalisation of the output to a suitable range. In this particular case Pericleus has six objects, so our desired range is from 0 to 5. The (normalised) first ten numbers of the equation are 4, 0, 1, 3, 3, 3, 1, 3, 2, and 4. We use these numbers as indices for the Pericleus’ objects which, in turn, represent pitches (notes). So, we have the following pitches resulting from applying the equation: 7, 0, 1, 5, 5, 5, 1, 5, 2, and 7 (figure 7):

We -arbitrarily- assign those notes to the cello. After that, we repeat the same process again for the violin, this time by setting the value of *a* to 0.976. The ten new notes are: 7, 7, 0, 0, 1, 5, 2, 7, 7 and 0 (figure 8):

## Duration-rhythm:

The process of determining the duration of the notes is the same as above. First we define the duration set (figure 9):

Then we have to create the duration array, which contains five objects. The array’s objects have the same value with their corresponding index. The name of this array is *Aspasia* (you can see a certain pattern emerging here, regarding the naming conventions) and the following expressions should be obvious: Aspasia[0] = 0, Aspasia[1] = 1, Aspasia[2] = 2, Aspasia[3] = 3, Aspasia[4] = 4.

Once again, we set the value of *a* to 0.954 and run the equation for the first 10 numbers: 3, 2, 3, 1, 2, 2, 3, 0, 2 and 3 (figure 10):

We assign these values to the violin. Doing the same for the cello, for *a* = 0.9666 we have: 3, 2, 2, 2, 3, 0, 2, 3, 2 and 3 (figure 11):

**Dynamics:**

The -by now familiar- process is repeated again. First we define a set for the following dynamics: p, mp, mf, f and store them in an array called *Pheidias*. Therefore, Pheidias[0]=0, Pheidias[1]=1, Pheidias[2]=2 and Pheidias[3]=3. We set the value of *a* to 0.889 and run the equation four times (the author dislikes the frequent change of dynamics). The results are: 2, 0, 0, 2 or mf, p, p and mf and are going to affect the cello part. For the violin, we set *a* to 0.9234, run the equation and pick up the six first numbers: 2, 1, 2, 0, 2, 2 or mf, mp, mf, p, mf and mf.

After having completed this process and, with a little help from the creative mind, the final result is a small fragment for the duet (figure 12):

# Audio example – Fractal Piece No. 3 “Orange”

Personally, I have used fractals as a compositional tools for a number of -mainly- electroacoustic works, such as *Fractal Piece No. 6*. This piece is a demonstration of the process that I described in the tutorial. It uses the same Lorenz equation in order to control a wide range of musical parameters, with the use of arrays. I implemented the algorithm for this piece in *C*, a computer programming language. Each instrument layer has its own C program, which needs to be compiled each time that a change is required. This is time consuming, but the results can be awarding. The advantage of this method is that I could use different arrays at different points within the piece, thus creating more variety. The results were translated automatically as a *Csound score*. The sound was also made on CSound, whereas the final mix was made on *CMix*. I used a Karpus – Strong plucked strings algorithm instrument, as well as a physical modelling vibraphone. I also used convolution as an effect on the instruments.

# Conclusion

Use of fractal equations in music is a form of algorithmic composition. An interesting issue that arises is the level of human interference in the actual process of algorithmic composition. In other words, should the composer change the result of an algorithm according to his/her taste, or apply it as it is? Although this is a general question regarding algorithmic composition, I think it would be interesting to discuss it here briefly, as an epilogue to this article. Especially since nowadays we are many decades away from the climate that post-War composers were facing and the quest for an “objective” compositional system do not seem to be that popular anymore.

In theory, somebody could argue that an algorithm is a perfect composition tool, in the sense that, with the right deisgn, its output has the potential to create a result that would reflect all the things that the composer would like to express. So, it would be enough to simply run the algorithm, pick up the results and apply them directly to the music. As a consequence, the success of the composer lies exclusively with the design of the algorithm and the translation of its output to a language that musicians understand and are able to perform, or maybe not even that is we are talking about computer music. If we look into the future, maybe some day Expert Systems, or machines equipped with Artificial Intelligence will be able to design such algorithms and create music without any human interference whatsoever, sending the composers of that time straight to the Jobcentre.

Fortunately for composers, this version of the future seems distant. Now matter how complex and detailed the present algorithms may be, they have not proven themselves to be *that* good when it comes to music. Even Iannis Xenakis has admitted to having changed the output of his extremely sophisticated algorithms (Xenakis was a mathematician among other things), in order to create what he perceived as a more pleasant (and -fortunately for the interpreters of his music- playable) sonic result.

I believe that the final judge for the various elements that make up a work of music should be the ear of the composer. If something does not sound good enough to you, change it. Maybe at this point one could also argue about the definition of “good enough”, at which point anybody doing that is invited to have a beer with the author because the argument does not lead anywhere. Fact is that too much reliance upon a mathematical equation has certain dangers for the work, in terms of balance and evolution. What looks good on one domain does not necessarily translate equally well to another.

However, overall I would say that the -tasteful- use of fractal sequences in music can create some really exciting sonic worlds. Their biggest advantage is that, being so abstract in nature, they can be assigned to a wide range of music parameters, from pitch to dynamics, time etc. leading to patterns that are similar, but not identical, therefore interesting to use. Hope you enjoyed the post, stay tuned for more!

*© 2013 Achilleas Sourlas. All rights reserved.*