tsp_rooms
The parent task, tsp_rooms, gets control port events and updates gRoom as follows:
The way this is done is that each room's soundfile is designed so it can play in a loop. In addition to this, the end of each sound file, and additional optional marked locations within the sound file, must be musically sensible locations to transition to the beginning of any of the other room's sound files. When playback reaches the next marked position in, or the end of, the current room's sound, a default decision function is called to check to see if the main task changed room. If the room is still the same, then the current sound continues to play, or loops if at the end.
If the room has changed, the SPPlayer is instructed to begin playing the sound for the new room.
Note that the soundtrack adapts to room changes by the main task instead of making a sharp transition as soon as the room changes. It is possible for the main task to make several room changes before the soundtrack thread discovers that the room has changed at all. This results in smooth soundtrack transitions that occur at seemingly random locations, which is far less likely to become annoying to a game player than a soundtrack that predictably changes the instant the player crosses a given threshold.
spCreatePlayer,
tsp_switcher,
tsp_algorithmic