ProTools - prepareToPlay only called once, BEFORE setStateInformation?

Hi,

I’m having a problem with another ProTools quirk.

It seems that prepareToPlay is called only once, BEFORE the first and second call to setStateInformation.

It’s not called when pressing play or anything else.

The problem is, my plugins load a bunch of filters from a file, and ProTools gets stuck on re-loading a session when I try to load them directly in setStateInformation, so I thought I would load the files in prepareToPlay and just re-load the filename.

But if prepareToPlay is called before I even have a chance to load the filename, and never again, I’m not quite sure where i should load my filters …

Anybody got a hint ?

Best,
n

How about setting a flag in setStateInformation() (e.g., “newFilterFileSet = true;”) that you can then check in your timerCallback() function, which will load the filters (and reset the flag)?

If that is too long of a process to do at idle time, then maybe use a separate thread to handle loading filters into an alternate data structure from your “live” filters, then, when loaded, setting a flag (e.g., “newFilterFileLoaded = true;”) that the loading has finished, and letting timerCallback() swap which is the “live” and which is the “alternate” data structure when that flag is set?

Hmm so far I don’t have any timers running, so I didn’t think about that. It’s true that I could start a timer that checks the flag and loads the filters, and then stops itself.

The timer idea works, just delaying the loading of the filters by 200ms does the trick. Not terribly elegant but hey …

1 Like