00 \u00a0 \/**********************************************************************\r
01 \u00a0 Copyright (c) 2016 Mark C. Erickson\r
02 \u00a0 \r
03 \u00a0 Permission is hereby granted, free of charge, to any person obtaining \r
04 \u00a0 a copy of this software and associated documentation files (the \r
05 \u00a0 \"Software\"), to deal in the Software without restriction, including \r
06 \u00a0 without limitation the rights to use, copy, modify, merge, publish, \r
07 \u00a0 distribute, sublicense, and\/or sell copies of the Software, and to \r
08 \u00a0 permit persons to whom the Software is furnished to do so, subject to \r
09 \u00a0 the following conditions:\r
10 \u00a0 \r
11 \u00a0 The above copyright notice and this permission notice shall be included \r
12 \u00a0 in all copies or substantial portions of the Software.\r
13 \u00a0 \r
14 \u00a0 THE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND, EXPRESS \r
15 \u00a0 OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF \r
16 \u00a0 MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. \r
17 \u00a0 IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY \r
18 \u00a0 CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, \r
19 \u00a0 TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE \r
20 \u00a0 SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. \r
21 \u00a0 \r
22 \u00a0 Based on:\r
23 \u00a0 \thttp:\/\/www.musicdsp.org\/showone.php?id=97\r
24 \u00a0 \r
25 \u00a0 **********************************************************************\/\r
26 \u00a0 \r
<\/p>
Disclaimer...<\/a> 96 \u00a0 @gfx 100 70\r
27 \u00a0 desc:Envelope Detector 2, v1.0.0\r
28 \u00a0 \r
29 \u00a0 \r
30 \u00a0 slider1:0<0,1,1{OFF,ON}>HP\r
31 \u00a0 slider2:100<200,10000,1>Frequency\r
32 \u00a0 slider14:100<3,1000,1>Attack (us)\r
33 \u00a0 slider15:100<3,1500,1>Release (ms)\r
34 \u00a0 \r
35 \u00a0 \r
36 \u00a0 @init\r
37 \u00a0 x = 0;\r
38 \u00a0 x1 = 0;\r
39 \u00a0 x2 = 0;\r
40 \u00a0 y = 0;\r
41 \u00a0 y1 = 0;\r
42 \u00a0 y2 = 0;\r
43 \u00a0 d = sqrt(2);\r
44 \u00a0 \r
45 \u00a0 ga = gr = 1;\r
46 \u00a0 e = 0;\r
47 \u00a0 \r
48 \u00a0 \r
49 \u00a0 @slider\r
50 \u00a0 ga = exp(-1\/(srate*slider14\/1000000));\r
51 \u00a0 gr = exp(-1\/(srate*slider15\/1000));\r
52 \u00a0 \r
53 \u00a0 slider1 == 1 ? (\r
54 \u00a0 slider2 > 199 ? (\r
55 \u00a0 w = 2.0 * $pi * slider2 \/ srate;\r
56 \u00a0 beta = 0.5 * (( 1.0 - d \/ 2.0 * sin(w) ) \/ ( 1.0 + d \/ 2.0 * sin(w) ));\r
57 \u00a0 gamma = ( 0.5 + beta ) * cos(w);\r
58 \u00a0 alpha = ( 0.5 + beta - gamma ) \/ 4.0;\r
59 \u00a0 );\r
60 \u00a0 );\r
61 \u00a0 \r
62 \u00a0 @sample\r
63 \u00a0 a = spl0; \r
64 \u00a0 b = spl1;\r
65 \u00a0 \r
66 \u00a0 a < 0 ? i = -a : i = a; \r
67 \u00a0 b < 0 ? j = -b : j = b;\r
68 \u00a0 j > i ? i = j : i = i; \/\/ find max\r
69 \u00a0 e < i ? (\r
70 \u00a0 e *= ga;\r
71 \u00a0 e += (1-ga)*i;\r
72 \u00a0 ) \r
73 \u00a0 \ud83d\ude41\r
74 \u00a0 e *= gr;\r
75 \u00a0 e += (1-gr)*i;\r
76 \u00a0 );\r
77 \u00a0 \r
78 \u00a0 slider1 == 1 ? (\r
79 \u00a0 x = e*2 - 1;\r
80 \u00a0 y = 2.0 * ( alpha * ( x + 2.0 * x1 + x2 ) + gamma * y1 - beta * y2 );\r
81 \u00a0 x2 = x1;\r
82 \u00a0 x1 = x;\r
83 \u00a0 y2 = y1;\r
84 \u00a0 y1 = y; \r
85 \u00a0 e = (y + 1) \/ 2;\r
86 \u00a0 );\r
87 \u00a0 \r
88 \u00a0 gDB = abs(20 * log10(e));\r
89 \u00a0 \r
90 \u00a0 e < 0.00000000001 ? e = 0 : e = e;\r
91 \u00a0 \r
92 \u00a0 spl0 = e; \r
93 \u00a0 spl1 = e;\r
94 \u00a0 \r
Graphics...<\/a><\/p>
97 \u00a0 gfx_x=gfx_y=5;\r
98 \u00a0 gfx_r=0.7; \r
99 \u00a0 gfx_g=1;\r
100 \u00a0 gfx_b=0.1;\r
101 \u00a0 gfx_a=1;\r
102 \u00a0 gfx_drawchar($'E');\r
103 \u00a0 gfx_drawchar($'N');\r
104 \u00a0 gfx_drawchar($'V');\r
105 \u00a0 gfx_drawchar($' ');\r
106 \u00a0 gfx_drawchar($'2');\r
107 \u00a0 gfx_drawchar($':');\r
108 \u00a0 gfx_drawchar($' ');\r
109 \u00a0 gfx_drawchar($'-');\r
110 \u00a0 gfx_drawnumber(gDB,1);\r
111 \u00a0 \r
112 \u00a0 gfx_x=gfx_y=25;\r
113 \u00a0 gfx_rect(5, 25, gDB*10, 25);\r\n
<\/p>Download<\/a>\n","protected":false},"excerpt":{"rendered":"","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[13],"tags":[],"_links":{"self":[{"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/329"}],"collection":[{"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=329"}],"version-history":[{"count":3,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions"}],"predecessor-version":[{"id":579,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=\/wp\/v2\/posts\/329\/revisions\/579"}],"wp:attachment":[{"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=329"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=329"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.auriculaonline.com\/wp\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=329"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}