AudioFormatWriter bug?


It appears that AudioFormatWriter::writeFromAudioReader has a bug. The documentation says:

At least with a wave file reader and writer combo, this appears to fail, producing an empty (headers only) file. Passing any positive value for numSamplesToRead works as expected.

Looks like it just needs a:

if (numSamplesToRead < 0) numSamplesToRead = reader.lengthInSamples;


But line 404 of juce_AudioFormat.cpp does exactly what you’re suggesting… Are you looking at an old version of the codebase?


Yep. I was working from 1.46 or shortly thereafter. I see the fix in 1.5. Thanks.