[tritu] create and implement crate
parent
83ba18c991
commit
0f56d9a9c8
14
README.md
14
README.md
|
@ -56,6 +56,7 @@ the following is the current list of plugins
|
||||||
- hysteria: hysteresis nonlinear effect
|
- hysteria: hysteresis nonlinear effect
|
||||||
- threebandeq: 3 band eq
|
- threebandeq: 3 band eq
|
||||||
- threebandwidth: 3 band stereo widener
|
- threebandwidth: 3 band stereo widener
|
||||||
|
- tritu: say-goodbye-to-your-audio distortion
|
||||||
|
|
||||||
### basic_gain
|
### basic_gain
|
||||||
|
|
||||||
|
@ -159,6 +160,19 @@ parameters:
|
||||||
|
|
||||||
bands work as they do in `threebandeq`. the width parameters control how wide an audio signal should be in the stereo field. `width` of 1 leaves the audio as is, `width` of 0 makes it mono, values between 0 and 1 decrease the stereo width, values over 1 increase it.
|
bands work as they do in `threebandeq`. the width parameters control how wide an audio signal should be in the stereo field. `width` of 1 leaves the audio as is, `width` of 0 makes it mono, values between 0 and 1 decrease the stereo width, values over 1 increase it.
|
||||||
|
|
||||||
|
### tritu
|
||||||
|
|
||||||
|
hard limiter followed by a soft limiter with distortion
|
||||||
|
|
||||||
|
parameters:
|
||||||
|
- `pregain`: pregain for the hard limiter
|
||||||
|
- `drive`: drive for the soft limiter
|
||||||
|
- `distortion`: amount of distortion on the soft limiter
|
||||||
|
|
||||||
|
distortion affects lower volumes more than higher volumes, so if you crank up `drive` a lot, there will be less distortion (this is a good thing for high values of `distortion`!). if you leave `drive` low and set `distortion` to max, your audio will turn to almost white noise
|
||||||
|
|
||||||
|
i like this plugin a lot
|
||||||
|
|
||||||
## contributing
|
## contributing
|
||||||
|
|
||||||
issues and prs are welcome, but please open an issue before making any big pr, i don't wanna have to reject a pr where you have put a lot of effort on
|
issues and prs are welcome, but please open an issue before making any big pr, i don't wanna have to reject a pr where you have put a lot of effort on
|
||||||
|
|
|
@ -0,0 +1,11 @@
|
||||||
|
[package]
|
||||||
|
name = "tritu"
|
||||||
|
version = "0.1.0"
|
||||||
|
edition = "2018"
|
||||||
|
|
||||||
|
[lib]
|
||||||
|
crate-type = ["cdylib"]
|
||||||
|
|
||||||
|
[dependencies]
|
||||||
|
baseplug = { git = "https://github.com/wrl/baseplug.git", rev = "9cec68f31cca9c0c7a1448379f75d92bbbc782a8" }
|
||||||
|
serde = "1.0.126"
|
|
@ -0,0 +1,75 @@
|
||||||
|
#![allow(incomplete_features)]
|
||||||
|
#![feature(generic_associated_types)]
|
||||||
|
|
||||||
|
use baseplug::{Plugin, ProcessContext};
|
||||||
|
use serde::{Deserialize, Serialize};
|
||||||
|
|
||||||
|
baseplug::model! {
|
||||||
|
#[derive(Debug, Serialize, Deserialize)]
|
||||||
|
struct TrituModel {
|
||||||
|
#[model(min = 1.0, max = 100.0)]
|
||||||
|
#[parameter(name = "pregain")]
|
||||||
|
pregain: f32,
|
||||||
|
#[model(min = 0.0, max = 20.0)]
|
||||||
|
#[parameter(name = "drive")]
|
||||||
|
drive: f32,
|
||||||
|
#[model(min = 0.0, max = 3.0)]
|
||||||
|
#[parameter(name = "distortion")]
|
||||||
|
distortion: f32,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for TrituModel {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
pregain: 1.0,
|
||||||
|
drive: 1.0,
|
||||||
|
distortion: 0.0,
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
struct Tritu;
|
||||||
|
|
||||||
|
impl Plugin for Tritu {
|
||||||
|
const NAME: &'static str = "tritu";
|
||||||
|
const PRODUCT: &'static str = "tritu";
|
||||||
|
const VENDOR: &'static str = "unnieversal";
|
||||||
|
|
||||||
|
const INPUT_CHANNELS: usize = 2;
|
||||||
|
const OUTPUT_CHANNELS: usize = 2;
|
||||||
|
|
||||||
|
type Model = TrituModel;
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn new(_sample_rate: f32, _model: &TrituModel) -> Self {
|
||||||
|
Self
|
||||||
|
}
|
||||||
|
|
||||||
|
#[inline]
|
||||||
|
fn process(&mut self, model: &TrituModelProcess, ctx: &mut ProcessContext<Self>) {
|
||||||
|
let input = &ctx.inputs[0].buffers;
|
||||||
|
let output = &mut ctx.outputs[0].buffers;
|
||||||
|
|
||||||
|
for i in 0..ctx.nframes {
|
||||||
|
let pregain = model.pregain[i];
|
||||||
|
let drive = model.drive[i];
|
||||||
|
let distortion = model.distortion[i];
|
||||||
|
|
||||||
|
output[0][i] = trituradora(input[0][i], pregain, drive, distortion);
|
||||||
|
output[1][i] = trituradora(input[1][i], pregain, drive, distortion);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
fn trituradora(input: f32, pregain: f32, drive: f32, distortion: f32) -> f32 {
|
||||||
|
// multiply by pregain and hard clip
|
||||||
|
let hard = (input * pregain).clamp(-1.0, 1.0);
|
||||||
|
// multiply by drive
|
||||||
|
let val = hard * drive;
|
||||||
|
|
||||||
|
// weird thingy i made up: https://www.desmos.com/calculator/bzprjqhudd
|
||||||
|
val.tanh() * (distortion / val).cos()
|
||||||
|
}
|
||||||
|
|
||||||
|
baseplug::vst2!(Tritu, b"tri2");
|
Loading…
Reference in New Issue