music · as · code

Write music in plain text.
Play it. Print it.

earmuff is a language for composing music as source code — so you get git, diffs, review, and scripting for free. Compile to MIDI, play it live, or engrave real sheet music.

▶ Try the playground Read the docs
No install needed — it compiles and plays right in your browser.
song.ear
project "demo" {
    bpm 96; time 4 4;

    track "piano" instrument "piano" {
        let changes = [Cmaj7, Am7, Dm7, G7];
        for ch in changes { bar quarter { ch ch ch ch } }
    }

    track "lead" instrument "violin" {
        // a caret carries a note's octave: E^5 is E in octave 5
        bar quarter { E^5 G^5 B^5 (E^5 + octave) }
    }
}

A composer's tools, a developer's workflow

Everything you'd want from a real toolchain — because earmuff source is just text.

📝

Readable syntax

A step grid for rhythm, named notes and chords (C#, Am7), and an escape hatch for exact timing.

🔁

Programmable

Reusable patterns, for loops over chord progressions, conditionals — all resolved at compile time, so it's deterministic.

🎛️

Full MIDI

Notes and chords alongside control change, pitch bend, aftertouch, program change, and sysex.

🎼

Sheet music

Engrave a real score to PDF or SVG via LilyPond — from the exact same source.

🎹

Hear it instantly

Play straight to a synth, or write a Standard MIDI File for any DAW.

🧩

Editor support

A VS Code extension with diagnostics, autocomplete, and a live score preview that updates as you type.

One source, three outputs

earmuff parses and analyzes your piece, expands it into a precise event stream, then renders it however you need.

song.ear
your source
elaborate
parse · analyze · expand
🎹 MIDI & playback
🎼 sheet music
📄 LilyPond

Bring tunes in, too: earmuff -import song.mid turns a Standard MIDI File back into editable .ear source — or drop a .mid (or .ear) right onto the playground. And every piece exports to a Standard MIDI File with -out.

See it in action

Write music as code, hear it, and watch it engrave — in your editor or right in the browser.

The earmuff playground: source on the left, engraved sheet music on the right, live events streaming below.
The playground — edit, play, and see the score and the live event stream, all in the browser. Import a .mid or .ear by dropping it on the page.
The earmuff VS Code extension: highlighted .ear source with a live engraved sheet-music preview beside it.
The VS Code extension — syntax highlighting, live diagnostics, and a sheet-music preview that re-renders as you type.

Start composing in text

Free and open source. Written in Go.