Handling Structures, and Smoothing values

cat's picture

I'm in the middle of a project, I've just had to rewrite a significant part, as silly me I forgot you can't get values out of an iterator, well on 10.5, and without significant cpu hit. So now I need to smooth a structure that is being sent to a dmx node, preferably without using 72 smooth nodes... Is their a way of doing this in java? Is there any way to select elements of a structure for example all the x's, or just the x's and y's of a xyz structure, where the structure is a structure of structures... see attachment I'm more a vvvv users so I'm missing vector splits and vector joins, and being able to damp an array with 1 node of course :S My patch has gone from lovely and sleek in interators, and is now far more noodly than I would have liked! Any help would be appreciated, especially as my java is zilch! :)

Cat

PreviewAttachmentSize
Screen shot 2011-02-16 at 00.02.23.png
Screen shot 2011-02-16 at 00.02.23.png13.48 KB

jersmi's picture
Re: Handling Structures, and Smoothing values

Regarding separating structure elements, inserting three Structure Index Member patches after should work to separate X, Y, Z. For index, 0 = X, 1= Y, 2 = Z. Likewise you could use a Structure Key Member patch with X, Y and Z for keys.

You could use javascript as well (and by the way, it's "javascript" in QC -- java and QC are not such good friends). I believe this would work inside an iterator:

function (__number X, __number Y, __number Z) main (__structure queue, __index index)
{
   var result = new Object();
   if (queue != null) {
      result.X = queue[index][0];
      result.Y = queue[index][1];
      result.Z = queue[index][2];
   }
   return result;
}

gtoledo3's picture
Re: Handling Structures, and Smoothing values

usefuldesign posted exactly what you're looking for (I think), awhile back... it's javascript that smooths multilane (eg., more 2d, 3d, 4d, etc.) structures, so it works around not being able to do smoothing with the "use smooths in iterator, publish results" method, or using openCL.

PreviewAttachmentSize
alastair leith js structure smooth.qtz2.66 KB

usefuldesign.au's picture
Re: Handling Structures, and Smoothing values

Infact. I'm just about to post new exciting ways of doing it! I'll try and finish off this week.

The code for single values is done for all the smooth equations, eg. sine, cubic, exponential etc. etc. email me at usefuldesign #at# gmail #dot# com for the code.

Need to do Array to n dimensions version still.

cat's picture
Re: Handling Structures, and Smoothing values

I'd found something like that as an audio structure smooth, but it doesn't work with the structure of structures, I think? Can't use iterators as the frame rate drops to 8fps when I've tried that, and the index member returns just one set of xyz co-ords, and the key member doesn't seem to get the values from the nested structure. Attached is my patch, I can't see how to handle structures in a neat manner without a stupid amount of noodles, look in the DMX macro to see that :S I'm actual using xyz, rather than just the xy that I need as I need to add values to a structure, and 1024's 1d math node crashes as soon as I connect an out from it... 3d works ok so I'm using that. I need to smooth the DMX as its driving servos that can't move over a certain speed without grinding teeth off gears, but also need to smooth the gfx as well to match. Useful things to know how to do in general would be, separate elements from a structure of structures, so all x's all y's etc, keeping them as structures, and recombine as x,y,x,y... repeat, or all x's followed by all y's all in 1 structure, in vvvv these are such basic things, but then again arrays are treated no differently from single values there.,I don't know how you live without them in qc! Are there any clip resources that do them? Any more help you could give would be appreciated, could do with having a prototype working by tomorrow!

cat

PreviewAttachmentSize
Help.qtz115.7 KB

usefuldesign.au's picture
Re: Handling Structures, and Smoothing values

Oh and thanks for the catch GT!

usefuldesign.au's picture
Re: Handling Structures, and Smoothing values

If your servos are that powerful I'd be looking to govern them in some way electronically, cause you never know what software is going to throw at them in the testing phase. An arduino could easily handle such signal processing and there's heaps of publicly usable code on their forums.

Also I'm following John Boxall's blog t r o  n i x s t u f f  about all things Arduino, he is a fellow Australian and a very clever guy. Totally of topic, check out the worlds smallest oscilloscope you can plug into your bread board — the size of your thumb and only $35, unbelievable!

Anyhow, yes other noodling environments do handle spreads/arrays 'better' than QC, but as a consolation you get to bang your head against the Javascript world for hours, because what you want is conceptually very simple to write Javascript code for. It's just the little code expression details that are all waiting to trip you up! I'll have a quick look at your file, can't promise anything. I'd be better just finishing the new improved smooth structure patch to deal with arrays.

cat's picture
Re: Handling Structures, and Smoothing values

Added more below, when my browser didn't update..

cat's picture
Re: Handling Structures, and Smoothing values

Actually its more that the gears are a bit shit, they dont break everytime, but there liable to do so, so limitiing is necessary, the project is already built so there no going to arduino now, and really how hard can it be to smooth data in qc... Unfortuantly being a bit dyslexic coding isn't easy as I can't see why code doesn't work, even when keywords are high lighted as wrong, thats why I use noodles, and not something like ofx! This is a project for a friend, and originally I did tell him to use a seprate control pc, ie vvvv, but he's a mac boy and wants to use 1 laptop, and I do qc for vj patches and fx with vdmx, so I thought, how hard can that be...?!? I'm kind of suprised they're aren't more modules for handling arrays though, I don't think that the implimentation is necessarily worse, just the the tools for handling them is limited, hence your making a smooth structure patch now is great, but how did you all manage without it!
That oscilloscope is pretty cute :)

