55 lines
1.3 KiB
Rust
55 lines
1.3 KiB
Rust
#![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<Self>) {
|
|
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");
|