valda

Scores you can type.

valda plays Alda, the music language written in plain text, straight from your terminal.

One small binary with a synthesizer built in. Play a score, keep jamming in a REPL, or export it to MIDI and WAV for your DAW.

valda play -c 'piano: c8 d e f g4 a8 b > c2'
valda export -f song.alda -M 1 -o song.mid

This preview reads a small part of Alda (parts, notes, rests, chords, octaves, durations and tempo) and plays it with a simple browser synth. valda itself reads the whole language and plays it with a General MIDI SoundFont.

Get valda

Build it from source, or run it in Docker without installing anything else. Either way, run valda doctor first to check your setup.

Build from source

Needs the V compiler (tested with 0.5.1) and a C compiler. The synthesizer and audio code are built in. For playback, add a General MIDI SoundFont, for example Debian's timgm6mb-soundfont package.

git clone https://github.com/rodabt/valda
cd valda && v -prod -cc gcc -o valda .

Then put the valda binary on your PATH.

Run it in Docker

The image includes valda and a small SoundFont, so MIDI and WAV export work straight away. The wrapper script runs it like an installed binary, on files in the current directory.

docker build -t valda .
scripts/valda-docker.sh export -f song.alda -O wav -o song.wav

On Linux and WSL the wrapper plays through your computer's sound server. Elsewhere, export WAV and play the file. The README covers the REPL server and other options.

From the terminal

Every command takes a file (-f), a string of code (-c) or a score piped in on stdin.

valda play -f song.alda
Plays the score and returns when it ends. Use --from and --to with times like 0:30 or with marker names to hear one section.
valda export -f song.alda -o song.mid
Writes a Standard MIDI File. Add -M 1 to give each part its own named track, so your DAW shows the piano, bass and drums separately.
valda export -f song.alda -O wav -o song.wav
Renders audio offline, faster than real time, with your SoundFont.
valda repl
Write music a line at a time and hear each line as you enter it. The server speaks Alda's nREPL protocol, so Alda's editor integrations can connect to it. It only accepts connections from your own machine unless you add --host 0.0.0.0, for example to reach it inside a container.
valda import -i musicxml -f score.musicxml
Turns MusicXML from a notation program into Alda code you can edit.
valda doctor
Checks your setup: parsing, MIDI export, the SoundFont, the audio device and the REPL. If there's no sound device, it says so, and play stops with the same message instead of playing silence.

Examples

29 scores come with valda, from a single line to a nine-part concerto. Open one to read the code, then play it.

Start here

Short scores that each show one idea.

Full pieces

Transcriptions and originals to listen to and pick apart.

Things only text can do easily

Ideas that are awkward to play by hand.

  • phaseThree strings in three different tempos, drifting apart.
  • polyPolyrhythms on woodblock, agogô and piano.
  • all-instrumentsOne lick on each of the 128 General MIDI instruments.
  • alternate-endingsRepeats with first and second endings.
  • nestingVoices inside parts, and repeats inside voices.
  • midi-channel-management31 parts, more than MIDI's 16 channels, sharing them automatically.

To play one: valda play -f examples/bach_cello_suite_no_1.alda. The full list is in the examples folder.

Learn the language

valda runs the same language as Alda 2, so Alda's tutorials apply word for word. Wherever they say alda, type valda.

  • Alda tutorial

    Start from nothing: parts, notes, octaves, durations, chords, then voices, variables and markers.

  • Cheat sheet

    The whole syntax on one page. Keep it open while you write.

  • Alda reference docs

    Every attribute, the instrument list, repeats, cram, alda-lisp and the REPL.

  • valda README

    Building valda, setting up a SoundFont, every command, and how valda differs from Alda.

Ask Claude to write it

Two Claude Code skills come with valda. Describe what you want to play along with. Claude plans the form, writes the .alda score, checks it with valda and exports MIDI or WAV.

valda-music

Backing tracks and practice material: jam tracks in blues, rock, pop, funk, jazz, bossa, reggae, country, metal or ballad style, chord progressions, scales, modes, arpeggios, interval and rhythm drills, and tempo ramps with a click.

“A 12-bar blues in A at 96 BPM with bass, piano and drums. Leave the guitar out, I'll play that.”
# Claude shows the plan before writing the score
intro 4 | verse 8: Am F C G ×2 | chorus 8: F C G Am ×2 | outro 4   @ 100 BPM ≈ 1:07

valda-drums

Drum parts for rock, pop and metal, from punk and pop-punk to thrash and metalcore. Grooves, fills, crashes, builds, stops and endings, arranged across intro, verse, chorus, bridge and outro. It also adds drums to a score you already have.

“A pop-punk drum track at 170 BPM: verse, chorus, verse, chorus, bridge, double chorus. Put a fill into every chorus.”
#     1 & 2 & 3 & 4 &
# HH  x x x x x x x x
# SN  . . x . . . x .
# BD  x . . . x x . .
verseA = [
  V1: (vol 70) o2 f+8 f+ f+ f+ f+ f+ f+ f+
  V2: r8 r (vol 90) o2 d r r r d r
  V3: (vol 92) o2 c8 r r r c c r r
  V0:
]

Link both skills into Claude Code, then start a new session:

skills/install.sh

Using Docker? Start Claude Code with VALDA pointing at the wrapper, so the skills run valda through the image. Keep your scores under the folder you start it from.

VALDA=$PWD/scripts/valda-docker.sh claude