This week I worked more on my prototype.

Below are the issues that I had solved:

  1. I fixed the function for calculating duration for each note.

Screen Shot 2018-10-09 at 7.36.41 PM.png

Above is the content in MIDI file. If the time=0 means the note is playing, if the time=10 means the note will be played after time value 10 after the previous note.

But the first version of this program, we only read in the message “noteon”. This would lead to the bug when the time value is keep running in other message such as “noteoff”, “set_tempo”, etc. The duration of a note would be wrong if we did not add up the time value in other message.

So, I did keep adding up the time variable when message did not equal to “note_on”. And when we run to “note_on”, we will use the function _sequence(previous_chunk, current_chunk, timer) to calculate the duration and create markov chain.

2. We need to detect chords

The first version I did was to read the note in chords track in each bars separately. And the compare the note with note in the chords list I defined.

The problem is that music will not follow the rules all the time. Sometime there will have extra note in a chord that would make the detection fail. So, I compare the note and record the most related list as result.