Hi,
I have a scenario where I’m reading the audio file being recorded from another process/program. This works well in general; however I would like to be able to affect how the audio file is flushed to disk. In particular, it would be very useful if the WAV header was flushed to disk immediately so that I can open the file on the other side without having to wait for the first audio block to be flushed.
I managed to do this by patching the AudioFileWriter
constructor:
AudioFileWriter::AudioFileWriter (const AudioFile& f,
juce::AudioFormat* formatToUse,
int numChannels,
double sampleRate,
int bitsPerSample,
const juce::StringPairArray& metadata,
int quality)
: file (f), samplesUntilFlush (numSamplesPerFlush)
{
CRASH_TRACER
f.engine->getAudioFileManager().releaseFile (file);
if (file.getFile().getParentDirectory().createDirectory())
{
const juce::ScopedLock sl (writerLock);
writer.reset (AudioFileUtils::createWriterFor (formatToUse, file.getFile(), sampleRate,
(unsigned int) numChannels, bitsPerSample,
metadata, quality));
writer->flush(); // <---- Added this line
}
}
While this works, I would prefer not having to patch the tracktion engine source code. Is there any other way?
Also, the flush interval is defined as a constant in the same file (numSamplesPerFlush
), it would be nice if it was a variable that could be changed from the “outside world”!
Thanks
Erik