Create a file for each plugin instance


#1

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


#2

The safest thing might be a Uuid.
HTH


#3

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

Rail


#4

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


#5

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:


#6

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.