LV2: how to do reliable data transfer from GUI to DSP?

Programming applications for making music on Linux.

Moderators: MattKingUSA, khz

Post Reply
witchspace
Established Member
Posts: 60
Joined: Sun Jul 13, 2014 7:14 pm
Location: Eindhoven

LV2: how to do reliable data transfer from GUI to DSP?

Post by witchspace »

In my LV2 plugin I have to transfer a reasonably large (~20-30KB) amount of data from the GUI to the DSP reliably. Speed is less important.

Currently I do this by calling the write_function, however it can happen that ringbuffers overflow and events get lost (errors such as "CarlaRingBuffer::tryWrite(0x7ffffffe9828, 266): failed, not enough space"). There is no feedback to the application in this case. Hence I'm rate-limiting the sending of events, like in the old MIDI days, but it's quite ugly as the size of the underlying buffers differs per host. So to do this properly one would have to implement a TCP-like windowed protocol..

A possible alternative would be to write an intermediate file, then transfer the filename to the DSP as a Path atom. However this means non-realtime work on the side of the DSP (and the need for a worker). But does this break network transparency as it assumes a file is present on both the GUI and DSP side? Or can it be assumed that the host does a file transfer when necessary?

Are there any options that I've missed?
witchspace
Established Member
Posts: 60
Joined: Sun Jul 13, 2014 7:14 pm
Location: Eindhoven

Re: LV2: how to do reliable data transfer from GUI to DSP?

Post by witchspace »

falkTX wrote:You have 2 options:

1. set minimum-size property on the atom port so hosts will have enough space (chunk size + a few bytes for the atom/sequence header)
this can be done like this:

Code: Select all

@prefix lv2: <http://lv2plug.in/ns/lv2core> .
@prefix rsz: <http://lv2plug.in/ns/ext/resize-port> .
...
# in the port stuff
           rsz:minimumSize 32767 ;
           atom:bufferType atom:Sequence ;
Thanks, that sounds like the easiest and least invasive option! It gives a controllable buffer size which is exactly what I need.
2. use direct-access. This should only be used as last option, do not use it if you can.
Agreed. I was trying to avoid direct access.
Post Reply