Recording in-game audio of arbitrary duration to file

Hi everyone

I found this excellent audio recording script from 2012 by Loren.
http://forum.unity3d.com/threads/writing-audiolistener-getoutputdata-to-wav-problem.119295/

Did anynone solve the problem of recording and saving a clip without predetermining the duration?

~ce

After messing with the script I found that it actually does record arbitrary durations. I also found that I could reduce latency by 1) calling Microphone.Start, 2) wait until Microphone.GetPosition started to increase, 3) set audioSource.timeSamples to Microphone.GetPosition 4) and finally start writing to file.