The music is the soundtrack to the player interacting with the system. (Not always, but this is my personal favorite starting point.)
Imagine watching the player playing the game. You are composing the soundtrack to that.
Length of a session. Story of a session. Session to session. Story of that.
The simple fact of playing a game over a period of time and interacting with it is something the music needs to reflect.
Gameplay footage. Now imagine footage of a player interacting with the game to produce that gameplay. What can you expect the player to think and feel?
Persuasion technique: pacing and leading. Watch skilled rhetoricians in action. First describe the current situation. Reflect people’s own thoughts and experiences back to them. Nothing more. Gain trust. Show that your mind is like their mind. Then make predictions about what they will be feeling and thinking. Vague if necessary, like astrology. Always a way it can come true. When your predictions come true the crowd trusts you more and more. You go from reflecting to something more. Be patient with this. Eventually you break the barrier between their mind and you mind. They are in your reality now. They expect anything you say to be true now and will perceive reality differently to make your words true. You can persuade anyone of anything with enough time. You must believe this.
Now with game music. Imagine footage of a player interacting with the system. At first, reflect what they see back to them with music and sound effects. Reward and encouragements. Establish comfort. Tropes, genre expectations, cliches. Establish trust.
Now the music does something which is weird and doesn’t reflect the game. Huh, what’s that? Then the game moves into the next part. It’s a perfect fit! Wow, the music predicted that. Repeat. Sharper contrasts between music and gameplay. More time between prediction and fulfillment. Trust, trust, trust. Break down the barriers between minds.
Learn, from deep experience, intuition, testing, where this breakdown occurs.
Make sure, along the way, that the music, in addition to matching the game, also follows it’s own internal logic, whatever that may be. Rhythm, theme, harmony, color, etc.
Now follow the music to its own place. The player is ready. Barrier between minds dissolved. Go further and further. Make the player invest in your frame. The player will see in the gameplay and the visuals whatever it is the music is suggesting. You have transformed the game with your music.
This of course is the ideal. May only ever be partially realized. No formula, only heuristic. Art, not science.
Remember, tell the story of of an individual session and also the story that happens from session to session. The game knows when you’re playing a lot. The game knows when you’ve taken a break. Learn, through heuristic, when to shift down from dissolution to prediction or reflection. Remember, heuristic, heuristic, heuristic.