58 lines
1.5 KiB
Rust
58 lines
1.5 KiB
Rust
#![allow(incomplete_features)]
|
|
#![feature(generic_associated_types)]
|
|
|
|
use baseplug::{Plugin, ProcessContext};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
baseplug::model! {
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
struct ThreeBandEqModel {
|
|
#[model(min = -90.0, max = 3.0)]
|
|
#[parameter(name = "gain", unit = "Decibels",
|
|
gradient = "Power(0.15)")]
|
|
gain: f32
|
|
}
|
|
}
|
|
|
|
impl Default for ThreeBandEqModel {
|
|
fn default() -> Self {
|
|
Self {
|
|
// "gain" is converted from dB to coefficient in the parameter handling code,
|
|
// so in the model here it's a coeff.
|
|
// -0dB == 1.0
|
|
gain: 1.0,
|
|
}
|
|
}
|
|
}
|
|
|
|
struct ThreeBandEq;
|
|
|
|
impl Plugin for ThreeBandEq {
|
|
const NAME: &'static str = "basic gain";
|
|
const PRODUCT: &'static str = "basic gain";
|
|
const VENDOR: &'static str = "unnieversal";
|
|
|
|
const INPUT_CHANNELS: usize = 2;
|
|
const OUTPUT_CHANNELS: usize = 2;
|
|
|
|
type Model = ThreeBandEqModel;
|
|
|
|
#[inline]
|
|
fn new(_sample_rate: f32, _model: &ThreeBandEqModel) -> Self {
|
|
Self
|
|
}
|
|
|
|
#[inline]
|
|
fn process(&mut self, model: &ThreeBandEqModelProcess, ctx: &mut ProcessContext<Self>) {
|
|
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.gain[i];
|
|
output[1][i] = input[1][i] * model.gain[i];
|
|
}
|
|
}
|
|
}
|
|
|
|
baseplug::vst2!(ThreeBandEq, b"tAnE");
|