VST 2.4 Specs: setBlockSize always called before processing?

DSP, Plug-in and Host development discussion.
Wild Hades
KVRist
174 posts since 6 Sep, 2007

Post Mon Dec 04, 2017 3:08 pm

Hello,

kinda stupid question, but I couldn't figure it out from the VST 2.4 "specs" (or better, code comments...):

am I wrong supposing that setBlockSize(int) must be called at least once by the host, before calling processReplacing/processDoubleReplacing for the first time?

All the hosts I've tried so far are doing this, but I'm wondering if this is stated somewhere in the VST 2.4 code/specs.
I usually perform memory allocations on the setBlockSize method, so it would really suck if I'd need to call it explicitly from the audio thread if the host has never called it before (plus, I hate to put "ifs" in the audio processing routine).

Thanks in advance,
Federico

camsr
KVRAF
6858 posts since 17 Feb, 2005

Re: VST 2.4 Specs: setBlockSize always called before processing?

Post Mon Dec 04, 2017 9:34 pm

Here's the comment from the sdk:
///< Called when the Maximum block size changes (always in a suspend state). Note that the sampleFrames in Process Calls could be smaller than this block size, but NOT bigger.

I suppose the confusion comes from "always in a suspend state".

I have previously used the plugin Open() to do allocations with success. You can call getBlockSize() there and it should almost always return a valid size. (At least it did in FL studio). You can always allocate more than you'll ever need, it's not likely to cause any performance issue.
Image

mystran
KVRAF
4981 posts since 12 Feb, 2006 from Helsinki, Finland

Re: VST 2.4 Specs: setBlockSize always called before processing?

Post Fri Dec 08, 2017 7:11 am

Wild Hades wrote: I usually perform memory allocations on the setBlockSize method, so it would really suck if I'd need to call it explicitly from the audio thread if the host has never called it before (plus, I hate to put "ifs" in the audio processing routine).
You can safely assume setBlockSize and setSampleRate get called at least once before the first resume(), which is always called before the first processXXX calls.
If you'd like Signaldust to return, please ask Katinka Tuisku to resign.

Wild Hades
KVRist
174 posts since 6 Sep, 2007

Re: VST 2.4 Specs: setBlockSize always called before processing?

Post Sat Dec 09, 2017 7:12 am

mystran wrote:You can safely assume setBlockSize and setSampleRate get called at least once before the first resume(), which is always called before the first processXXX calls.
That's nice to know! Thanks!

Return to “DSP and Plug-in Development”