In this recipe, you added four GameObjects to the scene, each containing AudioSources linked to 140 bpm music clips. You created a C# script class, called LoopScheduler, and added an instance to an empty GameObject. You associated the four AudioSources in your GameObjects with the four slots in the public AudioSource array variable in your scripted component.
The number of music clips you use can easily be changed by changing the size of the public array variable.
The Start() method counts the length of the array to set the numLoops variable. Then, it calculates the number of seconds to delay before starting each clip (this is fixed according to the beats-per-minute and beats-per-measure). Finally, it sets the current time to be the time to start the first loop.
The Update() method decides whether it's time to schedule the next loop. It does this by testing whether the current time, plus a one-second look-ahead, is past the...