Sunday, July 1, 2012

Tesseract: The artist's introduction to n-dimensional spaces

An artist's function is to take a set of elements (oil paints, cut-up audio, language) and embed them in structures. As an experiment, I have written a piece that stimulates the artist's sense of space, and forces them to consciously be mathematicians.



Tesseract is a piece in four movements for 8 parts. The artist chooses 4 dimensions that can be altered on his or her chosen elements, and throughout Tesseract, the artist will trace out a shape that shares its name with the piece: the 4-dimensional analog of the cube. In each movement, each part alters one dimension, as indicated in the piece, from either 0 to 1 (minimum to maximum) or from 1 to 0 (maximum to minimum.) Group 1 (parts 1-4) will move from the point (0,0,0,0) to (1,1,1,1) and group 2 (parts 5-8) will move from the point (1,0,0,0) to (0,1,1,1), and the paths all the parts take expresses every edge of the tesseract as an embedding in the artist's space.

A quick example of a musical interpretation of Tesseract:

  • 8 musicians playing the same (or different) amplified (or unamplified) instrument, each playing one of the 8 parts
  • The first dimension they choose is pitch. 0 corresponds to the lowest pitch their instrument produces, and 1 corresponds to the highest pitch their instrument produces (though they could pick the maximum and minimum pitch to be any set range)
  • The second dimension they pick is tempo, where 0 corresponds to very infrequently occurring note occurrences, and 1 corresponds to very frequent note occurrences.
  • The third dimension they choose is a panning oscillation, where 0 oscillates very slowly from left to right and 1 oscillates very quickly from left to right. 
  • The fourth dimension they choose is distortion, where 0 is very clean, and 1 is very distorted
In the first movement,
  1. Player 1 plays (+,0,0,0): he steadily increases pitch from minimum to maximum while keeping a very infrequent (slow) tempo, a slow panning oscillation, and a very clean signal.
  2. Player 2 plays (0,+,0,0): he steadily speeds up tempo while keeping the other dimensions at their minimum.
  3. Player 3 plays (0,0,+,0): increasing panning oscillation while maintaining the other dimensions at 0.
  4. Player 4 plays (0,0,0,+): increasing distortion while keeping the other dimensions at 0.
  5. Plater 5 plays (-,0,0,0): decreasing pitch from highest to lowest, while maintaining the other dimensions at 0.
  6. Player 6 plays (1,0,0,+): keeping pitch at a maximum while increasing distortion and maintaining minimum tempo and panning.
  7. Player 7 plays (1,0,+,0): keeping pitch at a maximum while increasing panning oscillation and maintaining minimum tempo and distortion.
  8. Player 8 plays (1,+,0,0): keeping pitch at a maximum while increasing tempo and maintaining minimum panning oscillation and distortion.
The other three movements continue in this fashion, and I leave it to the player to think about all the complex relationships between the parts that emerge from this structure.

Though I could attempt to explain the structure of a tesseract, it's much easier and more informative of me to refer you to this video of ProfessorElvisZap, who does an amazing job visually explaining higher dimensional geometry: 



Though this is neither cutting edge mathematics, nor cutting edge music, it's a great way to shake up my writing process.

Thursday, December 29, 2011

A Funky Primer (Correspondents)

This post builds on my previous post, "Alarm Clock Blues", so if there are any confusing terms, please refer back to that one!

As is the case with most mathematics, it is easy to lose track of what the components of a structure look like when analyzing the way the structure interacts with other similar structures. In this post I'd like to explore the consequences of x- and y-blocks where gcd(x,y) != ("is not equal to") 1, since most music I listen to, and most people listen to, are made out of these blocks. I'll elaborate on this, but first let's get back to the B section of Alarm Clock Blues.

