Without getting into the details, I used two plugins for the generative music:
- Godot Meta Player (not affiliated with the other Meta), a tool for dynamic music, that I use to sync all the layers and also to bind events to the beat
- Simple Sampler, a plugin of my own, that allows to create musical instruments from samples.
There's a bit of music theory that I'll skip, but from there the basic idea is that I have a list of notes ("G4", "A4", etc), and when an event happens I pick one of them and play it with the desired instrument. Then there's some tweaks to avoid playing the same note twice consecutively, or giving random notes more or less chance to be played depending on the current bar.
I'm happy that you enjoyed the game. Thank you for your comment!