Can you please increase the AudioFormatWriter::writeFromFloatArrays() scratch size from 4096 to the same value you use for AudioFormatWriter::writeFromAudioReader (16384).
AT 96kHz when using AudioFormatWriter::writeFromAudioSource() it causes Pro Tools to choke and throw a warning dialog that the plugin is using too much CPU. Increasing the buffer helps to de-stress the system.
If you don’t want to change it then could you consider giving us an extra parameter which defaults to your value but allows us to increase the buffer without having to modify JUCE:
bool writeFromAudioSource (AudioSource& source,
int samplesPerBlock = 2048,
int readBufferSize = 4096);
I’ll categorize this as a Feature Request… but it’s more of a fix/enhancement.
I’m just wondering, are you using
AudioFormatWriter::writeFromAudioSource() from the audio thread? I’d expect Pro Tools to complain mostly about spending too much time there.
Just from a quick glance, I wouldn’t expect running a loop 4 times for a 4096 buffer vs. once for a 16384 buffer to make much of a difference in terms of performance. To me the multiple memory allocations
writeFromAudioSource() does would stand out as the problem spot.
So without rejecting the idea of increasing the scratch size, I’m just thinking about whether this would even be the right tool for you to address this problem.
Isn’t a AudioFormatWriter::ThreadedWriter the appropriate tool to write audio files from the audio thread?
Without knowing the background of the OP, if writing audio files from AAX there is a good chance we are talking about AudioSuite, which doesn’t write from a realtime thread.
But maybe that is irrelevant to the request anyway.
No it’s a worker Thread running at Thread::Priority::normal – it’s writing to a MemoryOutputStream for a ResamplingAudioSource… basically doing high quality sample rate conversion in a background Thread.
The problem actually is more related to the Thread changes than the buffer size… although that’s helped reduce the issue… I’m seeing the issue with 7.0.8 develop 10-21-23 but not with 7.0.7 develop 9-25-23
I’ll try and isolate what’s causing the issue and also check if it happens on our Intel i9 iMac running Catalina.