Monday, October 28, 2019

BEHIND THE SONG: The Music of (All) the Spheres and Kepler Jam

Our Kepler song was written by Luis and contains material and inspiration from a song called "El Cielo no es el Limite" ("The Sky is not the Limit") by Luz de Riada, written by our very own Ramsés. The main content of the song is meant to be a rock song with interesting and dynamic parts largely written independent of specific math. Working with Luis, I came up with the programmed sounds at the beginning and end of the song.  These are based on astronomer Johannes Kepler's 1619 work Harmonices Mundi ("Harmonies of the World"). I've heard the title "Music of the Spheres" used too for this content.

Famous composers like Philip Glass and Mike Oldfield have composed larger pieces entirely based on Kepler's life and work, but I believe I did some calculating others haven't.

Kepler is best known for his three laws of planetary motion, briefly:
  1. Planets follow elliptical orbits with the sun at one focus of the ellipse.
  2. A planet's orbit sweeps out equal areas in equal times.
  3. The amount of time an orbit takes is proportional to the planet's distance from the sun* raised to the power 3/2.
* sticklers may notice that if an orbit is elliptical, the distance from the sun isn't constant. The real distance this law uses is called the semimajor axis—this is half the distance from the perihelion to aphelion shown here (source: Brittanica):


A takeaway from this is that planets move faster if they are closer to the sun. Earth and Venus have orbits that are nearly circular, so their orbit speeds are pretty consistent. But other planets in the solar system have much more oblong orbits, which means that from the sun's perspective, these planets pass through the sky at different rates.

Kepler saw significance in this—he noticed that the ratios in the rates the planets move through angles in the sky are similar to those found in musical scales. From a translation of his work here:

"Accordingly you won't wonder any more that a very excellent order of sounds or pitches in a musical system or scale has been set up by men, since you see that they are doing nothing else in this business except to play the apes of God the Creator and to act out, as it were, a certain drama of the ordination of the celestial movements."

The link above contains very detailed descriptions of Kepler's view that each planet in this cosmic symphony has a specific voice and that at certain times, they create beautiful intervals together.

Here is a reproduction of a figure from Kepler's work:

From Kepler's Harmonices Mundi (1619), with text translated to English

The thing to notice is that Mercury has a wide range of notes (because its orbit is elliptical and its speed varies a lot) and planets like Venus and the Earth don't have a wide range—their orbits are more circular.

I duplicated some of the calculations, including the other planets.


By doing computations with the maximum and minimum distances, I could calculate for each planet the ratio of maximum to minimum angular speed, and compare this to musical intervals.

I found the answers Kepler got for Venus, Earth, and Saturn made a lot of sense. Jupiter is close to what I expected, but Mars was a little off—the perfect fifth shown in the scale above implies something like a 3:2 ratio of angular speeds, but my calculation came up short of that. Also, in Kepler's time, Uranus and Neptune weren't discovered, so I found the small intervals applicable to those planets also.

Each synthesized track at the start and end of our song represents an additional planet. The track begins with Neptune and goes in. Each planet inward starts with a higher (arbitrary) starting pitch, and the interval each goes up and down depends on its orbital motion. I made the total time for a single planet's "loop" proportional to how long the year was - so Mercury's very large up and down swing happens quickly over one measure, and (for example) Saturn's trip through a major third happens over 122 measures because Mercury makes 122 trips around the sun in the time it takes Saturn to go around once.  

It's a bit mechanical, yes, and I didn't make any fancy corrections to Kepler's original ideas for the original six planets. But for a synthesized intro, it was fun to put this together. The bleeping and blooping is scientifically inspired and sets up nicely the soft acoustic introduction to our song.

Tuesday, October 22, 2019

BEHIND THE SONG: Room 101

"'You asked me once,' said O'Brien, 'what was in Room 101.  I told you that you knew the answer already.  Everyone knows it.  The thing that's in Room 101 is the worst thing in the world."  - Nineteen Eighty-Four, George Orwell (movie clip of this scene)

My last post talks in detail how I turned a pattern into a rhythm and then into a song. Like "Rule 34," my song "Room 101" is based on a cellular automaton. The rule is, predictably, rule 101:


After playing with some different initial conditions under this rule using Mathematica, I got this pattern. To recap earlier posts, my idea is to use this pattern to define rhythm where a dark square signifies an eighth note and a white square signifies a quarter note. The top line represents the song intro, and then it proceeds.


