…is now set to 16384. Any reason not to set it to 44100?
maybe, if you debug with 44100Hz and the sample rate will be accidentally never set, you will never detect the bug.
Mmmh. The thing is that certain Nebula programs are running at 16 KHz in my plugin host (which is to a large extent based on JUCE’s plugin host)… although prepareToPlay is set with the correct sample rate. I don’t quite understand why at the moment, but setting the default sample rate to 44100 would at least make things work for the majority of projects. Not ideal, of course, in principle the correct sample rate should be set automatically…
EDIT: I’ve seen that in an earlier version the code was
which, at first sight, seems like the sensible thing to do when the plugin wants to know the sample rate… ?
That is a bit strange, I’m not sure exactly why I chose that number, and if I was writing it now I’d probably go for 44100 or 48000. Maybe I had a good reason for it…
But… it’s true that it should never actually be used if your host is initialised correctly when you load the plugins. Maybe you’re loading plugins before you’ve opened an audio device or something?
The issue is also present in the JUCE plugin host, I just checked that. Nebula (a nonlinear effect sampler which is getting pretty popular) does not call VstPluginInstance::handleCallback, but handleGeneralCallback because of effect->resvd2==0 in the audioMaster call (the “entry point for all callbacks from the plugin”). It seems that it uses this callback to get the sample rate from the host, and that the sample rate that is set in prepareToPlay is being ignored…
Are you sure that it’s not because they’re passing effect == nullptr ? The host sets the resvd2 value, so can’t really see how that’d become 0.
Either way, it’s a fault of the plugin, because if they call the host without supplying a valid effect object, then they’re clearly expecting to get some kind of “global” sample rate, and assuming that there’s one global sample rate is a really shameful bit of programming! Someone should let them know!