The 80's - Chaos

The wonderful thing about Csound is that it presents synthesis from a variety of perspectives and supports a wide range of learning styles - letting you see and work with an instrument from the "opcode level" to the "source-code level." For example, imagine that after experimenting with Hans Mikelson's new lorenz opcode and getting some great sounds from tweaking the parameters in real-time, you dig a little further. What does the Lorenz attractor look like and what sound patterns will it generate? Figure 17a & b show two views of the Lorenz attractor.


[index] [prev] [next]

[+] Home
[+] Tutorials

Figure 17a: The Lorenz Attractor.

Figure 17b: The Lorenz Attractor.

The lorenz opcode is an implementation of the Lorenz system of equations - one of the milestones in the development of chaos theory. The Lorenz system is a chaotic-dynamic system originally used to simulate the motion of a particle in convection currents and simplified weather systems. Lorenz discovered that small differences in initial conditions rapidly lead to diverging values. Lorenz's equations are approximated as:

  x = x + h*(s*(y - x))

  y = y + h*(-x*z + r*x - y)

  z = z + h*(x*y - b*z)
In figure 18 we see a version of the Lorenz instrument built from Csound primitives. Actually, this Csound instrument is being used as a "calculator" to solve the equations and return the result. The variable axnew is assigned to ax after it is computed and this new value is used again on the right hand side of the equation, two lines above, to compute the next block of samples. Remember that in Csound, an instrument is a programming loop in which i-values are computed once, k-values are computed at the control-rate (defaulting to 4100 times a second), and a-values are computed at the audio-rate (typically 44,100 times a second). A k-rate block of samples is computed and written to disk in each pass through the instrument.

Figure 18: A Csound Orchestra to compute the Lorenz attractor.

Once we understand this instrument, we might decide to look at the source code itself and compare the primitive opcode version to the actual C code (see figure 19). In Csound, you can always read and study the source code. In fact, you can compile in your own opcodes and expand the language that way as well.

Figure 19: Csound C Source-Code for the Lorenz opcode.

Although this well commented code is very readable, and I am happy to have access to it, I am also happy to know that learning Csound does not require that you learn C or that you do any C programming. So, even before there was a lorenz opcode in Csound, you could use Csound to study and explore the sound or the Lorenz attractor. But once it was agreed that it had a number of musical uses and produced some unique and interesting sounds, it made sense to add it to the language itself in the form of an opcode whose syntax is:

ax, ay, az  lorenz  ks, kr, kb, kh, ix, iy, iz, iskip
From the manual, we might compare the opcode-based instrument in figure 20 to the version built from Csound's basic opcodes shown in figure 18.

Figure 20: Chaotic orchestra file featuring the lorenz opcode.

Although this instrument produces some interesting "noise," it is pretty chaotic. In fact, one of the most important properties of chaotic systems is its "sensitivity to initial conditions." What would make our exploration of this new wavespace much more efficient would be to adapt the instrument so that we could use MIDI controllers to modify the parameters in real-time.

For this purpose we'll use Csound's new .csd unified file format. This structured data file uses markup language "tags" similar to HTML to delimit the various elements - the command-line options (CsOptions), the orchestra file (CsInstruments), and the score file (CsScore). The unified .csd file format is especially useful when you wish to embed the orchestra and score files into a webpage and access them both via a single click. Also, it is often convenient to associate the specific command-line settings with the orchestra and score file prior to rendering and this makes that possible as well. In figure 21 we see the MIDI.csd orchestra of a lorenz-FM instrument.

Figure 21: A MIDI-based Lorenz-FM instrument using the .csd unified file format.

In our MIDI version, we use the output of the lorenz opcode to chaotically modulate the frequency (icps+kx) and modulation index (kmod*ky) of Csound's FM foscil opcode. The controls are extremely sensitive, but a new class of timbres does pop out every now and then. Listen for the buzzing of the trombone player's lips against the mouthpiece!

  [next] The 90's - Waveguides