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

From: Michael Fisher <mfisher31@email-addr-hidden>
Date: Tue Nov 05 2013 - 07:48:15 EET

On Mon, Nov 4, 2013 at 6:52 AM, Aurélien Leblond <blablack@email-addr-hidden> wrote:

> Hi Michael,
>
>
> What I think I should be doing is using Blank Atom to transfer the
> data from DSP to UI, right?
>

It sounds logical to me, yeah. Doing it this way could be done by forging
the Blank atom and then writing the float array as raw. You would need to
map a few uris specifically for this to use inside of the blank object.

seems like peak proptocol etc etc.. would could also be used here. I don't
think there's a single host that supports any of those kinds of features
though....

some fake code doing it with an atom object and a raw buffer, I didn't try
to compile any of this let alone try it in a real plugin.

float buffer [bufsize];
uint32_t object_type = this->map ("http://myuri#object");
uint32_t prop_type = this->map ("http://myuri#prop");

...

ForgeFrame frame;

AtomObject obj (forge.write_blank (frame, 0, object_type));
forge.property_head (prop_type, 0);
forge.write_raw (buffer, sizeof (float) * bufsize);

forge.pop (frame);

and then on the GUI side use an AtomObject::iterator if you want it to look
more like c++.

AtomObject obj (data_from_port_event);
AtomObject::iterator prop = obj.begin();

float* buffer = 0;
while (prop != obj.end())
{
   if (prop->key == prop_type) {
      buffer = LV2_ATOM_BODY (&prop->value);
      break;
   }

  ++prop;
}

if (buffer)
    do_something_with (buffer);

regular object getting and querying obviously would also work on the GUI
end.

- guiext:notifyType atom:Blank ;
> - atom:supports atom:Audio ;
> - on the DSP side, use the AtomForge write_raw method to write the
> array of floats
>
> Is that the right way to go or is there anything else I should consider?
>
>
> As the the lv2 scope plugin has 2 inputs that need to be represented
> in the GUI, I was wondering if I can pass the 2 arrays of floats in
> one go through only one Atom.
> From the LV2 documentation, it looks like lv2 is loose enoigh that i
> can pass my own object, but I'm not sure how to approach that via LVTK
> (or via LV2 itself for that matter).
>
>
> Once again thanks in advance for your help,
>
> Aurélien
>
>
> On Mon, Oct 28, 2013 at 8:30 PM, Michael Fisher <mfisher31@email-addr-hidden>
> wrote:
> > On Mon, Oct 28, 2013 at 11:58 AM, Michael Fisher <mfisher31@email-addr-hidden>
> > wrote:
> >>
> >> On Mon, Oct 28, 2013 at 10:24 AM, Aurélien Leblond <blablack@email-addr-hiddenom>
> >> wrote:
> >>>
> >>> > The map object is 'just there' for when you need it, like creating
> new
> >>> > forges ;) I've always wondered if it made more sense to provide a
> >>> > accessor
> >>> > method to it for clarity Plugin::get_urid_map() const or
> something
> >>> > like
> >>> > that.
> >>> >
> >>> > That looks right for creating a forge, AtomForge's ctor will call
> >>> > lv2_atom_forge_init
> >>> > when the map is passed in (just like you do above)
> >>> >
> >>> >>
> >>> >> void Scope::run(uint32_t nframes)
> >>> >> {
> >>> >> // you're sending things in an atom sequence so get the size
> >>> >> information
> >>> >> // from the port buffer
> >>> >>
> >>> >> LV2_Atom_Sequence* aseq = (LV2_Atom_Sequence*) p (p_notify);
> >>> >> m_forge->set_buffer ((uint8_t*) aseq, aseq->atom.size);
> >>> >>
> >>> >> m_forge->sequence_head(m_notify_frame, 0);
> >>> >>
> >>> >> // sequences need a timestamp for each event added
> >>> >> m_forge->frame_time(0);
> >>> >>
> >>> >> m_forge->write_float(1604);
> >>> >> }
> >>> >>
> >>> >
> >>> > Still nothing happening on the GUI end ay? Could I just have a link
> to
> >>> > the
> >>> > full source code? I'm better debugging hands on. Sorry, I can't
> >>> > recall the
> >>> > git address to your plugin set.
> >>> >
> >>> > Forging atoms (in a way that actually works) isn't by any means a
> >>> > straight
> >>> > forward process.
> >>>
> >>> Thanks for checking, I really have the feeling I'm missing something
> >>> small here :)
> >>
> >>
> >> Yep, missing something small seems to happen to me frequently. I'm
> >> jumping over to my Linux machine and will give it a go.
> >>
> >>>
> >>>
> >>> The SVN is here:
> >>> svn checkout svn://svn.code.sf.net/p/avwlv2/code/trunk avw.lv2
> >>>
> >>> (Ingen is the host I use to test them)
> >>
> >>
> >
> > First things first. Your plugin, after modifying ttl files, works fine
> in
> > Jalv. For ingen support, your best bet might be to add a Trac ticket on
> > drobilla.net.
> >
> > Ok, so I figured out the problem... the GUI ttl file should look
> something
> > like this (with a portNotification setting)
> >
> > <http://avwlv2.sourceforge.net/plugins/avw/scope/gui>
> >
> > a guiext:GtkUI ;
> >
> > guiext:binary <scope_gui.so> ;
> >
> > guiext:portNotification [
> >
> > guiext:plugin <
> http://avwlv2.sourceforge.net/plugins/avw/scope>
> > ;
> >
> > lv2:symbol "notify" ;
> >
> > guiext:notifyType atom:Float
> >
> > ] .
> >
> >
> >
> > the Port definition in the plugin's turtle :
> >
> > ... [
> >
> > a lv2:OutputPort, atom:AtomPort ;
> >
> > atom:bufferType atom:Sequence ;
> >
> > atom:supports atom:Float ; # <<<<<< NEED THIS (i think)
> >
> > lv2:index 1 ;
> >
> > lv2:symbol "notify" ;
> >
> > lv2:name "Notify" ;
> >
> > ] .
> >
> >
> >
> > I also added more debug output to the GUI... all relevant changes were
> > committed in a git mirror on Github (its just easier for me to do that)
> The
> > only files I modified were scope*.* files
> >
> >
> > You'll want to look at the GUI code, because I also show you how to
> > 'un-package' the atom in the port_event method.
> >
> >
> > https://github.com/axetota/avwlv2/tree/devel
> >
> >
> >
>

_______________________________________________
Linux-audio-dev mailing list
Linux-audio-dev@email-addr-hidden
http://lists.linuxaudio.org/listinfo/linux-audio-dev
Received on Mon, 4 Nov 2013 23:48:15 -0600

This archive was generated by hypermail 2.1.8 : Tue Nov 05 2013 - 08:15:01 EET