Skip to main content

PluginRef

Struct PluginRef 

Source
pub struct PluginRef {
    pub format: PluginFormat,
    pub path: PathBuf,
    pub plugin_id: Option<String>,
    pub name: String,
    pub vendor: String,
    pub version: String,
}
Expand description

A specific plugin: bundle path plus the plugin id inside it.

Fields§

§format: PluginFormat§path: PathBuf

The .clap / .vst3 bundle (file or directory).

§plugin_id: Option<String>

Plugin id inside the bundle (CLAP id or VST3 class id). None = the only one.

§name: String§vendor: String§version: String

Implementations§

Source§

impl PluginRef

Source

pub fn from_path(path: impl Into<PathBuf>, plugin_id: Option<&str>) -> PluginRef

A plugin given directly by path (format from the extension, CLAP by default).

Source

pub fn resolve(query: &str, sound_paths: &[PathBuf]) -> Result<PluginRef>

Resolve a name, id, or path ("Surge XT", org.surge-synth-team.surge-xt, plugin:"Surge XT", /path/Foo.clap, /path/Foo.clap#plugin.id) against the scan cache, the standard plugin folders, and sound_paths.

Examples found in repository?
examples/render_note.rs (line 16)
10fn main() {
11    let args: Vec<String> = std::env::args().skip(1).collect();
12    if args.len() < 2 {
13        eprintln!("usage: render_note <plugin> <out.wav> [midi key] [param=value ...]");
14        std::process::exit(2);
15    }
16    let plugin = PluginRef::resolve(&args[0], &[]).unwrap_or_else(|e| {
17        eprintln!("{e}");
18        std::process::exit(e.exit_code)
19    });
20    let key: u8 = args.get(2).and_then(|k| k.parse().ok()).unwrap_or(60);
21    let params =
22        args.iter().skip(3).filter_map(|kv| kv.split_once('=').map(|(k, v)| (k.to_string(), v.to_string()))).collect();
23    let sr = 48000u32;
24    let events = [MidiEvent::note_on(sr as u64 / 10, 0, key, 0.8), MidiEvent::note_off(sr as u64, 0, key)];
25    let opts = PluginOptions { params, ..Default::default() };
26    match render_instrument_with(&plugin, &events, sr, 2.0, &opts) {
27        Ok(run) => {
28            let a = &run.audio;
29            let onset = a.data[0].iter().position(|v| v.abs() > 1e-4);
30            println!(
31                "{} ({}): {} frames, peak {:.3}, first sound at frame {:?} (note at {}), latency {}",
32                plugin.name,
33                plugin.format,
34                a.frames(),
35                a.peak(),
36                onset,
37                sr / 10,
38                run.latency
39            );
40            std::fs::write(&args[1], ferraus_core::wav::encode(a, 32, true).expect("encode")).expect("write");
41        }
42        Err(e) => {
43            eprintln!("{e}");
44            std::process::exit(e.exit_code);
45        }
46    }
47}

Trait Implementations§

Source§

impl Clone for PluginRef

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PluginRef

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for PluginRef

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for PluginRef

Source§

fn eq(&self, other: &Self) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for PluginRef

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for PluginRef

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.