Save unique String for each plugin instance


i am trying for a few days now to store a unique string (IP Address) for each plugin instance. The most comfortable option would be to use the AudioProcessorValueTreeState and just add a property. But the problem here is that the host does not differentiate between the instances of the plugin. I am using VST and Cubase for my test. When i close and reopen the session each plugin has the same ID. There is a post here on the forum that the host has access to the parameters and can handle them different than what getStateInformation() and setStateInformation() suggests.

Another option would be to write the string to a file in the user directory but then again there is an option needed to know which string belongs to which instance. I tried the Uuid class as a AudioProcessor member but it is not constant either when the plugin is reloaded.

I am not sure if the MemoryBlock class could be used and then recreate the getStateInformation() and setStateInformation() class.

Could anybody give me a hint how to do this? I really tried to find a solution but i couldn´t come up with something that actually works so far.


Did you try to create a UUID in a constructor of your plugin and then save it (in e.g. ValueTree → XML) in getStateInformation()? You’d need to make sure that the generated UUID is overwritten with setStateInformation().

That should work - new instances get a new ID, which is then saved as part of the session.

1 Like

Bear in mind that you don’t have control over what IP address is assigned to a NIC (which could be set up with a static network). And I know you didn’t mention it, but a MAC address is equally out of your control and is likely randomised by the OS. Using any of these for this purpose is generally a terrible idea!

Basically, +1 to what @adamwilson said. The juce::UUID should be really close to collision free. An alternative would be to use/store UTC time…

1 Like

Thank you both for your response. I have to appologise it was a stupid mistake. My network class had a static function that caused all the instances to connect to the same device. Everything is working now with the ValueTree->XML method.

Thank you very much for your help!!

2 lines…

static int count = 0;
std::string uniqueString = std::to_string(count++);

This will only work for plugins that share a process. Some hosts e.g. Bitwig can load plugins in different processes