<html><body style="word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space; "><div><br></div><div>Thanks. &nbsp;Please add there as you figure out stuff, don't worry about getting it exactly right, its a wiki, so it can be changed :)</div><div><br></div><div>.hc</div><br><div><div>On Feb 8, 2011, at 4:47 AM, Rich E wrote:</div><br class="Apple-interchange-newline"><blockquote type="cite">That makes sense, all except the names. :) &nbsp;Nice docs.<br><br><div class="gmail_quote">On Tue, Feb 8, 2011 at 6:33 AM, Hans-Christoph Steiner <span dir="ltr">&lt;<a href="mailto:hans@at.or.at">hans@at.or.at</a>&gt;</span> wrote:<br> <blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex;"><div style="word-wrap:break-word"><div><br></div><div>t_canvas is now just a t_glist. &nbsp;a t_glist is a list of objects that represents a patch, here's what I wrote about it a while back:</div> <div><br></div><div><a href="http://wiki.puredata.info/en/glist" target="_blank">http://wiki.puredata.info/en/glist</a></div><div><br></div><div>I am pretty sure that t_pd is a generic class pointer, like a pointer to Object in Java.</div> <div><br></div><div>.hc</div><br><div><div><div></div><div class="h5"><div>On Feb 6, 2011, at 2:15 AM, Rich E wrote:</div><br></div></div><blockquote type="cite"><div><div></div><div class="h5">Update to this: it seems that I can just use t_pd pointers to open and close the patches, although I still need to return the t_pd *x pointer from glob_evalfile(). &nbsp;I don't know which method is best for opening/closing, with t_canvas or t_pd.. &nbsp;<div> <br></div><div>The new methods look like this:</div><div><br></div><div><div>t_pd *glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir)</div><div>{</div><div>&nbsp;&nbsp; &nbsp;t_pd *x = 0;</div><div>&nbsp;&nbsp; &nbsp;t_pd *x_loaded = 0;</div> <div><br></div><div><span style="white-space:pre-wrap">        </span>/* even though binbuf_evalfile appears to take care of dspstate,</div><div><span style="white-space:pre-wrap">        </span> we have to do it again here, because canvas_startdsp() assumes</div> <div><span style="white-space:pre-wrap">        </span> that all toplevel canvases are visible. &nbsp;LATER check if this</div><div><span style="white-space:pre-wrap">        </span> is still necessary -- probably not. */</div> <div><span style="white-space:pre-wrap">        </span></div> <div>&nbsp;&nbsp; &nbsp;int dspstate = canvas_suspend_dsp();</div><div>&nbsp;&nbsp; &nbsp;binbuf_evalfile(name, dir);</div><div><span style="white-space:pre-wrap">        </span></div> <div>&nbsp;&nbsp; &nbsp;while ((x != s__X.s_thing) &amp;&amp; (x = s__X.s_thing))&nbsp;</div> <div>&nbsp;&nbsp; &nbsp;{</div><div><span style="white-space:pre-wrap">        </span>vmess(x, gensym("pop"), "i", 1);</div><div><span style="white-space:pre-wrap">        </span>x_loaded = x;</div> <div>&nbsp;&nbsp; &nbsp;}</div><div>&nbsp;&nbsp; &nbsp;pd_doloadbang();</div> <div>&nbsp;&nbsp; &nbsp;canvas_resume_dsp(dspstate);</div><div>&nbsp;&nbsp; &nbsp;return x_loaded;</div><div>}</div></div><div><br></div><div><div>t_pd *libpd_openfile(const char *basename, const char *dirname) {</div> <div><span style="white-space:pre-wrap">        </span>t_pd *x = glob_evalfile(0, gensym(basename), gensym(dirname));</div> <div><span style="white-space:pre-wrap">        </span></div><div><span style="white-space:pre-wrap">        </span>pd_pushsym(x);</div> <div><span style="white-space:pre-wrap">        </span>int dzero = canvas_getdollarzero();<span style="white-space:pre-wrap">        </span></div> <div><span style="white-space:pre-wrap">        </span>pd_popsym(x);</div> <div><br></div><div><span style="white-space:pre-wrap">        </span>return x;</div><div>}</div><div><br></div><div>void libpd_closefile(t_pd *x) {</div><div><span style="white-space:pre-wrap">        </span>pd_free(x);</div> <div>}</div><div><br></div><div><br></div><div>I would appreciate any feedback/suggestions from you guys who know the pd API much, much more thoroughly that myself.</div><div><br></div><div>Cheers,</div><div>Rich</div><br> <div class="gmail_quote">On Sun, Feb 6, 2011 at 4:49 PM, Rich E <span dir="ltr">&lt;<a href="mailto:reakinator@gmail.com" target="_blank">reakinator@gmail.com</a>&gt;</span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"> I can't remember, are questions related to pd's C API appropriate for pd-list, or are they better asked here? &nbsp;It seems that everyone who responds to those questions is on this list just as much, anyway.<br><br>I have been mucking around with opening and closing pd patches using API calls instead of pd's messaging system. &nbsp;The reason for this is that I would like to be able to manage (open/close) multiple instances of a patch, and be able to send each copy of the patch a unique message via its $0 argument (see&nbsp;<a href="http://www.mail-archive.com/pd-list@iem.at/msg41648.html" target="_blank">http://www.mail-archive.com/pd-list@iem.at/msg41648.html</a>). &nbsp;So far, the method has been to hack glob_evalfile to look like:<br> <br><div><div><div>t_canvas *glob_evalfile(t_pd *ignore, t_symbol *name, t_symbol *dir)</div><div>{</div><div>&nbsp;&nbsp; &nbsp;t_pd *x = 0;</div><div><span style="white-space:pre-wrap">        </span>/* even though binbuf_evalfile appears to take care of dspstate,</div> <div><span style="white-space:pre-wrap">        </span> we have to do it again here, because canvas_startdsp() assumes</div><div><span style="white-space:pre-wrap">        </span> that all toplevel canvases are visible. &nbsp;LATER check if this</div> <div><span style="white-space:pre-wrap">        </span> is still necessary -- probably not. */</div><div><span style="white-space:pre-wrap">        </span></div><div>&nbsp;&nbsp; &nbsp;t_canvas *x_canvas = 0;&nbsp;</div> <div><span style="white-space:pre-wrap">        </span></div> <div>&nbsp;&nbsp; &nbsp;int dspstate = canvas_suspend_dsp();</div><div>&nbsp;&nbsp; &nbsp;binbuf_evalfile(name, dir);</div><div><span style="white-space:pre-wrap">        </span></div> <div><span style="white-space:pre-wrap">        </span>while ((x != s__X.s_thing) &amp;&amp; (x = s__X.s_thing))&nbsp;</div> <div><span style="white-space:pre-wrap">        </span>{</div><div><span style="white-space:pre-wrap">                </span>x_canvas = canvas_getcurrent();</div> <div><span style="white-space:pre-wrap">                </span>vmess(x, gensym("pop"), "i", 1);</div> <div><span style="white-space:pre-wrap">        </span>}</div><div>&nbsp;&nbsp; &nbsp;pd_doloadbang();</div> <div>&nbsp;&nbsp; &nbsp;canvas_resume_dsp(dspstate);</div><div>&nbsp;&nbsp; &nbsp;return x_canvas;</div><div>}</div></div><div><br></div><div>The only addition is that x_canvas is retrieved before x is 'popped' off of pd's global stack, and is then returned, giving me a handle to close that particular patch with something like:</div> </div><div><br></div><div>canvas_menuclose(x_canvas, 0);</div><div><br></div><div>But I realize that in global_evalfile, t_pd and x_canvas point to the same address space. &nbsp;This leads me to ask, what is the difference between these two pointers? &nbsp;Is t_canvas a t_pd along with variables for its graphical nature?</div> <div><br></div><div>Mathieu also pointed to me (as I was using the first set of these) that canvas_setcurrent() and canvas_unsetcurrent() are aliases of pd_pushsym() and pd_popsym(). &nbsp;Is there a good reason to use one over the other? &nbsp;&nbsp;</div> <div><br></div><div>Last question: &nbsp;Does anyone see a way that I could get the value of x in glob_evalfile above without changing the function? &nbsp;I don't think it is a dangerous change (and it looks like I could just hand x.gl_pd to canvas_menuclose, thereby not really needing a t_canvas pointer), but I would of course prefer to not change the API if possible.</div> <div><br></div><div>Cheers,<br><font color="#888888">Rich</font></div> </blockquote></div><br></div></div></div> _______________________________________________<br>Pd-dev mailing list<br><a href="mailto:Pd-dev@iem.at" target="_blank">Pd-dev@iem.at</a><br> <a href="http://lists.puredata.info/listinfo/pd-dev" target="_blank">http://lists.puredata.info/listinfo/pd-dev</a><br></blockquote></div><br><div> <span style="font-size:12px"><br></span><span style="font-size:12px"><span style="border-collapse:separate;border-spacing:0px 0px;color:rgb(0, 0, 0);font-family:Helvetica;font-size:12px;font-style:normal;font-variant:normal;font-weight:normal;letter-spacing:normal;line-height:normal;text-align:auto;text-indent:0px;text-transform:none;white-space:normal;word-spacing:0px"><div> <br></div><div>----------------------------------------------------------------------------</div><div><br></div><div>The arc of history bends towards justice. &nbsp; &nbsp; - Dr. Martin Luther King, Jr.</div><br></span></span> </div> <br></div></blockquote></div><br></blockquote></div><br><div> <span class="Apple-style-span" style="border-collapse: separate; border-spacing: 0px 0px; color: rgb(0, 0, 0); font-family: Helvetica; font-size: 12px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; text-align: auto; -khtml-text-decorations-in-effect: none; text-indent: 0px; -apple-text-size-adjust: auto; text-transform: none; orphans: 2; white-space: normal; widows: 2; word-spacing: 0px; "><div style="word-wrap: break-word; -khtml-nbsp-mode: space; -khtml-line-break: after-white-space; "><br class="Apple-interchange-newline"><div><br></div><div>----------------------------------------------------------------------------</div><div><br></div><div>Terrorism is not an enemy.&nbsp;&nbsp;It cannot be defeated.&nbsp;&nbsp;It's a tactic.&nbsp;&nbsp;It's about as sensible to say we declare war on night attacks and expect we're going to win that war.&nbsp;&nbsp;We're not going to win the war on terrorism. &nbsp; &nbsp;&nbsp; &nbsp;&nbsp;- retired U.S. Army general, William Odom</div><br class="Apple-interchange-newline"></div></span> </div><br></body></html>