I encountered an issue where a sample rate change won't be reported to a plugin when used as VST.
It happens in Audacity with an audio file that has a sample rate other than 44.1kHz, e.g. 96kHz. The plugin only gets a sample rate of 44.1kHz from the JuceVSTWrapper via prepareToPlay(). I don't understand the VST API and it could be that Audacity is using it in strange ways. That said, it appears to me to be a Juce issue, according to the following insight.
A breakpoint in AudioEffect::setSampleRate() gets hit multiple times:
When the plugin gets loaded:
sampleRate = 48000
sampleRate = 48000
sampleRate = 44100 -> this gets forwarded by the JuceVSTWrapper to the plugin by calling its prepareToPlay().
When the offline processing gets started by clicking the 'Apply' button in Audacity:
sampleRate = 96000, with the corresponding call stack
#0 0x11614339 in AudioEffect::setSampleRate(float) at .../VST3 SDK/public.sdk/source/vst2.x/audioeffect.h:67 #1 0x11610f51 in AudioEffect::dispatcher(int, int, int, void*, float) at .../VST3 SDK/public.sdk/source/vst2.x/audioeffect.cpp:187 #2 0x11610ce7 in AudioEffectX::dispatcher(int, int, int, void*, float) at .../VST3 SDK/public.sdk/source/vst2.x/audioeffectx.cpp:318 #3 0x116164bc in JuceVSTWrapper::dispatcher(int, int, int, void*, float) at .../juce/modules/juce_audio_plugin_client/VST/juce_VST_Wrapper.cpp:1474 #4 0x11612ecb in AudioEffect::dispatchEffectClass(AEffect*, int, int, int, void*, float) at .../VST3 SDK/public.sdk/source/vst2.x/audioeffect.cpp:54 #5 0x0049aecf in VSTEffect::callDispatcher(int, int, long, void*, float) ()
Sadly, this sampleRate wont be forwarded to the plugin.
The AudioEffect::dispatcher (opCode, index, value, ptr, opt) is called with the arguments
opCode = effSetSampleRate
opt = 96000
but this information wont be passed to the plugin.
Audacity v.2.1.2
Mac OS X 10.11.2
Juce 28a322138d (2016 02 03)