I have actually done this before, granted not with a microcontroller. Last year I wrote some matlab code that you could use to "make a song". It took a cosine wave with a certain frequency, phase, duration, and sampling frequency and used these to recreate a note. The sound was then played...