[LV2] Need help sending a variable size atom from the UI of my plug-in
Clay Citadel
claycitadel at gmail.com
Mon Sep 6 08:25:10 PDT 2021
Hi,
I'm using c++ and lvtk framework, but I'll be perfectly happy with using
raw lv2 C functions to do this. Here is the code I have that works with
LV2_ATOM__eventTransfer:
In the UI code:
struct VectorOf5Ints {
uint32_t size; // sizeof(LV2_Atom_Vector_Body) + (42 *
sizeof(float);
uint32_t type; // map(expand("Vector"))
uint32_t child_size; // sizeof(float)
uint32_t child_type; // map(expand("Float"))
uint32_t elems[5];
};
VectorOf5Ints vec{sizeof(LV2_Atom_Vector_Body) + (5 *
sizeof(uint32_t)),
map(LV2_ATOM__Vector),
sizeof(uint32_t),
map(LV2_ATOM__Int),
{5, 9, 5, 9, 7}};
write(5, sizeof(vec), map(LV2_ATOM__eventTransfer), &vec);
where write is a LV2UI_Write_Function.
In the turtle file:
... , [
a lv2:InputPort, atom:AtomPort ;
atom:bufferType atom:Vector ;
lv2:designation lv2:control ;
lv2:index 5 ;
lv2:symbol "out_ui" ;
lv2:name "UI to Business comm" ;
rdfs:comment "UI -> communication" ;
resize_port:minimumSize 15360 ;
] ...
In the plug-in connect_port function:
configuration_from_ui = static_cast<int *>(data);
In the run function of my plugin:
for (auto i{0}; i <= 5+9; ++i) {
log.printf(map(LV2_LOG__Entry), "LV2LOGGER: %d\n",
configuration_from_ui[i]);
}
This works, but it attaches the event header because I'm using
LV2_ATOM__eventTransfer, but I really just want to use
LV2_ATOM__atomTransfer is there a way to do this? when I change it in the
code I get the following message in the console:
UI write with unsupported protocol 48 (
http://lv2plug.in/ns/ext/atom#atomTransfer)
Questions:
1) Is it really unsupported or am I doing something wrong? Like for
example, do I need to change something in the turtle file?
2) What I'm trying to do is send a configuration state from the UI to the
business end. Ideally I would like it to avoid sending the message every
frame, what is it doing right now? is the host constantly copying a 15360
size buffer every frame? or only when I use the LV2UI_Write_Function it
will copy the buffer into the business end of the plugin? what is the best
way of doing this? Am I on the right track?
3) If I must use eventTransfer how can get just the event body when I'm
reading it on the business end, notice I'm just doing a "for loop" for
testing and I figured out the event header is 5 ints worth of size.
Similarly, how do I get the atom body other than doing what I currently do
which is just added a number to the pointer and taking that.
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.lv2plug.in/pipermail/devel-lv2plug.in/attachments/20210906/2925b3fd/attachment.html>
More information about the Devel
mailing list