60 lines
1.5 KiB
Rust
60 lines
1.5 KiB
Rust
#![allow(incomplete_features)]
|
|
#![feature(generic_associated_types)]
|
|
|
|
use baseplug::{Plugin, ProcessContext};
|
|
use serde::{Deserialize, Serialize};
|
|
|
|
// TODO Everything
|
|
|
|
baseplug::model! {
|
|
#[derive(Debug, Serialize, Deserialize)]
|
|
struct QuinoaModel {
|
|
#[model(min = -90.0, max = 3.0)]
|
|
#[parameter(name = "gain", unit = "Decibels",
|
|
gradient = "Power(0.15)")]
|
|
gain: f32
|
|
}
|
|
}
|
|
|
|
impl Default for QuinoaModel {
|
|
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 Quinoa;
|
|
|
|
impl Plugin for Quinoa {
|
|
const NAME: &'static str = "basic gain plug";
|
|
const PRODUCT: &'static str = "basic gain plug";
|
|
const VENDOR: &'static str = "spicy plugins & co";
|
|
|
|
const INPUT_CHANNELS: usize = 2;
|
|
const OUTPUT_CHANNELS: usize = 2;
|
|
|
|
type Model = QuinoaModel;
|
|
|
|
#[inline]
|
|
fn new(_sample_rate: f32, _model: &QuinoaModel) -> Self {
|
|
Self
|
|
}
|
|
|
|
#[inline]
|
|
fn process(&mut self, model: &QuinoaModelProcess, 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!(Quinoa, b"tAnE");
|