This is how the algorithm I'm testing at the moment works.

First I collected together a file of about 350 tunes, taken
mostly from Henrik Norbeck's site and from Jack Campin's
mode tutorial (because those people are careful with their
transcriptions and their key assignments are generally
correct), plus a few other abcs from various locations.
I went through them and weeded out any where there were
key changes, or where I felt any doubt about the K: field
being correct.  I wrote a program to analyse the note useage
in these tunes, collecting the percentage of time the tune
spent on each note (lumping together notes in different
octaves) and recording the results separately for each mode.
(The tunes were all transposed to the key of C for this purpose.)

The averaged results looked like this:

      C       C#     D        D#     E       F       F#      G       G#
A       A#      B      n
Ion 24.81    0.00   14.86    0.02   19.16    6.44    0.19   18.53    0.00
10.40    0.25    5.35  199
Dor 25.14    0.00   14.53    8.71    0.21   12.70    0.00   18.56    0.13
3.23   16.62    0.17   61
Phr 32.90    9.50    0.00    7.75    3.31    9.41    0.00   15.74   12.61
0.00    8.78    0.00    6
Lyd 26.34    0.00   15.62    0.00   19.93    0.00    8.91   19.87    0.00
3.49    0.00    5.84    3
Myx 26.23    0.00   12.39    0.29   11.56   11.90    0.01   19.11    0.00
6.93   10.25    1.32   45
Aeo 26.59    0.00   10.66   13.23    0.00   13.44    0.00   19.53    2.14
0.14   13.97    0.30   41
Loc 40.84   11.66    0.00   19.17    0.00    7.50   15.84    0.00    0.00
0.00    5.00    0.00    1

(hope the table doesn't get its lines broken up in transit)

Clearly the number of measurements for the rare modes is
inadequate, but thats all the tunes I have for those.
You can see that the tonic is the most-used note in all
modes, but that there are distinct differences between modes
in the useage of the other notes.  The third is very common
in Ionian and Lydian, less so in Myx.  The major seventh
is weak in those scales which use it, but the minor seventh
is much more used, and so on.

In order to test a tune, I perform the same analysis, generating
a set of twelve numbers which I then try to fit against each
line of the table, in each of twelve rotations to test all 84
possible key/mode combinations.  It's a least-squares fit, and
the program gives the key and mode with the lowest score.  If the
next-best is within 10% it gives that too, and so on.  If the
tune is really ambiguous it may give up to four answers.

Of course it's not perfect.  Since human musicians often disagree
about what key a tune is in no program is going to be able to do
better.  Since it analyses tunes as a whole, it gets mislead
by tunes with key changes, and a surprising number of tunes
have hidden enharmonic key changes which don't usually get
notated.  It's not fazed by tunes which don't end on the tonic
though, as it pays no more attention to that note than any other.
The tune has to play properly in order for it to work, but the
key signature does not have to be correct - you can enter a
tune as K:C and simply sprinkle it with accidentals where necessary
to make it sound right, and the program will tell you what K:
you should have used.

For the tunes which have been posted here recently, it gives
E Dorian for all four versions of Morrison's Jig, with Em as
second best.  It gives Gm for the Presbyterian Hornpipe with
no alternative, and for Scan Tester's number 2 it gives D Mix
with G Major as second best.

Phil Taylor


To subscribe/unsubscribe, point your browser to: http://www.tullochgorm.com/lists.html

Reply via email to