I’m seeing this strange issue when trying to write an empty, 10 second long buffer to a .wav file upon instantiation of my plugin. I’m writing the file in a function that is called from the constructor of my AudioProcessor.
void FileIoAudioProcessor::writeFile()
{
File file(File::getSpecialLocation(File::SpecialLocationType::userDesktopDirectory).getChildFile("testBuffer.wav"));
AudioBuffer<float> testBuffer(2, 480000);
testBuffer.clear();
WavAudioFormat format;
std::unique_ptr<AudioFormatWriter> writer;
writer.reset(format.createWriterFor(new FileOutputStream(file), 48000, testBuffer.getNumChannels(), 24, {}, 0));
if (writer != nullptr) {
writer->writeFromAudioSampleBuffer(testBuffer, 0, testBuffer.getNumSamples());
}
}
The issue is that, upon loading my plugin in Ableton, the size of the file created seems to continuously grow for as long as my plugin is opened. For example, if I open the plugin and let it run for 1 minute, I get a file of size 100 MB. If I open the plugin and let it run for 10 minutes, I get a file of size 3 GB. In both scenarios, loading the resulting .wav file in a media player shows a 10 second long file. I also tried creating a raw pointer for the writer and manually deleting it but this did not change anything.
Another strange issue is that, if I try to open my newly generated .wav file while the plugin is open in the DAW, I get a playback error in whatever media player I use. If I want to play the file, I have to close the whole plugin down.
Thought these issues were interesting enough to post about. As it is, the current state of my file writing system is unusable. I’ve consulted a few people on the code and they claim that it checks out (the forums would confirm this as well). Does anyone know what’s going on?