
Alda: A music programming language - daveyarwood
http://daveyarwood.github.io/alda/2015/09/05/alda-a-manifesto-and-gentle-introduction/
======
zebproj
I've had a lot of experience with various musical languages (ChucK, Csound,
Supercollider, Max/MSP, PD, Faust etc.) I've even designed a few music
languages for myself. For what it's worth, I did go to a music school and
graduated with a bachelors degree in music, with a strong focus in computer
music composition.

In the case of Alda, I'm a little underwhelmed. To be fair, it seems that the
author of this software has done a good job meeting his goals. The syntax does
look quite intuitive, basing it off of Lilypond syntax was a good choice IMO.
I wouldn't call it a programming lanuage, and it can't do _everything_ I want,
but it seems to fit certain types of music quite well. Here is my big issue:

>In the near future, Alda’s scope will be expanded to include sounds
synthesized from basic waveforms, samples loaded from sound files, and perhaps
other forms of synthesis.

I don't want to say Alda sounds "bad", because soundfonts, samples, and basic
waveforms have their place for certain styles of music, but it is certainly
quite limiting. Considering that there are massive books written about the
"perhaps other forms of synthesis", it doesn't seem like sound itself to be
too big a focus.

From what I'm reading, Alda is essentially a MIDI file generator. It doesn't
actually produce music, rather, it sends MIDI instructions for how to play
music somewhere and leaves it up some other program to make the sounds. All of
the other music languages I've mentioned can _actually_ make music internally.

Have you ever considered using other music languages with Alda. Overtone is
just Supercollider + Clojure, so I'm sure you do something similar. I imagine
it would be pretty trivial to get Alda to write a Csound score, since it's
basically just a text table. PD has libpd, which I've had limited success
with. I might as well mention my project Soundpipe as a possible DSP engine as
well: www.github.com/PaulBatchelor/Soundpipe.git

~~~
daveyarwood
I really appreciate your input, and given your background with audio
programming languages, I completely understand how you would be underwhelmed
with where Alda is right now.

I do have pipe dreams of making Alda way, way more extensive than it is right
now. MIDI ended up being the easiest thing to implement as a sort of proof of
concept, but I am completely open to (in fact, am really hoping for) a wide
array of music generators at the disposal of Alda's syntax. The next major
milestone will be waveform synthesis, probably via a Java library like Minim
(my original idea was to control Supercollider via Overtone, via Alda, but it
seems there are too many setup issues involved, when compared to a self-
contained Java library that I can use from Clojure).

Being able to generate code in other audio programming languages is also a
thought I've had -- if not for Alda, then for a spinoff project. The primary
thing that inspired me to create Alda was that I love the unbounded potential
behind these more robust languages like ChucK and Csound, but the syntax of
these languages could be greatly simplified and adapted for use by composers
with little-to-no programming experience. I guess my point is that Alda
prioritizes aesthetics and simplicity over being a Turing-complete language
that lets you do everything you want.

~~~
mlangdon
Before even bringing in synthesis, my biggest request would be more control
flow (beyond the goto).

Loops, if statement, variables and incrementers. Maybe a "key change" we can
up X semi-tones after a keychange keyword without rewriting the notes.

------
ant6n
This is pretty neat. But I found it quickly getting very hard to read towards
the bottom.

I feel if there's a computer interpreting some sort of language, that it
should have a built in notion of the circle of fifths -- why should I give the
computer absolute notes, when everything in music is so relative. Maybe
viewing the notes in terms of do,re,mi would make sense, within the context of
being in some key; then jumping to another key (like the dominant, or the
minor version of the current key). Computers make computation cheap, which
means it should be easy to think in terms of abstractions (that's how
musicians think about music, then unwind those abstractions into absolute
notes when writing the music down).

But then I look at the current syntax, how it attempts to be extremely
compact, and worry that it won't be possible to extend to better abstractions
very well.

~~~
daveyarwood
I think this is a key thing to notice about Alda. It doesn't attempt to
provide abstractions for things like keys, scales, or even measures and time
signatures. It's more like writing Markdown: you already know what you want to
write; it just gives you a way to represent it in a compact way and turn it
into something you can hear back without having to reason too much about what
you've written. I want Alda to be as close as possible to a sheet of staff
paper that you can write notes on. MML is a very similar language in this
regard. The idea is that it's up to the composer to write down the exact notes
he/she wants, exactly how he/she wants them.

