# Access unique plugin instance id?

**URL:** <https://forum.juce.com/t/access-unique-plugin-instance-id/28901>\
**Category:** Audio Plugins\
**Created:** [August 6, 2018, 12:03pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901 "2018-08-06T12:03:38Z")\
**Posts on this page:** 19\
**Page:** 1

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [August 6, 2018, 12:03pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/1 "2018-08-06T12:03:38Z")

</div>

Hi,

is there any way to access a unique ID for each instance of a plugin (ideally by the time the constructor is called) ?

I assume as each host has the ability to store parameter data for each instance, there must be some identifier ?

The PluginDescription class has the uid field, but i can’t find a way to access this from a regular AudioProcessor … am i missing something here ?

There was a similar thread from a while ago, but that didn’t provide a satisfactory answer … ([Plugin instance id?](https://forum.juce.com/t/plugin-instance-id/9969))

Best,  
n

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 6, 2018, 12:12pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/2 "2018-08-06T12:12:22Z")

</div>

You can simply add a [Uuid](https://docs.juce.com/develop/classUuid.html) as a member.  
And you can add it to your setStateInformation, if you want it to be persistent.

The uuid of the [PluginDescription](https://docs.juce.com/develop/classPluginDescription.html#a6bddaeaf4147bb0827c18724cbc7bd4b) is actually rather to identify the type of your plugin than the instance.

You may still run into problems, e.g. FinalCutProX will create a hand full of instances of your plugins, each rendering a part of the waveform. I didn’t a good way to identify which one is the actually heard one or which is a background one, so you have to make sure, that they absolutely don’t interfere (plus not write the parameters, but rely on FCPX to set the parameters from the automation, otherwise it gets messy)

I had a long digging session at my previous job:

> [@Final Cut - Automation Bug](https://forum.juce.com/t/final-cut-automation-bug/25010/8):
>
> After a lot of testing and digging, I am convinced, that it is bad to save automated parameters in the getStateInformation() / setStateInformation(): Parameters are stored by the host outside the private stateInformation chunk. That is, because a parameter is only valid for a given timepoint The host will set the parameter outside of each processBlock call, so setting a value yourself is counter productive At least in final cut setting a value during playback will move the whole graph to fit t…

Hope that helps

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [August 6, 2018, 12:17pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/3 "2018-08-06T12:17:01Z")

</div>

Thanks for the quick answer !

I tried that actually, but the problem is, that this UUID will be generated by the time the plugin will be instantiated, but it’ll only be restored by the time `getStateInformation()` is called … this discrepancy is currently the source of some problems for me.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 6, 2018, 12:23pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/4 "2018-08-06T12:23:22Z")

</div>

I thought it might be a problem. Unfortunately the hosts are not prepared to support such a kind of self awareness of plugins, AFAIK. I didn’t find a solution for that, so I had to change my design to be agnostic to which instance it is.

Maybe if you describe your use case, sometimes it is possible by thinking outside the box…

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [August 6, 2018, 12:31pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/5 "2018-08-06T12:31:23Z")

</div>

Well, my plugins register themselves with a background application using IPC methods, so i either need to assign a new ID at registration time or (in case they’re restored) use the ID restored from the plugins memory block.

There are some ways around it, of course, i.e. registering and assign a different ID in case the plugin is restored, etc. etc. … but they’re all equally tedious and somehow uncomfortable, so i couldn’t decide on one yet …

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [August 6, 2018, 1:43pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/6 "2018-08-06T13:43:28Z")

</div>

I had a similar use case, so I ended up that the connection is my identification. I assume you are thinking how to make sure, that the parts of the state in the server sync up with the parts in the client.  
My solution was to keep the server dumb, and push the plugin’s state upon connect.  
Not sure if that works for you though.

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 3, 2019, 12:53am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/7 "2019-04-03T00:53:16Z")

</div>

[Sorry for cross-posting]

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?

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [April 3, 2019, 1:05am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/8 "2019-04-03T01:05:41Z")

</div>

Are you generating the Uuid in the AudioProcessor constructor and not in the constructor of the AudioProcessorEditor?

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 3, 2019, 1:15am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/9 "2019-04-03T01:15:57Z")

</div>

Inside AudioProcessorEditor constructor. For testing purposes I have:

```
NewpluginAudioProcessorEditor::NewpluginAudioProcessorEditor (NewpluginAudioProcessor& p)
    : AudioProcessorEditor (&p), processor (p)
{
    ...
    uuid_ = Uuid().toString();
}

```

And in the paint method:

```
void NewpluginAudioProcessorEditor::paint (Graphics& g)
{
    ...
    g.drawFittedText (uuid_, getLocalBounds(), Justification::centred, 1);
}
```

---

<div class="post-metadata">

**Author:** ![xenakios](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/xenakios/32/4047_2.png) [@xenakios](https://forum.juce.com/u/xenakios)\
**Post date:** [April 3, 2019, 1:23am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/10 "2019-04-03T01:23:30Z")

</div>

The host is free to create and destroy the editor many times during the plugin’s life time. You should have your Uuid as a member of the AudioProcessor itself.

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 3, 2019, 1:32am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/11 "2019-04-03T01:32:37Z")

</div>

Thanks a lot for the explanation, Xenakios.

Cheers.

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [April 3, 2019, 6:46am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/12 "2019-04-03T06:46:13Z")

</div>

By the way, apart from the problems with Final Cut mentioned above, Ableton Live (at least in combination with AU) has a quirk that makes the ID thing more complicated, see my post here:

> [@Quirky behaviour when changing blocksize \[Ableton | AU\]](https://forum.juce.com/t/quirky-behaviour-when-changing-blocksize-ableton-au/32294):
>
> Here’s another host quirk, for ableton this time: It seems like Ableton (tested with 9 and 10) creates new instances of AU plugins when the blocksize is changed and loads the Settings by copying over the memory block. When the samplerate is changed, the same instance is kept and prepareToPlay() called with the new samplerate. Neither does that happen with VST in Ableton, nor with AU in Reaper, as far as i am concerned. Has anybody else observed this ? I assume there’s no way to influence that…

Not sure how that affects your use case, but it surely does affect mine …

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 3, 2019, 9:53pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/13 "2019-04-03T21:53:52Z")

</div>

Actually, I have different behaviours between DAW. For instance, if I add AU plugin several times in the same track, the `uuid` is maintained in Ableton Live 10. On the other hand, `uuid` changes for every VST instance no matter if it is or not in the same track in Reaper.

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [April 4, 2019, 8:00am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/14 "2019-04-04T08:00:35Z")

</div>

Really? How do you add them, and how do you store the ID ? If i add my plugin instances to the same (audio) track from the selection menu, i don’t get that behaviour.

---

<div class="post-metadata">

**Author:** ![pauloesteban](https://avatars.discourse-cdn.com/v4/letter/p/a5b964/32.png) [@pauloesteban](https://forum.juce.com/u/pauloesteban)\
**Post date:** [April 4, 2019, 8:19pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/15 "2019-04-04T20:19:54Z")

</div>

I followed the suggestion from @Xenakios. Assign `uuid` inside the `AudioProcessor` constructor to a public member, and then, I access to the member in `AudioProcessorEditor`.

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [April 4, 2019, 8:37pm UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/16 "2019-04-04T20:37:19Z")

</div>

You might even add it to the AudioProcessor as

```auto
const Uuid pluginUuid;

```

That way you can be sure, it won’t change accidentally (unless you do const\_cast it, obviously).

If you see different values for the uuid, there are different instances. The host is free to do that for various reasons, e.g. hot swap to a different sample rate, FinalCut uses additional instances to render the preview of the waveform, and much more…

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [April 5, 2019, 7:18am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/17 "2019-04-05T07:18:40Z")

</div>

Hmm strange, because that’s how i do it as well, but I never experienced conflicts, except when re-storing the ID from via `setStateInformation` from the memory block.

Which is also why I can’t use `const` IDs ☹

---

<div class="post-metadata">

**Author:** ![daniel](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/daniel/32/790_2.png) [@daniel](https://forum.juce.com/u/daniel)\
**Post date:** [April 5, 2019, 9:20am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/18 "2019-04-05T09:20:05Z")

</div>

Well, if you are storing and loading the Uuid, then it all cannot work. That was my first problem with FinalCut as well, because all background instances will read the same state, and hence bear the same uuid.

This approach only works as a lifetime uuid. It does not work by design as persistent uuid for your problem.

---

<div class="post-metadata">

**Author:** ![parkellipsen](https://avatars.discourse-cdn.com/v4/letter/p/7993a0/32.png) [@parkellipsen](https://forum.juce.com/u/parkellipsen)\
**Post date:** [April 5, 2019, 10:08am UTC](https://forum.juce.com/t/access-unique-plugin-instance-id/28901/19 "2019-04-05T10:08:59Z")

</div>

Well, it does now to a certain degree, but yes it creates a lot of problems. I guess the FinalCut issue will never be solved in that context.

But I need to connect plugins amongst each other, and restore the connections from the DAW state, or the user would need to re-create all the connections each time they open a session.

I haven’t found another solution for that so far, other than persistent IDs ☹
