# Create singleton for each plugin instance

**URL:** <https://forum.juce.com/t/create-singleton-for-each-plugin-instance/37626>\
**Category:** Audio Plugins\
**Created:** [February 15, 2020, 3:32pm UTC](https://forum.juce.com/t/create-singleton-for-each-plugin-instance/37626 "2020-02-15T15:32:44Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![TheWaveWarden](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.juce.com/thewavewarden/32/13708_2.png) [@TheWaveWarden](https://forum.juce.com/u/TheWaveWarden)\
**Post date:** [February 15, 2020, 3:32pm UTC](https://forum.juce.com/t/create-singleton-for-each-plugin-instance/37626/1 "2020-02-15T15:32:44Z")

</div>

I have a singleton in my plugin, which distributes wavetables to the audio classes. Now i’m running into problems, since multiple instances are sharing data, which they really shouldn’t.

I know how to resolve the issues by making it not a singleton and attaching one to each pluginprocessor, but it is a considerable amount of work.

Hence the question: Is there a way to make each instance use its own singleton?

---

<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:** [February 15, 2020, 4:18pm UTC](https://forum.juce.com/t/create-singleton-for-each-plugin-instance/37626/2 "2020-02-15T16:18:35Z")

</div>

Making it a member of each AudioProcessor is really the easiest way to do.

You could arrange the stuff in a map inside your singleton and access it each time with a uuid that is stored in the AudioProcessor.  
But that is definitely more work and more error prone than refactoring the singleton into a member.
