I have created an instrument using a piezo buzzer and a microcontroller. It can play songs from both human input and from memory.
Useful links:
Frequencies of Notes: https://pages.mtu.edu/~suits/notefreq...
Code and Schematic: https://github.com/hooperwf1/piezo_in...