Introduction: Code to Analyze Gregorian Chants' Mode With MATLAB

This is a MATLAB code that tries to be a first approach to guessing a chant's mode only by using the incipit (the first few notes). The method followed is to create a database from around 200 incipits for each mode, and get the relative frequency of each note in each mode. Then some test chants are introduced and their notes' frequency are compared with those of each mode. They are assigned the mode with which they have the least distance, and then the accuracy of this method is tested.

Supplies

I used the archive from Biblioteca Nacional de España, as examples to use as database.

Step 1: Getting the Notes

First, we have to get the notes out of all the information that Biblioteca Nacional de España has in store for each chant. Using the previous algorithm, we only have the codified notes in the variable textoTotal.

Step 2: Creating the Database

Next, we create the histogram of the amount of appearances each note has in each mode, as well as each note's frequency. To do this it is necessary to search the Bb first so that they don't get confused with the B.

Step 3: Getting the Test Chants' Information

Now that we have the database, we start introducing the test chants. We keep using Biblioteca Nacional de España's archive. The archive also has each chant's mode labelled, so we get the notes and the mode, so we can compare the real mode and the one our method thinks it has.

Step 4: Calculating the Mode

Once we have each chant's codified incipit and real mode, now we calculate each note's frequency and we get the distance between that vector and each mode's corresponding vector, and establishing that the mode with the least distance is the correct mode. Then we compare this guessed mode with the real one.

Step 5: Results

Lastly, we take a look at the results. By doing this we see that the method has big room for improvement, but also it is right a decent amount of times. More importantly, it is noticeable that the performance depends on the mode, with modes 2, 6 and 8 yielding pretty good results, 3, 4 and 5 somewhat mixed results, and modes 1 and 7 with really bad results.

Improvements like taking the duration of the notes or the first note of each chant into account, as well as researching more sophisticated ways to calculate the most similar mode to each chant are due. In the meantime, this method can be a decent place to start.