Hi to all! Looking forward to 3.5’s audio capabilities, but still having some trouble with 3.4. I’ve narrowed down the problem to the following situation:
The scene contains a camera, and 3 GameObjects with 1 AudioSource each : metronome, met2 and met3. They all have the same AudioClip, which is a .25s click (precisely 11025 samples at 44100 hz). All cources set to loop, metronome audio source to PlayOnAwake.
Metronome has the following script attached to it:
var met2 : GameObject;
var met3 : GameObject;
private var offset : int;
function Update(){
if(Input.GetKeyDown(“2”)){
offset = audio.clip.samples - audio.timeSamples;
if(met2.audio.isPlaying == false){
met2.audio.Play(offset);
print(“anything”); //The Culprit
}
else{
met2.audio.Stop();
}
}
if(Input.GetKeyDown(“3”)){
offset = audio.clip.samples-audio.timeSamples;
if(met3.audio.isPlaying == false){
met3.audio.Play(offset);
}
else{
met3.audio.Stop();
}
}
}
Am I doing something wrong? Because when I hit 3, sync is perfect, but if I hit 2, the metronomes are out of sync at least 10% of the times, and once in a while seriously out of sync (50ms) a few times in a row. It seems printing a string is enough to trigger this inaccuracy…
I’m using Unity 3.4, Windows XP, audio settings to best latency, decompress on load, file is a wav (2d sound, but the same applies to 3d sounds).
My project is nearly done, and this is the one issue I do not know what to do with… Any help/hope would be greatly appreciated!
Many thanks,
Gregzo