A very basic music generator with Javascript and MIDI

The music is loosely based on my experience of popular western music.

I’ve tried to capture the creative process as I develop the system.

First pass

8 notes, repeating 12 times.

The music is comprised of 2 virtual ‘musicians’ or tracks using the GM Grand Piano:

The sound is very simple, a repeating sequence of 8 increasing notes. No AI and no development of those initial 8 notes. It’s very boring and repetitive.

Additional percussion sounds

The song generator has some development of the initial 8 notes.

After the initial run of 8 notes we made some random changes to the note’s pitch.

No AI, just random changes to the note’s pitch.

We’ve introduced new drum sounds (GM toms - high and low) on the 1 & 4.

The sound is interesting but definitely sounds random.

The notes are all one length with no pauses or breaks.

The notes do not follow a key signature.

Limiting the randomness

We limit the randomness to 4 octaves of C major.

Rest notes are included to try and make it a bit more interesting.

Perlin noise

We’ve experimented with Perlin noise. It makes the changes in pitch seem slightly less random.

The sound is random, but the changes in pitch are not so extreme.

How can we make it sound more like its going somewhere? Perhaps it needs more structure using chord progressions.

This example uses MIDI and real synths rather than the GM sounds.

MIDI and real synths

It’s not AI but this next example uses MIDI into Ableton Live and real synths (XP80, Spark LE, Ableton Live 8). We’ve nearly got an end to end system!

It would be great if the whole pipeline could generate the MIDI, perform it while recording and add the output to a radio stream.

System design

I built 3 components:

Recording studio

A song generator (written in Javascript). The generated songs are MIDI files, they are queued and then played. When played the audio is recorded and the resulting wav files are trimmed and converted to MP3 and uploaded to the Song Library.

Song library

A web API (written in Javascript and node.js). We store the songs and the associated metadata in a Mysql Database. Using the Web API we can generate playlists.

Radio station

Leveraging IceCast and LiquidSoap we can use the playlists to produce an internet radio station.



< Back to Home