Making Music With Hidden Markov Models: Music-Composition-For-Dummies-Cheat-Sheet - HTML

Download as pdf or txt
Download as pdf or txt
You are on page 1of 13

Making Music with Hidden Markov Models

Megan Robertson
Duke University
[email protected]

Anna Yanchenko
Duke University
[email protected]

Abstract
Hidden Markov Models (HMMs) are widely used for modeling sequential
data and have many varying applications. In this project, we use HMMs to
capture the latent elements involved in music creation. The observed states
are the pitch and velocity (volume) of each note in an existing song, while
the latent states include elements such as chord progression, harmonics,
dynamics and melody. In this paper, we implement three different Hidden
Markov Models trained on classical piano pieces and compare the resulting
compositions for each model.

Introduction

Hidden Markov Models are known for their use in language applications such as speech
recognition and handwriting recognition programs. Inspired by a recent homework assignment using Hidden Markov Models to generate text, we wanted to explore how successful
these same models would be in generating music. Thus, this project served as a platform
to combine our shared interests of music and statistics.
This project used music data in the form of MIDI (Musical Instrument Digital Interface) files.
This interface creates a form of communication between computers and musical instruments
that enables them to send instructions back and forth. MIDI files can contain multiple
channels that store information about the notes and velocities of different instruments.
Each notes pitch is coded as an integer between 0 and 127, where 60 refers to middle
C. The velocities are also coded as integers from 0 to 127. The files additionally contain
information about when a particular note starts and stops.1
Much thought and musical theory goes into composing any piece. The notes must progress
in a logical, harmonic way that is pleasing to the listener. The composer must pay close
attention to the circle of fifths to determine which notes sound musically cohesive.2 Dissonance can be used to elicit specific moods in the piece but does not occur by chance. In
addition, the composer must use melody, harmonies and dynamics to create a piece of music
that tells a story or conjures a specific emotion in the listener.
However, the MIDI data of a notes pitch and velocity in sequential order alone does not
capture all of the theory and ideas that create a composition. Therefore, we used Hidden
Markov Models (HMMs) to model the latent variables, specifically the musical theory that
goes into composing a piece. We utilized three different HMMs and trained them on classical
piano pieces. The estimated parameters were then used to generate new music based on the
modeling of the original piece. Our goal was to compare how successful each of the three
HMMs was in generating a musically pleasing piece and how similar our generated music
was to the original composition.
1

MIDI Manufacturers Association, An Introduction to MIDI


Music
Composition
for
Dummies,
http://www.dummies.com/how-to/content/
music-composition-for-dummies-cheat-sheet.html
2

Methods

Classical piano pieces were used to train each of the models. In this paper we present
the results for Gustav Holsts Jupiter from The Planets (arranged for piano) and Johann
Pachelbels Canon in D. The MIDI files for these songs were converted to Comma Separated
Value (CSV) files.3
The classical pieces were used to estimate the respective parameters of the models described
below. In this training, the tempo, key signature and length of the original song were not
changed. The only possible observed states were the velocities and note pitches present
in the original pieces. We treated the pitch of each note and its velocity as independent
variables. Once the parameters had been estimated, they were used to generate a new piece
of music. This process generated a CSV file of the new composition and this file was then
converted back to a MIDI file using the same program as above. The files could then be
played using a synthesizer or a program such as Garage Band.
The three models that we considered were a first order HMM, a second order HMM and a
first order HMM with two hidden states. We used the Baum-Welch algorithm to estimate
the parameters in our model, where {Xt } were the observed states and {Zt } were the
hidden states, t = 1, , T . The three models used the following parameters: the initial
distribution, i = P(Z1 = i), the transition matrix, Tij = P(Zt+1 = j|Zt = i) and the
emission distribution, i (Xt ) = p(Xt |Zt = i). For each of the three models, we assumed
that each Zt could take m possible discrete states and that each Xt could take k possible
discrete states, where 1, , k corresponded to the note pitches or velocities occurring in
the original piece. For example, if the original piece had ten different note pitches and
five different velocities, k = 10 for the HMM run on the observed notes (with each state
corresponding to a specific one of those 10 unique pitches) and k = 5 for the HMM run
on the observed velocities. The model was run once for note velocities and once for note
pitches.
The Baum-Welch algorithm was adjusted from the first order form to take into account
the structure of the parameters in the second order and two hidden state models. Using
the parameters estimated from the Baum-Welch algorithm, a new song was generated for
each of the three models. In order to evaluate the performance of each model, twenty-two
survey respondents were sent either the compositions inspired by Pachelbels Canon or those
inspired by Holsts Jupiter. They determined which of the compositions generated using
the three different HMMs they liked best. They were also provided the original versions
for both Jupiter and Pachelbels Canon and were asked which of the original versions they
thought inspired the remixes.

