For a first understanding of ofelia 2 and lua i studied ofelia-object-help.pd and tried to "simulate" a pd array with a lua table.
Somehow its not possible to use {} inside pure data objects or messages, otherwise i would put the lua script (while its short) directly into the [ofelia define] object.
ofelia_array.pd
@cuinjune i have a few questions regarding ofelia 2 if it doesnt matter:
Is there a way to use the [ofelia] variables outside of the [ofelia] objects (like with the @ variables and [ofSnd] / [.ofRcv] / [ofValue] objects in the old version)?
Is [ofExpr] and [ofExpr~] replaced by [ofelia define] (see [inlets_and_outlets] example in the help file)?
Do you have any plans to port the pdgui abstractions in the future? I really like them, and also would like to port the multitoggle/slider/radio abstractions as a first project to the new version. And the pdgui abstractions were a very good starting point for that.
Creating of. abstractions doesnt look that difficult, but i still have to understand it in detail.
And thanks for the great library, still need to learn a lot (lua and open frameworks)...
-
ofelia lua table and a few questions
-
@Jona Hi, I think I added them to pdexample patch.
Does this not work?
-
@cuinjune hi. "array get emulation" works but outputs the whole array, while with the pure data "array get" you can also set "first index to output" and "number of points". same for the pure data "array set" while the number of points is defined by the length of the input list and the array isnt resized (the set values are inserted).
array set emulation doesnt work for me, it just resizes the array (win10 pd64bit).
but should define a new array and not just insert some values?
here i tried to emulate pure data "array set" with the "setAt" method:
array_set_emulation.pd
but the last value of the list is always written to the last value of the array, doesnt matter which onset value is set.
i think because of the code in ofeliaBindings.h "n=size-1" which is meant for setting a single value?void setAt(int n, t_floatarg f) { t_garray *a; int size; t_word *vec; if (exists(&a) && getData(a, &size, &vec)) { if (n < 0) n = 0; else if (n >= size) n = size - 1; vec[n].w_float = f; garray_redraw(a); }```
-
@Jona Hi, I can confirm that pd.Array's setTable() function doesn't work properly on Windows.
Like you said, It seems to only change the array size.
I tested this on Windows, macOS and Linux and strangely this only happens on Windows.Do you mind posting about this issue on https://github.com/cuinjune/ofxOfelia/issues ?
I will work on fixing it as soon as possible.
Thanks! -
@Jona I edited your array set emulation patch and it seems to work.
array_set_emulation.pd -
hi @cuinjune thanks for the edited array_set_emulation patch, it works now i will post the pd.Array's setTable() issue on your github page soon.
edit: just realized that your array set emulation only seems to work if the onset value is zero too, but perhaps the onset option isnt needed anyways (or there are other ways to achieve that). -
@Jona Hi, I added the onset option.
array_set_emulation.pd -
@cuinjune thanks somehow i still get the same "bug" as i got in my attempt. the last value of the input list is always set to the last value of the array independently from the onset (if there are more values in the input list than are in the table left after the onset)... but perhaps its again a windows specific problem?
-
@Jona I'm sorry that happens when calling array:setAt() using the index larger than the array size in which case it internally clips the index to the "arraysize -1" (or last index).
This version will fix the issue. Let me know if it didn't.
array_set_emulation2.pd -
yes, thats it. thanks sorry if i didnt explain my (theoretical) problem precise enough.