OFGame Music System
From OpenFrag
The proposed music system is a sequencer that strings together short music clips in randomized path order, which is defined in an XML file per musical theme.
Themes
A theme is a set of related music clips that are meant to be played together. For example, there could be a Daytime Roaming theme, a Nighttime Roaming theme, and a Combat theme. The engine and map will dictate which themes should play when and where.
Theme Clips
A collection of short clips makes up a theme. Each clip can be of any length, and generally should contain trailing reverb or a fade-out near the end of the clip. A clip is usually a few bars of music.
Sequencing
An XML file (per theme) defines the first and next clips that can be played in the sequence. Each clip can have one or more target clips, which are randomly chosen by the engine and sequenced during the reverb tail of the current clip.
<theme tail="500"> <intro name="roam01" /> <intro name="roam02" /> <clip name="roam01"> <target name="roam02" /> <target name="roam03" /> </clip> <clip name="roam02"> <target name="roam04" /> <target name="roam07" /> <target name="roam08" /> </clip> <clip name="roam03"> <target name="roam05" /> <target name="roam06" /> <target name="roam09" /> </clip> <clip name="roam04" /> </theme>
A clip further down the branch can also target something near the beginning. The music keeps playing until the entire theme fades out. If a clip has no targets (as with roam04 above) then that will be the last clip in the currently playing chain.
The <theme> tag has an attribute called "tail" that tells the sequencer how much to overlap clips. For example, if the first clip is 10000 samples long, and the tail is 500, then the next clip in the chain should start after about 9500 samples.

