<div dir="ltr"><div class="gmail_extra"><div class="gmail_quote">On Thu, Nov 21, 2013 at 2:44 PM, Warren Koontz <span dir="ltr"><<a href="mailto:profwub@gmail.com" target="_blank">profwub@gmail.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"> it appears that I should instantiate a Multiverb object in "activate", apply it in "run" and delete it in "deactivate".</div>
</blockquote><div>Not exactly:<br></div><div>-instantiate is where you instantiate (malloc / new) your plugin<br></div><div><br>-activate is called *before* processing starts<br></div><div>-deactivate is called when processing is stopping.<br>
</div><div><br></div><div>Activate & deactivate might be useful to clear your reverb delay lines etc: its primary use is for transport relocation in a DAW & similar use cases where state like delay lines become invalidated.<br>
<br></div><div>-run is the "process" function yes, where the actual DSP code goes.<br></div><div> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<div dir="ltr"> So the object needs to be accessible in all three functions. I see two ways to do this:<div><div style="font-family:arial,sans-serif;font-size:13px">
<div><ol><li style="margin-left:15px">Declare a pointer to a Multiverb object as a static variatle (<font face="courier new, monospace">static Multiverb *revMono</font><font face="arial, helvetica, sans-serif">) near the top of the file containing the LV2 functions.</font></li>
<li style="margin-left:15px"><font face="arial, helvetica, sans-serif">Declare a pointer to a Multiverb object as a member of the same structure that contains the port variables.</font></li></ol><div><font face="arial, helvetica, sans-serif"></font></div>
</div></div></div></div></blockquote><div>Option 2 is correct.<br></div><div><br>Option 1 is horrible. Static state in a plugin means that only one instance of that plugin can be loaded: your plugin will crash the host if two are used. Never use static variables*. <br>
<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr"><div><div style="font-family:arial,sans-serif;font-size:13px"><div><div><font face="arial, helvetica, sans-serif">I also need to have access to the sampling rate, which I can get when "instantiate" is called. I can also save this as a static or a member of the above mentioned structure.</font></div>
</div></div></div></div></blockquote><div> </div><div>Since you're now creating (new / malloc) in instantiate(), you can keep the SR in the struct with the ports too. <br></div></div><br></div><div class="gmail_extra">
Good luck! -Harry<br><br><div>*Ok, there are exceptional circumstances where this might OK, but this isn't one of them.<br></div><br></div></div>