<html><head></head><body><div style="font-family: Verdana;font-size: 12.0px;"><div>There's not much you can do with data structures/pointers in externals if you stick to the official header "m_pd.h", but if you use "g_canvas.h", you can do all sort of things. Check the sections "scalars" and "templates" in the header file.</div>

<div> </div>

<div>If you have a gpointer, you can check "gp_stub->gs_which" to find out what kind of thing the gpointer points to (glist or array) and then use "gp_scalar->sc_vec" resp. "gp_w" as the "wp" argument to the template_* methods to access/manipulate data. But always remember to call "gpointer_check()" first to varify that the gpointer is still valid.</div>

<div> </div>

<div>Not that I've ever needed this :-)</div>

<div> 
<div>Christof
<div name="quote" style="margin:10px 5px 5px 10px; padding: 10px 0 10px 10px; border-left:2px solid #C3D9E5; word-wrap: break-word; -webkit-nbsp-mode: space; -webkit-line-break: after-white-space;">
<div style="margin:0 0 10px 0;"><b>Gesendet:</b> Samstag, 04. Januar 2020 um 16:49 Uhr<br/>
<b>Von:</b> "x nor" <x37v.alex@gmail.com><br/>
<b>An:</b> "Christof Ressi" <christof.ressi@gmx.at><br/>
<b>Cc:</b> pd-dev <pd-dev@lists.iem.at><br/>
<b>Betreff:</b> Re: [PD-dev] capabilities of data structures with externals</div>

<div name="quoted-content">
<div>
<div>BTW, I don't think anyone ever answered my first set of questions though they were sort of loaded with specific information about a specific goal, though I'm curious in general..</div>

<div> </div>

<div>I see in Christof's examples that I can create canvases in an external.. but my question was about what I can do with pointer methods in an external.</div>

<div> </div>

<div>Is there an example that uses the public API to discover information from a pointer? To traverse it and extract data? Augment data? Add data?</div>

<div>How about the pointer outlet capabilities for externals.. is there any point at this time? It looks like the public API has what an author would need to create an 'owned' pointer (gpointer_init) and then output it, but does the public API provide any way to actually associate anything useful with it?</div>

<div> </div>

<div>-Alex</div>
 

<div class="gmail_quote">
<div class="gmail_attr">On Fri, Jan 3, 2020 at 1:34 PM Christof Ressi <<a href="mailto:christof.ressi@gmx.at" onclick="parent.window.location.href='mailto:christof.ressi@gmx.at'; return false;" target="_blank">christof.ressi@gmx.at</a>> wrote:</div>

<blockquote class="gmail_quote" style="margin: 0.0px 0.0px 0.0px 0.8ex;border-left: 1.0px solid rgb(204,204,204);padding-left: 1.0ex;">
<div>
<div style="font-family: Verdana;font-size: 12.0px;">
<div>Hi,</div>

<div> </div>

<div>if you consider writing an external, why not include the data? Having the data model in Pd data structures and writing an external just to access it is certainly possible, but IMO doesn't make much sense.</div>

<div> </div>

<div>In your external you can create a (hidden) canvas and add garrays, either with graph_array() from g_array.c or or by sending the "array" message to the canvas with pd_typedmess(). DSP objects like [tabwrite4~] can then access those garrays by their name.</div>

<div> </div>

<div>This is how you create a hidden canvas: <a href="https://git.iem.at/pd/vstplugin/blob/master/pd/src/vstplugin~.cpp#L728" target="_blank">https://git.iem.at/pd/vstplugin/blob/master/pd/src/vstplugin~.cpp#L728</a></div>

<div> </div>

<div>And this is how you add objects: <a href="https://git.iem.at/pd/vstplugin/blob/master/pd/src/vstplugin~.cpp#L868" target="_blank">https://git.iem.at/pd/vstplugin/blob/master/pd/src/vstplugin~.cpp#L868</a></div>

<div> </div>

<div>NOTE: I wouldn't really recommend this</div>

<div> </div>

<div>---</div>

<div> </div>

<div>The other possibility is to have your data model in an abstraction, with the float arrays in [table] or [array define], and then use [clone] or dynamic patching. I think this is less work :-)</div>

<div> </div>

<div>---</div>

<div> </div>

<div>
<div>That being said, I think there should be a way for [tabwrite~] etc. to access data structure "float" arrays. See also: <a href="https://github.com/pure-data/pure-data/pull/667" target="_blank">https://github.com/pure-data/pure-data/pull/667</a></div>
</div>

<div>
<div> </div>

<div>Christof</div>

<div> 
<div style="margin: 10.0px 5.0px 5.0px 10.0px;padding: 10.0px 0.0px 10.0px 10.0px;border-left: 2.0px solid rgb(195,217,229);">
<div style="margin: 0.0px 0.0px 10.0px;"><b>Gesendet:</b> Freitag, 03. Januar 2020 um 17:59 Uhr<br/>
<b>Von:</b> "x nor" <<a href="mailto:x37v.alex@gmail.com" onclick="parent.window.location.href='mailto:x37v.alex@gmail.com'; return false;" target="_blank">x37v.alex@gmail.com</a>><br/>
<b>An:</b> pd-dev <<a href="mailto:pd-dev@lists.iem.at" onclick="parent.window.location.href='mailto:pd-dev@lists.iem.at'; return false;" target="_blank">pd-dev@lists.iem.at</a>><br/>
<b>Betreff:</b> [PD-dev] capabilities of data structures with externals</div>

<div>
<div>
<div>This past week I've finally learned a bit more about data structures in PD and I've successfully created my own data structures that model data from ATS files (sines + noise analysis models).</div>

<div>The re-synthesis ended up being a bit heavy because I didn't see a way to use tabread~/tabread4~ directly with arrays of complex data, so I patched some helpers that iterate the data structures and create float arrays from the fields as needed.</div>

<div> </div>

<div>I'm wondering if I can replace this with an external that deals with these details internally so I have a few questions before I go down that road:</div>

<div> </div>

<div>1) I see that I can register "pointer" methods for externals.. my structure has a field that stores an array that stores arrays of structs, can I expect to be able to get to that data in an external? Any examples?</div>

<div>2) If I am able to get to the data, can I mark it as 'used for dsp' somehow like i see you can do for garrays, and then use it within a dsp callback 'safely' or do i need to copy the data into separate float arrays to do that?.. maybe i should reorganize the data so that I don't have to do the copy, but if I end up creating a bunch of float arrays to model the data inside my data structure, can I then somehow treat it as a "garray" and mark it used in dsp and use it in my dsp method?</div>

<div> </div>

<div>Thanks,</div>

<div>Alex</div>
</div>
_______________________________________________ Pd-dev mailing list <a href="mailto:Pd-dev@lists.iem.at" onclick="parent.window.location.href='mailto:Pd-dev@lists.iem.at'; return false;" target="_blank">Pd-dev@lists.iem.at</a> <a href="https://lists.puredata.info/listinfo/pd-dev" target="_blank">https://lists.puredata.info/listinfo/pd-dev</a></div>
</div>
</div>
</div>
</div>
</div>
</blockquote>
</div>
</div>
</div>
</div>
</div>
</div></div></body></html>