@@ -18,7 +18,7 @@ size_t inputBusCountDSP(DSPRef pDSP);
1818bool canProcessInPlaceDSP (DSPRef pDSP);
1919
2020void setBufferDSP (DSPRef pDSP, AudioBufferList* buffer, size_t busIndex);
21- void allocateRenderResourcesDSP (DSPRef pDSP, uint32_t channelCount, double sampleRate);
21+ void allocateRenderResourcesDSP (DSPRef pDSP, uint32_t channelCount, double sampleRate, AUAudioFrameCount maxFramesToRender );
2222void deallocateRenderResourcesDSP (DSPRef pDSP);
2323void resetDSP (DSPRef pDSP);
2424
@@ -89,6 +89,7 @@ struct DSPBase {
8989
9090 int channelCount;
9191 double sampleRate;
92+ AUAudioFrameCount maximumFramesToRender = 0 ;
9293
9394 bool isInitialized = false ;
9495
@@ -134,6 +135,12 @@ struct DSPBase {
134135 std::atomic<bool > isStarted{true };
135136
136137 void setBuffer (AudioBufferList* buffer, size_t busIndex);
138+
139+ // / Set by AudioKitAU from AUAudioUnit.maximumFramesToRender before init().
140+ // / Subclasses may read `maximumFramesToRender` in their init() override to
141+ // / pre-size scratch buffers to the worst-case render size.
142+ void setMaximumFramesToRender (AUAudioFrameCount frames) { maximumFramesToRender = frames; }
143+ AUAudioFrameCount getMaximumFramesToRender () const { return maximumFramesToRender; }
137144 size_t getInputBusCount () const { return inputBufferLists.size (); }
138145
139146 virtual AUAudioFrameCount framesToPull (AUAudioFrameCount requestedOutputFrameCount) { return requestedOutputFrameCount; };
0 commit comments