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 "dsu", with the obvious meanings.

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

	D | "G"~G3 GAB | "D7"~A3 ABd | "G"edd gdd | "D7"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, it is ignored 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:
	suudsuuudsu
	
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.

One problem with this sort of matching is that some versions of a tune will often have a long note where other versions contain repeated notes. This can be handled by taking advantage of the perl pattern matching that is done here. If you add '+' after a letter, it means to look for one or more of that letter; if you add '*', it means zero or more. So, in our above example, the initial G3 GAB could be written G2G GAB. This can be matched by the pattern:

	s+uuds+uuudsu
	
This will take into account the possible repeated notes in the first two measures. Of course, this will also produce more suprious matches.