Vamp Plugins Forum

Development Topics => Plugin Development => Topic started by: yli on December 18, 2009, 23:54:50

Title: ::initialise and ::setParameters in Sonic Visualizer
Post by: yli on December 18, 2009, 23:54:50
Hi,

While debugging my plugin, I found the all the calls to ::setParameters happened before calls to ::initialise. This appears to be a bit awkward to me. Normally you would first initialize an object then start tweaking its parameters.

Anyone can shed some light?

Thanks
Title: Re: ::initialise and ::setParameters in Sonic Visualizer
Post by: cannam on January 06, 2010, 14:24:44

(Sorry to take so long to reply!)

Yes, this is intentional.  There is some rationale in the Vamp SDK programmer's guide at http://vamp-plugins.org/guide.pdf in the section entitled "What can depend on a parameter?" in chapter 6.

Remember that a Vamp plugin essentially gets a two-phase initialise -- first it is constructed, and only later is initialise() called.   The meaning of initialise() essentially is "set up all the internal parameters for your signal processing engine"; since these may depend on parameters of the plugin, and those parameters are not allowed to change during use, it is reasonable to ask them to be all set completely before that initialisation happens.

So, the order is construct - configure - initialise, which is indeed different from a real-time audio plugin API.

The design is intended to support signal processing methods in which initialisation is expensive, and to support plugins in which the very structure of the returned features may depend on the plugin's parameters.  (A constant-Q spectrogram with a parameterised bin count would be an example of both of these.)


Chris