Although the Imperial March from Star Wars has played on a floppy disk drive before, it's never been done this well. A blogger who goes by the name Silent explained how he did it:

The sound comes from a magnetic head moved by stepper motor. To make a specific sound, head must be moved with appropriate frequency.

FDD has a simple interface – the description may be found for example [ HERE ]. To move the head you need to activate the drive by pulling the DRVSB0 or 1 (depends on the cable you have and the connector – notice the crossover on the FDD ribbon cable) pin low and then falling edge on STEP pin makes the head move one step in direction dependent on DIR pin state.

An ATMega microcontroller is generating those frequencies and it makes the drives play music.