Synchronizing simultaneous and sequential music to create a simple 140 bpm music-loop manager
There are times when we need to precisely schedule audio start times to ensure a smooth transition from one music track to another, or to ensure simultaneous music tracks play in time together.
In this recipe, we’ll create a simple 4-track 140 bpm (beats-per-minute) music manager that starts playing a new sound after a fixed time – the result of which is that the tracks fit together perfectly, and those that do overlap do so in synchronicity.
Getting ready
For this recipe, we have provided several free 140 bpm music clips inside the 04_12
folder.
How to do it...
To create a music-loop manager, perform the following steps:
- Create a new Unity 3D project, and import the provided sound clip files.
- Create four GameObjects in the scene that contain an
AudioSource
component, linked to a different AudioClip loop from the 140 bpm files provided. You...