[][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.

    extern crate lv2rs_core as lv2core;
    use std::ffi::CStr;
    use lv2core::ports::*;
    
    struct MyPlugin {}
    
    impl lv2core::Plugin for MyPlugin {
        fn instantiate(
            _descriptor: &lv2core::Descriptor,
            _rate: f64,
            _bundle_path: &CStr,
            _features: Option<&lv2core::FeaturesList>
        ) -> Option<Self> {
            Some(Self {})
        }
    
        fn connect_port(&mut self, _port: u32, _data: *mut ()) {}
    
        fn run(&mut self, _n_samples: u32) {}
    }
    
    lv2core::lv2_main!(lv2core, MyPlugin, b"http://example.org/Dummy\0");