Sunday, February 17, 2019

Bluegrass Improvisation with Constraint Programming

Hi,
If you ever wondered, how to persuade a Constraint solver to do some bluegrass improvisations (no you haven't), wait no longer. Here is the answer:

Ok, it is not really "improvisation" but the generation of a melody under hand crafted constraints. But the constraints are similar to what you would read in books about bluegrass improvisation (Use the pentatonic scale..) minus the musicality ;-).
 Nevertheless i hope this is a good start for your own experiments with music and constraint programming.

The tough part was getting all the music libraries to work in the notebook, but thats software development (80% of the time you are spent with tasks not really relevant to what you want to achieve).

The implementation using Google's CP-SAT Solver (Google's CP SAT Solver) can be found in this github gist Fun With CP Bluegrass Improvisation.

If you are using Google's Colaboratoy (http://colab.research.google.com/) you should be able to open and run the notebook with "open in colab".


This is the result of one of the constraint solvers "solos":






And here are some examples, how real solos should sound ;-):

Solving CSP problems in the browser with Sentient

It is surprising difficult to find a CSP Solver for solving CSP Problems directly in Javascript. One such systems is Sentient https://sent...