I don't think so. I don't know anything about midi besides that it's a music format that holds synthesized sounds.
Look around for people that are working on open source projects that do what you want and take a look at there code, whatever language it's in. You should start with www.sourceforge.org, and www.freshmeat.net.
Good Luck. If you find a way to do it and need help with the PHP code just let me know.