plugin_host/
descriptor.rs1use std::path::PathBuf;
2
3#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash)]
5pub enum PluginFormat {
6 Clap,
7 Vst3,
8}
9
10impl PluginFormat {
11 pub fn extension(&self) -> &'static str {
12 match self {
13 PluginFormat::Clap => "clap",
14 #[cfg(target_os = "windows")]
15 PluginFormat::Vst3 => "vst3",
16 #[cfg(not(target_os = "windows"))]
17 PluginFormat::Vst3 => "vst3",
18 }
19 }
20
21 pub fn display(&self) -> &'static str {
22 match self {
23 PluginFormat::Clap => "CLAP",
24 PluginFormat::Vst3 => "VST3",
25 }
26 }
27}
28
29#[derive(Debug, Clone, PartialEq, Eq)]
31pub enum PluginCategory {
32 Instrument,
33 Effect,
34 Analyzer,
35 MidiEffect,
36 Other(String),
37}
38
39impl PluginCategory {
40 pub fn from_clap_features(features: &[&str]) -> Self {
41 if features.contains(&"instrument") { return Self::Instrument; }
42 if features.contains(&"audio-effect") { return Self::Effect; }
43 if features.contains(&"analyzer") { return Self::Analyzer; }
44 if features.contains(&"note-effect") { return Self::MidiEffect; }
45 Self::Other(features.join(", "))
46 }
47}
48
49#[derive(Debug, Clone)]
52pub struct PluginDescriptor {
53 pub id: String,
55 pub name: String,
56 pub vendor: String,
57 pub version: String,
58 pub description: String,
59 pub category: PluginCategory,
60 pub format: PluginFormat,
61 pub path: PathBuf,
63 pub index: u32,
65 pub audio_inputs: u32,
67 pub audio_outputs: u32,
69 pub has_midi_in: bool,
71 pub has_gui: bool,
73 pub file_hash: u64,
75}
76
77impl PluginDescriptor {
78 pub fn unique_key(&self) -> String {
80 format!("{}:{}:{}", self.format.display(), self.path.display(), self.index)
81 }
82
83 pub fn is_instrument(&self) -> bool {
84 self.category == PluginCategory::Instrument
85 }
86
87 pub fn is_effect(&self) -> bool {
88 self.category == PluginCategory::Effect
89 }
90}