Matching tunes by contour

The ABC tune finder uses index files that now include a simple sort of tune-contour code. This is calculated by taking the first 16 notes of the tune and listing whether the pitch goes up or down. It is encoded as a string of the letters "du", with the obvious meanings.

For example, consider the Kesh Jig, a well-known Irish tune that starts:

	D | ~G3 GAB | ~A3 ABd | edd gdd | edB dBA | ...
	
From the first note (D) to the second (G3) the tune goes up a fourth, so the first letter of the code is 'u'. The third note (G) is the same as the second, we ignore it. The tune then goes up a step (A), so the next letter is 'u'. Continuing, the entire line produces the code:
	uuuduuudududdudd...
	
You need not give such a long contour to the tune finder, and you might want to ignore the initial pickup note. Try the pattern:
	uuduuudu
	
This finds a lot of versions of the Kesh Jig, which isn't surprising. It also finds the Kincora Jig and Kerrigan's Jig, which on examination turn out to be alternate names for the Kesh Jig. And it finds The Castle, which turns out to be a trivial variant on the same tune.

This "tune contour" scheme has turned out to be a fairly effective way of finding a tune with unknown title. It's main problem is that it also gives lots of "false positives", tunes that have a similar contour but different intervals and rhythms. Research on this is ongoing ...