I remember once I extracted the MIDI files from TIE Fighter (ahh good ol' days poking around things with a hex editor). The music for the menus/etc. were some 30-odd regular length pieces (minute or two long)
The actual in-flight music, on the other hand, was something like 60 or so (I don't remember exactly how many, maybe more?) pieces, about 5-15 seconds long each, which the game would stitch together with some sort of logic (afterall, only certain phrases will sound right following other phrases of the music) to provide the background music while playing, which would of course attempt to match the action which was happening at the time in-game.
The effect was quite neat, but something like this requires a lot more work on the part of the composers and everyone else working on the game to make sure that the action and the music match up properly as well.
I'm pretty sure there was some element of randomness to it as well, since I remember flying around after having completed a mission, listening to the music which played indicating you were done, and listening for a good 20 minutes or so trying to figure out where it was looping or such, and not finding it. While there was a certain sequence in that one phrase of the music would follow another, it seemed like it would randomly pick what to play next at times.
I really miss stuff like that...