Magneson's List Tools [Deprecated]

Deprecated, use this instead: https://community.vuo.org/t/-/6543

The node set consists for now of eleven nodes (5 unique, and 2 sets of convenience nodes).

Sort with index

This takes a real-list as an input, and gives out a sorted list from highest to lowest number. More importantly it also spits out an index list of where the highest number exists in the input list. It does this in a highly inefficient manner mind you (at least I think so∞), so connecting it straight to an audio-rate node will choke your composition. Please see example for how to do so under somewhat safe circumstances.

Reorder List

Takes whatever list is presented at its input and reorders it to whatever is present at the “order list” input.

Reorder Layers

Takes a layer list as input and does the same as above.

Change Items In List

Changes items in a list based on their index.

Cut Wrapped List

Similar in function to the built-in Cut List, but the index wraps around the list, making for easy animation of smaller sequences from huge lists.

Get Items from List (2/4/8)

Gets 2/4/8 items from a list given individual indexes.

Get Items from List (2/4/8, sequential)

Gets 2/4/8 sequential items from a list given a starting index.


Changelog


V.4 update

Added Cut Wrapped List, which lets you cut out a segment from a list and wrap around. Useful for animations.


V.3 update

Added breakout boxes for getting 2/4/8 values from a list. Sequential or by indexes.


V.2 update

Added a “Change Items in List” node upon a request from @Bodysoulspirit.


– Ramblings from earlier iterations:

@Kewl’s question about layer sorting (found here: https://community.vuo.org/t/-/6097) intrigued me a bit, so I wrote up a couple quick nodes to address the issue. These are to regard as experimental at best, and is as always used entirely on ones own peril.

Note that I made the “Reorder Layers” node because I couldn’t quite get it to work with generic types. I think that was just me being stupid about something (like the audio rate), but didn’t bother to check after I made the layers one and got that to work. So, probably works, if not - don’t say you weren’t warned (and send me a message if you try it out and it doesn’t).

∞For the programmatically inclined, I used the VuoReal_max() function to sort the list and get the index. Probably shouldn’t, but that was as far as my brain managed to get today. Please have a peak at the code and send a message if it’s horrible.

Magneson.ListTools.vuonode (8.71 KB)

Magneson.ListTools.Demo_.vuo (12.5 KB)

Magneson.ListTools.vuonode (11.3 KB)

Magneson.ListTools.vuonode (27.7 KB)

Magneson.ListTools.vuonode (30.7 KB)

Screen Shot 2018-04-01 at 20.39.04.png

Screen Shot 2018-04-01 at 20.38.56.png

Screen Shot 2018-04-01 at 21.21.38.png

Screen Shot 2018-04-01 at 21.21.34.jpg

4 Likes

Don’t know where the example/demo went, maybe it’ll show up here?

Magneson.ListTools.Demo_.vuo (12.5 KB)

Hey, thanks! I will have a look at this…

So far, so good! I’m testing a slow machine (MBP 2013), but I’ll be testing more thoroughly in the next few days on a Mac Pro. So, again, thanks: the Sort with index & Reorder Layers combo is doing exactly what I wanted.

Cheers!

1 Like

This is amazing Martinus !
Analyzing your method made me realize some errors I suggested in my method on Kewl’s question.

I think I have come up with a method using stock nodes only though using make dictionary, but it’s not as good as your custom nodes. More nodes required, more type conversions and your composition feels smoother on my Macbook pro !

Sharing if one has to go with stock nodes only.
Basically Reorder List can be replaced with Get Items From List I guess. Although maybe your node is at this point already more optimized for this.
And for the Sort With Index I used a dictionary, indexes as values, and amplitudes as keys, and retrieved the keys sorted using Sort Points by Distance.
Where your node really shines is it does combine all these steps, and I guess that’s what makes your method way smoother !

And the composition is also very nice, the colors, the idea of spreading the layers randomly is a cool idea.
Anyway, congrats !

PS : Question to the team, is there a reason why Sort Points By Distance does not allow Reals (starting from 2D points only).
PS 2 : Definitely would be cool to have an index / position output on the Sort Points By Distance you know you can also post the nodes to be added to Vuo as stock nodes if you want Martinus ? I remember Alexander Mitchell did that for one audio node if I’m right.

![Dictionnary method][Dictionnary method]
[Dictionnary method]: https://vuo.org/sites/default/files/nodeset/Bodysoulspirit/2018-04-02%2004.09.20.png  

Sort Layer List With Dictionnary 1.1.vuo (11.5 KB)

2 Likes

Sending you some $ for this bytheway ! This is great

1 Like

Just realized technically one could also use a table instead of a dictionary for stock nodes method.
Your custom nodes are probably still better to do this since you don’t have to convert text lists to real etc.

Joining the composition for those interested.

![Sort With Table][Sort With Table]
[Sort With Table]: https://vuo.org/sites/default/files/nodeset/Bodysoulspirit/2018-04-02%2006.47.19.png

Sort Layer List With Table.vuo (10.9 KB)

1 Like

Thanks! Good to know it helps (but test a lot if using it for production!)! I had it running for a couple hours on my 2015 mbp (with Iris graphics) without any apparent issues, but you never know. I intentionally left the compostion at the maximum number of frequencies to stress test so it should crash pretty fast if there is any issues. If it then grinds to a halt it’s a sign that something isn’t right.

The sorting bit and getting the index can probably be done with stock nodes as it just is an implementation of the “Get Maximum” node for lists. The function itself gives you the index in the list. I really don’t know if this is intended use for it regarding efficiency or if there is a better way. From what I understand, internally it uses an array instead of a list to get the raw data, so it should be somewhat more efficient than a pure list approach. There is probably some room for improvement though, as it still takes a roundtrip through a list for every iteration of checking. If all that happens in an (the same) array instead, it might be better.

The way the sorting happens is finding the largest number, then adding it to one list, and the index of it to another list. Then it sets the current number to 0, and repeats. This is probably the least efficient sorting method, I think it’s in a general sense comparable to selection sort in this video: https://www.youtube.com/watch?v=kPRA0W1kECg . It might be possible with some “Build List” nodes, but I’m not quite sure. The reorder part as well should be possible in the same vein, but you’d need a fair bit of node wrangling to do so I guess.

Sort points by distance was my first thought as well, the problem I encountered there was that by sorting without having the index, it will put the largest value at index 1 no matter where it is in the spectrum. Sorta works for the random blobs, but you wouldn’t get the color separation based on frequency.

(I already have a couple of my shoddy image filter ports included in 1.2.6 ;) Polished by team Vuo of course!)

