I have written code that can do this, but it is not easy. A valid WAV file includes the length of the data chunk early on, but since the length is unknown, you'll need custom reader code. I also found that appending to a file on one thread while reading from it on another is fraught with difficulty. I ended up creating a long blank WAV file, and have one thread overwriting the samples in it while another played back from it. You might find it easier not to use a WAV file at all, and just have a raw PCM audio data file.
↧