0

Objective

I want to load an LV2 plugin, and then send filename to said plugin through LV2 Atom Sequences, but I am unable to get my head around LV2 atoms.

Background

I am the author of Amp Rack. It's an LV2 / LADSPA plugin host for Android, along with some plugins bundled with it. I started with LADPSA, and subsequently added support for LV2. As such, I don't use lilv or any other library to load LV2 plugins, but rather do it directly. It works perfectly.

The problem

Now I want to add Ratatouille, which is a NAM / AIDA-X / IR model loader. It had two Atom ports (one input and one output) which it uses to get filenames from the host. As such, I am unable to run the plugin, as it calls a check messages function during run, which crashes when it reaches the following code:

inline void Xratatouille::check_messages(uint32_t n_samples)
{
    if(n_samples<1) return;
    const uint32_t notify_capacity = this->notify->atom.size;
    lv2_atom_forge_set_buffer(&forge, (uint8_t*)notify, notify_capacity);
    lv2_atom_forge_sequence_head(&forge, &notify_frame, 0);

    LV2_ATOM_SEQUENCE_FOREACH(control, ev) {
        if (lv2_atom_forge_is_object_type(&forge, ev->body.type)) {

It crashes on the last line above.

The plugin has two Atom Ports:

        case 5:
            control = (const LV2_Atom_Sequence*)data;
            break;
        case 6:
            notify = (LV2_Atom_Sequence*)data;
            break;

After going through jalv and lilv code on github and the LV2 docs, and with the general understanding that I have of LV2 / LADSPA architecture, I understand that like the input / output / various control ports that plugins have, the Atom ports are pointers which are passed from the host to the plugin using the connect_port function.

In simple terms, what I understand is that I pass a float pointer from host to plugin through connect_port, and when I change the value of the pointer in the host, it changes in the plugin. This is how we pass data from host to the LV2 plugin. So far so good.

The Atom Sequence and its usage

This is where I am stumped. I created an Atom Sequence with malloc and passed it to the plugin. It crashes. Clearly this is not how it is done. I have no clue how to approach this. jalv and lilv source does this, but I couldn't understand how exactly this is done.

What I want to do

I only want to load the plugin, and send the filename through the atom port. For this, I think the Atom Sequence structure would have to be initialized and properly filled, so that when the plugin runs, even before the user has selected a file, the check messages code will go through the empty message properly.

Any help would be appreciated.

I only wish to get started with this simple implementation. I think what I need is:

  • Create an atom sequence (forge?)
  • Write it to the AtomPort
  • Get output from the output atom port and do something with it (I think)

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.