My Preparations
Here is a link to my starting code base/program at Wonderfl.
At the time of writing, the program just plays horrible generative music but the idea is to use the included ChordInfo class to actually have such music in the game.
You are free to use it as well if you want something like that.
The plan is to use the SiON synthesizer, which I can recommend for both music and sound effects (as an alternative to Bfxr), for playing whatever the generative music module spits out.