Re: [LAD] LV2: Communicate from the DSP to the UI

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: <devel@...>
Cc: Aurélien Leblond <blablack@...>, The Linux Audio Developers' Mailing List <linux-audio-dev@...>
Date: Wednesday, November 6, 2013 - 3:33 am

Hi guys,

On 11/05/2013 06:48 AM, Michael Fisher wrote:
[..]

[..]

That works all right, but it's not proper LV2 Atom/RDF.
- the receiver has no idea about the length
- if the host-buffer overflows there's no way to re-sync
- it cannot be interleaved with other DSP -> UI messages
- `jalv.gtk -d ...` cannot parse it as RDF
- ...

LV2_Atom_Vector is made for exactly that purpose.

from sratom/tests/sratom_test.c:

lv2_atom_forge_property_head(&forge, eg_vector, 0);
int32_t elems[] = { 1, 2, 3, 4 };
lv2_atom_forge_vector(&forge, 4, forge.Int, sizeof(int32_t), elems);

@Drobilla:
I think the last line is slightly wrong, it should be
lv2_atom_forge_vector(&forge, sizeof(int32_t), forge.Int, 4, elems);
as per ns/ext/atom/forge.h

lv2_atom_forge_vector(LV2_Atom_Forge* forge,
uint32_t child_size,
uint32_t child_type,
uint32_t n_elems,
const void* elems)

not that it really matters because only (child_size * n_elems) is used.

Either way, you'll likely need
http://lv2plug.in/ns/ext/resize-port/#minimumSize as well if you're
going to pass large chunks of data around.

-=-=-

Anyway even if you make it work, I doubt that you'll have much fun:

Atom messages are written into a ringbuffer in the LV2host in the
DSP-thread. This ringbuffer is sent to the UI by another thread
(jalv.gtk and ardour use a g_timeout() usually at 40ms ~ 25fps), and
finally things are drawn in the X11 thread ie. gtk-main or qt's main.

Other LV2 hosts may do do things differently and you have no control
over it.

As much as like LV2 from a user's perspective and host integration. It
kinds sucks for visualizations. The only realistic way do to RT
*visualizations* (e.g. a scope) right is to bypass the host (use
instance access & a semaphore) and use openGL with vblank-sync using a
custom thread in the UI (drobilla is going to blacklist me now).

Synchronizing even one [audio] thread with the gfx-hardware is not
trivial. Default LV2 communication involves two or more, including some
threads that the LV2-host controls. -- It may be fun for someone to sort
this all out, but not me.

That being said I do like LV2 Atoms, event-queues, mapped URIs, and more
generally the CY-y way of LV2, though. It's very nice, robust and
elegant for control. Sometimes a tad overkill, but heck, therefore it's
portable, too.

However, if you want to write a proper scope, make it a jack application
- or wait for Fons to release zita-scope.

-=-=-

I did some tests a while ago, passing raw audio data inside an
LV2_Atom_Vector to the UI. I've just added an over-simplified scope UI
so that you see for yourself. unzip,
make
sudo make install PREFIX=/usr
jalv.gtk http://gareus.org/oss/lv2/audiopipe
# curse loudly
sudo make uninstall PREFIX=/usr

Cheers!
robin

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[LAD] LV2: Communicate from the DSP to the UI, Aurélien Leblond, (Mon Oct 28, 2:00 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Michael Fisher, (Mon Oct 28, 2:52 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Aurélien Leblond, (Mon Oct 28, 3:24 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Michael Fisher, (Mon Oct 28, 4:58 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Michael Fisher, (Mon Oct 28, 8:30 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Aurélien Leblond, (Mon Nov 4, 12:52 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Michael Fisher, (Tue Nov 5, 5:48 am)
Re: [LAD] [LV2] LV2: Communicate from the DSP to the UI, David Robillard, (Wed Nov 6, 4:45 am)
Re: [LAD] LV2: Communicate from the DSP to the UI, Robin Gareus, (Wed Nov 6, 3:33 am)
Re: [LAD] LV2: Communicate from the DSP to the UI, David Robillard, (Wed Nov 6, 4:41 am)
Re: [LAD] LV2: Communicate from the DSP to the UI, Aurélien Leblond, (Wed Nov 6, 3:21 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, David Robillard, (Sat Nov 9, 7:09 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, Robin Gareus, (Wed Nov 6, 11:49 pm)
Re: [LAD] LV2: Communicate from the DSP to the UI, David Robillard, (Sat Nov 9, 7:10 pm)
Re: [LAD] [LV2] LV2: Communicate from the DSP to the UI, David Robillard, (Sun Nov 10, 6:58 pm)
Re: [LAD] [LV2] LV2: Communicate from the DSP to the UI, Aurélien Leblond, (Sun Nov 10, 8:05 am)