2.1

Model 1: First Order Hidden Markov Model

The simplest of the three models was the first order Hidden Markov Model. In this model,
the observed values, Xt , were the notes pitch or their velocity (modeled independently).
The model had only one hidden state, Zt , for each pitch or velocity and each hidden state
only depended on the prior hidden state (Figure 1). This model was run using m = 75
hidden states.

This was done using a program found at http://www.fourmilab.ch/webtools/midicsv/

Figure 1: Graphical Model - First Order HMM

The Baum-Welch Algorithm, as derived in class, was used to estimate the parameters of
this model. For details of the derivations and algorithm of this first order HMM see the
class notes.4
2.2

Model 2: Second Order Hidden Markov Model

The second order HMM assumed that each hidden state depended on the two previous
states (Figure 2). This enabled the model to capture more of the musical structure inherent
in the piece, since this structure was evolving over time and depended on more than just
the previous note. The Baum-Welch Algorithm was again used to estimate the parameters,
this time modified to accommodate the addition of another transition matrix,
Tijk = P[Zt = k|Zt1 = j, Zt2 = i]
which modeled the dependence of the current hidden state on the two previous hidden states.
The details of the algorithm for this model can be found in Mari and Schotts Probabilistic
and Statistical Methods in Computer Science5 , with a summary of the main results in the
Appendix (subsection 5.1). This model was run with m = 50 hidden states. Fewer states
were used than with Model 1 due to computational limitations.

Figure 2: Graphical Model - Second Order HMM


2.3

Model 3: HMM with Two Hidden States

The final model expanded on the initial model by adding a second hidden state (Figure 3).
This meta-state allowed the model to capture additional aspects of the hidden states and
the music generation process. These processes might have evolved at a rate different than
4

Statistics 531, Duke University Spring 2016. Instructor: Jeff Miller


Jean-Francoix Mari and Rene Schott, Probabilistic and Statistical Methods in Computer Science, Springer Science, pg. 161-167 and Brett Watson and Ah Chung Tsoi, Second Order Hidden
Markov Models for Speech Recognition, University of Queensland.
5

the processes that were present in the observed states and the first latent state. This
HMM involved a specific form of the transition matrix that allowed for a more efficient
implementation of the derived Baum-Welch algorithm. In particular, we assumed that the
transition matrix factored as
Tik,jl = Aij Bjkl = P(Rt = j, St = l|Rt1 = i, St1 = k),
where Aij = P(Rt = j|Rt1 = i) and Bjkl = P(St = l|Rt = j, St1 = k). A full derivation
for the Baum-Welch algorithm for this model can also be found in the Appendix (subsection 5.2). For each hidden state St , there were ten possible hidden states and for each hidden
state Rt , there were fifteen possible hidden states . These numbers were kept small so that
the parameters could be computed in a reasonable amount of time.

Figure 3: Graphical Model - First Order HMM with Two Hidden States

Results

3.1

Original Pieces