In our example, each pattern is made out of equally sized notes with distinct pitches- these are our components. While I don't really care about pitch, why waste a perfectly good extension to my x-axis? Without pitch, my blocks would be indistinct, since they are all full of notes without rests. By making all pitches in a block distinct, I make the width of a block clear. Additionally, I add clarity by making the first pitch of the block the lowest sounding pitch of the pattern. I could have equally made it first pitch the highest pitch of the pattern, as long as the first pitch was distinct.

As time progresses, chords are created by overlaying all of the parts. Here are the chords created for the first 12 beats of the B section (note that I put the 7-block, not the 6-block, in the bass. This is because the 7-block "causes the most trouble", since it is pairwise coprime to the other block lengths. And I've always thought the most interesting part should be in the bass.)

C4 --> C6 --> C5 --> Bb5 --> Eb5 --> G5 --> Eb6  --> Eb4 --> D4 --> C4   --> C6 --> C5   --> Bb5
C3 --> C5 --> C4 --> Bb4 --> Eb4 --> G4 --> Eb5  --> Eb3 --> C3 --> C5   --> C4 --> Bb4 --> Eb4
C2 --> C4 --> C3 --> Bb3 --> Eb3 --> G3 --> C2   --> C4   --> C3 --> Bb3 --> Eb3 --> G3  --> C2 
C1 --> C3 --> C2 --> Bb2 --> Eb2 --> G2 --> Eb3 --> C1   --> C3 --> C2   --> Bb2 --> Eb2 --> G2

The bottom line is Player 1, the second from bottom line is Player 2, etc. I bolded the first note of each block.

Now one might think that by repeating each pattern so many times would yield every possible chord made out of the domain notes in each block, but this is where gcd comes in once again.

If you have a x-block and a y-block with x,y not relatively prime (gcd(x,y) != 1), then you will not have every possible chord created by running the blocks end-to front until a congruence occurs (in which case the chord pattern will just repeat.) For example, in the B section of Alarm Clock Blues, you will never have a C2 (in Player 2) with a D4 (in Player 4) in the same chord. Player 2 is playing 6-blocks and Player 4 is playing 9-blocks, gcd(6,9) = 3 != 1.

Let's look at a much simpler example to understand the above more completely.


Here we have an 8-block stacked on 4-blocks stacked on 4-blocks. If you imagine the top line to be a hi hat, the middle line to be a snare, and the bottom line to be a bass drum, you have your absolutely most basic A Funky Primer rock beat. (If you can't imagine, I can't think of a more excited-to-teach-you guy than this one to show you what I'm talking about.)

In the bass 4-block, there is a hit on the first beat, and then a rest on the last three beats. In the snare 4-block there is two rests, a hit, then another rest on the last beat. In the hi hat 8-block, there is a hit on every beat. Like the C2 and D4, it's clear to see that the hit in the bass 4-block will never coincide with the hit in the snare 4-block. In fact, the bass hit will always line up with the first beat of the snare part and the snare hit will always line up with the third beat of the bass part. I will define the beat(s) that a beat from one block lines up with another block as a correspondent.

For example, the correspondent of the bass hit in the snare 4-block is the first beat of the snare 4-block. Similarly, the correspondent of the snare hit in the bass 4-block is the third beat of the bass 4-block. 

Now what are the correspondents of the bass drum hit in the hi hat 8-block? Well if you run the two end-to-front, as you see above, the bass drum hits line up with the 1st and 5th hi hat notes. Conversely, the correspondent of both the 1st and the 5th beat of the hi hat 8-block is the 1st beat of the bass 4-block.

Some notation: because already this idea is getting wordy let me define the following notation.
Given an x-block and y-block,
with x,y natural numbers not necessarily unequal,
and i a natural number representing some beat in the x-block,
and a1, ... , ak the correspondent beats in the y-block,
correspondent(x-block(i), y-block) = {a1,...,ak}
In plain english the above reads, "the correspondents of the ith beat of the x-block is the following subset of the y-block."

An example of the notation:
H = hi hat 8-block; B = bass 4-block; both as above (I have not yet introduced a way to define the blocks with numbers alone.) then,
correspondent(B(1),H) = {1,5}
correspondent(H(6),B) = {2}

To any mathematicians reading this, you probably want to scream at me for not just using modular notation (http://en.wikipedia.org/wiki/Modular_arithmetic a good starting point if you want to learn more.) Since you may at this point relate H to Z/8Z and B to Z/4Z, you may expect me just to use a statement like 6 (mod 8)  = 2 (mod 4). This was where I began my thoughts about the subject, but I have since realized that it would not be sufficient for music. The reason I want to invent the idea of a correspondent is because I don't want to assume that the contents of an x-block are distinct, because in music that is rarely the case.

First, I want to be able to account for rests, since what's not played is as equally important as what is played. For example, take S = the above snare 4-block. Sure, by my current definition of correspondent can compute and spit out an answer to the input: correspondent(B(1),S) = {1}, but that result doesn't really tell me anything musical since nothing is happening on the first beat of the snare 4-block. Therefore, if a correspondent beat is a rest, then the resulting correspondent set should just be marked with a *. So instead of correspondent(B(1),S) = {1}, I mark the beat with a star and I have correspondent(B(1),S) = {1*}.

But I want to push the idea of a correspondent further. Currently a correspondent as I define it fails to capture a situation like the following:


This is the same drum pattern with one small but significant addition. The bass part is no longer a 4-block since now there is an additional hit on the 7th beat of the pattern, so it is now also an 8-block like the hi hat. Now I need to rethink what question I'm trying to answer by finding a beat's correspondent in another block. A correspondent should tell me, in plain english, "what lines up with the note that I am looking at in the corresponding block." But if all I get out of correspondent(B(1),S) = {1*}, how am I supposed to know that the bass drum does in fact line up with the snare part, but only on the 7th beat, without having to look at the MIDI file?

Therefore when looking for my corresponding beats in the corresponding block, I should look at all beats in the corresponding block that correspond to all beats equivalent to the beat I am evaluating. 

Since all bass drum hits are equivalent in my scenario, I define the equivalence class B[1] = {1,5,7}. This is the location that all hits occur in B that are equivalent to the note that occurs on the 1st beat. This is clearly an equivalence relation, and therefore B[1] = B[5] = B[7] but in general I will take the first occurring beat to be my representative for the equivalence class. I'm afraid at this point some readers may be lost so let me give some examples.

Example 1

Example 1, A = 8-block
A[1] = {1,3,5,7,8}
A[2] = {2,6}
A[*] = {4}

Example 2
Example 2, B = 12-block
B[1] = {1,3,5,6,8,10,12}
B[2] = B - B[1]
=> B[*} = {null}


So now we are easily able to expand our definition of correspondent. The notation correspondent(B[1],S) (with square brackets instead of parenthesis) means to look for where all equivalent beats of the beat indicate correspond in the corresponding block. Therefore the following three statements are equivalent: 

correspondent(B[1],S) 
= {correspondent(B(1),S), correspondent(B(5),S), correspondent(B(7),S) 
= {1*, 3}

Lastly, since all rests are equivalent, I want a rest class to be defined by [*].

For example, in my second drum beat example, where B[1] = {1,5,7}, 
I can find B[*] = {2*,3*,4*,6*,8*} but since it's known that I'm looking at rests, I will just say B[*] = {2,3,4,6,8}. Note that in this scenario, where there is only one distinct note in the block, 
B[*] = B - B[1]. This will not always be the case in general. 

For the grand finale, I'm finally able to define blocks from scratch without having to write them out in reason or use music notation. To do this I will use equivalence classes. If I define all the equivalence classes in a block, I can then assign each class to a sound when I actually want to make music.


A = 8-block //as in Example 1
A[1] = {1,3,5,7,8}
A[2] = {2,6}
A[*] = {4}


B = 12-block //as in Example 2
B[1] = {1,3,5,6,8,10,12} //This is your standard bembé clave.
B[2] = {2,4,7,9,11} // fills in the spaces
=> B[*] = null

C = 15-block
C[1] = {1,2,3,5,8,13} //a recognizable pattern
C[*] = C - C[1]

D = 15-block
D[1] = {1,5,9,13}
D[3] = {3,6,9,12}

From my previous post I know that I'll have a congruence after lcm(12,8,15,15) = 120 beats, which equates to 120/12 = ten 12-blocks, 120/8 = fifteen 8-blocks, and 120/15 = eight 15-blocks.

Then I assigned a sound to each equivalence class, and here is what came out!


The above is a soundcloud link that is unfortunately not very informative unless you can pick out the parts by ear. Below is a link to a project I've been developing called Groovato. It's not quite finished, but it works extremely well illustrating this point. Simply scroll down to the groove called "8-12-15-15-Blocks", hit "Play it!", and then you can solo out the individual tracks at your discretion. If you create an account on Groovato you can also get a little more in depth with the tracks (altering their tempo, recording on top of them, downloading your recordings, creating your own grooves) but the whole thing is a little buggy so please be patient with it! It is definitely a better medium to explore track-based music with.


As always, please leave any feedback in the comments, as I need all the help I can get developing this thing.

Next up- Rhythmic Generators!

Alarm Clock Blues (Rhythmic Congruences)

The first piece I wrote on my computer with the intention of having it played by humans (it never was) was called Alarm Clock Blues.

I've been a drummer all my life so, to me, tonality is simply the vertical axis that makes my rhythmic grid two-dimensional. I've grown to appreciate and respect great writers of pitch-focused music, but I realize that I will never be able to write a good melody on purpose, nor will I be able to build and release tension with pitch alone, and therefore any interesting melodic properties of my music are a product of some rhythmic function I'm generating the sounds with, and are not of my own design.

Alarm Clock Blues by Rhythmic Mathematics Blog

The structure of Alarm Clock Blues is straight forward: A B A. Nothing of relevant interest happens in the A's, nor in the bridge between B and the second A. However, the B section is an illustration of the first rhythmic mathematical concept I want to discuss in this blog.

The piece is written for four pianists. The idea of the B section is as follows: one player plays a 6 beat pattern, the next plays the 6 beat pattern + 1 more beat, the next plays the 7 beat pattern + 1 more beat, and the last player plays the 8 beat pattern + 1 more beat.


If you're unfamiliar with piano roll notation for music, it's very easy to understand. The height of each note corresponds to its pitch (in Reason the y axis is a piano for quick reference) and the width of each note corresponds to its duration. For this section, the grid is 16th notes. The x-axis is time and it intuitively runs left-to-right.


The 6 beat pattern:

The 7 beat pattern:


The 8 beat pattern:


The 9 beat pattern:

Ever the lazy composer, all I did at this point was duplicate these patterns end to start until they all ended at the same point in time. Of course, being lazy, I didn't want to keep checking after every duplication to see if everything was lining up so I needed the answer to the following question: how many repetitions of each would I need to re-synchronize all of them?

The key to answering this question is considering each pattern as a block. This idea should appeal to your inner toddler. The width of the block is the number of beats in the pattern.  Visually, if you lay all the blocks used in the B section on top of each other you get the following structure (click image to expand):


The structure stacks 6-blocks upon 7-blocks upon 8-blocks upon 9-blocks. You may start to notice patterns already, but for clarity, here is the same image with only X-congruences (where X is the number of blocks start at the same point on the x-axis) highlighted:


As desired, there are only two 4-congruences, one the first and last beat of the structure.

Now the following observation can be made:

After every seven 6-blocks and every six 7-blocks there is a congruence between 6- and 7- blocks. In other words, if you play the 6-block pattern seven times and at the same time play the 7-block pattern only six times, you'll be in the same place in time. The same is true for every for 7- and 8-blocks, 7- and 9-blocks, and 8- and 9-blocks.

7-blocks stacked on 8-blocks

The following rule can be proposed based on the above observation: 
If you have an x-block and a y-block, where x and y are natural numbers (integers greater than 0), 
then for every x y-blocks and every y x-blocks you will have a congruence between the x- and y-blocks.

This reason this rule is not good enough for my needs is illuminated when stacking 6- and 8-blocks.

6-blocks stacked on 8-blocks

While there is a congruence after six 8-blocks and eight 6-blocks (the third 2-congruence highlighted above), there is also a congruence after three 8-blocks and four 6-blocks (the second highlighted 2-congruence.) In fact, if you didn't know that you were stacking 6- and 8-blocks, you would guess that this was a 3- on 4-block stack, since they look exactly the same without the context of the underlying grid.

Similarly, upon examination, there is certainly a congruence after nine 6-blocks and six 9-blocks, but there is also one after three 6-blocks and two 9-blocks.

So what makes the 6-8 block stack and 6-9 block stack different than the 6-7, 7-8, 7-9, and 8-9 block stacks? If the answer is not immediately clear, try to remember your 6th grade math class and the "greatest common divisor." The greatest common divisor, often referred to as gcd, of non-zero numbers is the largest positive number that divides the numbers without a remainder.

Ex.
   gcd(4,6) = 2 (Read "the greatest common divisor of 4 and 6 is 2")
Ex.
   gcd(5,3) = 1
Ex.
   gcd(4,8,12) = 4

Let's look at gcd's of our pairs:

gcd(6,7) = 1
gcd(6,8) = 2
gcd(6,9) = 3
gcd(7,8) = 1
gcd(7,9) = 1
gcd(8,9) = 1

We previously saw that there is a congruence of 6- and 8- blocks after four 6-blocks and three 8-blocks, and it is not coincidence that 6/gcd(6,8) = 6/2 = three and 8/gcd(6,8) = 8/2 = four. Also we see in the case of 6- and 9-blocks that 9/gcd(6,9) = 9/3 = three and 6/gcd(6,9) = 6/3 = two.

Note: if gcd(a,b) = 1 for any two non-zero a's and b's, then it is said that a and b are relatively prime, or coprime. I will be using this terminology in future posts.

Of course once you start remembering the greatest common divisor, the phrase "least common multiple" (abbreviated lcm) should start ringing in your ears. The least common multiple of some numbers is the smallest number divisible by all the numbers you're looking at. The least common multiple is what will lead us to the answer of our congruence question.

This brings us to the first conclusion I will propose on this blog, and though the proof is somewhat trivial, I will save it for a future post.

1st Polyrhythm Postulate
Given an x-block and a y-block,
where x and y are natural numbers,
a congruence between the x- and y-blocks exists after:
  
(lcm(x,y)/x) x-blocks and (lcm(x,y)/y) y-blocks.

This accounts for the case when the gcd of a pair is not equal to 1, but since 
you can take the lcm of multiple numbers, the postulate can be generalized.


1st Polyrhythm Postulate (Generalized)
Given an a1-block, a2-block, ... , ai-block (for some natural number i),
where a1, a2, ... , ai are natural numbers,
if some natural number L = lcm(a1,a2,...,ai),
then a congruence between all blocks exists after:
(L/a1) a1-blocks, (L/a2) a2-blocks, ... , and (L/ai) ai-blocks


Now I can finally answer my lazy composer question:
how many repetitions of 6-, 7-, 8- and 9-blocks would I need to have a congruence?

Here L = lcm(6,7,8,9) = 504

Therefore, my so dearly sought after 4-congruence exists after:

(504/6) = 84 6-blocks
(504/7) = 72 7-blocks
(504/8) = 63 8-blocks
(504/9) = 56 9-blocks


I am reminded of xkcd 974:



Such is the way of all good extensible ideas.