I realize this is disappointing if you're looking for something with more
abstractions, but on the bright side, I think there are some great languages
out there that do exactly that. If you haven't already, have a look at Music-
Suite ( [http://music-suite.github.io/docs/ref](http://music-
suite.github.io/docs/ref) ) and Overtone (
[http://overtone.github.io](http://overtone.github.io) ), along with the
Leipzig library, which adds functional programming abstractions for use with
Overtone (
[https://github.com/ctford/leipzig](https://github.com/ctford/leipzig) )

------
todd8
I'm not a musician of any kind, but I wanted to congratulate the creator of
Alda. I believe that (almost) everyone on Hacker News admires and respects
those who make interesting projects. We are a community of hackers that are
interested in reading about projects like yours. I see you just created your
HN account. Congratulations!

I found a few of the comments here a bit critical of Alda, but that's just the
way Hacker News works. There is such a large, diverse, intelligent, and
involved community on Hacker News that there are always people that have keen
insights or have already tried out related ideas resulting in useful, or not
so useful, observations. Inside the most critical comments may be the best
suggestions.

Keep us posted on the development of Alda; here on HN, everyone is cheering
you on.

------
phyzicist
I'd like to add to this discussion by mentioning the ChucK music programming
language ([http://chuck.cs.princeton.edu/](http://chuck.cs.princeton.edu/)).
Here is a TedX talk by the co-author, Ge Wang, talking about the joys of
digital instruments
([http://www.ted.com/talks/ge_wang_the_diy_orchestra_of_the_fu...](http://www.ted.com/talks/ge_wang_the_diy_orchestra_of_the_future)).
In the talk, Ge Wang talks about leading the Stanford Laptop Orchestra, which
uses ChucK to program all sorts of crazy digital instruments, and also talks
about "Ocarina" iPhone instrument. Cool stuff!

~~~
heuermh
+1 to ChucK!

I have a library of ChucK code here, LiCK

[https://github.com/heuermh/lick](https://github.com/heuermh/lick)

------
rebootthesystem
This is neat, of course. Yet, being classically trained myself and a software
engineer, both for 30 years, I have yet to find an alternative music notation
system that would make me proclaim I would use it.

When I look at a traditional score I see and hear the music in my mind pretty
much instantly. There is zero cognitive load, at least at the conscious level.
With any kind of text-based notation you have to read text.

Another point, perhaps minor, I think I can say that most of the world does
not learn notes as "CDE" but rather "do" "re" "mi". That's certainly how I
learned it because I did not study music in the US. Perhaps you've accounted
for this?

For me paper and pencil is still the best approach and the most natural
experience.

Notation is a powerful tool, in fact it is a tool for thought. I learned this
in CS when I studied APL and used the language professionally for nearly ten
years. Music very naturally lends itself to a sophisticated notation. I am not
sure taking that away can ever produce a better outcome.

Someone more qualified on the subject can probably explain why it is our
brains have evolved to be "tuned" for notation. My hypothesis is we evolved
powerful image recognition capabilities coupled with high speed classification
and semantic processing. We can instantly recognize shapes (predators,
something flying towards you, etc.) decide what it is, access a library giving
us options and decide how to react. All of that in a very small fraction of a
second. Notation benefits from us having developed such capabilities in our
brains.

It isn't my intent to criticize this effort. Without attempting new ideas
there can never be any progress. Kudos for trying.

I'll end with a question: What would you say is the use case for Alda?

~~~
sampl
> why it is our brains have evolved to be "tuned" for notation

I'm not sure they _are_ tuned--is there any reason you say this beyond
personal experience? Music notation is noriously difficult to learn for most
people, and many non-classical musicians avoid it entirely.

Maybe it's just self-selection. Those with a natural gift for reading are
likely to become classically trained musicians, and those without it are
likely to find other means of creative expression.

~~~
gtani
i think pianists, string, woodwind and guitar players look at scores
differently, they visualize them and start recruiting motor skills ahead of
time.

WHen i look at a Bach score as a pianist, i just kind of flow thru it, if i
see it as a guitar score, i think of the simplest fingering patterns (CAGED
patterns are the simplest framework), a woodwind player wants to pinpoint the
large intervals and octave breaks and other difficulties where intonation and
tone become tricky

(whereas with somebody laying out a c++ project or studying Baby Rudin (real
analysis), you can't explain it in terms of muscle memory

------
excel2flow
[https://en.wikipedia.org/wiki/List_of_audio_programming_lang...](https://en.wikipedia.org/wiki/List_of_audio_programming_languages)

What's the selling point of this one?

------
archimedespi
This is _awesome_ , I've dreamed about something like this for a long time.
Cool that it's done in Clojure too :)

~~~
vfdfv
I also think Clojure is a great fit.

I've had some really good results with sample-based algorithmic composition,
so I'm really looking forward to this:

 _" In the near future, Alda’s scope will be expanded to include sounds
synthesized from basic waveforms, samples loaded from sound files, and perhaps
other forms of synthesis."_

~~~
klum
Wonder if VST support is a possibility. Also things like automation, for
changing parameters like volume over time.

It's easy to see how a programming language can be a good fit for notating
certain kinds of music and allowing playback of it. Seems to me like the
challenge is to go beyond lining things up neatly to a grid and introducing
any kind of "looseness" to the music.

Edit: Then again, people do great stuff with trackers, so I'm sure a
programming language can be a great fit for some kinds of music.

~~~
vfdfv
Definitely!

Though you may already know, aligning notes to exact subdivisions of the beat
is called quantization.

[https://en.wikipedia.org/wiki/Quantization_%28music%29](https://en.wikipedia.org/wiki/Quantization_%28music%29)

Quantized music feels noticeably less organic and lively, to me at least.
Audio sequencers like Linux's Hydrogen give you the capability to mess with
"lead" and "lag", but it must be done individually for each note and so is
fairly tedious.

I've used the Python module pydub along with a random number generator to set
samples slightly ajar, but, while it helps, a purely random approach doesn't
capture how human performers implement lead and lag.

I absolutely recommend pydub as an easy way to manipulate sound files.

[https://github.com/jiaaro/pydub](https://github.com/jiaaro/pydub)

~~~
klum
Thanks for the info, pydub looks nice! And I suppose that when you have music
represented by a text file, as is the case in Alda, you can then use other
programs to operate on the text file (for example, you could probably write a
script to vary note/rest lenghts a bit using the quant attribute).

------
lukebennett
I get the thinking behind this, and seems a neat little tool. However, I can't
help thinking that the problem the author cites with modern GUIs being too
distracting to use is more likely to be solved long term by the likes of
StaffPad[0]. This allows you to physically write your notation on a blank
digital canvas, meaning the only difference to writing on a blank sheet of
physical paper is the tactile contrast of using a stylus rather than a
pen/pencil - something that is improving all the time.

[0] [http://staffpad.net](http://staffpad.net)

------
anderspitman
Disable non-error debug messages ([https://github.com/alda-
lang/alda#logging](https://github.com/alda-lang/alda#logging)):

export TIMBRE_LOG_LEVEL=error

alda repl

------
gott
This is a pretty advanced language, i like it much!!! I want to share what i
was experimenting with lately... It´s a very easy language to produce music in
the form binaural audio, it helps me to sleep with my insomnia. Sbagen is the
name and you create .sbg files.
[http://uazu.net/sbagen/](http://uazu.net/sbagen/) Idoser is based on the same
source Use this here to create or edit .drg files from or with .sbg files.
[http://binaural-spot.blogspot.de/2010/08/drg-author-
installe...](http://binaural-spot.blogspot.de/2010/08/drg-author-
installer.html) There is also an online converter for .drg files to .sbg and
the .sbg files actually show you the source, you can create wav files but they
are very large.. Use the .sbg files and in case you want this mobile, here is
an android version that can handle these kind of files:
[http://www.normalesup.org/~george/comp/binaural_player/](http://www.normalesup.org/~george/comp/binaural_player/)

------
geoffroy
Interesting ! Not that far from the new Common Lisp based language OMN brought
by Opus Modus which was released early this year
[http://opusmodus.com/omn.html](http://opusmodus.com/omn.html)

------
seba_dos1
Is there some "IDE" for it already or is this going to be my new side project?
:)

~~~
dmos62
Author mentions IDEs like Guitar Pro, etc. He referred to them as
"distracting."

~~~
seba_dos1
And I understand that. What I meant is something completely different - like a
set of autocompletion rules for chords and scales, "debugging" abilities (like
selectively playing particular voices or parts of song) and other stuff that
makes programming... err, composing in Alda easier.

Obviously reusing some already existing text editor, like Vim, Emacs, Sublime
or Atom will be the way to go when creating such "IDE". I definitely didn't
mean Guitar Pro/TuxGuitar with Alda as a backend, that would be kinda
pointless.

~~~
daveyarwood
I was about to say this, exactly! I could easily see something like this kind
of functionality in the form of a Vim plugin or Emacs mode.

------
ww520
This is pretty cool. Good work!

Couple things come to mind.

1\. Is there a way to play a selected segment of the music rather than the
whole file? While composing, replaying a segment over and over again is quite
common. Don't want to start from the beginning every single time.

2\. Is there a way to produce music sheet (PDF or PNG) from the source? There
would be really useful.

3\. Is there a way to format the notes into measures? I know the | is optional
and ignored. Can the program do reformat and automatically divides the notes
into measures?

4\. Emacs integration would be great. Using Emacs to edit. Do ^X^E to execute
the program to play the selected segment.

~~~
daveyarwood
Thanks for the kind words!

1\. I do have plans to implement start and end points for playback, either in
the form of minute/second markings or the already-implemented "markers" you
can place in an Alda score. I agree this is a crucial feature -- it will be
very useful when working on one small part of a large score. Eventually you
should be able to do something like: "alda play --file my-score.alda --start
0:30 --end chorus"

2\. Not yet -- I'm hoping we'll implement a way to generate LilyPond (
[http://lilypond.org](http://lilypond.org) ) typeset scores from Alda code.

3\. My philosophy on bar lines (and the reason why Alda ignores them as if
they were comments) is that they're essentially "invisible to the ears," and
so they don't serve much purpose except as a way to visually organize your
score file. However, in order to generate sheet music (e.g. by generating
LilyPond code), we will probably end up making them significant to the parser
after all. I can see how it might be useful to think of your score in terms of
measures, e.g. "play a few eighth notes, then rest until the end of the
measure," so I'm certainly open to the idea of implementing measures.

4\. I agree, although I'm a Vim user :P

~~~
MadcapJake
4) Just wrote [https://github.com/MadcapJake/language-
alda](https://github.com/MadcapJake/language-alda) for Atom. (Atom has the
great [https://github.com/atom/vim-mode](https://github.com/atom/vim-mode)
package and for the parent, though it seems less complete, there's
[https://github.com/avendael/atomic-emacs](https://github.com/avendael/atomic-
emacs))

Also in regards to the parent's interest in having a keybind to autoplay alda
files, there is [https://github.com/lsegal/atom-
runner](https://github.com/lsegal/atom-runner) and with a short snippet in
your config you'll have `alt-r` recognize alda files and play them!

For the language-alda package, I'm working on integrating autocomplete support
for instruments, markers and attributes. I think I can also add support for
atom-runner directly through the language package too.

Between playing around with the langauge and getting tooling support in Atom,
my whole Sunday was completely swallowed up! :P

------
hpvic03
Can this language produce an actual grand staff notation, e.g. in a pdf
format?

I'd like to use to write down compositions, but it would need that feature to
be useful. If I could write down compositions in Vim that would be killer.

~~~
daveyarwood
Not yet... but it's on my to-do list. At some point, we will hopefully be able
to generate LilyPond ( [http://lilypond.org](http://lilypond.org) ) scores
from Alda code.

------
tomcam
New to this stuff, but doesn't abc already cover this same ground?
[http://abcnotation.com/](http://abcnotation.com/)

------
rfotino
This looks great, I'll definitely be doing some experimenting! Any way to save
the output to an audio file when you're done rather than just hearing it
through Alda?

~~~
daveyarwood
Not yet -- I've had this feature on my mind for a long time, though. It's
pretty high up on the to-do list.

This is far from ideal, but as a workaround, you could set up a sound
recording program like Audacity to record system audio output and play your
score.

Hopefully in the near future you'll be able to do something like "alda play
--file my-score.alda --output my-file.wav" or something to that effect.

------
lajarre
It's written:

> o4 c++++-+-+-+

> The above is a really obtuse and unnecessary way to represent an E (a.k.a. a
> C-sharp-sharp-sharp-sharp-flat-sharp-flat-sharp-flat-sharp) in Alda.

This is equivalent to c++++, c 4-sharps. This is NOT e, as far as I know.

See
[https://fr.wikipedia.org/wiki/Comma_syntonique](https://fr.wikipedia.org/wiki/Comma_syntonique)
and how semi-tones are built.

I'm thus wondering how things are built behind the scenes..

------
akldjlafkjalfk
looks a little bit like lilypond

~~~
vixen99
Not much difference insofar as you type characters into a text editor &
present the result to be executed. I guess I'm missing something but I'd like
to see what it does that Lilypond does not already do brilliantly especially
in combination with something like Frescobaldi.

------
ademarre
Cool, but the tagline is redundant and awkward:

> _a music programming language for musicians_

I would suggest dropping one of the _musics_ : "a programming language for
musicians".

~~~
samwyse
Think that it is fine just the way it is. A "programming language for
musicians" could just as easily be BASIC or something, while a "music
programming language" could be aimed exclusively at computer scientists.

------
efnx
Besides this being rad - you can see in the Alda repl screeny that the author
has earthbound behind it. I love that game.

~~~
daveyarwood
Haha, good catch! I've been madly in love with Earthbound ever since it came
out. Playing it was a life-altering experience.

~~~
efnx
Me too. Very, very good game. It's the only real RPG I connected with, and one
of the few games that I hold close.

------
victor9000
Do you happen to have a demo link so we can hear what it sounds like?

------
TazeTSchnitzel
I installed it, but why is my console filled with debug output?

~~~
daveyarwood
I just deployed a new version of Alda earlier this afternoon (alda 0.4.5) --
it should update for you the next time you run Alda. This new version has
better default behavior for logging, i.e. not dumping a bunch of debug logs
onto your screen :)

------
anoncoder
Getting "Illegal Argument Exception" when running it.

------
mapcars
well, no sound from scratch on linux, clojure-1.7 and icedtea jvm.

