[lotr] make and implement crate
This commit is contained in:
parent
74b2344e99
commit
9853c36ae3
2 changed files with 66 additions and 0 deletions
12
crates/lotr/Cargo.toml
Normal file
12
crates/lotr/Cargo.toml
Normal file
|
@ -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" }
|
54
crates/lotr/src/lib.rs
Normal file
54
crates/lotr/src/lib.rs
Normal file
|
@ -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<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");
|
Loading…
Reference in a new issue