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: PathBufThe .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: StringImplementations§
Source§impl PluginRef
impl PluginRef
Sourcepub fn from_path(path: impl Into<PathBuf>, plugin_id: Option<&str>) -> PluginRef
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).
Sourcepub fn resolve(query: &str, sound_paths: &[PathBuf]) -> Result<PluginRef>
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<'de> Deserialize<'de> for PluginRef
impl<'de> Deserialize<'de> for PluginRef
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
impl StructuralPartialEq for PluginRef
Auto Trait Implementations§
impl Freeze for PluginRef
impl RefUnwindSafe for PluginRef
impl Send for PluginRef
impl Sync for PluginRef
impl Unpin for PluginRef
impl UnsafeUnpin for PluginRef
impl UnwindSafe for PluginRef
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> DeserializeOwned for Twhere
T: for<'de> Deserialize<'de>,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self> ⓘ
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self> ⓘ
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