Hi,
I’m trying to understand at what point a plugin has access to the i/o channel configuration, which has left me fairly confused about the OnActivate() function.
(Context is that I’m working on a plugin where a number of params are per-channel, i.e. there’s an independent instance of the param for each output channel. The plugin should accept a range of i/o configurations, so needs to get the number of input and output channels in order to set up the right number of params and their controls.)
I found a post of Oli’s which says “A plug-in’s I/O are not yet connected in the plug-in constructor. You can override IPlugProcessor::OnActivate() to do something when the I/O connections are known.”
From this, I concluded that I’d need to move most of my setup code into OnActivate. I inserted print statements to report the output of NInChansConnected() and NOutChansConnected(), trying to understand when OnActivate () is called.
Running in AULab, in the plugin constructor, the channel config reported is as Oli says: inputs = 0, outputs = 0.
Then OnActivate() is called, and also reports inputs = 0, outputs = 0.
Then OnActivate is called a second time (why?). Now, NInChansConnected = 2 (which is correct), NOutChansConnected = 0 (which isn’t)
On quitting the app, OnActivate runs again, this time correctly reporting inputs = 2, outputs = 2.
I’d be grateful for a). an explanation of what OnActivate() is doing, and/or b). suggestions as to the right way to get the channel config!