Here's the link to the code.
For this melody project I decided to create a sketch that would play notes from a minor chord randomly as the user presses a key on the keyboard. In addition to this, the user can also use the mouse to change the chord, as the mouse position is mapped to the width of the canvas, and this generates a new chord based on a new chosen frequency.
This musical function is visualized in the sketch with small ellipses that are placed with a settle random offset across the canvas but in correlation to their pitch and their starting frequency. I also made the background a gradient from black to white because the sound frequencies are ordered from lowest to highest (dark to bright).