esolang

Velato

The source code is a MIDI file. What counts is the interval between each note and a movable root, so a program can be composed, not just typed.

Daniel Temkin, 2009 · Turing complete: yes · ●●○ moderate · esolangs.org

The idea

Daniel Temkin made Velato in 2009. A program is a MIDI file, and only the pitch and order of the notes matter. Rhythm, dynamics and instrument are free. So the same program can be written as a march, a ballad or a jazz tune.

Read the story

The key idea is that commands are intervals, not notes. The first note of the program is the root. Every later note is read as its distance from the root: a major third, a perfect fifth, and so on. A command can also move the root, so the "key" of the program can change as it goes.

This makes programs singable, or at least listenable. Working programs tend to sound jazzy, because the commands force certain intervals together.

The machine

An imperative language with typed variables (int, char, double), while, if, input and printing. Each statement is a short phrase of notes, read relative to the current root.

First intervalStatement
Major 2ndChange the root: the next note is the new root
Minor 3rdLet: a variable (one note), then an expression
Minor 6thDeclare: a variable (one note), then a type
Major 3rdBlocks: then a second interval picks while, end while, if, else or end if
Major 6thSpecial: then a perfect 5th means print, a perfect 4th or major 6th means input

Expressions use their own intervals, where major and minor count the same. Numbers are one note per decimal digit, ending with a perfect fifth:

Digit0123456789end
Intervalm2M2m3M3P4dim5m6M6m7M7P5

A variable's "name" is a single note, so variables are pitches.

Example

Printing the letter A (code 65), read from the tables, with C as the root:

Printing the letter A (code 65), read from the tables, with C as the root:

C          the first note: root = C
A          major 6th: a special command
G          perfect 5th: print
E          3rd: the expression is a value
F          4th: of type char, digits follow
A♭         minor 6th: digit 6
G♭         diminished 5th: digit 5
G          perfect 5th: end of number

This is illustrative: it was read off the specification tables, not run through the compiler. Because only intervals matter, the same program starting on D (D B A F♯ G B♭ A♭ A) means exactly the same.

Patterns it teaches

  • Camouflage: code disguised as music. Unlike Rockstar's lyrics, the disguise is not text at all.
  • Encoding tricks: a relative encoding. The meaning is in the differences between symbols, not the symbols themselves, so a transposed program is the same program.

Try this

  1. Using the tables, write the notes for a statement that prints the number 42.
  2. Rewrite your answer with a root change in the middle, so it ends in a different key.
  3. Hard: install the Velato compiler, compose a two-statement program that sounds good, and run it.

Further

Non-textual

Source esolangs.org (CC0) · Edit on esolangs.org