Module rsynth::meta

source ·
Expand description

Mechanisms for defining the meta-data of a plugin or application.

rsynth uses a hierarchy of different traits that allow your audio application or plug-in to define various aspects of the meta-data.

Implementing each of these traits one by one can be rather tedious. For this reason, these traits have blanket impls, so that you only need to implement the Meta trait and in its implementation, return the meta-data.

Example

use rsynth::meta::{Meta, MetaData, InOut};
struct MyPlugin {
    meta: MetaData<&'static str, &'static str, &'static str>
    /* ... */
}

impl MyPlugin {
    pub fn new() -> Self {
        Self {
            meta: MetaData {
                general_meta: unimplemented!(),
                audio_port_meta: InOut {
                    inputs: vec![unimplemented!()],
                    outputs: vec![unimplemented!()],
                },
                midi_port_meta: InOut {
                    inputs: vec![unimplemented!()],
                    outputs: vec![unimplemented!()],
                },
            }
        }
    }
}

impl Meta for MyPlugin {
    type MetaData = MetaData<&'static str, &'static str, &'static str>;
    fn meta(&self) -> &Self::MetaData {
        &self.meta
    }
}

How it works under the hood

Back-ends may require the plugin to implement a number of traits concerning meta-data. Suppose for instance a backend requires plugins to implement the CommonPluginMeta trait. The CommonPluginMeta trait defines the “name” of the plugin. There is a blanket impl that implements the CommonPluginMeta for any type that implements Meta where the associated type Meta::MetaData implements the General trait (which allows getting general meta-data) where the associated type General::GeneralData implements the Name trait. Now the MetaData<G, _, _> struct implements General with associated type General::GeneralData equal to G. Also, Name is implemented for String and for &'static str. So if a plugin implements Meta with the associated type Meta::MetaData equal to the struct MetaData<&'static str, _, _>, then it automatically implements CommonPluginMeta.

Structs

  • A “marker” struct to be used as a type parameter for the Port trait, indicating that this implementation of Port defines meta-data for an audio port.
  • Represents meta-data about a input and output ports.
  • Represents general-purpose meta-data of an audio application or plugin.
  • A “marker” struct to be used as a type parameter for the Port trait, indicating that this implementation of Port defines meta-data for a midi port.

Traits

  • Define meta-data of an application or plugin as a whole.
  • Define the meta-data for an application or plug-in.
  • Implement this trait to indicate that a type can be used to represent meta-data that contains a name.
  • Define meta-data for input ports and output ports.