GithubHelp home page GithubHelp logo

dangoto100 / machine-learning-automatic-music-markov-chain Goto Github PK

View Code? Open in Web Editor NEW
3.0 0.0 2.0 15 KB

Automatic music composition based on Machine Learning and Markov Chains. Uses Pandas, Music21 library and Numpy on Python 3.6.1

Python 100.00%
python

machine-learning-automatic-music-markov-chain's Introduction

Machine-Learning-Automatic-Music-Markov-Chain

Automatic music composition based on Machine Learning and Markov Chains

This code will generate a music score based on a input score on midi format. Uses Markov Chains and probabilty tweaks with Pandas in order to build the score. Also uses Music21 MIT library (http://web.mit.edu/music21/) to manipulate input score and create outout score.

It was designed with the "For the love of God" score by Steve Vai - probably the best guitar virtuoso in the music business. The code also tries to understand the duration between notes and octaves, avoiding sudden changes of those. For example: if we are building a melody, then the duration must be similar on the riff. Similar when we are solo-ing, we must concatenate low duration notes.

It basically uses the following functions:

ConverMiditoList : This function will convert an input midi file to a Music21 object, that will allows us to later manipulate the score efficiently. Note that if the input midi file, you might need to explore the Music21 part, to obtain the istrument you want to analyze. In the tab under study it was partStream[5]. See code comments for further info.

createMarkovChain : This function will create a Markov Chain of first order. Computes probabiliites from one note to other.

buildsong : This function will build a song on the number of notes specified as input in the Music21 format. It will use Markov chains and probabilities to go for one note to other. Pitch and duration are "tweaked" to mantain the duration and octaves, trying to keep melody and solo "modes.".

Further study would be to parametrize automatically the tweaks for duration and octaves and create a numpy array of probabiity for those. Detecting usual duration, lenght and octaves for each part of the songs and appling it automatically. In this code is set manually via conditional statements like:

             if durations == 'S':
                x = np.random.choice(['64th','32nd','16th','eighth'], 1, p=[0.20,0.20,0.30,0.30])

An example of how to use the code:



Convlist = ConverMiditoList('C:\\Tabs\\FTLOG.mid')
Chainfirstorder = createMarkovChain(Convlist)
buildsong(Chainfirstorder,500)

machine-learning-automatic-music-markov-chain's People

Contributors

dangoto100 avatar

Stargazers

 avatar  avatar Bryan Duggan avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.