1 Like

This also seems to be working.

Sort Layer List.vuo (11.9 KB)

1 Like

@kewl

This also seems to be working.

Haha you came with a question and you just found the easiest way to achieve this it seems ;)
Dictionaries and Tables could probably still be useful in some cases you’d wanna map lists with different patterns than ascending/descending.
But for this case, your method is the straightforwardest.

@martinusmagneson

(I already have a couple of my shoddy image filter ports included in 1.2.6 ;) Polished by team Vuo of course!)

Ah ok sorry I did not see that, congrats !  

Inspired by both of you, for sure! For me, the keys were Make Points along Line, Get Items from List, and going parallel to the Process List creating the layers.

Thanks again!

1 Like

@MartinusMagneson, @Kewl, @Bodysoulspirit, this is great :)

@Kewl, you commented that your composition wasn’t as smooth as Magneson’s — try inserting a Hold List between the Build List and Get Items from List.

is there a reason why Sort Points By Distance does not allow Reals (starting from 2D points only).

No reason. In fact there’s a Sort List node coming in the next major release that will support Reals and many other data types.

Definitely would be cool to have an index / position output on the Sort Points By Distance

Yeah, or I wonder if there’s another good way to sort a list by another list — without having to construct and deconstruct a table (for Sort Table) — that might be more approachable to someone less familiar with math/programming.

Don’t know where the example/demo went, maybe it’ll show up here?

The example composition field was late to the party, but now it’s here. Sorry for the confusion.  

1 Like

Hey Jaymie,

The smoothness comment was from @Bodysoulspirit. In any case, I’m using my solution, which works great with stock nodes.

Cheers!

Thank you @JStrecker! Looking forward to the next release! Finally have had some time for Vuo again after three months of touring and a bajillion events. Must say that the API is quite neat now that I’ve gotten more familiar with it.

1 Like

@jstrecker

You commented that your composition wasn’t as smooth as Magneson’s — try inserting a Hold List between the Build List and Get Items from List

Ah yeah good point ! Also initially mine wasn’t as smooth also because I had the Receive Live Audio samples going into a Hold List BEFORE going into Calculate Amplitudes which means they had less data to process and therefore it wasn’t as smooth.
Since then, pretty much all methods seem as powerful, although on my old Macbook Magneson’s method and mine play at about 45 FPS where Kewl’s easiest method at 55.

1 Like