usefuldesign.au's picture
Re: Handling Structures, and Smoothing values

Well once apon a time Apple Smooth patch didn't even work inside iterators. Which is where I am stuck: leopard so your comp was a bit chopped up and I could really see what was going on, because it wasn't. There's an Apple smooth array Javascript patch in the Music Visualiser Template for a flat 1D array (well in Leopard anyhow). I'm not sure how you open those templates in SL. All I can offer for now…

cat's picture
Re: Handling Structures, and Smoothing values

Thanks for looking, I came across the 1d smooth, but how to separate the structures, and then put them back together again... ho hum

gtoledo3's picture
Re: Handling Structures, and Smoothing values

Did you look at the attachment yet? That does smooth structures.

gtoledo3's picture
Re: Handling Structures, and Smoothing values

You know what's screwed up w VVVV (in my opinion)? There's no notion of Viewer Run/Stop during prototyping, your programming environment is set to start running as soon as you open the file. I mentioned this to the creators and they were like "who would want that?"

cat's picture
Re: Handling Structures, and Smoothing values

Hmm, it does seem to like, nested structures, or doesn't work in my patch, does it not just work on 2d data? Just seen your collada post about stripping dimensions from an array though so thats an option... There is an enable for the renderer in vvvv, which does exactly that... But why would you want to? :D hehe The whole point of vvvv is that its always runtime, as is quartz, as far as I can see?... If you dont want something to process, you either feed it a null, or use the enables, more screwed up, but quite useful, is being able to mess with the xml of your patch, from within the patch, now that is wacky, someone once made an FFT display using the nodes within the patch... but the useful things are, you can load and create patches dynamically...

Now back to beating my head with a javascript stick...

cat's picture
Re: Handling Structures, and Smoothing values

http://kineme.net/forum/Discussion/DevelopingCompositions/Smoothingcoord...

http://kineme.net/files/ULTRA%20OBVIOUS%20Smooth%20Tester%20using%202D%20(JS)%20Smooth%20III%20ii.qtz

So I see in the comp here the smooth is handling a 4d array but with my 3d array it doesn't work. The output is as attached So why does it not work, or how do I add a z to an already created xyz structure?

PreviewAttachmentSize
Screen shot 2011-02-16 at 21.02.15.png
Screen shot 2011-02-16 at 21.02.15.png12.18 KB

usefuldesign.au's picture
Re: Handling Structures, and Smoothing values

Splitting and reconstituting done here.

