diff --git a/crates/lotr/Cargo.toml b/crates/lotr/Cargo.toml new file mode 100644 index 0000000..5579ef4 --- /dev/null +++ b/crates/lotr/Cargo.toml @@ -0,0 +1,12 @@ +[package] +name = "lotr" +version = "0.1.0" +edition = "2018" + +[lib] +crate-type = ["cdylib"] + +[dependencies] +baseplug = { path = "../baseplug" } +serde = "1.0.126" +utils = { path = "../utils" } diff --git a/crates/lotr/src/lib.rs b/crates/lotr/src/lib.rs new file mode 100644 index 0000000..8286a8e --- /dev/null +++ b/crates/lotr/src/lib.rs @@ -0,0 +1,54 @@ +#![allow(incomplete_features)] +#![feature(generic_associated_types)] + +use baseplug::{Plugin, ProcessContext}; +use serde::{Deserialize, Serialize}; + +baseplug::model! { + #[derive(Debug, Serialize, Deserialize)] + struct LotrModel { + #[model(min = 0.0, max = 1.0)] + #[parameter(name = "modulation")] + modulation: f32, + } +} + +impl Default for LotrModel { + fn default() -> Self { + Self { modulation: 1.0 } + } +} + +struct Lotr; + +impl Plugin for Lotr { + const NAME: &'static str = "lotr"; + const PRODUCT: &'static str = "lotr"; + const VENDOR: &'static str = "unnieversal"; + + const INPUT_CHANNELS: usize = 4; + const OUTPUT_CHANNELS: usize = 2; + + type Model = LotrModel; + + #[inline] + fn new(_sample_rate: f32, _model: &LotrModel) -> Self { + Self + } + + #[inline] + fn process(&mut self, model: &LotrModelProcess, ctx: &mut ProcessContext) { + let input = &ctx.inputs[0].buffers; + let output = &mut ctx.outputs[0].buffers; + + for i in 0..ctx.nframes { + let m = model.modulation[i]; + let one = (1.0 - m) + m * input[2][i]; + let two = (1.0 - m) + m * input[3][i]; + output[0][i] = input[0][i] * one; + output[1][i] = input[1][i] * two; + } + } +} + +baseplug::vst2!(Lotr, b"lotr");