- Distortion Overview
- Distortion, Polynomial, 2nd-Degree
- Distortion, Polynomial, 3rd-Degree
- Distortion, Chebyshev, 2nd-Order
- Distortion, Non-Linear, Asymmetry
- Distortion, Clipping, Symmetrical
- Distortion, Clipping, Asymmetric
- Distortion, Rectifier, Half-Wave
- Distortion, Clipping [B] Soft
- Distortion, Clipping [A] Soft
- Distortion, Bit Crusher
- Distortion, Crossover
- Distortion, Non-Linear, µLaw
- Distortion, Rectifier, Full-Wave
Author Archives: Admin
Meter, LUFS -18dB
00 /**********************************************************************
01 Copyright (c) 2014-2016 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 Reference: Rec. ITU-R BS.1770
23
24 **********************************************************************/
25
Disclaimer...
26 desc:LUFS Meter, Mono [-18dB], v1.0.1
27
28 @init
29 a1a = -1.69065929318241; // 48k prefilter, boost highs, model effects of head as a sphere
30 a2a = 0.73248077421585;
31 b0a = 1.53512485958697;
32 b1a = -2.69169618940638;
33 b2a = 1.19839281085285;
34
35 srate == 44100 ? (
36 a1a = -1.66365511325602; // 44k prefilter, boost highs, model effects of head as a sphere
37 a2a = 0.71259542807323;
38 b0a = 1.53084123005035;
39 b1a = -2.65097999515473;
40 b2a = 1.16907907992159;
41 );
42
43 axn=0;
44 axn1=0;
45 axn2=0;
46 ayn=0;
47 ayn1=0;
48 ayn2=0;
49
50 a1b = -1.99004745483398; // 48k High Pass
51 a2b = 0.99007225036621;
52 b0b = 1.0;
53 b1b = -2.0;
54 b2b = 1.0;
55
56 srate == 44100 ? (
57 a1b = -1.98916967362980; // 44k High Pass
58 a2b = 0.98919903578704;
59 b0b = 0.99956006454251;
60 b1b = -1.99912012908503;
61 b2b = 0.99956006454251;
62 );
63
64 bxn=0;
65 bxn1=0;
66 bxn2=0;
67 byn=0;
68 byn1=0;
69 byn2=0;
70
71 buf = 0; // buffer exists at offset 0
72 bufpos = 0;
73 buflength = srate * 3;//1.2; // 1200 ms
74
75 rmsSum = 0;
76 rmsTarget = 0.01;
77 LUFS_REF = pow(10, 20/-18);
78
79
80 @sample
81 axn2=axn1;
82 axn1=axn;
83 axn=spl0;
84 ayn2=ayn1;
85 ayn1=ayn;
86
87 ayn=b0a*axn + b1a*axn1 + b2a*axn2 - a1a*ayn1 - a2a*ayn2;
88
89 bxn2=bxn1;
90 bxn1=bxn;
91 bxn=ayn * sqrt(1.3);
92 byn2=byn1;
93 byn1=byn;
94
95 byn=b0b*bxn + b1b*bxn1 + b2b*bxn2 - a1b*byn1 - a2b*byn2;
96
97 rmsValue = byn * byn;
98 rmsSum -= buf[bufpos];
99 buf[bufpos] = rmsValue;
100 rmsSum += rmsValue;
101
102 bufpos = bufpos + 1 ;
103 bufpos > buflength ? bufpos = 0;
104
105 gain = 1.0;
106 rmsDelta = rmsSum / buflength;
107 rmsDB = 20 * log10(sqrt(rmsDelta) / LUFS_REF) - 24; // -21 for stereo simulation
108
109 spl0 = axn;
110 spl1 = spl1;
111
Graphics...
113 @gfx 100 18
114 gfx_x=gfx_y=5;
115 gfx_r=0.7;
116 gfx_g=1;
117 gfx_b=0.1;
118 gfx_a=1;
119 gfx_drawchar($'L');
120 gfx_drawchar($'U');
121 gfx_drawchar($'F');
122 gfx_drawchar($'S');
123 gfx_drawchar($' ');
124 gfx_drawchar($'1');
125 gfx_drawchar($'8');
126 gfx_drawchar($':');
127 gfx_drawchar($' ');
128 gfx_drawnumber(rmsDB,1);
129
130
Sin Generator Pro
00 /**********************************************************************
01 Copyright (c) 2016 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Sin Generator Pro, v1.0.0
24
25 //slider1:.5664<0,1,0.001>Frequency ( see in text box below )
26 //slider2:1000<20,20000,1>Placeholder ( do not move )
27 slider1:.5664<0.3661,0.5664,0.00001>Frequency ( see in text box below )
28 slider2:1000<250,1000,1>Placeholder ( do not move )
29
30 @init
31 j = 0;
32 gain = 0.316;
33 pi2 = 2.0 * $pi;
34 angle = 0;
35
36 @slider
37 g = slider1 * 3;
38 h = 20 * pow(10,g);
39 slider2 = floor(h);
40 sliderchange(slider2);
41 slider_automate(slider2);
42 f = slider2;
43 theta = pi2 * f / srate;
44 //j = floor(( angle/theta ) - 1);
45 j = ( angle / theta ) - 1;
46
47 @sample
48 j += 1;
49 angle = j * theta;
50 c = sin( angle );
51 c *= gain;
52
53 spl0 = c;
54 spl1 = spl0;
Sin Generator
00 /**********************************************************************
01 Copyright (c) 2016 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Sin Generator, v1.0.0
24
25 slider1:1000<20,20000,0.1>Frequency
26 //slider1:1000<250,1000,1>Frequency
27
28 @init
29 j = 0;
30 gain = 0.316;
31 pi2 = 2.0 * $pi;
32
33 @slider
34 f = slider1;
35 theta = pi2 * f / srate;
36
37 @sample
38 j += 1;
39 spl0 = sin( j * theta );
40 spl0 *= gain;
41 spl1 = spl0;
Distortion, Polynomial, 2nd-Degree
00 /**********************************************************************
01 Copyright (c) 2014 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Distortion: Polynomial, 2nd-Degree, v1.0.0
24
25 slider1:0.5<0,1.0,0.01>Linear Gain
26
27 @init
28 gain = 0.5;
29
30 @slider
31 gain = slider1;
32
33 @sample
34 output = spl0;
35 spl0 > 0 ? ( output = gain * spl0 * spl0 + spl0; );
36 spl0 < 0 ? ( output = -1.0 * gain * spl0 * spl0 + spl0; );
37 spl0 = output;
38
39 spl1 = spl1;
40
Distortion, Polynomial, 3rd-Degree
00 /**********************************************************************
01 Copyright (c) 2014 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Distortion: Polynomial, 3rd-Degree, v1.0.0
24
25 slider1:0.5<0,1.0,0.01>Linear Gain
26
27 @init
28 gain = 0.5;
29
30 @slider
31 gain = slider1;
32
33 @sample
34 output = 1.5 * spl0 - 0.5 * spl0 * spl0 * spl0;
35 spl0 = gain * output + spl0;
36
37 spl1 = spl1;
38
Distortion, Chebyshev, 2nd-Order
00 /**********************************************************************
01 Copyright (c) 2014 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Distortion: Chebyshev, 2nd-Order, v1.0.0
24
25 slider1:0.5<0,1.0,0.01>Linear Gain
26
27 @init
28 gain = 0.5;
29
30 @slider
31 gain = slider1;
32
33 @sample
34 output = 2.0 * spl0 * spl0 - 1.0;
35 spl0 = gain * output + spl0;
36
37 spl1 = spl1;
38
IR Creator
00 /**********************************************************************
01 Copyright (c) 2014 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:IR Creator, v1.0.0
24
25 slider1: 1.0 < 0, 1.0 , 0.01 > IR Max
26
27 @init
28 max = 1.0;
29 count = 0;
30
31 @slider
32 max = slider1;
33
34 @sample
35 newSample = 0;
36 count = count + 1;
37 count == 25 ? ( newSample = max * 0.9999999; );
38 spl0 = newSample;
MS Encoder/Decoder
00 /**********************************************************************
01 Copyright (c) 2016 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:MS Encoder/Decoder, v1.0.0
24
25 @init
26 gain = 0.707;
27
28 @slider
29
30 @sample
31 left_in = spl0 * gain;
32 right_in = spl1 * gain;
33
34 // create MS pair ENCODER
35 mid = left_in + right_in;
36 sides = left_in - right_in;
37
38 // output
39 spl0 = mid;
40 spl1 = sides;
Distortion, Non-Linear, Asymmetry
00 /**********************************************************************
01 Copyright (c) 2014 Mark C. Erickson
02
03 Permission is hereby granted, free of charge, to any person obtaining
04 a copy of this software and associated documentation files (the
05 "Software"), to deal in the Software without restriction, including
06 without limitation the rights to use, copy, modify, merge, publish,
07 distribute, sublicense, and/or sell copies of the Software, and to
08 permit persons to whom the Software is furnished to do so, subject to
09 the following conditions:
10
11 The above copyright notice and this permission notice shall be included
12 in all copies or substantial portions of the Software.
13
14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
15 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
17 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
18 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
19 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
20 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21 **********************************************************************/
22
Disclaimer...
23 desc:Distortion: Non-Linearity, Asymmetry, v1.0.0
24
25 slider1:0.5<0,1.0,0.01>Linear Gain
26
27 @init
28 gain = 0.5;
29
30 @slider
31 gain = 1.0 - slider1;
32
33 @sample
34 spl0 = spl0;
35 spl0 < 0 ? ( spl0 *= gain; );
36
37 spl1 = spl1;
38