Music from the printer?
Yes, it has been done before, see here and here.

The README file of the first repository linked above contains a detailed explanation of the basic idea/calculations involved.  A short excerpt:


  As you can set the parameters of G1 in such a way as to precisely control the velocity and the distance of a movement along a certain axis, you can control the operation frequency of the stepper motors as well as the actual time to complete a movement.


On another note (pun intended), you can also play music by using the code M300.