setBlockSize(int) not getting called when the host default block size is set to 4096

35 views
Skip to first unread message

Federico Berti

unread,
Dec 4, 2017, 5:53:52 PM12/4/17
to Symbiosis AU VST
Hello everyone,

I've just noticed that when your host is set to use a block size of 4096 samples, the setBlockSize(int) method of the VST specification is never being called before processing.
In this code (v1.30):

void SymbiosisComponent::updateMaxFramesPerSlice(int newFramesPerSlice) {

if (maxFramesPerSlice != newFramesPerSlice) {

maxFramesPerSlice = newFramesPerSlice;

reallocateIOBuffers();

propertyChanged(kAudioUnitProperty_MaximumFramesPerSlice, kAudioUnitScope_Global, 0);

vst->setBlockSize(maxFramesPerSlice);

}

}

the "if" is what causes this behavior, as the 
maxFramesPerSlice default value is 4096 (see the kDefaultMaxFramesPerSlice static constant), so the expression will evaluate to false and the setBlockSize call will never happen.
In my case, if the 
setBlockSize method is never called before processing, my plug-in is left in a partially initialized state and crashes. Am I wrong in supposing that setBlockSize must be called at least once before calling processReplacing(...)?
What's supposed to be the best way to fix this issue?

1) change the code to:


void SymbiosisComponent::updateMaxFramesPerSlice(int newFramesPerSlice) {

if (maxFramesPerSlice != newFramesPerSlice) {

maxFramesPerSlice = newFramesPerSlice;

reallocateIOBuffers();

propertyChanged(kAudioUnitProperty_MaximumFramesPerSlicekAudioUnitScope_Global0);

}

        if (vst->getBlockSize() != maxFramesPerSlice)

            vst->setBlockSize(maxFramesPerSlice);

}

2) same as 1), but without the 
if (vst->getBlockSize() != maxFramesPerSlice) check. We basically let the VST implementation (and not Symbiosis) decide whether or not do something with the supplied block size when it's identical to the current one


3) Perform a check on the process calls of the VST implementation and eventually call setBlockSize there if it has never been called before (I really hate this solution, as it may lead to performing memory allocations on the audio thread, plus the block size passed on the process method may be different (smaller) from the one set during the setBlockSize call, so I must also perform some kind of rounding which may still cause a new call to setBlockSize in the successive process calls, if my block size guess is wrong...)

Thanks in advance,
Federico Berti - Ignite Amps

Reply all
Reply to author
Forward
0 new messages