Mondrian Project

News

The new version of MondrianPM implements most of the features of MondrianLive.

Check out the paper and poster for ICMC 2006.

Introduction

Most MIDI sequencers and music description languages organize music in long lines that are stacked on top of each other, like this:

This approach mimics the traditional notation, but I would like to work in a more flexible setting. To wit, I would like to create music by lining up a few notes sequentially, stacking such lines on top of each other, aligning such stacks sequentially, stacking the resulting compound objects on top of each other, etc. In other words, I would like to structure music like one of Piet Mondrian's paintings.


Piet Mondrian, Composition A, 1923

Mondrian is an attempt to create a language that supports the expression of such structures, as well as a set of tools for using Mondrian code when recording or performing. Some features:

Multiple backends
Mondrian is designed to work with multiple backends. Currently, there are three backends, a MIDI file writer and two interactive sequencers.
MondrianLive and MondrianPM
Mondrian comes with MondrianLive and MondrianPM, two interactive sequencers that act as an arpeggiator, pattern sequencer, etc. MondrianLive directly uses the ALSA sequencer API, while MondrianPM uses portmidi. MondrianLive is more powerful but limited to Linux; MondrianPM currently lacks a few features but should work across all popular platforms. Both MondrianLive and MondrianPM manage their own MIDI connections and compensate different latencies across output devices.
Vim plugins
Both MondrianLive and MondrianPM can be used as a vim plugin, effectively turning vim into a musical instrument. (As a matter of fact, this was part of my original motivation behind the project.)
Emacs plugins
The package includes emacs plugins for MondrianLive and MondrianPM that behave much like the corresponding vim plugins.
Online demo
Just type some Mondrian code into an HTML form, and get a MIDI file in response.
Easy collaboration
One can create and share libraries of small reusable chunks of Mondrian code, such as bass lines, drum patterns, arpeggios, etc. Since notes can be defined in a relative fashion, by stepping up or down through user-defined scales, such building blocks are easy to transpose and adapt for reuse. Since meaningful chunks of code are small enough to be pasted in to instant messages, one might combine, say, vim or emacs, MondrianLive, and gaim to have distributed jam sessions.
Small size
The language definition is simple enough to implement in about 600 lines of Python code. Moreover, one only needs to know a small subset of the language to get started.
Keystroke efficiency
The notation is intended to be rather compact. While it probably won't be possible to type Mondrian code in real time, it should be possible to call and modify macros in a live performance. In most cases, translations of MIDI files to Mondrian (the distribution includes a tool that automatically translates MIDI to Mondrian) seem to be no more than 50% longer than the original binary file, and they may even be shorter than the original MIDI code if the piece is sufficiently regular.
GPL
Mondrian is available under the GNU General Public License

Example

Let's express a simple canon, Frère Jacques, in Mondrian. Here's the code that yields the first four notes:

2 > 2 > 2 2< 2
Explanation: Mondrian has a state consisting of the current note (initially C), current scale (initially C major), as well as a number of other properties. Note events are triggered by numbers giving the duration of the note. The first character, 2, triggers a quarter note of the current value, i.e., C (it's a quarter note because the number is interpreted as a negative exponent of two: 2^-2=1/4). The greater sign > moves the current note up in the current scale, i.e., the current note is now D. The next number, 2, triggers a quarter note D, and the next two characters, > 2, trigger a quarter note E. The next two characters , 2<, take us two steps down on the scale, back to C, and the final character, 2, triggers a quarter note C, so that we've defined the sequence CDEC.

Here's the beginning of the second line ("dormez-vous"):

(2> 2 > 2 > 1)
We first move up two steps, so that the current note is E, play a quarter note E, then a quarter note F, and finally a half note G (because 2^-1=1/2). The opening parenthesis saves the current state, and the closing parenthesis restores it, so that we're back to current note C even though the line ended in G.

The next line begins like this ("sonnez les matines"):

4> 3 > 3 < 3 < 3 < 2 2< 2
There are four eighth notes in this line (2^-3=1/8).

Since there's a lot of repetition in the song, let's define some macros that represent the basic building blocks:

!(2 >2 >2 2<2)!fj               # frere jacques
!(2>2 >2 >1)!dv                 # dormez-vous
!(4>3 >3 <3 <3 <2 2<2)!slm      # sonnez les matines
!(2 3<2 3>1)!ddd                # ding ding dong
The contents of macros are enclosed in exclamation marks, and the name of the macro follows the second exclamation mark. Some of the spaces that appeared above have been left out for compactness (the syntax is designed to be rather flexible that way). Comments begin with # and extend to the end of the line.

Now we express the entire melody in terms of these macros:

fj fj dv dv slm slm ddd ddd
We can save some keystrokes by calling each macro twice:
2fj 2dv 2slm 2ddd

Let's introduce more voices; we're dealing with a canon, after all.

 2fj
[2dv  | 2fj]
[2slm | 2dv  | 2fj]
[2ddd | 2slm | 2dv  | 2fj]
The first voice starts all on its own. After the first two measures (2fj) the second voice comes in. The opening bracket [ remembers the current time t0. We enter the third and fourth measure of the first voice (2dv). The vertical bar | takes us back to time t0, such that the first two bars of the second voice (2fj) are stacked on top of the third and fourth bars of the first voice. The closing bracket ] indicates the end of this stack. The time is now the end of the fourth measure of the first voice. The remaining lines introduce more and more voices.

This example illustrates the basic idea in a nutshell: We have macros that contain sequences of notes. Then we stack such sequences on top of each other, and finally we align the stacks after one another. This procedure can be iterated indefinitely, giving structures like Mondrian's paintings.

Here's the finished product:

!(2 >2 >2 2<2)!fj               # frere jacques
!(2>2 >2 >1)!dv                 # dormez-vous
!(4>3 >3 <3 <3 <2 2<2)!slm      # sonnez les matines
!(2 3<2 3>1)!ddd                # ding ding dong

160T

2fj 2dv 2slm 2ddd

 2fj
[2dv  | 2fj]
[2slm | 2dv  | 2fj]
[2ddd | 2slm | 2dv  | 2fj]
[2ddd | 2ddd | 2slm | 2dv]
[2ddd | 2ddd | 2ddd | 2slm]
[120T ddd 100T ddd | 2ddd | 2ddd | 2ddd]
The line 160T chooses a tempo of 160 beats per minute. The last line changes the tempo to 120 bpm (resp. 100 bpm) for a little ritardando at the end.

This example only shows the most basic features of the Mondrian language. We could now do the usual MIDI stuff, e.g., assign different instruments to the voices, use pitch bend or other effects, etc. There are also a few less obvious variations: Since we're only defining notes in relative terms, we can shift the entire thing to the key of A minor by adding the characters 2< at the top of the file. We could also switch to some entirely exotic scale.


Peter Brinkmann
$Date: 2006/11/19 22:53:33 $