AudioFormatWriter::ThreadedWriter.setFlushInterval has no effect?


#1

I just tried the ThreadedWriter class to write audio into a wav file. I thought it would be a good idea to make it flush only every couple of seconds.
So I passed a large value, 44100 * 5 for the numSamples parameter of the constructor and then called setFlushInterval with a value of 44100 * 3.

I observed the filesize in the linux file manager and it grows about every 500ms or possibly quicker. Am I doing something wrong?


#2

“Flush” means a bit different thing with the AudioFormatWriters than usually. Some audio file formats have data (often at the beginning of the file) that needs to be updated when writing them in order for the resulting file to remain usable. So there is probably 2 “flushes” going on with the ThreadedWriter : the usual OS provided flush which updates the file’s state on disk and the flush that updates the audio file metadata. AudioFormatWriter::ThreadedWriter::setFlushInterval likely just controls the time interval of the latter operation.


#3

Thanks for the hint Xenakios, that could be what is happening