A (very incomplete) project that combines machine learning with music.
Jupyter Notebook HTML Other
Latest commit dd91586 Apr 21, 2016 @evancchow Update README.md
Failed to load latest commit information.
.ipynb_checkpoints Added the altered scales in 9. May 5, 2014
alice Got the basic n-gram model working in subdirectory oscar/oscar2/ git … Apr 29, 2014
backup Discovered where the chords were in the MIDI file. Added capability t… Apr 28, 2014
presentationfiles Added the README file, and cleaned up a couple things in oscar2.py, f… May 8, 2014
singleline Discovering that alice.txt sounds like rubbish. Apr 28, 2014
README.md Update README.md Apr 21, 2016
alice.py Created the offset probabilities and eliminated 0 as a possible offse… Apr 28, 2014
alice.txt Basic n-gram frequencies and probabilities calculated. Haven't added … Apr 18, 2014
alicenotes.txt Discovered where the chords were in the MIDI file. Added capability t… Apr 28, 2014
pymiditest.py Basic n gram model with playing working. Added bars and duration. Apr 12, 2014


JazzML: Computational Jazz Improvisation

Originally inspired by Gillick et al. (2010): "Machine Learning of Jazz Grammars" http://www.mitpressjournals.org/doi/pdf/10.1162/COMJ_a_00006

UPDATE: See branch "research" for the latest working demo of the project. When executed correctly (download all files, run "$ python pipe.py"), assuming all libraries are installed, it will generate guitar improvisation and play it against the prerecorded accompaniment.

Computer jazz improvisation powered by machine learning, specifically trigram modeling, K-Means clustering, and chord inference with SVMs.

Needs to be better modularized.


  • NumPy
  • SciPy
  • Pandas
  • Scikit-Learn
  • Matplotlib

In addition, you'll need a couple of specialized music libraries for Python:

If you just want to read about my work (without running any code), please use the nbviewer for iPython notebooks 6a and 6b, which document the full process (except for parsing the raw MIDI data). Here are the links to my work:

Go into the directory: http://nbviewer.ipython.org/github/evancchow/jazzml/tree/master/oscar/oscar2/

In that directory, take a look at:
Notebook 1, getting the notes and generating the n-grams: 6a. The N-Gram Pipeline Part I.
Notebook 2, all the advanced clustering/classification for the ngrams: 6b. The N-Gram Pipeline, Part II.
Notebook 3, creating and training the SVM needed for (6b): 7. Predictive Chord Modeling with Bitwise Note Vectors.

For viewing those notebooks, if you get a 400 error on the nbviewer, refresh the page once or twice. Working on this error.

Check out the subdirectory "./presentationfiles" if you'd like to see some pictures of generated vs. original music.

I worked mainly in the subdirectory "./oscar/oscar2", so all of my main code is over there (although it's in iPython files, so you'll have to either get iPython or view the ipython files with http://nbviewer.ipython.org/.

If you're new here: Included is a sample MIDI file (Oscar-Peterson-2.mid) for analysis and generation. For a quick demo, go to the subdirectory "./oscar/oscar2" and run things in this order (assuming you have the dependencies):

First, run the script oscar2.py as:

$ python oscar2.py > oscar2chords.txt (or $ python oscar2.py > oscar2notes.txt based on stdin)

This should give you two data files which represent the chords and the notes encoded in the original MIDI file: oscar2chords.txt, and oscar2notes.txt.

Next, to generate new notes with the N-Gram model, run iPython notebook 6a: The N-Gram Pipeline, Part I which writes out the n-grams to the file oscar2ngrams.txt.

Next, to generate the chord classifier (SVM) with chord notes, first run iPython notebook 5: Extract Chords to process the raw data in oscar2chords.txt, clean it up, and write it out to oscar2chords_extract.txt. Then run iPython notebook 7: Predictive Chord Modeling with Bitwise Note Vectors, which reads in that just-created file, trains an SVM to return those chords based on consonant pentatonic notes (semirandomly generated), and cPickles that SVM to disk.

Finally, for chord accompaniment and dynamic playback, run notebook 6b: The N-Gram Pipeline, Part II.