You are better of learning a bit of JS to change the smooth array patch, it's a neater and more flexible way of doing it in my opinion. Your comp (and problem) is hard for me to read.

gtoledo3's picture
Re: Handling Structures, and Smoothing values

Yeah, but QC has a notion of prototyping and emulating the Run of the app - the Run/Stop feature on the viewer. What would be similar in QC is if "everything" had to link to some kind of patch time, which had to be stopped or started, or if one had to turn off every enable on every consumer... the VVVV way. You can do that in QC as well, but fortunately, have the option of just stopping the program from running, entirely apart from the using the nodes within the graph to do so.

After using QC, it's really hard to have to not have that implicit notion of start/stop built into the QC runner (the editor app). I'm not knocking VVVV, because it has it's own bag of tricks that are really cool... like in editor viewers, ala MAX, freeform noodle drawing, some robust interaction with shaders, etc.

A qtz can be manipulated as a plist or xml, by another qtz or app, if one wanted to, the same as you are describing w/ VVVV. That basic premise of manipulating the actual text of the file is present in a few different environments (not just QC and VVVV) as a last ditch workaround.

Back on task to the structure smooth:

Maybe the input structure isn't setup exactly right.

Come to think of it, it seems like artnet is a 1d (1 lane) structure... so I don't think you actually need 2d or 3d structure smoothing at all. Something like that music visualizer 1d structure smooth (or derived from) seems appropriate... or just using the iterator+smooth and forgetting about Leopard support all together.

cat's picture
Re: Handling Structures, and Smoothing values

Thanks Alastair, that's perfect :) Everythings smooth and peachy!

cat's picture
Re: Handling Structures, and Smoothing values

Disabling the renderer does that, everything connected to it stops processing I believe... But the is no emulation of the app, because the patch is the app... I'm fascinated to know where you use the start stop, it never really occurs to me to need it, maybe I'm missing something...

Yeah artnet is 1d, but I need to do some maths on the structures getting sent there, and 1024 structure maths patch crashes qc when I use the 1d, and not knowing of any other way to do the maths, I'm using a 3d structure and padding the z. If i didn't I'd still need to split the 1d structure into odd and even index's to drive the simulated mirrors, need my vector2d split :)

Reading the feedback on the structure tools page, from 2008, and theres a list of suggestions for structure manipulation, that would be really useful, I'd add my favorite spread nodes in vvvv, resample a structure to a different length with different interpolation types, vector[n] split and join (Alastair has a java split one in this thread :) ) Cons, add append a structure to another, I use these all the time in vvvv, and I think you'd find them extremely useful as objective c nodes in qc, well I would anyway! Array handling is actually vvvv best side, qc is its weakest I think... QC is hands down better in many other ways, integration with other apps, eg vdmx, is outstanding, or noise industries after effects filters, simply brilliant. The fact that kineme have to make all these addons I find strange, they should be built in, heres hoping that the forbidden fruit will grow roots and these things will be integrated into the main trunk of qc, because I'd love to ditch windows, vvvv is the only thing that keeps me there, especially seeing as 90% of my work is vvvv! The are still rumblings about vvvv becoming crossplatform and more open source, not anytime soon, although the open source parts are growing rapidly, but its on the road map, then vvvv as a plugin for qc, I can dream can't I? hehe Thanks for your time, the comp is working pretty much now, so all is good :)

franz's picture
Re: Handling Structures, and Smoothing values | FIX

_1024_1Dstructure crashes ? can you send me a crashing comp ? I'll try to fix it. Shouldn't be too hard....

franz's picture
Re: Handling Structures, and Smoothing values

Can you try this new version ? The 1Dstructure crash should be corrected now. Sorry for the inconvenience.

PreviewAttachmentSize
_1024_MATHStructure 1.3.plugin.zip17.21 KB

cat's picture
Re: Handling Structures, and Smoothing values

Thanks Franz, that looks good :)

franz's picture
Re: Handling Structures, and Smoothing values

cool. don't hesitate to notify me in case of a crash.