Geneseq: A Max external for generating melodies using a genetic algorithm


A genetic algorithm melody generator/sequencer for Max/MSP (Max external).

This Max external object implements a genetic algorithm for simple 8 step melodies using scale degrees. Given a target melody, evolve a population of candidate sequences and choose the best one for each generation. See the GitHub project’s README for a fuller description.

It was inspired by the Generative sequencers thread, specifically the post by @karol on describing a genetic algorithm for drum gates and the Genetic algorithm based drum sequencer for max4live. Additional inspiration is based on the use of genetic algorithms for guessing random strings of text, which could be used to represent a simple series of notes/scale degrees.

The motivation is to add cyclical variation to a melody that moves along a scale from random to intentional. A simple musical phrase is chosen. Successive iterations of sequences try to resolve towards it. With each cycle of these sequences evolving/resolving to the intended phrase, the cycle starts out feeling random but in a relatively short number of iterations becomes close to the target melody and eventually results in the target melody.

I am sharing this prototype here simply as a way to contribute some work back to the discussion referenced above that was a very big influence. I stumbled across the Lines thread at the same time I took my first foray into Max external development. As is probably evident, this is the work of someone very new to both C programming and developing Max externals.

For anyone interested in taking it for a spin, any/all constructive feedback is welcome. Feel free to say the C code stinks if you have any pointers (pun intended). Feel free to let me know if this could be improved from an idiomatic Max perspective (e.g., the design of messages and input, output and outlet choices).

Future enhancements may include more flexible configuration of default parameters.


  • Max 8
  • Building a Max external from source


See the GitHub README for geneseq and Example Patches once it is built.


Clone from:

Build from source using the Max SDK.

See the quick steps provided by @jojjjajjr below.


I’ll give this a spin tomorrow and report back.

For anyone that doesn’t know how to build externals, here’s how I got it working on my Mac:

  1. If you haven’t already, install XCode.
  2. Download the Max SDK and unzip it (or clone it from their Github repo)
  3. Create a directory in max-sdk/source and call it downloaded or whatever you’d like
  4. Clone the geneseq git repo in that new downloaded directory
  5. Open geneseq.xcodeproj and click the play button (or hit Cmd-B) to build the project
  6. If it succeeded, you should now have a geneseq.mxo in max-sdk/externals

i dont have room for xcode right now
would some share the external for mac?

1 Like (5.4 KB)

Here ya go! Let me know if it doesn’t work.


Hi Steve, just wanted to say that I am really happy and honored that my post inspired you to create such cool thing <3 If you are interested in exploring further biology related algorithms there is this really cool book:


Thanks for posting these instructions! I should have thought to include something like this in the original post.

1 Like

Thanks for the book recommendation. My university library even has an e-book copy, so I will start taking a look. I stumbled upon a few open access course materials when I was reading up on this topic to get a few of the terms defined, but this looks like a very thorough overview and introduction.

Thanks again for sharing your projects and the extensive descriptions of the thinking behind them.

1 Like

thank. you!
works fine

1 Like

I can’t seem to get the external to work, I’ve downloaded the .mxo but it appears as folder and Max doesn’t recognize it, I’m on windows 10 and Max 8, any idea what could be wrong?

.mxo is a format for MacOS… (windows compatible externals would be .mxe)… you could try building it for windows using the same instructions jojjjajjr left above in the 2nd post down from the OP, but use the instructions here for VSStudio instead of XCode:
building Max externals per platform

It will only let me open genesec.c on viusal studio as the main file is an xcodeproj not a vsxproj, and it won’t let me build genesec.c

no prob, if i get to a pc sometime soon, i’ll try it, but basically what you’d want to do if you want to take a further shot at it until someone else can, is take one of the SDK example projects for visual studio available in the SDK, and swap out the .c file for the one here(plus change the name to match this one… as it describes under the link above:
“ The easiest way to create a new external is to choose one of the existing SDK examples, duplicate it, and then change only the settings that need to be changed…”
since this is a max object, not an msp or jitter one, you’d want to use one of the max example projects).
in case that’s still unclear/complex, here’s a bump for anyone else who might have a pc on hand and wants to take a crack at it(apologies i’m unable to do so right at the moment).

1 Like

Thank you I will keep trying with the example projects, buy yeah would really appreciate anyone giving it a shot

1 Like

Thanks, @rajaTheResidentAlien for the assistance here. I don’t have access to a Windows computer so I cannot compile it or offer advice on how to compile the file. But definitely start from an existing example supplied by Cycling74 and then swap out the C file.

1 Like

I keep getting this error when building after taking one of the examples from the source folder and changing the .c file:

Severity Code Description Project File Line Suppression State
Error MSB4019 The imported project D:\Max Externals SDK\c74support\max-includes\max_extern_common.props was not found. Confirm that the expression in the Import declaration …\c74support\max-includes\max_extern_common.props is correct, and that the file exists on disk. Geneseq D:\Max Externals SDK\Downloaded\Geneseq\Geneseq.vcxproj 63