Thanks for liking the game!
Unfortunately I cannot share the source codes but I can share the idea of the generation.
Below are the high level descriptions of the generation procedures:
- Preparations:
- state machine of the chord progression that is commonly used in baroque/classical period (I simplified them a bit in this game)
- defines all the intervals of different church modes (I only use a subset of them)
- determine a key as the base key for the chord progression.
- define different cadences e.g. authentic, half, plagal
- Generate random chord progression for different cadences as candidate phrases.
- For each phrase, create a melody line and properly distribute the melody line over the chord progression of the phrase.
- When a chord is changed during the gameplay, change the church mode that matches the chord and interpret degree of steppings according the scale of the current mode.
- For simplicity, the bass line is always in root position (no inversion) as I am running out of time to include this part.