I hope it's clear that this pattern is different from the one in "Rule 34." There are two features: (1) for the first few lines, this pattern is totally bonkers and (2) after that, it's just alternating white and dark stripes. I decided to run with that, and that's why "Room 101" starts with an intro that's rhythmically bonkers and then stabilizes into something normal.


I think showing off the clave part is sufficient. I let the top line define the first four measures of 5/4, and then each line after that gets a measure. Notice how every bar practically has a new time signature:  15/8, 5/4, 6/4, 13/8, 11/8, etc. You could say this isn't very musical (and I would have a hard time defending myself), but like with "Rule 34," I could just listen to my computer play this, and I got some ideas for at least some simple parts. The starting bass part doesn't match the claves exactly, but I think they sound good together.  Here's an image of it, and the version you hear on the record and live is still pretty much this:


When the song gets crazy, the key features are the bass and some strummed acoustic guitar chords that match the crazy measures. It certainly gave Mattias (and Kiko, another drummer who played with us) headaches on what usefully to play along with it, but I think we have something on the record that works. Usually live, Luis and I maintain the crazy structure together as best we can, and Mattias tastefully adds some percussion to match some of our accents in the background.

After the craziness, the song goes into alternating 4/4 and 8/4 bars, which was easy enough to structure normal music around. And then after that, I decided to take my license and split the difference—the rest of the song simply rocks out with a more free solo section in a steady 6/4. Nothing particularly nerdy or mathematical about that, but it's a lot of fun to perform.

A key mission for this project at least for me is to convince students and myself that nerding out on this math stuff can only enhance your creativity. As Luis says, it only adds, never subtracts. I could go on the computer in front of a class and say "cellular automata evolve in these four ways, etc., etc.," and show off the pictures, but especially working where I do I think it's helpful to back this up with "yeah, we looked at these things, and it inspired creativity in these ways."

It certainly worked for me, and even though I've been a musician for a long time, I needed the help. And I also now love Big Brother for some reason.

BEHIND THE SONG: Rule 34

From XKCD, one of my favorite nerdy comic strips

"If it exists, there is porn of it.  If there isn't, there will be."  - part of Urban Dictionary's definition of Rule 34

In my last post, I wrote about cellular automata and how there is a system for describing all the potential rules in an organized way. Each rule "number" corresponds to a set of instructions in binary. My post two posts ago talks about how 1D cellular automata evolve in different ways: the pattern may go all light or dark, it may freeze into something predictable, or it may exhibit what looks like chaotic behavior overall or locally in pockets.

Now let's talk music.

During my summer sabbatical project, I was working through a textbook on chaos and fractals that helped inspire this bit of songwriting. I took the opportunity to work through the book's exercises on Mathematica to relearn that program and explore some possibilities. Mathematica is especially suited for work on 1D cellular automata since Stephen Wolfram led the charge with both.

In the program, you can ask for a cellular automaton that's as "wide" as you want, with any "rule" that you want, for as many steps as you want (and with a random starting state - so rerunning the instruction would give a different pattern). So I started playing around. The musical thought that I went with was that I'd use the CAs to define rhythm: I would make my rows eight squares long, a black square would become an eighth note and a white one would become a quarter note. I found if the rule number was too high or low, the patterns would descend into one color quickly, and I wasn't in the mood to write anything in straight 8ths 4/4 time.

I didn't go into this assuming any particular rule number would work, but I found coincidentally that Rule 34 inspired me musically.


Notice the two T "tetris" pieces with black squares on the bottom correspond to the binary digits 32 and 2. One of my first sequences started and evolved like this:


When I first saw a set of starting squares like this, I thought about what rhythm it would make. I did my composing in GuitarPro and set up a simple percussion track that looked like this:


Hopefully you can see that this rhythm matches up with the top row of squares on the long image above. Then, rule 34 tells the squares how to evolve. It so happens that the first row when translated into eighths and quarters leads to a 6/4 rhythm, but from there on out only two black squares can be seen per row, so the remaining rows are 7/4 and the location of the eighth notes shifts. I wrote out this rhythm and gave each row basically two "bars" of my musical chart.


And this is where the magic happened for me. I'll probably talk more about myself as a composer later, but in my life I tend not to randomly hear stuff in my head that's new and original. But with this pattern, just hearing the computerized claves play this rhythm got me thinking, and so I wrote a bass line next.


