Create a file for each plugin instance

Hello,
i’m a newbie with Juce and C++.
I want to create a text file for each plugin instance that I set. Each file should have a different name.
I can do that by creating a static variable which is incremented when audioprocessor constructor is called, but if I launch two plugin host, I will have the same name for my first plugin instance of each host.
is there a way to have an access to the PID from the pluginhost or the plugin instance itself (then I’m sure I have an unique name)? or do you have any other idea?
Thanks a lot,
Léo

The safest thing might be a Uuid.
HTH

1 Like

Check out this thread: DefaultAppLogger and multiple instances of plugin for some ideas.

Rail

1 Like

Thanks, but sorry, I forgot to precise that I need to have access to this ID outside my code and my plugin.
thank again for the quick answer

I see. I would still create an Uuid in the plugin instance, but store it into a SharedResourcePointer, that @Rail_Jon_Rogut suggested in his thread?

Anyway, you will put the pieces together :wink:

1 Like

Depends on the degree of “uniqueness” that you need to obtain.

Using PID is still not granting you to obtain a unique ID after you restart your computer. If that’s the degree of uniqueness that you need, you can also make use of PluginHostType, which will give you the name of the DAW that is running your plug-ins.

Combine that with the instance number obtained from your static counter, and you should have a fairly decent and readable “identifier” for your instances that run concurrently.

2 Likes

I am working on a similar feature. I am using Uuid().ToString in the plugin constructor. I load the plugin on a track in Live and Reaper, but each time I close the plugin window (not unloading/removing the plugin) the uuid changes.

How can I retain the uuid for each instance until I unload the plugin?