Hi, i’m trying to create a .wav file with the content of a buffer. What am I doing wrong?
AndroidDocument destFile = child.createChildDocumentWithTypeAndName("audio/wav", "audiofile.wav");
DBG("SAVE LOG : created destFile");
std::unique_ptr<OutputStream> outputStream(destFile.createOutputStream());
juce::WavAudioFormat wavFormat;
auto* writer = wavFormat.createWriterFor(outputStream.get(), audioProcessor.getSampleRate(), 2, 16, {}, 0);
if (writer != nullptr) {
//outputStream.release(); // passes responsibility for deleting the stream to the writer object that is now using it
int numSamples = audioProcessor.sampleBuffer.getNumSamples();
DBG("SAVE LOG : Number of samples: " + String(numSamples));
DBG("SAVE LOG : First sample value: " + String(audioProcessor.sampleBuffer.getSample(0, 0)));
writer->writeFromAudioSampleBuffer(audioProcessor.sampleBuffer, 0, numSamples);
delete writer;
}
Logcat says:
W A resource failed to call AbstractCursor.close.
2024-09-28 22:02:41.327 11490-11504 System com.yourcompany.tesiplugin W A resource failed to call CursorWrapperInner.close.
2024-09-28 22:02:41.327 11490-11504 System com.yourcompany.tesiplugin W A resource failed to call AbstractCursor.close.
2024-09-28 22:02:41.327 11490-11504 System com.yourcompany.tesiplugin W A resource failed to call CursorWrapperInner.close.
2024-09-28 22:02:41.438 11490-11490 JUCE com.yourcompany.tesiplugin I JUCE Assertion failure in juce_WavAudioFormat.cpp:1689

