There could be two ways to approach this, the first way to to enter notes manually like the melody example, then "map" each note to a relay.
The other way is use a MSGEQ7 chip
http://www.cmiyc.com/projects/msgeq7-simple-spectrum-analyzer/
and write code to control the relays/transistors or FETs.