Getting Started with Algorithmic Composing

I have been periodically been asked for advice on getting started with algorithmic or automated composition. Unfortunately though, I have not been able to answer all of the questions I have received in this regard, and so I thought it best to address some of the more common issues here. The following points are what I recommend for getting started with algorithmic composing. This is based on my own experience and common problems I’ve seen like-minded people struggle with. Your millage may vary.

Start with “algorithmic,” not “automated.”

Although the terms are sometimes used interchangeably, “algorithmic composition” usually refers to appreciating mathematical models as sound or music, while “automated composition” more commonly implies some element of emulating human decision-making in music. Obviously, there is overlap between those two definitions, but the distinction is important: trying to emulate human decision making is an artificial intelligence task, and it is much more difficult than, say, turning a fractal into sound.

If you have little/no coding experience, or if you have coding experience but little/no musical experience, you will find it much easier to start by generating things that sound “interesting” through algorithmic composition rather than setting out to create a virtual Mozart to crank out chart-topping hits.

Pick a language/framework that works for you.

Before all else, pick a programming language or existing algorithmic composition framework to use. Start with freeware if you aren’t sure whether you’ll enjoy the process. There are plenty free algorithmic composing environments and compilers. Search the web and look for a tool set that is well-suited to your background.

If you already know how to code in at least one programming language, have a look for libraries that are already related to what you know. Here are a few I’ve worked with:

If you are more interested in sound than score-level representations, there are a number of domain-specific languages for this. For example:

There are also plenty of other options available in both categories (score- and sound-level). Take a look at multiple options and pick whatever appeals to you most. There is no single best language or framework to use.

Learn to code at least a little bit before setting musical goals.

It’s very hard to compose anything interesting if you are grappling with basic knowledge of the tool set. Write some test programs to do things you know you’ll want to do later, such as reading or writing files, working with lists of numbers, and so on. There are also a growing number of textbooks aimed specifically at musical applications of various programming languages – have a look for one for your language of choice.

There are a number of textbooks at this point that teach coding alongside musical applications. Examples of this include Making Music with Java and Making Music with Computers: Creative Programming in Python.

Pick a very specific subject for a first serious project.

Once you know the basics of the language, be very specific about what you’re setting out to do, and, perhaps even more importantly, don’t set your musical standards too high – otherwise you will likely end up quite frustrated. Stuck on what sort of first project to try? Look at what other people have done to get ideas. Here are a few popular topics that are also commonly used in algorithmic composition classes:

  • Making melodies with Markov chains (first order chains are easiest for a first project) – you can either specify the model by hand or train one from existing melodies.
  • Image sonification – turn pixels into notes.
  • Musical L-systems and context-free grammars – create a simple grammar for some musical property, such as melodies or chord progressions.

If you are very new to programming, pick simple algorithms. While more complex methods can produce more refined results, particularly using machine-learning strategies like neural nets, they can also be overwhelming to the novice coder. Start simple!

Set some limits for yourself.

If you are interested in producing formal musical works (in other words, having a point at which you stop and share what you’ve done), limits are important: how much do you feel the need to be composition control freak vs. being willing to let the algorithm show you its natural beauty (or lack of it)? If you don’t have a clear point at which something will be “done,” you can very easily drive yourself mad by never getting the exact sound you thought you’d achieve. Algorithmic work involves a lot of compromises. Decide up-front whether you’re just looking for machine-created inspiration for an otherwise human-made work or if you want to preserve elements of what the computer created (and, if so, how much).

Don’t use random numbers blindly.

Control your random seeds unless you truly don’t care what output you end up with. If you use a different seed each time, which is the default behavior in many languages, at least print it to the screen for reference. Otherwise, if you hear something you love, you may have no way to hear it a second time if you didn’t save the music by other means. How frustrating!

While seeding the random generator gives you the most control, it can also be annoying to manually type in a new seed each time if you want to hear, say, 20 different outputs by running your program repeatedly. Here’s one way to avoid blind use of generators that will still allows a new result each time you run the program (but you get to see what number actually produced the result!):

  1. Generate a random number, r.
  2. Print r to the screen or automatically write it to a file so you have it for reference.
  3. Seed the generator using r.

Similarly, if you don’t like what you ear, try more than one random number seed and experiment with other parameters if your model has them. Don’t dismiss a model or algorithm without some experimentation.

Present the final result as well as you can.

Whether one likes to admit it or not, sound matters – it’s the difference between listening to rich, captivating instruments and hearing everything on kazoo. If creating MIDI-level output, use interesting synthesizers to render it to audio. If you’re working at the sound level with harsh patterns like square waves, you may want to add a bit of reverb and other mastering to the final result (which can soften harsh sounds, particularly for those using headphones). If the work is intended for traditional instruments, try to at least use good-sounding virtual versions of them if you can’t get human performers. You will most likely be happier with the result if you do so and will likely get a better response from anyone you share your work with.

Try new things regularly.

This applies to music composition in a broader sense. It’s easy to get stuck in a rut of sameness and become bored as a result. Branch out and try something different from time to time. It’s particularly useful to try something alien, since you’ll learn more in exploring an unfamiliar topic. If you’ve never worked with anything but MIDI, try working with audio directly. Or, go the other way and try making scores for some really weird virtual instruments. If you work in the purely digital domain and want a big challenge, try generating a score for a real instrument and playing it! Even if you don’t like the result or the change of methods, you will learn from having tried it.

Don’t tie your creative process to specific tools.

This advice also applies to music composition in general, not just algorithmic work. Computers change and both hardware and software becomes outdated and incompatible over time. If you are in the practice of regularly trying to extend your musical tendencies in new directions and learning new tools, you will find it far easier to adapt when your favorite toolbox is rendered obsolete or even unusable by the forward march of technology. Don’t expect manufacturers to offer infinite backwards compatibility. They won’t, and they really don’t care how much you complain about it.

When working algorithmically, make sure you invest some effort in understanding the algorithms themselves, as these are mathematical concepts and, therefore, possible to use in many programming environments. The more you understand about how you got from a random number seed to a musical result, the less you will be chained to a particular software package.


Comments 3

Leave a Reply

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