The three models were originally trained on four different classical piano pieces (or orchestral
pieces arranged for piano). These four pieces included Claude Debussys Clair de Lune and
Antonin Dvoraks Largo from Symphony No. 9 (The New World), in addition to Jupiter
and Pachelbels Canon. Of the four pieces, Jupiter and Pachelbels Canon provided the
best results for all of the HMMs considered. It is possible that these pieces performed the
best because of their prominent melody from the beginning of the file used. For example, in
Clair de Lune, the piece builds for a while before the melody emerges, while the version of
Jupiter that we used to train the models featured just the main melody. Thus the melody
did not have to build over a long period of time. Our models may not have worked well for
these longer songs because the models did not have the capability to capture the building
structure and evolving melody of the song over a long stretch of notes.
Both Jupiter and Pachelbels Canon are well-known classical pieces whose themes occur
frequently in advertisements and other media forms. The two pieces have a logical musical
progression. It is obvious that these pieces are structurally sound and musically cohesive
given their popularity.
A sample of the sheet music for the first 13 measures of Jupiter in its original form is
included below (Figure 4). The top row of each line is usually played by the right hand of
the piano player and is written in Treble Clef (Figure 5), while the bottom row of each line
is usually played by the left hand and is written in Bass Clef (lower than Treble Clef)6 . The
two lines are played at the same time, thus there are 13 measures included in this original
6

http://www.guitarsite.de/p1042.htm

sheet music. A sample of the sheet music


for Pachelbels
Untitled
9 Canon is included in the Appendix
(Figure. =70
14).
Steinway Grand Piano

