23 May 2008

This is a relative of the much better known Fibonacci sequence. According to this Wikipedia article the sequence is relatively recent which seems surprising for something so simple. It is named after the architect and author Richard Padovan, although he attributes it to the Dutch architect Hans van der Laan, about whom, I have to admit, I know nothing.

In the Fibonacci sequence, each term (after the first couple) is the sum of the previous two terms. We can denote this as:
`Fib(n) = Fib(n-1) + Fib(n-2)`

The Padovan sequence is a simple variation on this:
`P(n) = P(n-2) + P(n-3)`

So the first few members of the sequence, after arbitrarily setting the initial terms to 1, are:
`1 1 1 2 2 3 4 5 7 9 12 16 21 28 37 49 65 86`

Self-similarity rears its head here... If you look at the differences between terms, starting with P(6) - P(5), you will find that they form the Padovan sequence.

To make Padovan music we can take advantage of another way of generating the sequence using an L-system which I'll define as follows:
1. Take the three notes G, A, B.
2. Begin the progression with G.
3. Follow the rules G -> A; A->B; B->GA

(note: I'm using GAB here rather than the more usual ABC, so that I can be lazy with my JFugue code and stay in the same octave)

Applying these rules the sequence builds like this:
`GABGAABBGAGAABABBGABGAGAAB`

The length of the note sequence at each stage is:
`1 1 1 2 2 3 4 5 7`

Here's what it sounds like, rendered using JFugue and arranged with two voices, one just behind the other. Self-similarity in the sequence results in the voices falling into step every so often. Keen listeners will also notice that I've exercised a little artistic licence and set the duration of the Bs to be twice that of the Gs and As.

16 April 2008

The Golden String

Here is a short piece of music generated using the Golden String - a binary sequence that starts out as 101011011010... and continues on forever (as these things tend to).

One way to build up the sequence looks like this:

1. 1
2. 10
3. 101
4. 10110
5. 10110101
6. 1011010110110101
Steps 1 and 2 are given; after that the sequence at each step grows by joining the sequences at the two preceding steps. As the sequence grows, the ratio of the number of 1s to the number of 0s approaches the Golden Section (~ 1.618), a number that pops up in nature, geometry and artistic composition. The sequence is also fractal, meaning that it appears similar when examined at a range of scales. You can even lop bits off the front and still get back to the original sequence !

You can find a much better explanation of the Golden String, and its many properties on this page, part of Ron Knott's stupendously encyclopedic Fibonacci web site.

To generate the piece I mapped the binary sequence to musical notes in two ways. Firstly, a simple mapping of 1s and 0s to low pitches to provide a background rhythm. The second mapping is a bit more interesting. The sequence was progressively read as seven-digit chunks (ie. chunk 1: positions 1-7 / chunk 2: positions 2-8 etc.). It turns out that only eight unique chunks of length seven can be found in the Golden String. I sorted these, treating them as binary numbers, and mapped them to notes in the A major scale (not for any deep mathematical or compositional reasons, I just like A major).

0101101 => A
0110101 => B
0110110 => C#
1010110 => D
1011010 => E
1011011 => F#
1101011 => G#
1101101 => A (next octave)

Using JFugue, I set two instruments to play these mapped notes in the piece, one starting slightly behind the other.

Daniel Cummerow, a web-pioneer of algorithmic music, has also based a piece on the Golden String, using quite a different approach for the mapping. You can listen to it here.