- Home /
Synchronise the Time for Two or More Audio Clips
Hey guys,
The game that we're working on has to do with sound and music mostly. Now what we're having trouble with is trying to synchronise the Music Track. Basically, we have three instruments, and these will be picked up by the character. Once picked up, the music of that instrument starts playing. However, these need to be FULLY synchronised, which at the moment can't seem to find a correct answer.
So basically I need an answer in JAVASCRIPT to this scenario, if possible:
Character picks up instrument
Music of that instrument starts playing
After 30 seconds, character picks up second instrument
Second instrument track needs to start playing at its 30 seconds interval as well, not at 0 so it will be fully synced with the previous instrument. Music of First instrument still playing.
After 1 minute, character picks up third instrument
Third instrument tracks needs to start playing at its 1 minute interval as well, not at 0 so it will be fully synced with the previous instruments. Music of First & Second instruments still playing.
PLEASE NOTE THE FOLLOWING
Each instrument track is set as an AUDIOCLIP variable and cannot be different. Audio Source is definitely out of the question as it won't work of what we intend to do (already tried it)
The times aren't fixed, as one user might be faster/slower than another.
Thanks!
Answer by MakeCodeNow · Feb 17, 2014 at 02:30 AM
Check out AudioSource.timeSamples. If you have an audio source per track and set the timeSamples correctly before calling AudioSource.Play() then it will start at exactly the right part. I use this currently and it works well. This doesn't guarantee that they will stay in sync forever, but usually it's good enough.
The most correct solution is to use a multitrack (i.e. > 2 track) wav and then fade tracks in or out as they are needed, but I'm not sure if this is possible to do in Unity.
Your answer
Follow this Question
Related Questions
InGame Time out of synch with cooldown if resting (time goes faster). 2 Answers
How to define the number of times of an event? 1 Answer
How to synchronize Datetime from server to client? 0 Answers
Texts Highlighted at certain time (Karaoke like for spelling storytelling) 0 Answers
two projects in the same time 4 Answers