turtle.audio

4 min read Original article ↗

The Basics

What am I looking at?

A Musical Line Drawing

turtle.audio is an audio environment where simple text commands generate lines that can play music.

Double-click to create a new line. Give it a rule: use m to move forward, r to turn right 90 degrees, and l to turn left 90 degrees.

The white box represents the starting point of our line. You can drag it anywhere on the grid.

Clicking on the Paint tab switches to Paint mode. Select a note and paint it to the grid!

Basic Rules

  • m → Move
  • r → Turn right
  • l → Turn left
  • w → Wait for one beat

Putting a number after a rule will repeat the rule that many times. m7, for example, will move forward seven times.

Here are a few rules to get you started:
  • m7 → A line that covers 8 grid boxes
  • m4r m4r m4r m4r → A square in 4/4 time
  • mrmrmmrmmrmmmrmmmrmmm → A spiral in 4/4 time

Writing Rules

How to draw interesting scenes

The Classics

A simple linear step sequencer can be created by placing a few lines next to one another with rules like m15 (for vertical lines) or r m15 (for horizontal lines).

Squares can also serve as good step sequencers, since they can selectively share notes. Writing mmmmrmmmmrmmmmrmmmmr is a bit cumbersome, so you can use parentheses to repeat instructions a certain number of times. mmmmrmmmmrmmmmrmmmmr is equal to (mmmmr)4 and, even simpler, (m4r)4.

This rule creates a 16-step square.

Use a variable for more possibilities

A variable that you can add to and subtract from enables more interesting shapes, like spirals. You can add a variable after any instruction — mi, ri, li, or wi — to execute the instruction i times in a row.

Using variables

  • i → a variable which starts at 0
  • i+ → add 1 to the variable
  • i- → subtract 1 from the variable

The rule (mi+rmir)4 will produce a spiral. It loops the instruction mi+rmir four times...

Loop #1

  1. 1. move forward i + 1 steps (1)
  2. 2. turn right
  3. 3. move forward i (1) steps

Loop #2

  1. 1. move forward i + 1 steps (2)
  2. 2. turn right
  3. 3. move forward i (2) steps

etc.

Change the value of i

If you want to set the value of i before you start using it, you can use square brackets like so: [i=2]. You can put these statements anywhere in a rule to quickly change values.

Keyboard Shortcuts

There's a shortcut for everything

Sound Mode

  • tab → Switch to Paint mode
  • shift + click → Add a new line
  • command + drag → Pan around the scene

Paint Mode

  • tab → Switch to Draw mode
  • shift + click on a paint color in the color palette → Preview the sound
  • command + drag → Pan around the scene

In paint mode you can use your keyboard to select notes. The a key represents C, w is C#, etc., all the way up to the ' (apostrophe) key. If you have a line selected you can hold shift while selecting a key to preview it.

Playback Controls

  • space → play/pause
  • left arrow → move 1/16th note backward when paused
  • right arrow → move 1/16th note forward when paused

Advanced Rules

If you're feeling adventurous

More control over the variable

In addition to incrementing the variable when using it (with i+ and i-), you can set and increment the value of the variable as a standalone expression by placing it in brackets.

  • <instruction>i+2 → the current value of i plus a value (e.g. mi+5)
  • <instruction>i-2 → the current value of i minus a value (e.g. mi-5)
  • <instruction>i*2 → the current value of i multiplied by a value (e.g. mi*3)
  • <instruction>i/2 → the current value of i divided by a value (e.g. mi/3)
  • [i=5] → set the value of i (e.g. [i=5] (mirmi+r)4)
  • [i++] → increment i
  • [i--] → decrement i
  • [i+=5] → add to the value of i
  • [i-=5] → subtract from the value of i
  • [i*=5] → multiply the value of i
  • [i/=5] → divide from the value of i (rounds to the nearest integer)
  • [i%=2] → set i to the remainder of i divided by a value