A Library for Algorithmic Music Composition

Written by on November 22, 2020 in LISP, Music, Programming with 0 Comments

I have recently started implementing a library for algorithmic music composition. It provides higher-level algorithms and abstractions for composing multi-track music, and works with Opusmodus software. Opusmodus is a great platform for music composition and has excellent support for MIDI-based music. My library is an attempt to enrich the Opusmodus platform with features that facilitate easier composition. The implementation is in a rudimentary stage, and I am excited by the possibilities it offers. The preview that I shared with some of my friends has attracted positive comments already!

This post is a sneak preview for the benefit of my readers. I am also sharing the links for a couple of song snippets (8-bar phrases) for download.

Let me start off with a simple app that I built on Windows. It provides a convenient UI for adjusting the key parameters used in the synthesis example. The app remotely connects to my iMac that runs Opusmodus as a server application for generating the music.

App for Controlling Opusmodus

App for Controlling Opusmodus

A brief explanation of the UI follows. The IP address and Port number are required for the app to communicate with the music server. The algorithms internally rely on six random numbers. These can be configured in the UI. The three buttons next to the seeds help in selecting the random values. You will see some examples later.

We can customise the pitch generation strategy by choosing an appropriate generator (five are supported at present). We can also choose the scales (along with the root) used in the melody as well as chord. Finally, we can define the Time Signature (2/4 and 4/4 are supported as of now) and the Beats-per-Minute.

When the “Generate” button is clicked, the app communicates with Opusmodus server, passes on the parameters for synthesis, and causes the music to be emitted. At present, the program only plays 8 bars (it is trivial to extend it to longer bars).

To make things interesting, I am routing the generated MIDI output from Opusmodus to Reaper DAW. There are 4 tracks as you can see.

Reaper DAW

Reaper DAW

For the different instruments, I am using Reason Rack Plugins for Guitar, Piano, Lead, and Drum. See the images below.

Guitar Plugin

Guitar Plugin

Piano Plugin

Piano Plugin

Lead Plugin

Lead Plugin

Drum Plugin

Drum Plugin

Now listen to the snippet generated by the above set of parameters.

Music Snippet-1

For the benefit of those who can read music notation, the above snippet looks like this:

Snippet-1 Notation

Snippet-1 Notation

Let us now change some parameters and generate another snippet.

Changed Parameters

Changed Parameters

Here is the generated music:

Music Snippet-2

And here is the notation:

Notation for Snippet-2

Notation for Snippet-2

The above two snippets are based on 2/4 Time Signature. Let us switch to 4/4 and 100 BPM.

One of the amazing features of Opusmodus is its support for over a hundred “scales”, including some from India! The following example uses “mela-harikambhoji” from Indian Carnatic Music. This time, I have changed the “seeds” to be all “nil” so the pitches generated will be more random.

Parameters Changed Again

Parameters Changed Again

Here is the music snippet:

Music Snippet-3

Here is the notation:

Notation for Snippet-3

Notation for Snippet-3

When one or more of the seeds are “nil”, the other parameters being fixed, we still get different music fragments each time. To demonstrate this, I am using the same parameters as the earlier one, but now listen to the music generated:

Music Snippet-4

The corresponding notation is this:

Snippet-4 Notation

Snippet-4 Notation

For further variety, I can change the instruments mapped to different tracks. Or even play the same set of tracks through multiple DAWs such as Ableton Live and Reaper simultaneously (I have tried this and it sounds great.)

I hope the above samples give you an idea of the capabilities of the library as of now. There is quite a bit of work to do and I will share the updates at regular intervals.

The UI is implemented in C++ on Windows 10 (64 bit) using RAD Studio 10.3.2.

Have a nice weekend and great week ahead!

Tags: , ,

Subscribe

If you enjoyed this article, subscribe now to receive more just like it.

Subscribe via RSS Feed

Leave a Reply

Your email address will not be published.

Top