The rhythm of this part matches that of the claves. I continued this for the rest of what feels like a "verse."

I wanted some interesting transition and maybe another section of the song, though, so I kept playing with initial conditions to see what interesting patterns would come out. A different starting state led to a pattern that's a little more active.


Notice the top line of this has five black squares and three white squares, and the subsequent lines have three black squares and five white squares. Therefore, the top line represents a bar of 11/8 and the rest show a pattern that translates (with my scheme) to 13/8. Now we're talking.


Again, compare these rhythms with the top two lines in the CA above. I heard this in my head as a transition and new section, and the 13/8 bit needed to be faster. So this transition and new part is what you hear on the album. If anything, even though this is the craziest section of the song, it is the most derivative because my former band Might Could released a song in 13/8 that we all loved a great deal. But I loved getting back to that rhythm through purely nerdy mathematical means. Totally made using "Rule 34" worth it.

I treated the 13/8 bit as a solo section, wrote a transition back to the first part of the song, and finished it off. It's not mathematical, but the switch from the 13/8 part back to the slower section is the part I strangely felt the most creative. I can't really explain it.

Anyway, that's how I took a cellular automaton idea, merged it with an internet meme somewhat by chance, and got some interesting musical sections out of it. My next entry will be about "Room 101," a song that used a different rule for a new and interesting effect. In a later entry, I will talk about how The Devil's Staircase plays all of this live. After all this work, do we play every nuance in eighth note placement?  Do we do the strange 11/8 and 13/8 stuff?

No, not at all.

But it's a fun part of the process to talk about.

Thursday, October 17, 2019

Binary counting and cellular automaton rules

In my last post introducing the idea of a cellular automaton (CA), I described a CA as a system that evolves on a turn-by-turn basis according to a set of simple rules. Conway's Game of Life is a 2D grid on which cells are born, survive, and die from one step in time to the next.

I summarized the rules of Conway's game in five bullet points. The CA systems I use in my music are 1D instead of 2D, and instead of the rules being summarizing the rules as bullet points, they exist in chart form. One such chart was shown in the "rule 90" image from my last post (again, many of these images come from here):

The summary of rule 90 is at the top, and it looks like a bunch of colored Tetris pieces. These pieces tell us everything we need to know about the rule. To see a cell's status on the next "turn," you need to know the cell's current status and the status of its two nearest neighbors. For example, look at this part blown up from the upper left:

This piece tells us two things: (1) if a cell is currently black and its two neighbors are as well, it will be white on the next turn and (2) if a cell is currently black and has a black cell on its left and a white cell on its right, it will be black on the next turn. You can go to the right along that chart and see all the other possibilities for bunches of three cells—there are eight of them because there are 2^3 or 8 possibilities for each set including a cell and its neighbors.

You might fairly ask, "What about the edges?" Typically, we solve that problem by using what is called periodic boundary conditions. Briefly summarized, that means that wrap-arounds work.  So if you're a cell on the right edge, you have a left neighbor as usual, and your "right neighbor" is the cell on the far left of the pattern - that's the other cell that dictates your color next turn.

So why is this picture called rule 90?  If you look at the numbers below the rule picture, you see a series of zeroes and ones:

Notice the blocks with zeroes involve a cell being white on the next turn and blocks with ones involve a cell being black on the next turn. The eight possibilities are arranged in the same order for each rule set, but the ones and zeroes change. Read left to right, we get a number 01011010. This is a binary number.

Our normal counting is done with a ones place, tens place, hundreds place, etc., with each place filled by a digit 0-9. Binary numbers have a ones place, twos place, fours place, etc., with each place filled with a digit 0-1 (corresponding to "off" and "on" in a circuit - something computers understand for sure.) So 01011010 = 0x128 + 1x64 + 0x32 + 1x16 + 1x8 + 0x4 + 1x2 + 0x1 = 64+16+8+2 = 90.

We can represent any number from 0-255 in binary using eight binary places, so there are 256 rules we can make using different combinations of ones and zeroes. Rule 0 would mean that no matter what the state of a cell and neighbors is, the next turn will yield a white cell. Rule 255 means that no matter what the state of a cell and neighbors is, the next turn will yield a black cell. So those two rules form pretty boring patterns (all white or all black)—it's the ones in between that became interesting to me.

