Linear Recurrence Relations in Music

advertisement
Linear Recurrence Relations
in Music
By Chris Hall
The Aim of My Project
• The goal was to take a composition by
Beethoven and generate a linear
recurrence relation that best represents
the tonality of the music.
• Sonata No. 1, Op. 12 in D Major
Linear Recurrence Relations
• xn= a1xn-1 + a2xn-2 + … + akxn-k
Premises
• only the melodic line was used; no chords. This
allows the counting of only a single note at a
time.
• The range of notes used was restricted to the
audible range as determined by MIDI: Z128.
• The value of a single note was determined by
MIDI format with middle C being 60. All notes
were sequentially valued based on their pitch
relative to the pitch of the notes immediately
above and below (i.e. if E is 20, D# is 19 and F
is 21).
What was investigated
•
•
•
•
The degree of the recurrence relation
The range for coefficients
The best algorithm for finding the relation
The best-fit solution
Establishing the quality of results
• The standard deviation of the original set of notes was
considered the maximum allowable error for the notes
being generated by the relation.
• The calculated errors considered for comparison were
the square errors of the generated notes from the
original notes.
• The average square error of all the notes generated was
then compared to the standard deviation of the original
note set. Only those errors below the standard deviation
were considered acceptable.
• The highest quality results were considered to be
acceptable results with the farthest distance from the
standard deviation.
The Method
• The first avenue taken was to consider the same number
of equations as unknowns, where the unknowns were
the coefficients of the recurrence relation.
• Like all following methods, MATLAB was used to
generate notes, errors and comparisons.
• The MATLAB program was written to allow the user to
enter in their desired degree of relation (which
corresponds to the number of unknowns). For the sake
of comparison, more than one degree could be entered
at a time.
• The program then produces a series of average square
errors on a graph that correspond to the number of
equations used, the theory behind which will be
discussed a bit later.
The First Program
Using more equations
• In order to vary the number of equations
used, the least squares method was used.
• Because the rank of each matrix was full,
a unique solution could be obtained.
• Moreover, since the function considered
was the sum of the square errors, the
Hessian Matrix of the function was always
a multiple of the product of the matrix with
its transpose.
A simple 4x2 example
fc1 ,c2 
a3 c1 a2 c2 a1 2 
a4 c1 a3 c2 a2 2 
a5 c1 a4 c2 a3 2 
a6 c1 a5 c2 a4 2
Take the gradient and solve for zero:
c 1 a 22 a 23 a 24 a 25 c 2 a 1 a 2 a 2 a 3 a 3 a 4 a 4 a 5 a 2 a 3 a 3 a 4 a 4 a 5 a 5 a 6 
c 1 a 1 a 2 a 2 a 3 a 3 a 4 a 4 a 5 c 2 a 21 a 22 a 23 a 24 a 1 a 3 a 2 a 4 a 3 a 5 a 4 a 6 
Which is:

a 22 a 23 a 24 a 25 

a 1 a 2 a 2 a 3 a 3 a 4 a 4 a 5 

a 1 a 2 a 2 a 3 a 3 a 4 a 4 a 5 

a 21 a 22 a 23 a 24 

c1

c2

a 2 a 3 a 3 a 4 a 4 a 5 a 5 a 6 

a 1 a 3 a 2 a 4 a 3 a 5 a 4 a 6 
A Ac A b
T
T
The Least Squares Solution
Other definitive information
• I know that the point zero is a local
minimum because the Hessian Matrix of
my original function is positive definite.
2

a 22 a 23 a 24 a 25 

a 2 a 1 a 3 a 2 a 4 a 3 a 5 a 4 

a 2 a 1 a 3 a 2 a 4 a 3 a 5 a 4 

a 21 a 22 a 23 a 24 
since it is
2A T A
The Discreet Case
• The next path for investigation was to analyze
coefficients with discreet rather than continuous
ranges.
• It should be noted that these ranges included
but were not limited to finite fields.
• Since the notes themselves were elements of
finite range (remember, Z128 ) the ranges for the
coefficient vectors investigated were covered by
the range of the notes
The Discreet Case cont’d
• Another MATLAB program was written that allowed the user to input
a desired range of coefficients and the desired number of equations.
• For reasons to be discussed shortly, only degrees two and three
were used.
• In the degree two case, the square errors were calculated in arrays
for all possible combinations of the range of coefficients and then
stored in a square matrix that was Range(C)xRange(C) for
comparison. The output is the coefficient vector along with the least
square error. A graph is also generated that compares the original
note set along the total number of notes use with the generated
notes.
• The difference in the degree three case was in the storage of the
square errors. In this case, three dimensional storage was required.
The Discreet Program
Output for Range 3 with 10
Equations
Output for Range 3 with 10
Equations
Testing With an Actual Recurrence
Relation
• An actual recurrence relation was written
to test the program.
• When the chosen range covered the range
of the original coefficients, the program
generated the sequence exactly.
Otherwise, it produced a best
approximation.
Test with [1,4,6] as the Coefficient
Vector and a Range of 5 with 7
Equations
Test with [1,4,6] as the Coefficient
Vector and a Range of 7 with 7
Equations
Test with [1,4,6] as the Coefficient
Vector and a Range of 7 with 7
Equations
Future Work
• For more discreet analysis, writing a MATLAB
program that allows for the continual expansion
of the degree should be done.
• Applying the same methods to other, perhaps
less complex, pieces of music (portions of
Pachelbel’s Cannon in D Major, for instance).
• For musical analysis, writing a MATLAB program
that would export the generated notes, replacing
the originals in the original MIDI file. We might
not be producing Beethoven, but it might still be
musically interesting.
References
• Steven J. Leon, Linear Algebra With Applications. 7 ed.
pp.51, 382-383,234-244 (2006).
• C.W. Groetsch and J. Thomas King, Matrix Methods &
Applications. pp.115-118, 283 (1988).
• Carla D. Martin, PhD, James Madison University.
• Ken Schutte, Massachusetts Institute of Technology
• Mei Chen, PhD, The Military College of South Carolina
Download