Similar melodies algorithm