How convert a Standalone Program to Plugin

Hey, i’ve writte a wavetable sythesizer, that i would like to use as Plug-in. But when i tried to copy it from the juce standalone to plugin preset it i’ve got a lot of errors. Mostly because my variables from Plugin Processor where not declared in the Editor, and the slider listeners have not found the sliders. When i’ve tried to make them global i got “duplicated symbols for archtecture” errors. Whats the best way, maybe is there a tutorial i’ve missed? Sorry for my bad english and noobish question^^

It’s going to be a bit involved. The standalone app and plugin projects need to be coded quite differently. I don’t think there’s any tutorial for that. But whatever you do, don’t use global variables for anything, those are really problematic and should not be used for plugin projects.

Ok, I’ve got it working without global variables, I didn’t understood how to point to the processor. (If somebody doesnt understand it too, theres a pointer called AudioProcessor, works in PluginEditor: AudioProcessor.YourVariableFromPluginProcessor = …)
But i dont really understand, why are global variables so problematic?

There are two big problems with global variables.

The first one is Plugin specific: Global variables exist exactly once in a process. As a hosted plugin becomes part of the host application process this also applies to global variables declared in your plugin code. This means, if you create multiple instances of your plugin in the same host, all the plugin instances will access the single instances of those variables. While this can be used intentionally to share data between plugin instances, you usually don‘t want this as default behaviour. For an example, if you had a global pointer to the processor that would be set in the processor constructor, this would always point to the instance created last. This is probably not what you want in case you used that pointer to access the processor from the editor code.

The second one is that there is no guaranteed order of initialization of global variables. The more you use them, the more you will be running into situations where you need the value of one global variable to initialise another. If they are initialized in different order, your code will break and you might have a hard time finding that bug.


Makes perfectly sense, thanks a lot :slight_smile:

If you create a plugin from projucer, it also creates a standalone project sharing the plugin code without the need to convert,