A probabilistic melody analyzer and generator