Different samplebanks loading



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…??? :smiley:

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


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!


Thanks, I was afraid of that too. :smiley:

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 :slight_smile:


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.


Ok, thanks alot!! :blush: