GraphTunes - making music with Markov chains

Idea

The idea of modeling music with a Markov chain grew out of twin motivations to create a composing program that leverages common UI metaphors from drawing applications and a desire to avoid the proto-typical linear playback of traditional composing software. The Markov Chain model is particularly interesting because it allows users to impose as little or as much structure on the composition as they wish.

What is it?

The software allows users to draw nodes and directed edges (lines connecting nodes) on the canvas. Each node corresponds to a note of music. Nodes have the following properties:

Nodes can have an unlimited number of outgoing or incoming edges. Each edge has a probability that it will be selected as the transition during graph traversal. The edge probabilities are constrained so that the probabilities of all outgoing edges from a node sum to 1.

The user "plays" the graph by placing walkers on different nodes of the graph. Walkers traverse the graph by randomly choosing which edges to follow according to their probabilities. Each time a walker hits a new node, a note is played. The walker will take Transition Time milliseconds to reach the next node in the graph. If a node has no outgoing edges, the walker dies.

Usage/Screenshots

The application has 4 modes for editing, manipulating, and playing the graph. Each mode has different capabilities:

  1. Selection mode - allows the user to move node and delete nodes or edges
  2. Node Drawing mode - allows the user to add nodes to the canvas
  3. Edge Drawing mode - allows the user to add edges to the canvas
  4. Playback mode - allows the user to add walkers to the graph

Adding Nodes

To enter Node Drawing mode, click on the Pen icon in the toolbar. (Alternatively, press Ctrl+N or 2.) Click anywhere on the canvas to create a new node.


Adding Edges

To enter Edge Drawing mode, click on the Arrow icon in the toolbar. (Alternatively, press Ctrl+E or 3.) Click on a node, drag the mouse, and release on another node to create an edge from the first node to the second.


Moving or deleting nodes

To enter Selection mode, click on the Move icon in the toolbar. (Alternatively, press Ctrl+S or 1.) Click on a node to select it, and press Backspace, Delete or D to remove it. Click and drag the node to move it.

Deleting edges

To enter Selection mode, click on the Move icon in the toolbar. (Alternatively, press Ctrl+S or 1.) Click on an edge to select it, and press Backspace, Delete or D to remove it.

View/Edit node properties

To enter Selection mode, click on the Move icon in the toolbar. (Alternatively, press Ctrl+S or 1.) Click on a node to select it. You can change the node properties in the "Node properties" window and press the "Apply" button to apply your edits. Alternatively, when a node is selected:

View/Edit edge properties

To enter Selection mode, click on the Move icon in the toolbar. (Alternatively, press Ctrl+S or 1.) Select an edge on the graph, and the source node will be displayed in the Node Properties window. You can edit this edge's probability by:

Playback!!!!!

Click on the Play icon in the toolbar to enter Playback mode . (Alternatively, press Ctrl+P or 4.) Click on any node on the graph to add a walker to the graph at that node. Now sit back and enjoy your composition, or lean forward and continue tweaking your graph!


Source

The source code can be downloaded here. It was built on 32-bit Ubuntu linux using the Alsa sound library, stlport, fluidsynth, RtAudio and Qt. The RtAudio library is included in the source zip, and the rest is dynamically linked.

Questions? Comments?

You can email me at crystal (dot) lemire (at) cs (dot) stanford (dot) edu.