Singleton instance


Hi All,

I have something where I need your help. It is probably more related to C++ than juce but
makes me feel stupid.

In my plugin I made the Audioprocessor (so called “myFilter”)a singleton. The plugin has a physical Midi input from where I
receive Midi controller messages. These messages get processed internaly and then I have to call
setParameterNotifyingHost to inform the host about the parameter changes. Since the audioprocessor
is a singleton, I use myFilter::getInstance() to get its pointer but it always creates a new instance
of myFilter (I think so because the constructor gets called).
Is this because the Midi input thread is not the message thread and would

const MessageManagerLock mmLock

be the the right way?

Thank you for providing some light here!



Agh! No, a plugin can’t be a singleton!! There obviously need to be multiple instances of a plugin, and you never create or delete these objects yourself - leave it to the wrapper!

In fact, I’d recommend avoiding singletons, statics or any type of global data in plugins if possible. It’s possible, of course, but you need to be very careful and aware of threading issues when you share stuff between plugin instances.


Thank you Jules, I’ll follow your route…