Please click this link for the code and schematic diagram:
bit.ly/2NSosDM
Basics of Arduino - Sound Control with Active Buzzer
I am using in this project an active buzzer to make sound.
By definition, an active buzzer has a built-in oscillating source, so it will make sounds when electrified. It is often more expensive than passive buzzer because of multiple built-in oscillating circuits.
Music by: https://www.free-stock-music.com