The output file has 0 second of length, but still has a size about 70Mb.
Values of the above variables: samplePerBlockExpected: 1920 processSpec->sampleRate: 48000 readerSource->getAudioFormatReader()->lengthInSamples: 9482112 readerSource->getAudioFormatReader()->bitsPerSample: 32
The writer returned by format.createWriter is a raw pointer and needs to be deleted after writing the data, which also finalizes the file as a proper wav file. Didn’t you get a Juce memory leak warning about that?
There must be some deletion order problem happening, I’d need to check what’s the correct way to do it in your code since you deal a bit differently with the file output stream object.
This is how I am doing it :
juce::File outfile(path);
outfile.deleteFile();
auto ostream = outfile.createOutputStream();
WavAudioFormat wav;
auto writer = wav.createWriterFor(ostream.release(), sr, 2, 32, {}, 0);
// my processing loop...
delete writer;
Difficult to say without seeing all of the code…You might need to start the transport source, seek it to the beginning etc before doing the offline render.
Yes it has sound now but it cut like 20 last seconds of the audio,
is the value returned by readerSource->getAudioFormatReader()->lengthInSamples not correct?