Check out the picture of rule 90 again. Go down the rows and see how one row evolves to the next - use the rule table to check! We see that as the pattern evolves, we get a picture that looks like the fractal Sierpinski's Triangle. That link gives some very technical details, but a cool thing to see from it is that more than one CA rule gives the triangle.

I became interested in what kind of patterns could come from different rules and starting conditions, and so my next step was to get on a computer and start playing around with numbers by trial and error. Many rules and starting states of the CA "game" are boring, but a few inspired some music, as my next two posts will discuss.

Tuesday, October 8, 2019

What is a Cellular Automaton?

When I think of the term automaton, I picture something like a robot, but another context in which the word is used is the idea of a cellular automaton, which is a dynamical system involving an array or grid (that's the "cellular" part) that evolves in discrete time steps according to simple rules. The way cellular automata most resemble robots is in the rules, or "programming," if you will.

What's a dynamical system? Basically any system that changes in time. We can call something like the weather a dynamical system. What makes weather different from cellular automata is that we can analyze the weather of whatever size space we want and time passes essentially continuously.

CAs are simpler—space is divided into clearly separate cells and time evolves in a step-wise fashion, almost as though each step is a turn in a game. In fact, the most famous cellular automaton is probably Conway's Game of Life which can be "played" here. It consists of a 2D grid of cells, with different colors for "alive" and "dead" cells.  The rules by which it evolves are:

  • start with some arrangement of live cells
  • any live cell with fewer than two live neighbors dies
  • any live cell with two or three live neighbors lives on to the next generation
  • any live cell with more than three live neighbors dies
  • any dead cell with exactly three live neighbors becomes a live cell
One layout possible at the link above looks like this:


To get this, select "Gosper Glider Gun" from the pulldown at the bottom.  This pattern is so named because as it evolves, the live cells form patterns of "bullets" that shoot in the direction of the picture's bottom left.

Steven Wolfram (of Wolfram Alpha and Mathematica fame) and collaborators studied one-dimensional versions of these. Think of a few cells along a line instead of a grid, and each cell evolves according to its own status and that of its nearest neighbors. And instead of one set of rules, we have 256 of themWolfram MathWorld is an incredible resource for many topics in math, but this one especially.

I will explain some of the specific rules in later posts about my songs that use CAs. But here it is worth asking the question: why are these cool and why would a musician be interested in them?  

CA patterns evolve in one of four ways: (1) the diagram quickly turns all one color or the other, (2) the configuration freezes into a regular pattern such as diagonal lines, (3) the cells seem to evolve chaotically, and (4) there isn't a regular pattern to the cells but they do have complex local structures. For item (1) I chose the simplest rules since those get to one color quickly with a single colored cell starting us off, but different initial conditions evolve this way for other rules.

Some rules even evolve into patterns that look like fractals. More on those later.

With one point and a specific rule, a fractal pattern emerges!  (reference)


So what I did was play around with some initial conditions and patterns to see what emerged. I then converted the patterns to rhythms with black cells corresponding to eighth notes and white cells to quarter notes. In one song ("Rule 34"), there are two sections, each with an intro pattern setting up the main pattern of the section. A different time signature is needed for each introduction and section. In another (called "Room 101" but using Wolfram's Rule 101), an initial condition appears to evolve chaotically, and the music's pattern is equally crazy. It's basically a different rhythm and time signature for each measure. After some of this, though, the pattern stabilizes into what I call the main groove of the song.

People make up different rhythmic ideas for sections all the time, but I think CAs gave me some interesting ideas to play with. Even hearing them with a simple clave track made me hear melodies in my head I normally wouldn't have had access to.

What's going on here?

This blog site is here to talk about the science and mathematics behind the compositions of The Devil's Staircase, a band started by Luis Nasser and Tim McCaskey. Luis and Tim are professors in the Science and Mathematics Department at Columbia College Chicago and have been long-time bandmates in groups including Sonus Umbra and Might Could.

The current lineup of the band includes Luis on bass, Tim on acoustic guitar, Aaron Geller (also formerly of Might Could) on electric guitar, Ramsés Luna (of Luz de Riada) on sax and MIDI winds, and Mattias Olsson (also of Döskalle, his solo work, and his studio) on drums and other fun instruments.

The Devil's Staircase makes instrumental rock music using patterns in science and mathematics to inform the compositions. Whether this music educates you or just helps you rock out, we are here to help.