# Different samplebanks loading

**URL:** <https://forum.juce.com/t/different-samplebanks-loading/25025>\
**Category:** Audio Plugins\
**Created:** [November 7, 2017, 1:23pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025 "2017-11-07T13:23:42Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![kaukomedia](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kaukomedia](https://forum.juce.com/u/kaukomedia)\
**Post date:** [November 7, 2017, 1:23pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025/1 "2017-11-07T13:23:42Z")

</div>

Hi!

I have a sampler which loads different samplebanks as wanted by the user. The issue is that I’d like it to load up the default one when the plugin is first time added to the project. But, when the project is saved, and re-opened, I don’t want the plugin to load the default package but the user chosen one. I do have user-chosen package loading in “setStateInformation” method, which enables to load up the custom package when the project is re-opened. That’s ok. But the issue is, when loading up the default one, if it happens in the constructor of my AudioProcessor, it happens even during re-opening of the project.

I placed the default loading method in my getStateInformation for now, and I could work with that, but it’s uncertain to me, does the getStateInformation happen for any DAW by default when adding a new plugin instance to the project. It seems to do so in Reaper and Logic. Obviously getStateInformation happens possibly many times in second however the DAW chooses to do so, and I’ve got checks for that not to load the package each time… But I bet it’s not the bast place.

Do you have knowledge on does getStateInformation happen each time plugin instance is added, and does it happen even when re-opening a project, before, or after setStateInformation…??? 😃

Or even better, do you got any ideas how to make this not so quirky… hah.

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 7, 2017, 1:40pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025/2 "2017-11-07T13:40:03Z")

</div>

> [@kaukomedia](#):
>
> Do you have knowledge on does getStateInformation happen each time plugin instance is added, and does it happen even when re-opening a project, before, or after setStateInformation…??? 😃

Nothing is certain - even if we could say “every host we’ve ever tested does X and Y in a certain order” then a DAW could be released tomorrow that does things differently.

So you just have to assume that the host will do whatever it wants, and write code to handle every situation, I’m afraid!

---

<div class="post-metadata">

**Author:** ![kaukomedia](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kaukomedia](https://forum.juce.com/u/kaukomedia)\
**Post date:** [November 7, 2017, 2:26pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025/3 "2017-11-07T14:26:55Z")

</div>

Thanks, I was afraid of that too. 😃

Well… Would you say… to implement these in get/setStateInformation and to make sure, is to put a check in prepareToPlay in case either of those state methods didn’t occur? Does the prepareToPlay happen certainly each time user hits playback? I assume it’s not a method a host would call?

I was also thinking of timer-based checks but… lol 🙂

---

<div class="post-metadata">

**Author:** ![jules](https://avatars.discourse-cdn.com/v4/letter/j/41988e/32.png) [@jules](https://forum.juce.com/u/jules)\
**Post date:** [November 7, 2017, 3:03pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025/4 "2017-11-07T15:03:41Z")

</div>

Depends entirely on what you need to do, but yes, when prepareToPlay is called you should make sure you do whatever’s needed to be ready to safely play something.

---

<div class="post-metadata">

**Author:** ![kaukomedia](https://avatars.discourse-cdn.com/v4/letter/k/74df32/32.png) [@kaukomedia](https://forum.juce.com/u/kaukomedia)\
**Post date:** [November 7, 2017, 3:06pm UTC](https://forum.juce.com/t/different-samplebanks-loading/25025/5 "2017-11-07T15:06:28Z")

</div>

Ok, thanks alot!! 😊
