- Home /
Log exact time that sound is played
I'm working on a project where after the 'game' has been played, I need to synchronise the actions that happened in Unity with a recording by an external program on a different machine. I plan to send the audio from Unity to the other machine which will record it on a different channel and I can then use this to synchronise the recording with the actions that were made Unity. At the moment the best I can come up with is the following:
sw = new StreamWriter(filename, true);
sw.WriteLine("{0},{1},{2},{3},0", Time.time, transform.position.x, transform.position.z, transform.rotation.y);
sw.Close();
audio.PlayOneShot(signal);
So using this I will know that at each time point the player was in ___ position. The problem with this however is that there will be a slight delay between logging the data from Unity, and sending the audio signal. I need a sub millisecond level of precision for this task. Does anyone know a better way of doing it, or if it's possible to simultaneously play a sound while writing to a log file?