I pulled a piezo speaker from an old desktop computer that I had. These things can run directly off the GPIO or you can add a resistor to lower the volume if necessary. I connected the speaker to pin GPIO18 (PWM) and GND.
I then used a modified version of the code presented here on the third post. I do not take any credit for writing this code.
What the poster did not mention was that “tone 60” is equivalent to MIDI middle C. From there you can figure out what value most of the major notes are. Then you can create a little song by expanding upon that script which is what I have done. I did it line by line which is likely the laziest and most inefficient method. Instead an array could have been used or an input file to be parsed. You can also change the time length of each note but I just left most of them 0.1 seconds.
There are more efficient ways of doing it, but I was working with what I had for my first go at the GPIOs.
I get my GPIO breakout and breadboard this week, so I will play around more.