Structure > Outputs Patch

Here's an idea for an addition to a future Structure Tools: A patch that takes a structure as input, and creates an output port for itself of the appropriate type for each item in the structure.

a|x

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.

cybero's picture
Re: Structure > Outputs Patch

Neat idea, outputting the structure members. Could retain formatting, cuts out some of the need for index member and / or key member.

toneburst's picture
Re: Structure > Outputs Patch

cybero wrote:
...cuts out some of the need for index member and / or key member.

That's the plan :D I used to use structures a lot to bundle-up sets of control-signals, but it's always a pain constructing a macro to break the individual values back out of the struct. This could make that process a lot less fiddly.

a|x

jersmi's picture
Re: Structure > Outputs Patch

Just last night I was dealing with this and in my newbness was wondering about a javascript solution? Javascript would predetermine i indices, but otherwise is this a stupid idea?

toneburst's picture
Re: Structure > Outputs Patch

Would be a good approach, if the JavaScript patch allowed you to dynamically create inputs/output ports. Unfortunately, you have to hard-code the i/o ports into the main function header.

a|x

tobyspark's picture
Re: Structure > Outputs Patch

damn! why haven't i written such a patch already. i've certainly had thoughts in that direction, but not the moment of clarity to sit down and properly think about it.

would probably need a "generate inputs" button in the settings pane, so that ports don't disappear beneath you when something gets disconnected etc.

not saying i'm going to do it mind you, would need to come up when i'm deep in making custom stuff for a project.

toneburst's picture
Re: Structure > Outputs Patch

Hi toby,

good thought re. the 'Generate Ports' button. I hadn't thought of that.

Good luck with the project.

a|x

usefuldesign.au's picture
Re: Structure > Outputs Patch

At first I was thinking this is for a multi-item struct with sub-elements as in

<control-code>
   [geshifilter-code]&#10;      &lt;time&gt;3.0&lt;/time&gt;&#10;      &lt;X&gt;0&lt;/X&gt;&#10;      &lt;Y&gt;0&lt;/Y&gt;&#10;      &lt;Z&gt;0&lt;/Z&gt;&#10;   [/geshifilter-code]
   [geshifilter-code]&#10;      &lt;time&gt;5.0&lt;/time&gt;&#10;      &lt;X&gt;0.25&lt;/X&gt;&#10;      &lt;Y&gt;0.23&lt;/Y&gt;&#10;      &lt;Z&gt;0.24&lt;/Z&gt;&#10;   [/geshifilter-code]
   </control-code>

Now I'm thinking you are saying you would extract a code item from the structure before it gets to the custom patch which will then just output single values for time, X, Y, & Z elements.

Would be neat if when it received a full multi-item structure with sub-items it outputted structures of the common sub-items, ie a separate structure for time, X, Y, & Z each on it's own output port.

toneburst's picture
Re: Structure > Outputs Patch

I was thinking along the lines of:

if item i of input structure is a single value
   create output port of matching type
 
if item j of input structure is itself a structure
   create output port of type structure

You could then simply connect another instance of the patch to structure outputs to extract individual values

a|x

dust's picture
Re: Structure > Outputs Patch

i have been thinking about that lately as well. like an output factory for a structure. i have some code laying around that does this for the ipad.. i think right now its set to an iteration of 52 seeing its for cards. but xml node parsing or using an xml formatted osc string can dynamically generate objects without having to make a model.

how to do that in a qc plugin i have no idea i haven't tried it but i know it can be done certainly in the xib settings context, i had done that with an AU host plugin i lost.

usefuldesign.au's picture
Re: Structure > Outputs Patch

Okay you're talking about a straight top level structure splitter patch (nothing like input splitter patch thought!) as I understand you now.

If that's the horizontal approach I was thinking vertical as in group the like sub-elements into new structures. Your way could be an issue if the input structure gets big! I guess you'd just have to use Range Patch on the structure before it hits the splitter patch.

