hey all, i'm trying to dig into data structures and having problems to understand the usage of arrays:
is the only possibility to access a data structure array elemnt by element, or is there a way to set all values at once (with a list of values, similar to [array set])?
thanks in advance!
-
data structure arrays
-
@ingox just a quick question: what is the meaning of the -f flag in array sum? does it mean "field"? what is a field? a hint would be nice...
-
@toxonic Yes, since the array only contains the field y, the notation is not needed in this case, as i stated in my second answer. But since data structure arrays can contain multiple fields, i suppose that the -f flag can be used to only access specific fields. I haven't actually tried it out, so i wouldn't know for certain. I took this from the pd array-and-data-structures subpatch in the array help file.
-
For example here the array has two fields, y and c. The plot only goes over y and without specifying a field also the sum is only made over y. But i can specify the field c for the sum and this also works: struct-array2.pd.
But i am just figuring this stuff out right now, i have no deeper knowledge of all of that.
-
@ingox ah, ok - thank you much! i already had a look into the help files, but somehow i couldn't find much about the meaning of the flags, except that you can use them to refer to data structure arrays - but not much about how they get used. i think, the pd documentation lacks a bit in regard to data structures. i find it quite awkward to figure out all the functions of data structures at all,... your explanation make sense!
-
ok, one more:
i played around a bit with that stuff and found, that it could be useful to build a kind of sliderpack with a dynamic amount of sliders in it. but how can i get the index of an element while changing it with the mouse?
i can set the index with [element], but i don't know how to get it?
sliderpack_test.pd -
@toxonic To my knowledge, you can't if the sliders are elements of an array. If they are single data structure representations, you can get their respective pointer from the [struct].
See for example:
https://forum.pdpatchrepo.info/topic/10756/vanilla-struct-multislider-with-jump-on-click-and-drag
https://forum.pdpatchrepo.info/topic/10854/xy-abstraction-to-get-mouse-click-and-drag-coordinates-vanilla -
thank you, nice patches! that will get me started!
-
@toxonic The xy patch still contains a bug and the idea was to combine xy with the multislider, as the method with the rows and columns isn't efficient at all, but i haven't found the motivation yet to tackle this issues