Skip to content

Try my Web App: Melodique, a Procedural Melodic Phrase Generator

January 28, 2012

I just completed Melodique, a web app to procedurally generate melodic phrases. The tool randomly selects chords from a specified scale and then voices them using simple melodic patterns. There are many options the user can tweak to customize the process. The notes generated are displayed on a piano roll view rendered using the HTML5 canvas, and sound output can be produced using the Web Audio API (currently supported by Chrome only, but Safari should follow shortly). I coded my own simple virtual analog synthesizer to produce the synthesized piano sounds.

Programming this tool was a way for me to learn and experiment with music theory. One of the things I’ve been curious about was how I could go about randomly generating patterns that have a fairly high chance of sounding musical. The techniques used by Melodique are quite simple, chords are selected from a scale, and the choice of chords is biased more heavily towards degrees I, IV, V and vi. This is nothing revolutionary, but the tool may be useful for those learning about music theory, or simply looking for melody ideas (you can very rapidly generate and listen to many variations).

You can try Melodique at the following address:

I plan to continue experimenting with music. My next goal is to try using Markov chains or a probabilistic state machine of some sort to generate electronic music. I may also try using stochastic techniques to generate interesting sounding synthesizer patches. To be continued!

From → JavaScript, Music

  1. stanlea permalink

    Adding more scales would be cool (at least blues scales)

    • Takes one line of code to add a scale, I just need to have it in interval notation :)

      What’s the formal name of some blues scales?

  2. Formal name – Blues Pentatonic.

    interval formula: 1, b3, 4, b5, 5, b7

    example – C, Eb, F, Gb, G, Bb

    I like your web app, it’s cool. Though the first two chords and melodies it generated were in 12/8 time, oddly. 123 123 123 123… etc

    • Still rather new to music theory, I might be getting some aspects wrong.

      I will add the blues pentatonic scale tonight.

    • I added the new scale with the intervals 3 2 1 1 3 2 (half-steps), which makes for 7 notes in total if we include the starting note again. Hopefully that’s correct.

  3. reaktorplayer permalink

    Thanks for sharing your work.

    I posted it at:

  4. Robin permalink

    Maxime, this is a really nice tool. Thanks for making it available.

  5. jakerman999 permalink

    Not sure if intended, but each subsequent play of the audio is faster.

    Would it be possible to generate audio in this method such that each chord or progression is based off the previous, and just have the program generate and endless stream of music? Would that still be considered music?

Trackbacks & Pingbacks

  1. Exporting MIDI Files using Data URIs « Pointers Gone Wild
  2. Venturing into Electronic Music « Pointers Gone Wild

Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s

%d bloggers like this: