Sunday, September 8, 2019

Jammer



Jammer is a web toy that acts as a strange kind of music sequencer. It consists of a hexagonal grid of tiles that can be toggled between two states: white and black; or for the more imaginative: alive, and dead. Each tile is tied to a specific piano note, and it will play that note while it is alive. In addition to the grid of piano tiles, Jammer has a rule-set which defines the evolution of the grid from one state to the next. When consecutive states of the grid are calculated live and played in sequence -- provided an interesting rule-set and appropriate starting conditions -- the result is a dance of live and dead tiles across the screen accompanied by a chorus of all the living tiles singing together at once.

Try it out here. (It does not work on mobile.)

View code on Github.

If this gives you a familiar feeling in one or more ways, that is likely because I stole two existing concepts and married them together to produce it. The grid based environment of stateful tiles which change over time according to a rule-set makes this a kind of cellular automata, while the hexagonal grid of piano keys and the name of the project calls to mind the amazing, yet unfairly unpopular jammer keyboard.

Cellular Automata

As mentioned, this program is a cellular automaton. Specifically, it is a two dimensional cellular automaton with a hexagonal grid. I will spare the reader a full explanation of cellular automata since there is a great wealth of great introductory literature which already exists on the topic, (Wolfram, Wikipedia, SEP) but to quickly summarize: cellular automata are made of a grid of 'cells' that each exist in multiple states. Each cell has a neighborhood of cells around it which that cell looks to when deciding how to adjust its own state. The most famous Cellular Automaton is Conway's Game Of Life, a two dimensional square Automaton which exhibits exceptionally interesting behavior, in spite of a dead-simple set of rules.

I consider cellular automata to be elegant and beautiful for the complicated and/or chaotic visuals they are capable of producing from a simple set of rules. They are an excellent case study in the phenomenon of emergence. Some even believe that the universe itself has a structure that can be be mapped onto a cellular automaton. Whether or not this is true, it is certain that many facets of the natural universe can be modeled with surprising accuracy using cellular automata, and cellular automata can give rise to patterns with a familiar kind of visual beauty that we often find in nature.

Jammer Keyboard

The jammer keyboard is 2003 re-invention of the piano keyboard with an entirely new key layout. Rather than tones being arranged in a one dimensional sequence from low-high, the jammer keyboard places notes on a two dimensional hexagonal array; supposedly they are placed in an arrangement which makes the keyboard both easier to learn and more expressive.

Not only does it seem easier to learn to play the jammer keyboard than a traditional keyboard, getting started on a jammer makes it easier to learn the theory of music in general as opposed to a learning on traditional layout. All of these benefits stem from the same core innovation: a hexagonal note layout allows important musical intervals and relations between notes to always share the same geographic arrangement no matter where they appear on the keyboard. There are several such hexagonal note layouts that a Jammer keyboard can utilize, but the most interesting is the Harmonic Table Layout.

While the first physical Jammer keyboard was made in the 21st century, the theoretical underpinning for the Harmonic Table Layout was not a recent innovation; it was originally discovered in 1739 by none other than our old friend, Leonhard Euler. Euler had a penchant for expressing complex interrelated mathematical ideas in a concise and elegant manner, and his masterful eye did not spare music theory. The harmonic table layout is an implementation of Euler's Tonnetz: a musical lattice which encodes harmonic relationships in a two dimensional space. The harmonic table layout is a highly compact encoding of music into space, in the sense that the notes of all common chords are placed physically adjacent to each other. Coherent melodies can be formed by simply 'crawling' over the topography of the keyboard.



   
local relationships of notes in harmonic table

Cellular automata are ordinarily fantastic at crawling around a grid in an interesting way, relying only on the state of local geography. By letting loose a cellular automata into such an environment where the local geography encodes musical relationships, it can now explore a whole new domain.

What's The Big Deal?

Of course, musical cellular automata are nothing new, simply googling musical cellular automaton will prove this fact. I even have created a 'piano shaped' one dimensional automaton in the same vein as WolframTones as one of my first coding projects. However, I see an important difference between most existing musical cellular automata implementations and Jammer.

It is one thing to create a music generator from a cellular automaton by mapping position to tones in a way which removes all except the tones of a particular scale which are guaranteed to sound good together -- this is, in a sense, harvesting the randomness and the patterns of a cellular automaton and 'correcting' the result into something which sounds like music. But this is a degeneration from the elegance of what it means to be a cellular automaton; the rules are no longer simple. What is special about Jammer is that the local environment of a note will consist of only notes with a special musical relationship to it, while the global environment contains the entirety of tonal space rather than being trimmed to a particular scale. This means that the 'neighborhood' of each cell -- which determines the next state of that cell -- not only contains cells that are physically proximal; they are musically proximal as well. The result is a cellular automaton which dances between all musical notes and is capable of producing musical sequences of notes, without any special rules or post-corrections. It is a simple foundation from which both complicated and chaotic music can emerge.




Now this was all very dramatic and fun to write, but the fact is: it is much easier to produce chaotic music pieces with this tool than complicated ones, as evinced by the discordant attempts at compositions I've strewn throughout this post. However, I believe that with some practice it has the potential to be a an intuitive platform for spinning out interesting generated melodies -- particularly when additional cell states are thrown into the mix (see: next steps for development below).

Getting Started

The web-app has very few controls. While paused, you can click on cells to toggle the state of the board, and you can define rules which will determine the evolution of the cells. To start defining rules, press R to bring up the rule definition screen.

I think its probably easiest to show by example. Let's first make a rule such that if the neighbor directly below a cell is alive, then the current cell will become alive on the next frame. Then, we can turn on a tile or two on the board and play this new composition.




Now on each frame, the notes crawl up the grid while simultaneously crawling up to the next perfect fifth. Next, we could create an additional rule which causes the inverse effect (crawling down) and see how these two rules interact with each other.


Hmmmm, that was a bit short. What happens if we do this...?


I haven't really gotten started myself in exploring this toy, and I would love to hear anyone's compositions. 2^13 rule-sets are currently possible... What is the iconic rule-set for this CA? What is the Conway's Game of Life for music? Let me know if you find it!

Next Steps For Development

I have had a lot of fun working on this web-app so far, and it is definitely still a work in progress. Below are listed the updates I'd like to add when I get time which will enable richer compositions and provide a better user experience. Contact me if there is a missing a feature you want.
  • More comprehensible rule GUI with descriptions of note relations directly written on the rule definition grid, and with a mini-map to the side displaying all existing rules in a cogent fashion.
  • Tempo slider.
  • Allow a rules to be made based on the number of cells in the neighborhood that are of a particular state without regard to their relative position, in the same way as the rule-set for Conway's Game of Life is defined.
  • Multiple states beyond black and white which have different musical qualities. For instance different states could represent different musical instruments, different timings, different octaves, or entirely different note layouts. 'Logistic' states which play no sound could be used as a compositional tool to play a part in triggering sounding notes.
  • Option to reduce neighborhood to nearest-6 cells.
  • State ignorant rules - 'grey' tiles which enable rules to have patterns where part of the neighborhood can match any state (or even a subset of states).
  • Resizable environment -- the current size is simply a homage to the traditional dimensions of the jammer keyboard. When I first began the project I didn't imagine I would need the dimensions to be scalable beyond (or below) this. But on reflection, very small environments the size of one or two octaves could be interesting, as could extremely large ones.
  • Ability to import or export rule-sets and seeds as JSON files so compositions can be saved and shared around.
  • Ability to directly export midi files.

No comments:

Post a Comment