/MusicGenerationWithML

Using a machine learning model to predict good music and using the model output as rewards for a reinforcement learning algorithm.

Primary LanguageOpenEdge ABL

Music Generation With Machine Learning

This is a repository for generating music by combining different machine learning algorithms. The main idea is to have a model for predicting whether a melody is good. You then use a reinforcement learning agent which gets feedback from that model to construct a policy which leads to creating good music.

All code was written by me except for the RL code in music_generation/reinforcement_learning.py.

To Do

  • Understand the MIDI file format
  • Write a MIDI parser
  • debug the MIDI parser
  • write the music theory code
  • organize the data set
  • generate random songs as bad songs for the music rating predictor
  • implement features for a music rating predictor
  • create the data for the music rating model
  • train the music rating model
  • gather RL code
  • write the environment class for the RL agent
  • try formulation 1
  • investigate improving performance of the RL agent
  • create an "environment to MDP" function to create an MDP of the music generation dynamics
  • try dynamic programming on the MDP
  • create a MIDI file data formatter to transform MIDI data files in a format this readable for my algorithm
  • try formulation 2

Music Rating Model Results

A random tree model was trained on a data set of 285 points using a train, validation, test split of 0.6, 0.2, 0.2. The resulting validation set and test set accuracies accuracy were 95.7% and 98.2% respectively.

Music Generation Model Results

See some generated melodies here: https://www.youtube.com/watch?v=3oOwJkIX-Uc

Possible Reinforcement Learning Formulations:

  1. 1 bar of music with 8 eighth notes (agent determines the notes)
  2. same as previous example, but 1 new action is added to be able to sustain the previous note.
  3. generate a 4 bar phrase using a I IV V I chord progression
  4. 2 separate agents to handle rhythm and melody generation (inspired by Maluuba's paper on separation of concerns)
  5. 1 agent which decides the next note and duration in the moment

Next Steps:

  1. try Monte Carlo Tree Search
  2. have an agent which manages repitition of melodies
  3. have an agent which manages harmony structure
  4. MORE DATA!!
  5. plot bigrams and trigrams of notes
  6. try dynamic programming on an approximation of the MDP