Audio input filter

At least writing to a WAV file is pretty simple. Just write 44 zeros, then start writing the audio samples. When you stop, seek back to the beginning of the file and write the WAV header where you originally put those zerso. You'll need to know how many samples you wrote, and details like the sample rate to produce a valid header.

WAV is fundamentally a file storage format, where you know the total size of the data. It's pretty much meaningless in the context of continuous streaming.