O [
. #
. . . . .. . . .
. .#
. . . ...
& O O \ ... ### " ... ## . ..
.. .
.. --- .. . ... ### " .. ## . ..
-. -..
% O O [\ ..
.. -- ..
..
-O . .
2

!
!
O . . . .. -- .
. .# . .
& O O ..
. - . . .. ## . .. . . . .. . .. ## . .. . -- .. .. ## . ..
-- . . -- . ..
.. . . . . . .
% OO .
. .
O. . .
.
.
8

O .
& O O .. . ..
15

% OO . . .
O. . .

. . ..
. .. ## . ..Song
... --- 4: Jupiter
.. . ... ###- Original
.
.. . ..Figure
" .# .
. - ..
. . . .
-..
. . . . . . -- .
.
. .

O
. # . . . ..
& O O ... ### " ... ## . ...
..
-.. .
% O O -- ...
O22

.. . . .. Z .. \ --...
.
. Z\ --

O
. # . . . ...
& O O ... . . ... --- .. . ... ### " ... ## . ..
-% OO .. -- .. - ..
..
O.
29

.. . . .. - . .
.
. -- .
-.. -- ...
-

Y\ . [\ . # . . # . .. . . .
.. ## " .. ## .
..
..
Y\ . [\ - .
-.
.
.
.

.. . . .. !
.
. -- .. . .. ## . .. .
. -- . ..
.
. -

Figure 5: Musical Clefs: Treble Clef and Bass Clef

3.2

Model 1: First Order Hidden Markov Model

The Jupiter remix created using the first order Hidden Markov Model had lots of octave
and large pitch interval jumps that were not present in the original song. For example,
in measures one, three and four in the sheet music for the piece generated by this model
(Figure 6), pitches jump over an octave or more from one note to the next. In addition, there
were more rests in the first two lines of the remix and there were also more quarter and half
notes than occurred in the original piece. The melody of the song seemed to be distributed
about equally between the left and the right hands, while in the original composition the
right hand had the entire melody, while the left hand played the accompaniment. There
was also no musical resolution at the end of this remix.
5

Untitled 9

. =70

Steinway Grand Piano

O [ .# !
& O O \ . ..## . - . 2

% O O [\ O

.
.

.. D
.
.
.-

D D
. DD
.
.# . . . . . .
- .
.# .
. . . . . ..
.# . .
.
"
-

.
.. D . .. . ..
. . . . . . .. ...
. D - ..
.
. .
#
.
.
.# "
. .
DD . .
D
-#
% OO - . . -#
.. D D . # ." .
O
. ..
O .D
& O O . ..
9

. . .6:. Jupiter
D D Figure
O
.. . . Remix
.. . . Z\
- Model
1 . . .
.
.
.
& O O .. .. .
.
.
.
.
.
.. . # . . notes
E . more dotted
Z\ notes
The remixed
but
% O Oversion
## . . - Canon
--had
## less- sixteenth
. of.. Pachelbels
. --eighth
"
O - piece.
.
"
than the original
Pachelbels
Canon
consists
of
mostly
or
sixteenth
notes
"
-#
17

for the melody. There were also more rests in this remixed version than there are in the
25
original. Finally,
D Y were[octave
D jumps and
O Z .there
. jumps of large
-- pitch
# !intervalsD Din this version
(Figure 15).
& O O \ . \ . \ . . . . . . ... . . . -- . .. # . . # .
..

The first order HMM compositions sounded


very
different from the original compositions.
Z\
Y\ because
[\ - the. model
- # did not
- # capture enough of the
- .structure of
% O O occurred
This probably
. overall
O
- .together
the original piece.- Thus there
were some notes that occurred
that musically should
.
not have, 33leading to dissonance, while there is no dissonance in the original songs. For
. . measures,
. first order
example, the Omelody
. - . Canon
. . . builds
. - over several
. . for -Pachelbels
. # . . . yet. our
O O .able
.
.
.analogous
&not
.
.
HMM was
to capture
enough
of
this
building
structure
to
generate
an
.
.
.
progressing melody.
3.3

. . - . . -% O O . D .. -- .. - . O
.
.
#
" .Model
Model 2: Second Order Hidden Markov

D D .
.

The Jupiter composition created using the second order Hidden Markov Model was an
improvement on the first remix. It still had some large interval jumps in terms of pitch, but
fewer jumps than Model 1 (Figure 7). The chords also made more sense in the piece and
Untitled
9 rests than the first order composition,
there was less dissonance. The piece also
had fewer
1
.
=70
Steinway
Grand
Piano
but more rests than in the original composition.

O [
& O O \ --

.. ## . .
. . . . D -- . D D # . . . . .. . - ..
.
.. .
.DD
D D . . DD
% O O [\ D D ..
.. D D
.
- . - .
O
2

D
O DD
. - ..
. . .. . . & O O ..
- ... . . .
. . . ..
.
.
9

% OO O

. -#

.. - #

.. .. .
. . .

. . .

Remix - Model
. - Figure
. - 2D . . - .. Z\
O
. . . 7:. Jupiter
. .. . ... & O O .. . ..
. .. . .
. -The Canon
created
using the
Model
D . Hidden
D D . Z\had more
- .. Markov
% composition
. .second
..order
O O O -than
- sixteenth
sixteenth notes
but fewer
notes
version
# the first. remix,
. than .the original
-#
17

(Figure 16). There were still awkward interval jumps present in the piece. Overall, the
25
chords made
more sense. and
wasD less dissonance
piece than the first remix.
. . in this
[\ -there
O O Z\ of- theY\ generated
.. be
. than the .first .model.
.
.
The progression
song
seemed
to
more
logical
This
O
.
.
&
-.
.
- .
.

% O O Z\
O
33

. .
Y\ . [\ D D E # . . D .6
"" .. . -

.#
-- . # . .

.
D

probably occurred because the second order HMM captured more structure than the first
order HMM.
3.4

Model 3: First Order Hidden Markov Model with Two Hidden States

Of the three remixes for Jupiter, this version had the fewest rests of the remixed compositions, but more than the original version (Figure 8). It also contained large interval jumps.
Untitled
These jumps between notes were larger
than those9that occurred in the original song, but
.
=70
Steinway
Grand Piano
tended to be smaller than the jumps in the other
versions.

.#
.
O [
. . . .. - .. - .
& O O\ -

. D . - . - . . .# .
"

% O O [\ - .
O

.
.

..

D . . -

E."

-#

D - ..
. .

- D -#
DD
O .# . .
-- .. . . . . D . .
.
& O O .# "
.
.
. . .
..
#
. . .. .
% OO . . .. . . . . . . . . .
O
.
.
.
10

D ..
. - . . # ! . . . . . . . Z\
Figure
8:
Jupiter
Remix
.
. .3
#
. . .
. # - .Model
.
. .. . . . Z
. - D D .. % O . E ."
. D D the. two
. .more
Likewise, forO Pachelbels
latent
state
version
had
eighth and
O
. Canon,
.
.
. \sixteenth
.
O
&OO 18

notes than the other two remix versions (Figure 17). However, it still did not have as many
25
as the original
jumps between successive
. .there
. . . notes.
Zversion
D Yand
[ D were
D . still large interval
D

O O \ ..

\ .

.. ..

. -- ##

. .#

..

#
. # . .the velocities for
& O figures
. -10, Figure
. .11,-Figure
. ## "display
.12)
The following
. (Figure 9, Figure
successive notes of the original compositions and the remixes. The same figure can be found
Y\ . [\ -Canon
D . D 18).
D . -- .. .
in the Appendix
% O Z\ for
.
- Pachelbels
. .(Figure
OO

For the original Jupiter piece, the velocity appears to be approximately randomly scattered
about 80 with
a few outliers but no apparent structure. For Model 1 and Model 2, however,
33
. over
. # There
.
D D
OO O to
- .. structure
- time.
there appeared
lines
-. Dbe .significant
. in- the.velocity
. ## . .were straight
&
.
.
of constant velocity that -were not present in the original piece. Finally,
Model 3 appeared
.
to best replicate the velocity found in the original piece, as the velocities again appeared
-- D structure
. -- ## perhaps
D E .with
. . . . than- originally.
. D
. D more
. slightly
randomly%
scattered,
O . . .though

OO

. .

For Pachelbels Canon, the velocities" increased to about the middle of the original piece
and then decreased again in a parabola-like shape. None of the three models were able to
recreate this pattern in the velocity and they all had significant, straight structure and much
less variation in velocity than the original piece.
3.5

Summary

Overall, the remix generated using the second order Hidden Markov Model appeared to
have the best musical structure of all of the remixes, while the remix created using the first
order Hidden Markov Model with two latent states had better musical chords. In all of the
new compositions, the melody seemed to be split between the two hands. The models did
not catch the general structure that lower notes, those played by the left hand, were longer
in the original versions of the pieces and tended to be accompaniment, while most of the
melody was in the notes played by the right hand. In all of the models, the dynamics were
modeled independently from the pitches and as a result the dynamics did not always occur
in a logical fashion. There were many instances where certain notes were uncomfortably
loud compared to the rest of the piece.
7

90 100
80

Velocity

80

60

70

70

90 100

Jupiter Model 1

60

Velocity

Jupiter Original

200

400

600

800

1000

1200

Figure 9: Initial condition

200

600

800

1000

1200

Figure 10: First Order HMM

80

Velocity

60

70

80
70
60

90 100

Jupiter Model 3

90 100

Jupiter Model 2

Velocity

400

200

400

600

800

1000

1200

Figure 11: Second Order HMM

200

400

600

800

1000

1200

Figure 12: Two Hidden States

Twenty-two individuals were sent the three versions of one of the two original songs and were
asked which version they preferred (Figure 13a) as well as which original song, Jupiter or
Pachelbels Canon, they thought generated the new versions (Figure 13b). Of the listeners
asked about the compositions inspired by Pachelbels Canon, three preferred Model 1, six
preferred Model 2 and only one preferred Model 3. Six out of ten correctly identified the
original composition. Of those that listened to Jupiter, none of the respondents preferred
Model 1, ten preferred Model 2 and two preferred Model 3. Eight of twelve respondents
correctly chose Jupiter as the original composition for the other remixes. For both groups,
Model 2, the second order HMM, was by far the overall preferred composition.
Full MP3 versions of all generated songs, as well as the original versions of Jupiter and
Pachelbels Canon are included with the paper. As above, in the naming of the MP3s,
Model 1 refers to the first order HMM, Model 2 to the second order HMM and Model 3 to
the two hidden state HMM.

Conclusion and Further Research

Of the three models used to create the remixed compositions, none of the models produced
pieces that sounded like coherent music throughout the duration of the generated piece.
There was not a remix that told a story or evoked an emotion, like the originals. This
was not surprising given the relatively simple structures of our models. There were certain
points in some of the pieces where individual measures sounded good, but the overall piece
still was not as cohesive as we would have liked. The second order HMM seemed to perform
the best in creating music.
One extension of this project we would like to explore is the application of higher order
Hidden Markov Models. Models of higher orders would allow for the current note pitches
8

Favorite Compositions

Guesses of Original

15

10

count

count

10

0
Model 1

Model 2

Model 3

No

Yes

Favorite
Song

Canon

Correct
Song

Jupiter

(a) Preferred Compositions

Canon

Jupiter

(b) Inspiration for the Remixes

Figure 13: Survey Results


and velocities to depend on more previous states and capture more complex musical theory.
This would introduce more structure and dependence into the models that could create the
cohesion in the pieces that was missing above. The second order HMM seemed to perform
the best, so it would be interesting to see how a third, fourth or fifth order HMM could
improve the generated compositions.
In addition, we need to include the dependencies between the dynamics and the notes in
the model. This could improve the disconcerting loud notes in the pieces. Modeling such
dependency could also extend to orchestral pieces with multiple instruments. This would
require the dependencies between instruments to be modeled as well. Increasing the number
of hidden states for our current model might also improve our results, but this requires more
computational power or optimization of the current code.
The resulting compositions from these models showed promising results, but there is significant room for improvement. The improvements and extensions described above could
elevate our results to more cohesive and complicated compositions that have more of a
resemblance to actual music composition.

5
5.1

Appendix
Baum-Welch Algorithm for Second Order HMM

1. Run first order Baum-Welch to estimate , T, .


2. Use second order Baum-Welch to estimate Tijk :
Forward Algorithm:
1 (i) = i i (X1 )
2 (i, j) = 1 (i)Tij j (X2 )
:
:
t+1 (j, l) =

m
X

t (i, j)Tijl l (Xt+1 )

i=1

where 2 t T-1
and 1 j,k m.
Pm
Thus, P(X|) = i=1 T (i, m).
Backward Algorithm:
t (i, j) =

m
X

t+1 (j, k)Tijk k (Xt+1 )

i=1

where 2 t T-1 and 1 j,k m.


Baum-Welch Estimate for Tijk :
P
t (i, j, k)

Tijk = P t
k,t t (i, j, k)
where 2 t T-1 and
t (i, j, k) =

t (i, j)Tijk k (xt+1 )t+1 (j, k)


P(x|)

Iterate until convergence.


5.2

Baum-Welch for First Order HMM with Two Hidden States

Define the following:


Aij = P(Rt = j|Rt1 = i)
Bjkl = P(St = l|Rt = j, St1 = k)
Tik,jl = Aij Bjkl = P(Rj = j, St = l|Rt1 = i, St1 = k)
Zt = (Rt , St )
The constraints are

Aij = 1,

Bjkl = 1.

Define c to be a constant. Then,


Q(, k ) = c +

n XX
X
t=2 i,k

Pk (Rt1 = i, St1 = k, Rt = j, St = l|X) log Tik,jl

j,l

10

Let
Bt,ik,jl = Pk (Rt1 = i, St1 = k, Rt = j, St = l|X).
We have that
log Tik,jl = log Aij + log Bjkl .
Thus,
0=

n XX
X
X

1
(Q(, k )
Aij ) = (
)
Bt,ik,jl
Ai j
A
ij
t=2
j
k

Aij =

n XX
X
t=2

t=2

Bt,ik,jl

n XX
XX
j

Bt,ik,jl

For each i,
n X
X

Aij

Bt,ik,jl

t=2 k,l

X
XX

1
(Q(, k )
Bjkl ) =

Bt,ik,jl
Bjkl
B
jkl
t=2 i

0=

Bjkl =

n X
X
t=2

Bt,ik,jl

For each j, k,
23

5.3

&

Q Q \\

Bt,ik,jl
. . . .
. . . . . . . . . . . .t=2. .i . . . . . . . . . .
Bjkl

n X
X

% Q Q \\
Pachelbels
Canon
. Results

.
.
.
.
.
.
25
Q . . . . . . . . . . . . . . . . .
.
& Q
. . . . . . . . . .
.

% QQ . .
27

&

QQ

% QQ

. .

. .

. .

. .

!
. .. . . . Figure
.. ## .14:.. .Pachelbel
. . .. ## Original
. .. ## . .. P . . . -"
"
"

.
% QQ . . .
. .
33

. . . .
.
.
.
.
.
.
.
.
.
.
.
.
.
.
. . . . . . . . .
.

Q . ##
& Q.
29

. .

11
. .. ...
... . ..
!

. ..

. ..

Q \
& Q\ .
24

. .
. . . .
% Q Q \\ . . . . . . .
Q
#
& Q . . .. .. . . . .
! .#
% QQ . #
.
.
..
.#

. ..

27

30
Q
& Q -#

.# .

. . . .. . . .
.

. .# .

. . .

.#

.
..

. ..
. . .. .

.#
.

.
" -

.#

!
.

.
Figure- 15: Pachelbel
Remix - Model
1 .
. .
.
. . .
. . !
%26 Q Q . . . . E . . . . . ! E . . .. D .E ." . . . . # .
. "
Q \
E ! .# "
.
. . . # .. - #
& Q \ . # .! . # . . . . # . . #
-#
34
QQ
D D
D
.
&
- # . . .. - # E . . # -. .- -- . .. . . . . .
% Q Q \\"
#
.
.
.
.
.
.
.
D
.
.
.
%29 Q Q
.. .
. .. - .
.
.
.
.
!
.
.
Q .
E
E . .
. .
. . & Q
. # ." . # "
. . . .
"
41
QQ
D
D
&
% Q Q ... .
. D E. . .. . .. - # . . .. .
.
. ., D
.
.
.
"
. D .. D . D
D
%33 Q Q .. .
. .
. DE !
.
.
QQ
.. Figure. 16: Pachelbel
. .. 2. . - . ,
Remix
- Model
.
.
& . .. . ..
.. . .
..
..
E . ...
D . %
..
.! .
24 Q Q
.
.
Q Q \\- D
.
.
E
.
. .
.
" . . . .
&
. .
... ...
.. . .. .
38
Q D
D - . -# . . D . -#
D . D
& Q QQ \\. . # . . # . .
%
. . . . .
. . -#
. ..
. .
D
.
D
.
.
D
.
D
#
2
%
- .. - .
27 Q Q .
. ! - # .. .. .. .
QQ
. P .- .
.#
.
#
.
.
& #
. .
. ...
.. .
. ...
E... .... ...
% QQ
. . .
.
.
.
.
. . .
31
!
QQ
D- Model
. . .3 . .
.
.
Figure
17:
Pachelbel
Remix
.
.
.#
&
.. . # . . .
..
..
,
-DE !
% Q Q .. D E . .
. . .
. D
.
#
.
"
...
"
.
. .
36
. D
.
Q
D
& Q .. . .. P -.. P -- -- . . ... . . P . Q . - #
.
.
.. . D2
.D .D
% QQ . E . . .
.
"
. ,
Q
& Q ..
42

% QQ .

-#

12

.
..
-

.
.

D
D

. D
.

80

Velocity

40

60

80
60
40

Velocity

100

Canon Model 1

100

Canon Original

200

400

600

800

1000

Figure 18: Initial condition

200

800

1000

100
80

Velocity

40

60

60

80

100

Canon Model 3

40

Velocity

600

Figure 19: First Order HMM

Canon Model 2

200

400

600

800

1000

Figure 20: Second Order HMM

400

200

400

600

800

1000

Figure 21: Two Hidden States

References
1. MIDI Manufacturers Association, An Introduction to Midi.
2. Music
Composition
for
Dummies,
http://www.dummies.com/howto/content/music-composition-for-dummies-cheat-sheet.html
3. MIDI to CSV: http://www.fourmilab.ch/webtools/midicsv/
4. Hidden Markov Models, Statistics 531, Duke University Spring 2016. Instructor:
Jeff Miller
5. Jean-Francoix Mari and Rene Schott, Probabilistic and Statistical Methods in
Computer Science, Springer Science, pg. 161-167.
6. Brett Watson and Ah Chung Tsoi, Second Order Hidden Markov Models for Speech
Recognition, University of Queensland, 146 - 151.

13

You might also like