Compare commits
No commits in common. "97985eb14d2f235ba06f499adc2c3737a780c34e" and "ba9a74eb67974d58c87e7258c745486ee781d81b" have entirely different histories.
97985eb14d
...
ba9a74eb67
15
README.md
15
README.md
|
@ -4,7 +4,7 @@ some VST plugins made in Rust using `baseplug`
|
||||||
|
|
||||||
source for the plugins are inside the `crates` folder. all plugins have only been tested on macos with reaper
|
source for the plugins are inside the `crates` folder. all plugins have only been tested on macos with reaper
|
||||||
|
|
||||||
disclaimer: i am not responsible for loss of work, time, sanity, or anything else if you decide to use these plugins
|
disclaimer: i am not responsible for loss of work, time, sanity, or anything else if you decide to use this plugins
|
||||||
|
|
||||||
as of now no plugin has ui, so they all just have a few sliders with whatever look your daw gives them
|
as of now no plugin has ui, so they all just have a few sliders with whatever look your daw gives them
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ the following is the current list of plugins
|
||||||
- multidim: randomized midi note generator
|
- multidim: randomized midi note generator
|
||||||
- robotuna: automatic pitch correction
|
- robotuna: automatic pitch correction
|
||||||
- hysteria: hysteresis nonlinear effect
|
- hysteria: hysteresis nonlinear effect
|
||||||
- threebandeq: 3 band eq
|
- threebandeq: [WIP] 3 band eq
|
||||||
|
|
||||||
### basic_gain
|
### basic_gain
|
||||||
|
|
||||||
|
@ -134,16 +134,7 @@ turn the values up for loud and distorted. don't set them all to the max at once
|
||||||
|
|
||||||
### threebandeq [WIP]
|
### threebandeq [WIP]
|
||||||
|
|
||||||
simple three band equalizer
|
wip, there's nothing yet
|
||||||
|
|
||||||
parameters:
|
|
||||||
- `low band`: frequency at which the low band ends
|
|
||||||
- `high band`: frequency at which the high band starts
|
|
||||||
- `low gain`: gain for the low band
|
|
||||||
- `mid gain`: gain for the mid band
|
|
||||||
- `high gain`: gain for the high band
|
|
||||||
|
|
||||||
low band goes from 0hz to `low band`, mid band goes from `low band` to `high band`, high band goes from `high band` to half the sample rate
|
|
||||||
|
|
||||||
## contributing
|
## contributing
|
||||||
|
|
||||||
|
|
|
@ -9,5 +9,3 @@ crate-type = ["cdylib"]
|
||||||
[dependencies]
|
[dependencies]
|
||||||
baseplug = { git = "https://github.com/wrl/baseplug.git", rev = "9cec68f31cca9c0c7a1448379f75d92bbbc782a8" }
|
baseplug = { git = "https://github.com/wrl/baseplug.git", rev = "9cec68f31cca9c0c7a1448379f75d92bbbc782a8" }
|
||||||
serde = "1.0.126"
|
serde = "1.0.126"
|
||||||
|
|
||||||
utils = { path = "../utils" }
|
|
||||||
|
|
|
@ -1,77 +1,35 @@
|
||||||
#![allow(incomplete_features)]
|
#![allow(incomplete_features)]
|
||||||
#![feature(generic_associated_types)]
|
#![feature(generic_associated_types)]
|
||||||
|
|
||||||
// https://www.musicdsp.org/en/latest/Filters/236-3-band-equaliser.html
|
|
||||||
|
|
||||||
use baseplug::{Plugin, ProcessContext};
|
use baseplug::{Plugin, ProcessContext};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
use utils::threeband::*;
|
|
||||||
|
|
||||||
baseplug::model! {
|
baseplug::model! {
|
||||||
#[derive(Debug, Serialize, Deserialize)]
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
struct ThreeBandEqModel {
|
struct ThreeBandEqModel {
|
||||||
#[model(min = 0.0, max = 15000.0)]
|
#[model(min = -90.0, max = 3.0)]
|
||||||
#[parameter(name = "low band")]
|
#[parameter(name = "gain", unit = "Decibels",
|
||||||
low_band: f32,
|
gradient = "Power(0.15)")]
|
||||||
#[model(min = 0.0, max = 15000.0)]
|
gain: f32
|
||||||
#[parameter(name = "mid band")]
|
|
||||||
high_band: f32,
|
|
||||||
|
|
||||||
#[model(min = 0.0, max = 3.0)]
|
|
||||||
#[parameter(name = "low gain")]
|
|
||||||
low_gain: f32,
|
|
||||||
#[model(min = 0.0, max = 3.0)]
|
|
||||||
#[parameter(name = "mid gain")]
|
|
||||||
mid_gain: f32,
|
|
||||||
#[model(min = 0.0, max = 3.0)]
|
|
||||||
#[parameter(name = "high gain")]
|
|
||||||
high_gain: f32,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
impl Default for ThreeBandEqModel {
|
impl Default for ThreeBandEqModel {
|
||||||
fn default() -> Self {
|
fn default() -> Self {
|
||||||
Self {
|
Self {
|
||||||
low_band: 800.0,
|
// "gain" is converted from dB to coefficient in the parameter handling code,
|
||||||
high_band: 5000.0,
|
// so in the model here it's a coeff.
|
||||||
|
// -0dB == 1.0
|
||||||
low_gain: 1.0,
|
gain: 1.0,
|
||||||
mid_gain: 1.0,
|
|
||||||
high_gain: 1.0,
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[derive(Default)]
|
struct ThreeBandEq;
|
||||||
struct Eq(ThreeBandSplitter);
|
|
||||||
impl Eq {
|
|
||||||
#[allow(clippy::too_many_arguments)]
|
|
||||||
pub fn process(
|
|
||||||
&mut self,
|
|
||||||
input: f32,
|
|
||||||
lf: f32,
|
|
||||||
hf: f32,
|
|
||||||
lg: f32,
|
|
||||||
mg: f32,
|
|
||||||
hg: f32,
|
|
||||||
sample_rate: f32,
|
|
||||||
) -> f32 {
|
|
||||||
let (l, m, h) = self.0.process(input, lf, hf, sample_rate);
|
|
||||||
|
|
||||||
l * lg + m * mg + h * hg
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
#[derive(Default)]
|
|
||||||
struct ThreeBandEq {
|
|
||||||
l_eq: Eq,
|
|
||||||
r_eq: Eq,
|
|
||||||
}
|
|
||||||
|
|
||||||
impl Plugin for ThreeBandEq {
|
impl Plugin for ThreeBandEq {
|
||||||
const NAME: &'static str = "threebandeq";
|
const NAME: &'static str = "basic gain";
|
||||||
const PRODUCT: &'static str = "threebandeq";
|
const PRODUCT: &'static str = "basic gain";
|
||||||
const VENDOR: &'static str = "unnieversal";
|
const VENDOR: &'static str = "unnieversal";
|
||||||
|
|
||||||
const INPUT_CHANNELS: usize = 2;
|
const INPUT_CHANNELS: usize = 2;
|
||||||
|
@ -81,8 +39,7 @@ impl Plugin for ThreeBandEq {
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
fn new(_sample_rate: f32, _model: &ThreeBandEqModel) -> Self {
|
fn new(_sample_rate: f32, _model: &ThreeBandEqModel) -> Self {
|
||||||
// Default cause we want to start with 0s in everything
|
Self
|
||||||
Self::default()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
#[inline]
|
#[inline]
|
||||||
|
@ -90,20 +47,9 @@ impl Plugin for ThreeBandEq {
|
||||||
let input = &ctx.inputs[0].buffers;
|
let input = &ctx.inputs[0].buffers;
|
||||||
let output = &mut ctx.outputs[0].buffers;
|
let output = &mut ctx.outputs[0].buffers;
|
||||||
|
|
||||||
let sr = ctx.sample_rate;
|
|
||||||
|
|
||||||
for i in 0..ctx.nframes {
|
for i in 0..ctx.nframes {
|
||||||
// frequencies
|
output[0][i] = input[0][i] * model.gain[i];
|
||||||
let lf = model.low_band[i];
|
output[1][i] = input[1][i] * model.gain[i];
|
||||||
let hf = model.high_band[i];
|
|
||||||
|
|
||||||
// gains
|
|
||||||
let lg = model.low_gain[i];
|
|
||||||
let mg = model.mid_gain[i];
|
|
||||||
let hg = model.high_gain[i];
|
|
||||||
|
|
||||||
output[0][i] = self.l_eq.process(input[0][i], lf, hf, lg, mg, hg, sr);
|
|
||||||
output[1][i] = self.r_eq.process(input[1][i], lf, hf, lg, mg, hg, sr);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,4 +1,3 @@
|
||||||
pub mod buffers;
|
pub mod buffers;
|
||||||
pub mod logs;
|
pub mod logs;
|
||||||
pub mod pitch;
|
pub mod pitch;
|
||||||
pub mod threeband;
|
|
||||||
|
|
|
@ -1,57 +0,0 @@
|
||||||
/// Very small amount
|
|
||||||
const VSA: f32 = 1.0 / 4294967295.0;
|
|
||||||
|
|
||||||
/// Splits the input into three bands
|
|
||||||
#[derive(Default)]
|
|
||||||
pub struct ThreeBandSplitter {
|
|
||||||
// Filter #1 (Low band)
|
|
||||||
f1p0: f32, // Poles ...
|
|
||||||
f1p1: f32,
|
|
||||||
f1p2: f32,
|
|
||||||
f1p3: f32,
|
|
||||||
|
|
||||||
// Filter #2 (High band)
|
|
||||||
f2p0: f32, // Poles ...
|
|
||||||
f2p1: f32,
|
|
||||||
f2p2: f32,
|
|
||||||
f2p3: f32,
|
|
||||||
|
|
||||||
// Sample history buffer
|
|
||||||
sdm1: f32, // Sample data minus 1
|
|
||||||
sdm2: f32, // 2
|
|
||||||
sdm3: f32, // 3
|
|
||||||
}
|
|
||||||
impl ThreeBandSplitter {
|
|
||||||
/// Returns (low, mid, high) bands
|
|
||||||
pub fn process(&mut self, input: f32, lf: f32, hf: f32, sample_rate: f32) -> (f32, f32, f32) {
|
|
||||||
let lf = 2.0 * (std::f32::consts::PI * (lf / sample_rate)).sin();
|
|
||||||
let hf = 2.0 * (std::f32::consts::PI * (hf / sample_rate)).sin();
|
|
||||||
|
|
||||||
// Filter #1 (low pass)
|
|
||||||
self.f1p0 += lf * (input - self.f1p0) + VSA;
|
|
||||||
self.f1p1 += lf * (self.f1p0 - self.f1p1);
|
|
||||||
self.f1p2 += lf * (self.f1p1 - self.f1p2);
|
|
||||||
self.f1p3 += lf * (self.f1p2 - self.f1p3);
|
|
||||||
|
|
||||||
let l = self.f1p3;
|
|
||||||
|
|
||||||
// Filter #2 (high pass)
|
|
||||||
self.f2p0 += hf * (input - self.f2p0) + VSA;
|
|
||||||
self.f2p1 += hf * (self.f2p0 - self.f2p1);
|
|
||||||
self.f2p2 += hf * (self.f2p1 - self.f2p2);
|
|
||||||
self.f2p3 += hf * (self.f2p2 - self.f2p3);
|
|
||||||
|
|
||||||
// we subtract from sdm3 because the filter has a three sample delay
|
|
||||||
let h = self.sdm3 - self.f2p3;
|
|
||||||
|
|
||||||
// Calculate midrange (signal - (low + high))
|
|
||||||
let m = self.sdm3 - (h + l);
|
|
||||||
|
|
||||||
// Shuffle history buffer
|
|
||||||
self.sdm3 = self.sdm2;
|
|
||||||
self.sdm2 = self.sdm1;
|
|
||||||
self.sdm1 = input;
|
|
||||||
|
|
||||||
(l, m, h)
|
|
||||||
}
|
|
||||||
}
|
|
Loading…
Reference in New Issue