mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-09 23:34:20 +00:00
AUv3SynthPluginDemo: Use the new AudioFormat::createWriterFor overload
This commit is contained in:
parent
386daafe23
commit
9feee44070
1 changed files with 13 additions and 6 deletions
|
|
@ -443,14 +443,21 @@ private:
|
|||
void swapSamples()
|
||||
{
|
||||
MemoryBlock mb;
|
||||
auto* stream = new MemoryOutputStream (mb, true);
|
||||
|
||||
{
|
||||
std::unique_ptr<AudioFormatWriter> writer (formatManager.findFormatForFileExtension ("wav")->createWriterFor (stream, lastSampleRate, 1, 16,
|
||||
StringPairArray(), 0));
|
||||
writer->writeFromAudioSampleBuffer (currentRecording, 0, currentRecording.getNumSamples());
|
||||
writer->flush();
|
||||
stream->flush();
|
||||
std::unique_ptr<OutputStream> stream = std::make_unique<MemoryOutputStream> (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<int> (mb.getSize()), "wav");
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue