[LAD] [ALPHA] ladspa.m.lv2 - Some questions :D
d at drobilla.net
Thu May 9 20:46:51 UTC 2013
On Tue, 2013-04-23 at 12:47 +0200, hermann meyer wrote:
> > 2] I'm a little bit puzzled by how the patch_set messages together
> > with the LV2 worker extension works. If you take a look at this run()
> > function
> > https://github.com/fps/ladspa.m.lv2/blob/master/instrument.cc#L702
> > you'll see that I have an extra LV2_ATOM_SEQUENCE_FOR_EACH at the
> > start of the function to process the patch_set messages. I tried to
> > integrate that into the loop later on (that iterates over the
> > sample_count frames and lets the midi events take effect at their
> > respective frame), but once I do that, patch loading stops to work. I
> > must be missing something fundamental. So if any LV2 guru might want
> > to take a look, I'd be very grateful, too
(Sorry for the late reply, I don't monitor LAD very closely these days)
You should be able to handle all the events in one loop.
However here you seem to be iterating over all events *for every frame*?
That would cause a problem with loading since you'll issue a ton of
identical load requests, but it also probably isn't what you want for
MIDI either. You'll trigger everything repeatedly and the timing is
wrong. I think you need to unify your two loops here.
The general pattern for sample-accurate event receiving is work through
time in the event loop, outputting everything up to the current event.
So you start with t=0. The next event loop in the loop is at t=5, so
render the output for 0..5, process the event (to e.g. trigger a voice
or whatever), then continue. After the loop output everything from the
last event to the end of the cycle.
So your event processing loop is your processing loop, and proceeds in
'chunks' delimited by events.
The magic of the worker extension is you can do non-RT things like load
new sample banks, which will happen RT-safe (with latency) if running
realtime, but if freewheeling (e.g. for export) the scheduled work will
execute immediately/synchronously. Thus you can get sample accurate
exporting, e.g. with a patch load at t=0 and a note on at t=1 the note
is guaranteed to play with the new patch (in the export). You don't
need to worry about this, but it's why things are the way they are...
plus it's pretty cool :)
Hopefully that makes sense, the simplest example of how to do this is in
the metro example:
tl;dr: Do that :)
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 836 bytes
Desc: This is a digitally signed message part
More information about the Linux-audio-dev