When I woke up this morning, I though about tobyspark's comment and considered this patch as it stands might be unworkable, as in it can only generate ports when the composition is running, which might not be possible until you get the patch noodled up correctly (after you, no after you, sir) — perhaps it would be better to manually add the key names to in the settings inspector? (I know we don't like stuff being unexposed in the settings haha).

toneburst's picture
Re: Structure > Outputs Patch

Quote:
When I woke up this morning, I though about tobyspark's comment and considered this patch as it stands might be unworkable, as in it can only generate ports when the composition is running, which might not be possible until you get the patch noodled up correctly (after you, no after you, sir) —

Hmm... not quite sure why that's a problem. I'd envisage you connecting a structure to the input, then hitting the 'Generate Outputs' button. Oh.. maybe you mean that because of lazy execution, the input structure will be null until it's connected to something else downstream... that could be an issue, damn...

a|x

usefuldesign.au's picture
Re: Structure > Outputs Patch

Yeah, you could possibly have a dummy output port that's always there to force evaluation but you still have the problem of needing the composition to execute to generate the ports and then it would need to save them until next time the composition is run or opened.

To me it makes more sense to have a settings panel where you can choose by named keys or by index. Then if named is chosen, you add them and type them in like the Keyboard patch. If by index, then have max, range options like the input splitter patch when set to index type. I guess that's not much difference to making a Javascript patch to split a structure and just re-naming the outputs. Might be faster though??

gtoledo3's picture
Re: Structure > Outputs Patch

If you have to name them, what's the point? The indices/keys should already be established by the time it hits the structure input port (how could they not be?).

Evaluate, autoconfigure by input port.

toneburst's picture
Re: Structure > Outputs Patch

I'm with George on this one. If you have to manually name the output ports, then you may as well just create a load of Structure Key/Index Member patches.

a|x

gtoledo3's picture
Re: Structure > Outputs Patch

I don't think there should be a problem keeping the output ports setup in the composition once they are generated, re: the comment above by usefuldesign. Once the output ports are generated, they're there in the file.

The one thing I wonder about is the ability of the QC Editor to handle the graphic toll of configuring what could possibly be thousands of outputs in one fell swoop. Maybe the patch would have to add one at a time, and keep referencing the structure count until it was "done". That might make the Editor "not" flip out (speculation on my part), if a structure that was sizable was configured.

toneburst's picture
Re: Structure > Outputs Patch

I think we're talking at cross-purposes here. I'm not talking about taking a structure with thousands of members, and creating outputs for each one- there would be no utility in doing that, and it would no doubt bring the QC Editor to it's knees, as George points out. I can definitely see cases where being able to create output ports from a structure of a few members would be really useful, however.

a|x

cwright's picture
Re: Structure > Outputs Patch

To the editor, there are 2 aspects in play here. The first was solved writing some of the kineme patches, and that's disabling redraw notifications for changes (old versions of GLTools would redraw the graph for each added port when changing splines -- disabling notifications made it stop updating until the final configuration was reached). So that's not a problem.

The second problem is actually rendering -- that is a function of port count, so it'll slow down some, but hopefully not too severely.

There's a lot to be gained by cutting out extra patches -- less patches = lower graph evaluation overhead.

ginsu777's picture
Re: Structure > Outputs Patch

this is interesting to me. If you see some of my recent posts around here, i am trying to find a neat way to take XML data that is streamed from a device using

 nc localhost 8168 [code]  The resultant stream has this format [code]
<$xml_message id=$ID time=$TIME $xml_message_dataname=$value 
             [$xml_message_dataname=$value [...]] />[code]
and looks like this:
[code]<HeartRate id='8655h' timestamp='1278200656.36' BPM='76' />
<HeartRate id='8655h' timestamp='1278200656.60' BPM='76' />
<HeartRate id='8655h' timestamp='1278200656.85' BPM='76' />
<HeartRate id='8655h' timestamp='1278200657.09' BPM='76' />[code]
 
I want to strip out anything that is not associated with the BPM, and plot the values on an X-Y, Y=BPM, X=patchtime