Alda, music programming language for minimalists

Alda programming mac terminal vimI came across an interesting open source tool called Alda which basically uses command line interface to compose music. It’s a music programming language with a simple syntax which can be used to compose MIDI scores in a text editor. 

Alda processes a score sequentially, keeping track of information about each instrument. including the instrument’s volume, tempo, duration, offset, and octave. The construction of scores is based on melodies which are represented by streams of letters and characters, adding numbers after the letters to tweak the length of the notes.

But why?

It does sound complex and maybe even useless to many, as there exists a list of softwares which can easily transcribe melodies to music sheet. But I do get the concept of Alda. The creator’s original idea was to eliminate distractions caused by complicated user interfaces and get back to basics, that is focus on composition.

As the creator Dave Yarwood simply puts it, “I’m envisioning a world where programmers and non-programmers alike can create all sorts of music, from classical to chiptune to experimental soundscapes, using only a text editor and the Alda executable,”.

Instruments and soundfonts

Currently only instruments which correspond to the instruments in the General MIDI sound set are supported. Those include variants of piano, chromatic percussion, organ, guitar, bass, strings, ensemble, brass, reed, pipe, synth lead, synth pad, synth effects, ethnic, percussive, sound effects and percussion. More detailed information of those can be found here.

Alda uses the default JVM soundfonts, and it’s recommended to install a good freeware soundfont like FluidR3 for a better sound. The script to install FluidR3 is already in the repo:

$ scripts/install-fluidr3

Sheet and command

An example of a sheet is shown below. Those are usually saved in a file with *.alda extension.

# Prelude, Cello Suite No. 1 in G Major (BMV 1007)
# J.S. Bach

(tempo! 60)
(quant! 99)

cello “main”:
o2 g16 > d b a b d b d < g > d b a b d b d
o2 g > e > c < b > c < e > c < e < g > e > c < b > c < e > c < e
o2 g > f+ > c < b > c < f+ > c < f+ < g > f+ > c < b > c < f+ > c < f+
o2 g > g b a b g b g < g > g b a b g b f+
o2 g > e b a b g f+ g e g f+ g < b > d c+ < b

The syntax and notations are documented in detailed here. To play the score, simply type the following in the terminal:

$ alda play --file filename.alda

It’s also possible to play a piece of music directly:

$ alda play --code "piano: f d a e~4"

Another cool thing that comes with it is the interactive REPL (Read-Eval-Play Loop) which allows you to play around with the syntax on the fly. Access the REPL by typing $ alda repl. Once you’re in, just type the proper syntax, and enter to hear your music, and finetune accordingly.

Editor plugins

That’s another cool feature which I really like. I am currently using Vim to try out Alda, and it’s always nice to have a syntax highlighter, and those are available for Alda for editors like Sublime Text, Atom, Vim and Emacs. Below is how the syntax is highlighted in Atom. Clean!

Atom Alda syntax highlighter

Sharing is caring!

Leave a Reply

Your email address will not be published. Required fields are marked *