Every now and then, somebody tells me that they just installed Alda and they’re enjoying it, but that they aren’t quite sure where to start when it comes to writing a piece of music. The trouble is that Alda is significantly more useful to those of us who already have some knowledge of songwriting or music theory. If you don’t have that kind of background, you might feel like you could use some direction.
For a long while now, I’ve been meaning to create a series of blog posts that will bring the rest of us up to speed so that we can all use Alda to write music. I think Alda can be a great tool for computer-savvy people to learn the basics of music theory and start writing music.
So, let’s get started!
If you haven’t already, install Alda. If you already have Alda
installed, make sure you’re using the latest version by running
If you’ve done this properly, you should be able to run
alda version in your
terminal and see output like the following:
I recommend installing a good, free MIDI soundfont, as described here in the Alda README. The sound quality will be noticeably better, and so will the music that you write!
As you read through the examples in this blog series, type them yourself and use Alda to play them back. Don’t just copy and paste them into your REPL or text editor; type them out yourself! The process of typing the code yourself will get you more familiar with the syntax and help you learn faster.
There are a few different ways that you can follow along:
The Alda REPL
Alda has an interactive mode called the Read-Eval-Play Loop. To
start a REPL session, run
You can now enter Alda code, line by line, and each time you press Enter, the line of code that you entered is played back.
Text editor + terminal
You can edit your Alda code in a text file, using whatever text editor you like
best, and then, in a separate terminal, use the
alda play command to play the
contents of the file.
Text editor plugin
There are Alda plugins available for a handful of text editors. The Vim and Emacs plugins, in particular, give you the ability to play back the contents of your file (or just parts of it, e.g. what you have currently selected) just by pressing a couple of keys.
Your first notes
When you’re learning to play the piano, one of the first things you learn is where to find “middle C” on the keyboard.
To play middle C in Alda, switch to the fourth octave (
o4) and play
C in other octaves
This is only one instance of the note “C.” There are other C’s on the piano; they sound just like middle C, but they are in a lower or higher octave.
Notes besides C
Remember this: C is where the octave starts. The note letters are A through G, so it’s a little weird that the first note is C instead of A, but that’s just the way it is. (I’m not actually sure why it works that way. If you’re reading this and you know, please enlighten me!)
If you start at C and make your way up the keyboard (C, D, E, F…), you’re playing a C major scale.
Hear how the notes keep getting slightly higher in pitch. Notice how after G comes A; A is higher than G.
At this point, we’ve just played a B, and the next note up is a C. So, if we started in octave 4, then this next C is the start of octave 5.
Alda has a “next octave up” operator (
>) that lets you say the same thing in a
Experiment with changing the octave in the example above from
o4to a different octave number and see how that sounds.
Start in octave 0, play a C, go up an octave using
>, play a C, go up an octave, play a C, etc.
Start in octave 8, play a C, go down an octave using
<, play a C, go down an octave, play a C, etc.
Play an A minor scale. An A minor scale has the same notes as the C major scale, but you start on A instead of C.
Find a list of all of the instruments available in Alda. Try some of them out and find a few in particular that you like.
~ fin ~
That’s all for now. Stay tuned for more of these in the near future!
Reply to this tweet with any comments, questions, etc.!