Based on mathematical music theory, you might want to see some files created on MATLAB File Exchange on Music Piano and other links.
Do look at these links and other references:
https://uk.mathworks.com/matlabcentral/fileexchange/65665-make-a-song
http://www.mathworks.com/matlabcentral/fileexchange/21262-matlab-piano
For References:
http://users.rowan.edu/~shreek/networks1/music.html
https://en.wikipedia.org/wiki/Piano_key_frequencies
http://www.seventhstring.com/resources/notefrequencies.html
See this build of comprehensive music synthesizer in MATLAB. Hear a song HERE:
https://www.youtube.com/watch?v=1VsMi1kEdI0
For MIDI:
http://www.mathworks.com/matlabcentral/fileexchange/27470-midi-tools
http://www.mathworks.com/matlabcentral/linkexchange/links/2774-midi-toolbox
For Sound synthesis:
http://www.mathworks.com/support/books/book49107.html
http://www.mathworks.com/matlabcentral/fileexchange/23526
http://www.mat.ucsb.edu/~b.sturm/SSUM/docs/SSUM.htm
Best wishes