From d15fa8f0e37e4cff50e3a0b35db60cd8856e4d19 Mon Sep 17 00:00:00 2001 From: j-bresson Date: Sun, 16 Jan 2022 02:32:34 +0100 Subject: [PATCH] Adapt the max capacity of AudioFormatWriter::writeFromFloatArrays Currently this operation is limited and asserts if the incoming audio buffer has more than 255 channels. Since `chans` is a vector, it seems straightforward to adapt its size and support any value of `numSourceChannels`. This will also spare the creation of 256 int pointers when buffers of less than 255 channels are written. --- modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp index d74c7986c2..6025858d2c 100644 --- a/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp +++ b/modules/juce_audio_formats/format/juce_AudioFormatWriter.cpp @@ -157,7 +157,7 @@ bool AudioFormatWriter::writeFromFloatArrays (const float* const* channels, int if (isFloatingPoint()) return write ((const int**) channels, numSamples); - std::vector chans (256); + std::vector chans (numSourceChannels + 1); std::vector scratch (4096); jassert (numSourceChannels < (int) chans.size());