Saul's Log - October 31, 2001
This past week a couple people asked me for information about the music system. I thought I'd take my two responses, add some detail, and put them here for everyone to read.

First of all, I received an e-mail asking if there were any limits on the amount of RAM or CPU that custom music files can use. The answer is no, there are no limits whatsoever. Our engine will play any music that it is able to load into memory. We have imposed limits on ourselves for the Battlegrounds soundtrack so that we can stick to our minimum system requirements, but these limits are not hard-coded.

So, if you want to write your own music for Battlegrounds (and I hope some people do!), you have two choices. You can conform to the limits set in the soundtrack, in which case your song can be played by anyone who owns the game. Or, you can exceed those limits to achieve higher sound quality, with the understanding that a player might need a higher-end machine to play your song. (Or, to look at it another way, they may have to sacrifice some visual quality to play it on a lower-end machine).

The second question was posed by Destro on the forums. Destro wanted some details on how a mood was selected and what the exact moods are that our music engine supports. (These "moods" are the different sections you hear in the MP3's on the previews page).

Before I get into specifics, I'd like to mention one thing: our music system is 100% expandable. If you create an add-on that includes new types of gameplay, you aren't limited to the 10 moods that are built into the game (the "base" moods). You can create your own user-defined moods and write scripts that tell the engine when to select them. I'll discuss expanding the music system in another log. For now, I'll stick to the base system that will come with the game.

The music system relies on two main factors to select the moods in a song: "match standing", and "match completion".

Match standing refers to how well the player or team is doing compared to their opponent(s). A special in-game variable, which is unique to each player and measures their standing from 0% to 100%, is categorised into one of five values: "really losing", "losing", "tied", "winning" and "really winning".

Match completion refers to how close the match is to reaching an ending. An ending can be caused by time running out, a score limit being reached, a player running out of energy, or any other number of factors. Another in-game variable measures match completion from 0% to 100%. It is categorised into four values: "early", "middle", "near ending", and "pre-start / after-the-end".

By combining match standing and match completion, we select one of 10 moods:
Silent
Selected whenever match completion is "pre-start/after-the-end" - in other words, while waiting for competitors, or when a match has finished.
Early
Selected whenever match completion is "early" - this is introductory music that sets the mood and allows some action to take place to determine match standing.
Winning, Tied, Losing
Selected when match completion is "middle" and the match standing is "winning", "tied", or "losing". These 3 moods are played during the main body of the match to indicate how well the player is doing. They are generally fast-paced and can be uplifting, sad, tense, ominous or evoke other strong emotions.
Really Winning, Really Losing
Selected when match completion is "middle" and the match standing is "really winning" or "really losing". These 2 moods are generally more ambient and mellow than the previous three. They often use minimal percussion.
Time/Winning, Time/Tied, and Time/Losing
Selected when the match completion is "near ending". Time/Winning is selected if match standing is "really winning" or "winning", and similarly for Time/Losing. This is fast-paced, tense music that gets the player's adrenaline pumping toward the end of the match.
Generally, a song will progress from Silent, through Early, through one or more of the "middle" moods, then to a "near ending" mood, then back to Silent. However, it is possible to jump to any mood at any time.

So, if you are creating an add-on with new gameplay, you can enable dynamic music without much effort. By using the default mood-selecting scripts the music system will handle everything - you just need to set Match Completion and Match Standing to appropriate values as the match progresses. If you are creating a score-based game, even this code has been made for you.

So, there you have it. Next log I'll talk about expanding the music system to use it for more complex or weird types of gameplay. I'll include an actual example of an add-on and detail how you would customise the music system to work for that add-on.