1
0
Fork 0

Add a ClapPlugin trait

Just like the Vst3Plugin trait
This commit is contained in:
Robbert van der Helm 2022-02-28 14:45:07 +01:00
parent 8c63cebc07
commit d5d90e3e61
8 changed files with 31 additions and 9 deletions

6
Cargo.lock generated
View file

@ -101,6 +101,11 @@ version = "1.0.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]]
name = "clap-sys"
version = "0.1.0"
source = "git+https://github.com/glowcoil/clap-sys?rev=3ef7048e1d3b426a7c6b02b5d3ae18f14874d4e5#3ef7048e1d3b426a7c6b02b5d3ae18f14874d4e5"
[[package]]
name = "clipboard-win"
version = "3.1.1"
@ -530,6 +535,7 @@ dependencies = [
"assert_no_alloc",
"atomic_float",
"cfg-if",
"clap-sys",
"crossbeam",
"lazy_static",
"nih_plug_derive",

View file

@ -33,6 +33,8 @@ nih_plug_derive = { path = "nih_plug_derive" }
atomic_float = "0.1"
cfg-if = "1.0"
# For CLAP 0.18
clap-sys = { git = "https://github.com/glowcoil/clap-sys", rev = "3ef7048e1d3b426a7c6b02b5d3ae18f14874d4e5" }
crossbeam = "0.8"
lazy_static = "1.4"
parking_lot = "0.12"

View file

@ -18,7 +18,8 @@
extern crate nih_plug;
use nih_plug::{
formatters, Buffer, BufferConfig, BusConfig, Plugin, ProcessContext, ProcessStatus, Vst3Plugin,
formatters, Buffer, BufferConfig, BusConfig, ClapPlugin, Plugin, ProcessContext, ProcessStatus,
Vst3Plugin,
};
use nih_plug::{BoolParam, FloatParam, IntParam, Params, Range, SmoothingStyle};
use nih_plug::{Enum, EnumParam};
@ -409,6 +410,8 @@ fn unnormalize_automation_precision(normalized: f32) -> u32 {
- (normalized * (MAX_AUTOMATION_STEP_SIZE - MIN_AUTOMATION_STEP_SIZE) as f32).round() as u32
}
impl ClapPlugin for Diopser {}
impl Vst3Plugin for Diopser {
const VST3_CLASS_ID: [u8; 16] = *b"DiopserPlugRvdH.";
const VST3_CATEGORIES: &'static str = "Fx|Filter";

View file

@ -3,8 +3,8 @@ extern crate nih_plug;
use atomic_float::AtomicF32;
use nih_plug::{
util, Buffer, BufferConfig, BusConfig, Editor, IntParam, Plugin, ProcessContext, ProcessStatus,
Vst3Plugin,
util, Buffer, BufferConfig, BusConfig, ClapPlugin, Editor, IntParam, Plugin, ProcessContext,
ProcessStatus, Vst3Plugin,
};
use nih_plug::{FloatParam, Params, Range, SmoothingStyle};
use nih_plug_egui::{create_egui_editor, egui, widgets, EguiState};
@ -202,6 +202,8 @@ impl Plugin for Gain {
}
}
impl ClapPlugin for Gain {}
impl Vst3Plugin for Gain {
const VST3_CLASS_ID: [u8; 16] = *b"GainGuiYeahBoyyy";
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";

View file

@ -2,8 +2,8 @@
extern crate nih_plug;
use nih_plug::{
formatters, util, Buffer, BufferConfig, BusConfig, Plugin, ProcessContext, ProcessStatus,
Vst3Plugin,
formatters, util, Buffer, BufferConfig, BusConfig, ClapPlugin, Plugin, ProcessContext,
ProcessStatus, Vst3Plugin,
};
use nih_plug::{BoolParam, FloatParam, Params, Range, Smoother, SmoothingStyle};
use parking_lot::RwLock;
@ -129,6 +129,8 @@ impl Plugin for Gain {
}
}
impl ClapPlugin for Gain {}
impl Vst3Plugin for Gain {
const VST3_CLASS_ID: [u8; 16] = *b"GainMoistestPlug";
const VST3_CATEGORIES: &'static str = "Fx|Dynamics";

View file

@ -2,8 +2,8 @@
extern crate nih_plug;
use nih_plug::{
formatters, util, Buffer, BufferConfig, BusConfig, Plugin, ProcessContext, ProcessStatus,
Vst3Plugin,
formatters, util, Buffer, BufferConfig, BusConfig, ClapPlugin, Plugin, ProcessContext,
ProcessStatus, Vst3Plugin,
};
use nih_plug::{BoolParam, FloatParam, Params, Range, Smoother, SmoothingStyle};
use std::f32::consts;
@ -176,6 +176,8 @@ impl Plugin for Sine {
}
}
impl ClapPlugin for Sine {}
impl Vst3Plugin for Sine {
const VST3_CLASS_ID: [u8; 16] = *b"SineMoistestPlug";
const VST3_CATEGORIES: &'static str = "Instrument|Synth|Tools";

View file

@ -19,8 +19,8 @@ pub use param::range::Range;
pub use param::smoothing::{Smoother, SmoothingStyle};
pub use param::{BoolParam, FloatParam, IntParam, Param};
pub use plugin::{
BufferConfig, BusConfig, Editor, NoteEvent, ParentWindowHandle, Plugin, ProcessStatus,
Vst3Plugin,
BufferConfig, BusConfig, ClapPlugin, Editor, NoteEvent, ParentWindowHandle, Plugin,
ProcessStatus, Vst3Plugin,
};
// The rest is either internal or already re-exported

View file

@ -101,6 +101,11 @@ pub trait Plugin: Default + Send + Sync + 'static {
fn process(&mut self, buffer: &mut Buffer, context: &mut impl ProcessContext) -> ProcessStatus;
}
/// Provides auxiliary metadata needed for a CLAP plugin.
pub trait ClapPlugin: Plugin {
// TODO: Add the required fields, just like the [Vst3Plugin] trait
}
/// Provides auxiliary metadata needed for a VST3 plugin.
pub trait Vst3Plugin: Plugin {
/// The unique class ID that identifies this particular plugin. You can use the