[][src]Macro lv2rs_core::lv2_main

macro_rules! lv2_main {
    ($c:ident, $s:ty, $u:expr) => { ... };
}

Create lv2 export functions.

This macro takes a struct that implements Plugin and creates the required functions a plugin needs to export in order to be found and used by plugin hosts.

In order to properly work, it needs three arguments:

  • The namespace of the lv2rs-core crate: You may use this crate via re-exports and therefore, the name of the namespace is needed in order to call the appropiate functions.
  • The struct type that should be used as the Plugin implementation.
  • The URI of the plugin. Please note that the URI needs to be a bytes-array and null-terminated, since the C world has to interact with it.

Example usage:

extern crate lv2rs_core as core;
use std::ffi::CStr;

struct MyPlugin {}

impl core::Plugin for MyPlugin {
    fn instantiate(
        _descriptor: &core::Descriptor,
        _rate: f64,
        _bundle_path: &CStr,
        _features: Option<&core::FeaturesList>
    ) -> Option<Self> {
        Some(Self {})
    }

    fn connect_port(&mut self, _port: u32, _data: *mut ()) {}

    fn run(&mut self, _n_samples: u32) {}
}

core::lv2_main!(core, MyPlugin, b"http://example.org/Dummy\0");