Csound Csound-dev Csound-tekno Search About

Re: [Cs-dev] Multiple instance changes

Date2005-07-08 18:12
FromMichael Gogins
SubjectRe: [Cs-dev] Multiple instance changes
1. Declare a structure with member variables to hold the state for your plugin.
2. Move all variables used by your plugin, that had been declared static, to your structure.
3. Every function called inside your plugin should take, as a first argument, a pointer to your structure.
3. Then your functions look something like this:

int MyPluginFunction(struct MyPluginStruct *myPluginStruct, int someOtherParameter, char *someStringParameter)
{
   myPluginStruct->otherParameter = someOtherParameter;
   strcpy (myPluginStruct->stringParameter, someStringParameter);
   return myPluginStruct->whatever;
}


-----Original Message-----
From: Andres Cabrera 
Sent: Jul 8, 2005 1:04 PM
To: csound-devel@lists.sourceforge.net
Subject: Re: [Cs-dev] Multiple instance changes

Hi,

I'm working on LADSPA and DSSI host plugins for csound, and I need to
remove some static variable. What's the correct way to do this in C not
C++?

Thanks,
Andr�s

On Sat, 2005-05-28 at 15:26, Michael Gogins wrote:
> Those responsible for opcodes -- plugin opcodes, or builtin opcodes -- may need to make changes in their code now that people will be using Csound 5 in multiple instantiations, e.g. as several csoundvst_api objects in PD or multiple CsoundVST plugins in Cubase.
> 
> If you have objects or other variables that are global to your plugin module, you will need to change these from single objects to a table of objects indexed by the Csound instance. The easiest way to do this is to declare
> 
> std::map myobject;
> 
> instead of 
> 
> MyGlobalObject myobject
> 
> in your code.
> 
> Then you would access it
> 
> myopcodefunc(void *csound, MyOpcodeStruct *struct)
> {
>    myobject[csound].doSomething();
> }
> 
> instead of
> 
> myopcodefunc(void *csound, MyOpcodeStruct *struct)
> {
>    myobject.doSomething();
> }
> 
> Of course there are "C"-only ways of doing this.
> 
> I am fixing up the mixer and STK opcodes to work this way.
> 
> Regards,
> Mike
> 
> 
> 
> 
> 
> 
> -------------------------------------------------------
> This SF.Net email is sponsored by Yahoo.
> Introducing Yahoo! Search Developer Network - Create apps using Yahoo!
> Search APIs Find out how you can build Yahoo! directly into your own
> Applications - visit http://developer.yahoo.net/?fr=offad-ysdn-ostg-q22005
> _______________________________________________
> Csound-devel mailing list
> Csound-devel@lists.sourceforge.net
> https://lists.sourceforge.net/lists/listinfo/csound-devel
> 
> 



-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/csound-devel





-------------------------------------------------------
This SF.Net email is sponsored by the 'Do More With Dual!' webinar happening
July 14 at 8am PDT/11am EDT. We invite you to explore the latest in dual
core and dual graphics technology at this free one hour event hosted by HP,
AMD, and NVIDIA.  To register visit http://www.hp.com/go/dualwebinar
_______________________________________________
Csound-devel mailing list
Csound-devel@lists.sourceforge.net