From 9feee440708d71220a242ee04df63b83ab3ce116 Mon Sep 17 00:00:00 2001 From: attila Date: Wed, 11 Jun 2025 18:07:56 +0200 Subject: [PATCH] AUv3SynthPluginDemo: Use the new AudioFormat::createWriterFor overload --- examples/Plugins/AUv3SynthPluginDemo.h | 19 +++++++++++++------ 1 file changed, 13 insertions(+), 6 deletions(-) diff --git a/examples/Plugins/AUv3SynthPluginDemo.h b/examples/Plugins/AUv3SynthPluginDemo.h index cafe69a8f4..0e662119bb 100644 --- a/examples/Plugins/AUv3SynthPluginDemo.h +++ b/examples/Plugins/AUv3SynthPluginDemo.h @@ -443,14 +443,21 @@ private: void swapSamples() { MemoryBlock mb; - auto* stream = new MemoryOutputStream (mb, true); { - std::unique_ptr writer (formatManager.findFormatForFileExtension ("wav")->createWriterFor (stream, lastSampleRate, 1, 16, - StringPairArray(), 0)); - writer->writeFromAudioSampleBuffer (currentRecording, 0, currentRecording.getNumSamples()); - writer->flush(); - stream->flush(); + std::unique_ptr stream = std::make_unique (mb, true); + auto* ptr = stream.get(); + + const auto writerOptions = AudioFormatWriterOptions{}.withSampleRate (lastSampleRate) + .withNumChannels (1) + .withBitsPerSample (16); + + if (auto writer = formatManager.findFormatForFileExtension ("wav")->createWriterFor (stream, writerOptions)) + { + writer->writeFromAudioSampleBuffer (currentRecording, 0, currentRecording.getNumSamples()); + writer->flush(); + ptr->flush(); + } } loadNewSampleBinary (mb.getData(), static_cast (mb.getSize()), "wav");