Music patterns for different subtests of the Test of Musical Expertise were constructed in such a manner as to reflect different degrees of contextual constraint, according to the procedure discussed by Brian Hayes(1983). [1]


Subtest 1 (zero-order music approximation)

The least amount of contextual constraint (zero-order music approximation of classical Western tonal music) was simulated by a simple strategy.  Each symbol in the character set was assigned an integer or a letter (e.g., pitch C = code symbol C,  pitch C# = code symbol 1. . .).


For each character to be generated, a random integer or letter was chosen in the same range and the corresponding character was generated.  A short fragment of music created by this process is shown in Figure 1.  All characters have the same frequency in order-zero simulation, 1/12 (see Figure 1).

The Description of the
Test of Musical Expertise

Figure 1. Zero-order music appreciation.



Subtest 2 (2nd-order music approximation)

In 2nd order music approximation, the basic assumption is that a pitch’s probability of appearing at a given point in notated classical Western tonal music depends strongly on the preceding pitches.  For example, after a “F#”, a “G” is most likely.  The procedure is to set up a separate frequency table for each symbol in the character set.  The frequencies are recorded in a two-dimensional array with 12 rows and 12 columns, for a total of 144 elements.  An example of the frequency table used in the present study of 2nd-order simulation is shown in Table 1. (The array is “normalized” by rows, meaning that comparisons are valid only within a row.


Table 1.  Frequency Table for Telemann’s
Concerto for Two Violins

When music is generated from the two-dimensional array, the character most recently chosen determines which row of the table is examined in picking the next character.  For example, if the preceding letter is a “C#”, only the elements of the second row are taken into consideration.  The largest element of the second row is “D”, and so it is the likeliest pitch; “E”, “G#”, “A”, and “B” also have a chance of being selected.  Impossible combinations such as “C#C” and “C#F” have zero frequency, and so they can never appear in the program’s output.  Order-2 musical simulation begins to show the first hints of real classical Western tonal music structure.  Common intervals such as major thirds, begin to show up often and the use of arpeggios is a conspicuous pattern. Figure 2 shows a brief example.

Figure 2. 2nd-order music approximation.



Subtest 3 (3rd-order music approximation)

The 3rd-order algorithm selects each pitch in the random musical text according to probabilities determined by the two preceding letters.  A three-dimensional array is generated with twelve planes.  Each plane is made up of twelve rows of twelve columns.  Suppose at some point in the creation of the music the music interval “EF#” has been generated.  The program must then look to the fifth plane (corresponding to “E”) and to the seventh row on that plane (corresponding to “F#).  In that row, “G” is the likeliest choice.  If “G” is selected, then in the next iteration the choice will be made from the eighth row of the seventh plane, the position in the table specified by the letter sequence “F#G”.


The stylistic qualities of the music begins to appear obvious in order-3 simulation.  Patterns of intervals and arpeggios and the characteristic endings of sequences are unmistakable.  Figure 3 shows an example.

Figure 3. 3rd-order music approximation.




The Hayes algorithm was implemented in the present study.  The source of melodic material was programmed.  A limited input sample was used, read from the disk just once, and stored in an array.  The sample of melodic material stored in the array was Telemann’s  Concerto for Two Violins.


In the present study, the Travesty program, named “BIGARRAY” was indexed by a range of letters and integers representing the twelve chromatic pitches.  As the source text was read in, linefeeds and carriage returns were stripped out, and rests in the music were eliminated.  The cleaned-up result was stored, character by character, in “BIGARRAY”.  For an order-n scan, the first n-1 character off the source was put into a small array called Pattern.


The remainder of the task was simple in principle.  A Match procedure ran through BIGARRAY, checking for matches with the contents of pattern.  Each time a match was found, the next  character was stored.  At the end of the scan, one of the stored characters was randomly chosen for printing, the more frequent ones being the more likely choices.  A new pattern was made by dropping the old pattern’s first character and appending the character just printed.  The procedure was continued until the desired number of characters in the output had been generated.  In addition, the end of the “BIGARRAY” was wrapped back to the beginning by appending as many of the opening characters as there are in the search pattern.  Thus, the program was locked into an endless loop.




Hayes, Brian.  “A Computer Recreations:  A Progress Report on the Fine Art of Turning Literature into Drivel.”  Scientific America (Nov. 1983): 18-28.


Knecht, Melissa G. “Music Expertise and Memory:  The Relationship Between Music  Expertise and Memory of Music Patterns, Within Various Degrees of Contextual Constraint.” Music Education Research 5:3 (November 2003): 227-242.



[1] Hayes, Brian.  “A Computer Recreations:  A Progress Report on the Fine Art of Turning Literature into Drivel.”  Scientific America (Nov. 1983): 18-28.

© 2015 Developing Your Musical Mental Map
Dr. Melissa Knecht
Professor of Music at Hillsdale College  |  Tel: (517) 437-7341

Shar Music

Tel: 1 (800) 248-7427