1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
// Copyright (c) 2021-2022 Weird Constructor <weirdconstructor@gmail.com>
// This file is a part of synfx-dsp. Released under GPL-3.0-or-later.
// See README.md and COPYING for details.
//! A collection of wave shaping functions.
// Ported from LMMS under GPLv2
// * DspEffectLibrary.h - library with template-based inline-effects
// * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
//
// 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
/// i: signal
/// ```
// Ported from LMMS under GPLv2
// * DspEffectLibrary.h - library with template-based inline-effects
// * Copyright (c) 2006-2014 Tobias Doerffel <tobydox/at/users.sourceforge.net>
//
/// Foldback Signal distortion
/// ```text
/// gain: 0.1 - 5.0 default = 1.0
/// threshold: 0.0 - 100.0 default = 0.8
/// i: signal
/// ```