Crap when plugin MIDI data bounced to new audio track

Hi,

I have created a plugin (synth), which plays nicely in a MIDI track,
But when I do Bounce to new audio track (Studio One) or Render in place (Cubase), it renders with a crappy sound like a sample rate was reduced dramatically.

What am I missing and what can be the reason?

Thank you in advance,
Lubenskiy.

A common caveat:

In realtime you have sometimes measures to return in case something is not ready, e.g. BufferingAudioSource etc.
In non realtime this will always happen, because the audio callback will happen as fast as possible.
Therefore in non realtime you need to change all such occasions to blocking operation until the sound was successfully created.

But could be anything else given the vague information