From 7e743eae0730dcb3700dd12eb5810713c3485bb4 Mon Sep 17 00:00:00 2001 From: Weird Constructor Date: Fri, 6 Aug 2021 02:02:26 +0200 Subject: [PATCH] Documented more stuff --- src/dsp/helpers.rs | 20 ++++++++++++++++---- src/dsp/node_vosc.rs | 38 +++++++++++++++++++++++--------------- 2 files changed, 39 insertions(+), 19 deletions(-) diff --git a/src/dsp/helpers.rs b/src/dsp/helpers.rs index 0d2e3d1..3d0ed2b 100644 --- a/src/dsp/helpers.rs +++ b/src/dsp/helpers.rs @@ -281,7 +281,19 @@ pub fn note_to_freq(note: f32) -> f32 { // * DspEffectLibrary.h - library with template-based inline-effects // * Copyright (c) 2006-2014 Tobias Doerffel // -/// Signal distortion +// Original source seems to be musicdsp.org, Author: Bram de Jong +// see also: https://www.musicdsp.org/en/latest/Effects/41-waveshaper.html +// Notes: +// where x (in [-1..1] will be distorted and a is a distortion parameter +// that goes from 1 to infinity. The equation is valid for positive and +// negativ values. If a is 1, it results in a slight distortion and with +// bigger a's the signal get's more funky. +// A good thing about the shaper is that feeding it with bigger-than-one +// values, doesn't create strange fx. The maximum this function will reach +// is 1.2 for a=1. +// +// f(x,a) = x*(abs(x) + a)/(x^2 + (a-1)*abs(x) + 1) +/// Signal distortion by Bram de Jong. /// ```text /// gain: 0.1 - 5.0 default = 1.0 /// threshold: 0.0 - 100.0 default = 0.8 @@ -1634,9 +1646,9 @@ macro_rules! fa_distort { ($formatter: expr, $v: expr, $denorm_v: expr) => { { let s = match ($v.round() as usize) { 0 => "Off", - 1 => "tanh", - 2 => "?!?", - 3 => "fold", + 1 => "TanH", + 2 => "B.D.Jong", + 3 => "Fold", _ => "?", }; write!($formatter, "{}", s) diff --git a/src/dsp/node_vosc.rs b/src/dsp/node_vosc.rs index cb0c7aa..d547225 100644 --- a/src/dsp/node_vosc.rs +++ b/src/dsp/node_vosc.rs @@ -52,36 +52,44 @@ impl VOsc { Note: The signal input allows detune +-10 octaves.\ \nRange: (Knob -0.2 .. 0.2) / (Signal -1.0 .. 1.0)\n"; pub const d : &'static str = - "VOsc d\n\nRange: (0..1)\n"; + "VOsc d\nThis is the horzontal bending point of the waveform. \ + It has a similar effect that pulse width settings have on other \ + oscillators. Make sure to try modulating this parameter at audio rate!\ + \nRange: (0..1)\n"; pub const v : &'static str = - "VOsc v\n\nRange: (0..1)\n"; + "VOsc v\nThis is the vertical bending point of the waveform. \ + You can adjust the effect that 'd' has on the waveform with this \ + parameter. Make sure to try to modulate this parameter at audio rate!\ + \nRange: (0..1)\n"; pub const vs : &'static str = - "VOsc vs\nScaling factor for 'v'.\nRange: (0..1)\n"; + "VOsc vs\nScaling factor for 'v'. If you increase this beyond 1.0, \ + you will hear formant like sounds from the oscillator. Try adjusting \ + 'd' to move the formants around.\nRange: (0..1)\n"; pub const dist : &'static str = - "VOsc dist\nDistortion."; + "VOsc dist\nA collection of waveshaper/distortions to choose from."; pub const damt : &'static str = - "VOsc damt\nDistortion amount."; + "VOsc damt\nDistortion amount.\nRange: (0..1)\n"; pub const ovrsmpl : &'static str = "VOsc ovrsmpl\nEnable/Disable oversampling."; - pub const wtype : &'static str = - "VOsc wtype\nWaveform type\nAvailable waveforms:\n\ - Sin - Sine Waveform\n\ - Tri - Triangle Waveform\n\ - Saw - Sawtooth Waveform\n\ - Pulse - Pulse Waveform with configurable pulse width"; pub const sig : &'static str = "VOsc sig\nOscillator output\nRange: (-1..1)\n"; pub const DESC : &'static str = r#"V Oscillator -A vector phase shaping oscillator, to create interesting waveforms and -ways to manipulate them. +A vector phase shaping oscillator, to create interesting waveforms and ways to +manipulate them. It has two parameters ('v' and 'd') to shape the phase of the +sinusoid wave, and a third parameter 'vs' to add extra spice. +With distortion you can beef up the oscillator output even more and to +make it more harmonic you can apply oversampling. "#; pub const HELP : &'static str = r#"VOsc - Vector Phase Shaping Oscillator -A vector phase shaping oscillator, to create interesting waveforms and -ways to manipulate them. +A vector phase shaping oscillator, to create interesting waveforms and ways to +manipulate them. It has two parameters ('v' and 'd') to shape the phase of the +sinusoid wave, and a third parameter 'vs' to add extra spice. +With distortion you can beef up the oscillator output even more and to +make it more harmonic you can apply oversampling. "#; }