- Home /
how to start audioloop synced to one playing
hi there!
imagine one audioloop playing. now we want to start another loop in sync to the one allready playing. best would be to wait until loop1.timeSamples == 0 again - but how to recognize this?
or is it possible to start another loop from a specific sample?
thx!
Answer by Thom Denick · Feb 02, 2011 at 10:50 PM
Assuming your two audio clips are recorded in sync, you can just start your second audio loop at the same .time that your current audio loop is at.
private AudioSource soundOne; private AudioSource soundTwo;
Start() { soundOne.Play(); }
private void startLoopTwo() { if(soundOne.isPlaying){ soundTwo.time = soundOne.time; soundTwo.Play(); } }
If you need more precision, you can use time samples...
I haven't actually done this, but this seems to be the way to go about it via: http://unity3d.com/support/documentation/ScriptReference/AudioSource-timeSamples.html
and
http://unity3d.com/support/documentation/ScriptReference/AudioSource.Play.html
hey, cheers, man! thats simple. thanx! but I am more interested in starting the loop "on the one" - or even more interested in later have the option to start another sample on every fourth beat or so...
Starting on the "one" is kind of tough because it's unlikely with a float value you're ever going to be perfectly on the one. You could add a check for a soundOne.time range in your Update $$anonymous$$ethod. If(soundOne.Time >= 0.0f &&
Your answer
Follow this Question
Related Questions
Is there a way to loop mp3 files seamlessly? 2 Answers
AoTTG - Modding with Visual Basics + .NetReflector SFX Mod 0 Answers
Play Audio OnTriggerEnter then loop 2 Answers
How to delay a audio loop? 1 Answer
Why Doesn't My Music Loop? 5 Answers