Sample rate validity



the code documentation says (see: AudioProcessor::getSampleRate declaration):

[code] /** Returns the current sample rate.

    This can be called from your processBlock() method - it's not guaranteed
    to be valid at any other time, and may return 0 if it's unknown.
double getSampleRate() const throw()                      { return sampleRate; }[/code]

So, does this mean that there is only a valid sample rate between a call to prepareToPlay and releaseResources, but not outside this pair of functions?

Which then implies that a plugin should do all its sample rate based initialization (like buffer reallocatoins etc…) in the prepareToPlay call?


Yes indeed. Outside of those, the processor may be completely disconnected from any kind of playback device, so the idea of a sample rate would be meaningless.



OK, thanks for confirming.