What are the mathematical tools that I can employ for automatic music composition?
There is an open source on the similar project you may be interested: http://sourceforge.net/projects/amc/
The program generated chords and bass lines from .wav or .midi input.