Category Archives: Dynamics
Envelope Detector 4
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 Based on:
23 http://www.musicdsp.org/showone.php?id=136
24
25 **********************************************************************/
26
Disclaimer...
27 desc:Envelope Detector 4, v1.0.0
28
29
30 slider1:0<0,1,1{OFF,ON}>HP
31 slider2:100<200,10000,1>Frequency
32 slider14:100<3,1000,1>Attack (us)
33 slider15:100<3,1500,1>Release (ms)
34
35
36 @init
37 x = 0;
38 x1 = 0;
39 x2 = 0;
40 y = 0;
41 y1 = 0;
42 y2 = 0;
43 d = sqrt(2);
44
45 ga = gr = 1;
46 e = 0;
47
48
49 @slider
50 ga = exp(-2/(srate*slider14/1000000));
51 gr = exp(-2/(srate*slider15/1000));
52
53 slider1 == 1 ? (
54 slider2 > 199 ? (
55 w = 2.0 * $pi * slider2 / srate;
56 beta = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
57 gamma = ( 0.5 + beta ) * cos(w);
58 alpha = ( 0.5 + beta - gamma ) / 4.0;
59 );
60 );
61
62 @sample
63 a = spl0;
64 b = spl1;
65
66 a < 0 ? i = -a : i = a;
67 b < 0 ? j = -b : j = b;
68 j > i ? i = j : i = i; // find max
69 i > e ? (
70 e = ga * (e - i) + i;
71 )
72 🙁
73 e = gr * (e - i) + i;
74 );
75
76 slider1 == 1 ? (
77 x = e*2 - 1;
78 y = 2.0 * ( alpha * ( x + 2.0 * x1 + x2 ) + gamma * y1 - beta * y2 );
79 x2 = x1;
80 x1 = x;
81 y2 = y1;
82 y1 = y;
83 e = (y + 1) / 2;
84 );
85
86 gDB = abs(20 * log10(e));
87
88 e < 0.00000000001 ? e = 0 : e = e;
89
90 spl0 = e;
91 spl1 = e;
92
Graphics...
94 @gfx 100 70
95 gfx_x=gfx_y=5;
96 gfx_r=0.7;
97 gfx_g=1;
98 gfx_b=0.1;
99 gfx_a=1;
100 gfx_drawchar($'E');
101 gfx_drawchar($'N');
102 gfx_drawchar($'V');
103 gfx_drawchar($' ');
104 gfx_drawchar($'4');
105 gfx_drawchar($':');
106 gfx_drawchar($' ');
107 gfx_drawchar($'-');
108 gfx_drawnumber(gDB,1);
109
110 gfx_x=gfx_y=25;
111 gfx_rect(5, 25, gDB*10, 25);
Envelope Detector 3
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 Based on the MDA Dynamics VST plug-in:
23 http://mda.smartelectronix.com
24
25 **********************************************************************/
26
Disclaimer...
27 desc:Envelope Detector 3, v1.0.0
28
29 slider1:0<0,1,1{OFF,ON}>HP
30 slider2:100<200,10000,1>Frequency
31 slider14:100<3,1571,1>Attack
32 slider15:100<3,1571,1>Release
33
34
35 @init
36 x = 0;
37 x1 = 0;
38 x2 = 0;
39 y = 0;
40 y1 = 0;
41 y2 = 0;
42 d = sqrt(2);
43
44
45 @slider
46 att = 1 - pow(10, -301030.1 / (slider14*srate));
47 rel = 1 - pow(10, -301.0301 / (slider15*srate));
48
49 slider1 == 1 ? (
50 slider2 > 199 ? (
51 w = 2.0 * $pi * slider2 / srate;
52 beta = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
53 gamma = ( 0.5 + beta ) * cos(w);
54 alpha = ( 0.5 + beta - gamma ) / 4.0;
55 );
56 );
57
58 @sample
59 e = env;
60 re = ( 1 - rel );
61 at = att;
62
63 a = spl0;
64 b = spl1;
65
66 a < 0 ? i = -a : i = a;
67 b < 0 ? j = -b : j = b;
68 j > i ? i = j : i = i; // find max
69
70 i > e ? e = e + at * (i - e) : e = e * re; // envelope
71
72 slider1 == 1 ? (
73 x = e*2 - 1;
74 y = 2.0 * ( alpha * ( x + 2.0 * x1 + x2 ) + gamma * y1 - beta * y2 );
75 x2 = x1;
76 x1 = x;
77 y2 = y1;
78 y1 = y;
79 e = (y + 1) / 2;
80 );
81
82 gDB = abs(20 * log10(e));
83
84 e < 0.00000000001 ? env = 0 : env = e;
85
86 spl0 = e;
87 spl1 = e;
88
Graphics...
90 @gfx 100 70
91 gfx_x=gfx_y=5;
92 gfx_r=0.7;
93 gfx_g=1;
94 gfx_b=0.1;
95 gfx_a=1;
96 gfx_drawchar($'E');
97 gfx_drawchar($'N');
98 gfx_drawchar($'V');
99 gfx_drawchar($' ');
100 gfx_drawchar($'3');
101 gfx_drawchar($':');
102 gfx_drawchar($' ');
103 gfx_drawchar($'-');
104 gfx_drawnumber(gDB,1);
105
106 gfx_x=gfx_y=25;
107 gfx_rect(5, 25, gDB*10, 25);
Envelope Detector 2
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 Based on:
23 http://www.musicdsp.org/showone.php?id=97
24
25 **********************************************************************/
26
Disclaimer...
27 desc:Envelope Detector 2, v1.0.0
28
29
30 slider1:0<0,1,1{OFF,ON}>HP
31 slider2:100<200,10000,1>Frequency
32 slider14:100<3,1000,1>Attack (us)
33 slider15:100<3,1500,1>Release (ms)
34
35
36 @init
37 x = 0;
38 x1 = 0;
39 x2 = 0;
40 y = 0;
41 y1 = 0;
42 y2 = 0;
43 d = sqrt(2);
44
45 ga = gr = 1;
46 e = 0;
47
48
49 @slider
50 ga = exp(-1/(srate*slider14/1000000));
51 gr = exp(-1/(srate*slider15/1000));
52
53 slider1 == 1 ? (
54 slider2 > 199 ? (
55 w = 2.0 * $pi * slider2 / srate;
56 beta = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
57 gamma = ( 0.5 + beta ) * cos(w);
58 alpha = ( 0.5 + beta - gamma ) / 4.0;
59 );
60 );
61
62 @sample
63 a = spl0;
64 b = spl1;
65
66 a < 0 ? i = -a : i = a;
67 b < 0 ? j = -b : j = b;
68 j > i ? i = j : i = i; // find max
69 e < i ? (
70 e *= ga;
71 e += (1-ga)*i;
72 )
73 🙁
74 e *= gr;
75 e += (1-gr)*i;
76 );
77
78 slider1 == 1 ? (
79 x = e*2 - 1;
80 y = 2.0 * ( alpha * ( x + 2.0 * x1 + x2 ) + gamma * y1 - beta * y2 );
81 x2 = x1;
82 x1 = x;
83 y2 = y1;
84 y1 = y;
85 e = (y + 1) / 2;
86 );
87
88 gDB = abs(20 * log10(e));
89
90 e < 0.00000000001 ? e = 0 : e = e;
91
92 spl0 = e;
93 spl1 = e;
94
Graphics...
96 @gfx 100 70
97 gfx_x=gfx_y=5;
98 gfx_r=0.7;
99 gfx_g=1;
100 gfx_b=0.1;
101 gfx_a=1;
102 gfx_drawchar($'E');
103 gfx_drawchar($'N');
104 gfx_drawchar($'V');
105 gfx_drawchar($' ');
106 gfx_drawchar($'2');
107 gfx_drawchar($':');
108 gfx_drawchar($' ');
109 gfx_drawchar($'-');
110 gfx_drawnumber(gDB,1);
111
112 gfx_x=gfx_y=25;
113 gfx_rect(5, 25, gDB*10, 25);