Duplicating an AudioPluginInstance


I wrote a function duplicatePlugin() that is supposed to make a 1:1 copy of a plugin (without the editor, but including its state):

[code]AudioPluginInstance* duplicatePlugin(AudioPluginInstance *plugin)
if (plugin==0) return 0;

PluginDescription description;
AudioPluginInstance* instance=AudioPluginFormatManager::getInstance()->createPluginInstance(description,String("Could not create plugin instance!"));
if (instance!=0)
	MemoryBlock memBlock;
	instance->setStateInformation(memBlock.getData(), memBlock.getSize());

return instance;


I must have forgotten something, because when I call the process() method of the duplicated plugin (VSTi), no sound is coming out, whereas the first one (the original) produces sound.
Oh, and just to say, I did not forget to call prepareToPlay() on the second plugin, so that’s not the problem.


Did you call setPlayConfigDetails()?


That function is called anyway in prepareToPlay() (in the first line of code) !? Shouldn’t really need to call it?


Ok, I found out that:

  • my function was not the problem.
  • one has to call AudioPluginInstance::process() at least 2 times with an empty MIDIBuffer before passing the MIDIBuffer with the actual MIDI Notes, otherwise there will be no sound output.

So this seems to be a bug!? Have you got any idea why one has to call process() twice before calling it a third time with the actual MIDI data?


There’s nothing I’ve written that would do anything like that - midi buffers just get passed straight through. What kind of plugin is it? Have you traced into these process calls to see what happens?


Alright, this seems to happen only with one precise VSTi (ofcourse I just had to pick that one, bad luck for me), so it’s for sure not a JUCE bug…