I have been looking into starting audio music loops in sync with each other. I have managed to get things working in the editor, but have discovered a problem (possible bug) with the iPhone. Note I am using Unity 3.0 f1.
What I have worked out so far:
All audio started in the same frame is started at exactly the same time. This means I can do audioSource.Play() on a number of audio sources in the same Update() and they all start perfectly in sync. This works running in the editor and running on the iPhone. No problems here.
Calling audioSource.timeSamples within a frame always returns the same value, even when you call it mutliple times and do stuff in between those calls. I am guessing the where the audio was up to at the start of the frame - not really important. This is good as it makes 3. possible.
Due to 2. above I can call newAudioSource.Play(playingAudioSource.clip.samples - audioSource.timeSamples) to reliably start a playing newAudioSource exactly after playingAudioSource finished (or starts its next loop). This works running in the editor but DOES NOT work on the iPhone. On the iPhone it seems like the audio plays immediately, it doesn’t honor the delay samples.
I haven’t found too much doco on the way the new audio stuff works with Unity 3.0, but have worked this out through experimentation.
Can anyone confirm what I have worked out is correct?
Can anyone confirm that the iPhone isn’t honoring the delaySamples in audioSource.Play(delaySamples)? If this is a case then I guess it is a bug.
you can not search the bug database. you can only access your own reported bugs and bug reports you got linked by someone cause they reported it.
Given that not even 3.0 is released yet and going by the past, 3.1 might very well not happen in 2010. Unity commonly has 1-2 feature addition release per year ie upgrades like 3.0 to 3.0 and 1-2 bugfix releases per feature addition release ie 3.0.0 → 3.0.1 → 3.0.2 / 3.1.0 → 3.1.1
Doubt any date estimate would help, even if UT would give them (which they so far didn’t), because UT strives for quality not meeting date with piles of crap. Unity 3.0 release for example is summer 2010
Thanks for the replies andeeee / dreamora - dissapointing that this probably won’t be fixed for such a long time given the feature opens up a number of audio possibilities.
@Andeeee: You have provided a bug number. Can you provide me a URL so that I can have a look at that bug?
Yes - I am noticing delays when playing sounds on the iphone as well - around 0.2 seconds. Had a search around the forums and have found a few threads indicating such and that bugs have been raised for the delay issue.
You specifically mention 2D sound - which is what I have been testing with. I haven’t tried leaving things as 3D sounds. I am away from my dev box at the moment - but do things work if you use 3D sound?
This delay is that with decompressOnLoad checked? In general, for lowest latency use decompressOnLoad flag. This way the sound is prepared at load time and should not have more than a few ms of delay. But of course they should never have a ~0.2 sec delay in any case.
I am getting lag with it checked or unchecked. Also I am used uncompressed audio. Have tried WAV and AIFF. Always lagging on iPhone. In editor plays immediately.
And about looping issue, I have a Prefab that has a Audio Clip attached and it’s config to play looping. When I drag it to a scene and hit “Play”, the sound stopped immediately after playing one time but do the looping 2nd time or so. The way to re-produce it:
Create a Audio Looping Prefab.
Drag it to a scene.
Hit Play button and it will play single time.
Then hit stop.
Again play again, this time it should be ok.
This is how I re-producd it in Editor. For Device,this bug re-produced all time. Bug Report has been submitted.
This is what we have in doc and I’m using uncompressed file ( WAV file ). But I did check the box as you suggest to do this. It’s seems, delay did reduce a little bit but still has some clearly :(.
And about looping, how can I deal the looping as my game need it obviously? Any tricks or suggestions? We need are holding our release