Re: [LAD] [ALPHA] ladspa.m.lv2 - Some questions :D

From: David Robillard <d@email-addr-hidden>
Date: Thu May 09 2013 - 23:46:51 EEST

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:

http://lv2plug.in/browser/trunk/plugins/eg03-metro.lv2/metro.c#L296

tl;dr: Do that :)

-dr

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev

Received on Fri May 10 00:15:03 2013

This archive was generated by hypermail 2.1.8 : Fri May 10 2013 - 00:15:04 EEST