diff --git a/crates/dctortion/Cargo.toml b/crates/dctortion/Cargo.toml new file mode 100644 index 0000000..fc093d6 --- /dev/null +++ b/crates/dctortion/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "dctortion" +version = "0.1.0" +edition = "2021" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +baseplug = { git = "https://github.com/wrl/baseplug.git", rev = "9cec68f31cca9c0c7a1448379f75d92bbbc782a8" } +serde = "1.0.126" +utils = { path = "../utils" } diff --git a/crates/dctortion/src/lib.rs b/crates/dctortion/src/lib.rs new file mode 100644 index 0000000..b895dce --- /dev/null +++ b/crates/dctortion/src/lib.rs @@ -0,0 +1,51 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +use baseplug::{Plugin, ProcessContext}; +use serde::{Deserialize, Serialize}; + +baseplug::model! { + #[derive(Debug, Serialize, Deserialize)] + struct GainModel { + #[model(min = 0.0, max = 1.0)] + #[parameter(name = "offset")] + offset: f32, + } +} + +impl Default for GainModel { + fn default() -> Self { + Self { offset: 0.0 } + } +} + +struct Gain; + +impl Plugin for Gain { + const NAME: &'static str = "dctortion"; + const PRODUCT: &'static str = "dctortion"; + const VENDOR: &'static str = "unnieversal"; + + const INPUT_CHANNELS: usize = 2; + const OUTPUT_CHANNELS: usize = 2; + + type Model = GainModel; + + #[inline] + fn new(_sample_rate: f32, _model: &GainModel) -> Self { + Self + } + + #[inline] + fn process(&mut self, model: &GainModelProcess, ctx: &mut ProcessContext) { + let input = &ctx.inputs[0].buffers; + let output = &mut ctx.outputs[0].buffers; + + for i in 0..ctx.nframes { + output[0][i] = input[0][i] + model.offset[i]; + output[1][i] = input[1][i] - model.offset[i]; + } + } +} + +baseplug::vst2!(Gain, b"tAnE");