i am not sure if this patch is useful. i tried to find out how to use the -s (struct) flag with the [array] object.
this way it is possible to use data structure arrays with [array]. while it is possible to make data structure arrays with multiple variables [array] accepts only field y from data structure arrays.
interestingly it is 50 times faster to read [get] with [element] pointer than to read [array get] or [array get -s] (with 10000 elements).
with an array with more than 100000 elements the [get] method is the only one that does not take forever...
if i set the pd array with a data structure array with more than 10000 elements, the pd array is not drawn correctly (but the values are still there).
-
[array] / [text] Pointer
-
i wonder especially about this sentence in the [set] help file: "Arrays are accessed using the [element] object, and lists using [text] objects." Access arrays with [element] is no problem, but how can i use lists with data structures and access them with [text]? Or do I misunderstand something from the help file?
edit: the explanation is at the bottom of the [text] help file [pd text-and-data-structures]...
-
here is what i could find out about the text pointer and data structures. there is even a text field in [struct] and you can draw the first 100 lines of the text.
it is also possible to save multiple texts in one [struct] object.
but it seems not much faster to access text from data structures than from the usual [text] object because there is no direct access like array has with [element].textPointer.pd
somehow the drawn text disappears after reopening the patch (but the stored text data is still accesseble). -
@Il pleut pointed out that the arrayPointer test does not make any sense as it is. The second inlet of [array get] needs a one, so that it calls only one array element at once, and then the resulting realtime values from the four methods are quite similar
-
Esta lloviendo in Berlin...
-
@Il-pleut I am just guessing, but I would say data structures are just a little faster than normal [array] and [text] objects... But the main bottleneck is the visual representation, if you draw a lot of data like a big game of life grid (which is the same for regular gui elements).
But for "normal" interfaces it is totally sufficient.
And perhaps data structure visuals are even a little more efficient than regular gui elements because, for example, a data structure grid carries less information than a grid of toggles? -
@Jona From what I've saw, i'd say that, arrays pointing to data structures are "data structure" efficient; maybe arrays are actualy data structures. The text object is realy slow compared.
The fastest combo is:
- data structures
- array get -s -f, the data structure flags / get /set /element to call and write the data,
- list store, to store the pointer, to move among the scalars, if there is no solution to set the pointers at creation time.
I call it the pointer's combo.
I only use text for:
1- write and open text file ;
2- store a set of data of variable size, since creating and deleting data structures can lead to audio crack, memory access problem maybe. But i don't count on accessing those data very often.When I create a patch that computes a lot of data, the engine core and the display should be made with the pointer's combo , and only the slow parts should use text. Input gui elements should be used as inputs, not outputs . NO GUI ELEMENTS SHOULD BE ON THE PATH OF DATA COMPUTING.
The usage of data structure is justified for data computation as much as it is for data visualisation, because they are "sound safe" : they won't cause audio click.
Esta lloviendo in Berlin...
-
@Il-pleut that all makes sense. Also the sound safe statement seems true. It is only that the interface itself can get slow, like in this grid with 2048 fields: https://forum.pdpatchrepo.info/topic/10734/vanilla-struct-sequencer/9
This patch also demonstrates some limits: https://forum.pdpatchrepo.info/topic/10674/experimental-vanilla-xy-pad-very-heavy-data-structure -
Optimisation is achived by a lot of different means. The explanations I wrote above are a starting point.
Esta lloviendo in Berlin...
-
Hey, sorry to ask on this old topic, but I think is related enough. How did you know that the default array structure is "float-array z"? I couldn't find this anywhere else.