Linear Recurrence Relations in Music By Chris Hall.

23
Linear Recurrence Relations in Music By Chris Hall

Transcript of Linear Recurrence Relations in Music By Chris Hall.

Page 1: Linear Recurrence Relations in Music By Chris Hall.

Linear Recurrence Relations in Music

By Chris Hall

Page 2: 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

Page 3: Linear Recurrence Relations in Music By Chris Hall.

Linear Recurrence Relations

• xn= a1xn-1 + a2xn-2 + … + akxn-k

Page 4: Linear Recurrence Relations in Music By Chris Hall.

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).

Page 5: Linear Recurrence Relations in Music By Chris Hall.

What was investigated

• The degree of the recurrence relation

• The range for coefficients

• The best algorithm for finding the relation

• The best-fit solution

Page 6: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 7: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 8: Linear Recurrence Relations in Music By Chris Hall.

The First Program

Page 9: Linear Recurrence Relations in Music By Chris Hall.
Page 10: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 11: Linear Recurrence Relations in Music By Chris Hall.

A simple 4x2 example

fc1 ,c2 a3 c1a2 c2a12 a4 c1a3 c2a22 a5 c1a4 c2a32 a6 c1a5 c2a42

c1a22 a3

2 a42 a5

2 c2a1a2 a2a3 a3a4 a4a5 a2a3 a3a4 a4a5 a5a6c1a1a2 a2a3 a3a4 a4a5 c2a1

2 a22 a3

2 a42 a1a3 a2a4 a3a5 a4a6

Take the gradient and solve for zero:

a22 a3

2 a42 a5

2 a1a2 a2a3 a3a4 a4a5

a1a2 a2a3 a3a4 a4a5 a12 a2

2 a32 a4

2

c1

c2

a2a3 a3a4 a4a5 a5a6

a1a3 a2a4 a3a5 a4a6

ATAc ATb

Which is:

The Least Squares Solution

Page 12: Linear Recurrence Relations in Music By Chris Hall.

Other definitive information

• I know that the point zero is a local minimum because the Hessian Matrix of my original function is positive definite.

2a22 a3

2 a42 a5

2 a2a1 a3a2 a4a3 a5a4

a2a1 a3a2 a4a3 a5a4 a12 a2

2 a32 a4

2

since it is

2ATA

Page 13: Linear Recurrence Relations in Music By Chris Hall.

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

Page 14: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 15: Linear Recurrence Relations in Music By Chris Hall.

The Discreet Program

Page 16: Linear Recurrence Relations in Music By Chris Hall.

Output for Range 3 with 10 Equations

Page 17: Linear Recurrence Relations in Music By Chris Hall.

Output for Range 3 with 10 Equations

Page 18: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 19: Linear Recurrence Relations in Music By Chris Hall.

Test with [1,4,6] as the Coefficient Vector and a Range of 5 with 7

Equations

Page 20: Linear Recurrence Relations in Music By Chris Hall.

Test with [1,4,6] as the Coefficient Vector and a Range of 7 with 7

Equations

Page 21: Linear Recurrence Relations in Music By Chris Hall.

Test with [1,4,6] as the Coefficient Vector and a Range of 7 with 7

Equations

Page 22: Linear Recurrence Relations in Music By Chris Hall.

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.

Page 23: Linear Recurrence Relations in Music By Chris Hall.

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