Category Archives: EQs
EQ, Biquad
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:EQ, Biquad, v1.0.1
24
25 slider1:0<0,7,1{Low-Pass,High-Pass,Bandpass,Notch,All-Pass,Peak,Low-Shelf,High-Shelf}>Type
26 slider2:0<-18,18,0.1>Boost/Cut
27 slider3:1000<20,20000,1>Frequency
28 slider4:2<.25,10,0.1>Q
29 slider5:0<-20,12,0.1>Output Gain
30
31
32 @init
33 a0=1;
34 a1=-1.66365511325602; // LUFS 44k prefileter
35 a2=0.71259542807323;
36 b0=1.53084123005035;
37 b1=-2.65097999515473;
38 b2=1.16907907992159;
39
40 x=0;
41 x1=0;
42 x2=0;
43 y=0;
44 y1=0;
45 y2=0;
46
47 mFreq = 1000.0;
48 mType = 0;
49 mBoost = 0.0;
50 mSR = srate;
51 mBW = 2.0;
52 mGain = 0.0;
53
54
55 @slider
56 mType = slider1;
57 mBoost = slider2;
58 mFreq = slider3;
59 mQ = slider4;
60 mGain = slider5;
61 gain = pow( 10.0, mGain / 20.0 );
62
63 A = sqrt( pow( 10.0, mBoost / 20.0 ));
64 omega = 2.0 * $pi * mFreq / mSR;
65 sn = sin( omega );
66 cs = cos( omega );
67 alpha = sn / ( 2 * mQ );
68 beta = sqrt(A) / mQ;
69
70 // LPF
71 mType == 0 ? (
72 b0 = (1 - cs) / 2.0;
73 b1 = 1 - cs;
74 b2 = (1 - cs) / 2.0;
75 a0 = 1 + alpha;
76 a1 = -2 * cs;
77 a2 = 1 - alpha;
78 );
79
80 // HPF
81 mType == 1 ? (
82 b0 = (1 + cs) / 2.0;
83 b1 = -(1 + cs);
84 b2 = (1 + cs) / 2.0;
85 a0 = 1 + alpha;
86 a1 = -2 * cs;
87 a2 = 1 - alpha;
88 );
89
90 // BP
91 mType == 2 ? (
92 b0 = alpha;
93 b1 = 0;
94 b2 = -alpha;
95 a0 = 1 + alpha;
96 a1 = -2 * cs;
97 a2 = 1 - alpha;
98 );
99
100 // NOTCH
101 mType == 3 ? (
102 b0 = 1;
103 b1 = -2 * cs;
104 b2 = 1;
105 a0 = 1 + alpha;
106 a1 = -2 * cs;
107 a2 = 1 - alpha;
108 );
109
110 // APF
111 mType == 4 ? (
112 b0 = 1.0 - alpha;
113 b1 = -2.0 * cs;
114 b2 = 1.0 + alpha;
115 a0 = 1.0 + alpha;
116 a1 = -2.0 * cs;
117 a2 = 1.0 - alpha;
118 );
119
120 // PEAK
121 mType == 5 ? (
122 b0 = 1.0 + ( alpha * A );
123 b1 = -2.0 * cs;
124 b2 = 1.0 - ( alpha * A );
125 a0 = 1.0 + ( alpha / A );
126 a1 = -2.0 * cs;
127 a2 = 1.0 - ( alpha / A );
128 );
129
130 // LSHELF
131 mType == 6 ? (
132 b0 = A * ((A + 1) - (A - 1) * cs + beta * sn);
133 b1 = 2 * A * ((A - 1) - (A + 1) * cs);
134 b2 = A * ((A + 1) - (A - 1) * cs - beta * sn);
135 a0 = (A + 1) + (A - 1) * cs + beta * sn;
136 a1 = -2 * ((A - 1) + (A + 1) * cs);
137 a2 = (A + 1) + (A - 1) * cs - beta * sn;
138 );
139
140 // HSHELF
141 mType == 7 ? (
142 b0 = A * ((A + 1) + (A - 1) * cs + beta * sn);
143 b1 = -2 * A * ((A - 1) + (A + 1) * cs);
144 b2 = A * ((A + 1) + (A - 1) * cs - beta * sn);
145 a0 = (A + 1) - (A - 1) * cs + beta * sn;
146 a1 = 2 * ((A - 1) - (A + 1) * cs);
147 a2 = (A + 1) - (A - 1) * cs - beta * sn;
148 );
149
150 // precompute the coefficients //
151 q0 = b0 / a0;
152 q1 = b1 / a0;
153 q2 = b2 / a0;
154 q3 = a1 / a0;
155 q4 = a2 / a0;
156
157
158 @sample
159 x2 = x1;
160 x1 = x;
161 x = spl0;
162 y2 = y1;
163 y1 = y;
164 y = q0*x + q1*x1 + q2*x2 - q3*y1 - q4*y2;
165 spl0 = y * gain;
166
EQ, Parametric
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:EQ, Parametric, v1.0.1
24
25 slider1:2000<20,20000,1>Frequency [Hz]
26 slider2:3.16<0.91,10,.01>Q
27 slider3:0<-24,12,0.1>Gain [dB]
28
29 @init
30 x=0;
31 x1=0;
32 x2=0;
33 y=0;
34 y1=0;
35 y2=0;
36 q = sqrt(2);
37 gain = 0;
38
39 @slider
40
41 slider2 > 0.90 ? q = slider2;
42 q < ( 2.1 * slider1 / srate ) ? ( q = 2.1 * slider1 / srate );
43 slider2 = q;
44 sliderchange(slider2);
45
46 w = 2.0 * $pi * slider1 / srate;
47 mu = pow( 10, slider3 / 20.0 );
48 Z = 4.0 / ( 1.0 + mu );
49 mBeta = 0.5 * (( 1.0 - Z * tan(w/2.0/q) ) / ( 1.0 + Z * tan(w/2.0/q) ));
50 mGamma = ( 0.5 + mBeta ) * cos(w);
51 mAlpha = ( 0.5 - mBeta ) / 2.0;
52
53 @sample
54 x = spl0;
55 y = 2.0 * ( mAlpha * ( x - x2 ) + mGamma * y1 - mBeta * y2 );
56 x2 = x1;
57 x1 = x;
58 y2 = y1;
59 y1 = y;
60 spl0 = ( y * ( mu - 1.0 )) + x;
61
EQ, Nth-Order Notch
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:EQ, Notch Nth-Order, v1.0.1
24
25 slider1:2000<20,20000,1>Cutoff [Hz]
26 slider2:2<2,8,2>Order [N]
27 slider3:2<0.5,20,0.1>Q
28
29 @init
30 M = 1;
31 Q = 2;
32
33
34 @slider
35
36 function find_Dk(index stages)
37 (
38 _k = index;
39 _M = stages;
40 2.0 * sin($pi*(2*_k-1)/(2*_M));
41 );
42
43 slider1 > 19 ? (
44 slider2 > 1 ? (
45
46 slider3 > 0.5 ? Q = slider3;
47 Q < ( 2.1 * slider1 / srate ) ? ( Q = 2.1 * slider1 / srate );
48 slider3 = Q;
49 sliderchange(slider3);
50
51 N = slider2; // order N, 2 < N < 8
52 M = N / 2; // # of cascaded elements M, 1 < M < 4
53 w = 2.0 * $pi * slider1 / srate;
54 dE = 2.0 * tan( w / (2.0 * Q)) / sin(w);
55
56 k = 1;
57 j = 1;
58 Dk = find_Dk(k, M);
59 Ak = (1 + sqr(dE / 2.0)) / (Dk * dE / 2.0);
60 dk = sqrt(( dE * Dk ) / (Ak + sqrt(sqr(Ak) - 1) ));
61 Bk = Dk * (dE / 2.0) / dk;
62 Wk = Bk + sqrt(sqr(Bk) - 1);
63 theta_1k = 2.0 * atan(tan(w/2.0) / Wk);
64
65 beta1 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_1k) ) / ( 1.0 + dk / 2.0 * sin(theta_1k) ));
66 gamma1 = ( 0.5 + beta1 ) * cos(theta_1k);
67 alpha1 = 0.5 * (0.5 + beta1) * ((1 - cos(theta_1k))/(1 - cos(w)));
68
69 M > 1 ? (
70 k = 1;
71 j = 2;
72 theta_2k = 2.0 * atan( Wk * tan(w/2.0) );
73
74 beta2 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_2k) ) / ( 1.0 + dk / 2.0 * sin(theta_2k) ));
75 gamma2 = ( 0.5 + beta2 ) * cos(theta_2k);
76 alpha2 = 0.5 * (0.5 + beta2) * ((1 - cos(theta_2k))/(1 - cos(w)));
77 );
78
79 M > 2 ? (
80 k = 2;
81 j = 1;
82 Dk = find_Dk(k, M);
83 Ak = (1 + sqr(dE / 2.0)) / (Dk * dE / 2.0);
84 dk = sqrt(( dE * Dk ) / (Ak + sqrt(sqr(Ak) - 1) ));
85 Bk = Dk * (dE / 2.0) / dk;
86 Wk = Bk + sqrt(sqr(Bk) - 1);
87 theta_1k = 2.0 * atan(tan(w/2.0) / Wk);
88
89 beta3 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_1k) ) / ( 1.0 + dk / 2.0 * sin(theta_1k) ));
90 gamma3 = ( 0.5 + beta3 ) * cos(theta_1k);
91 alpha3 = 0.5 * (0.5 + beta3) * ((1 - cos(theta_1k))/(1 - cos(w)));
92 );
93
94 M > 3 ? (
95 k = 2;
96 j = 2;
97 theta_2k = 2.0 * atan( Wk * tan(w/2.0) );
98
99 beta4 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_2k) ) / ( 1.0 + dk / 2.0 * sin(theta_2k) ));
100 gamma4 = ( 0.5 + beta4 ) * cos(theta_2k);
101 alpha4 = 0.5 * (0.5 + beta4) * ((1 - cos(theta_2k))/(1 - cos(w)));
102 );
103
104 );
105 );
106
107 @sample
108 x_1 = spl0;
109 y_1 = 2.0 * ( alpha1 * ( x_1 - 2.0 * cos(w) * x1_1 + x2_1 ) + gamma1 * y1_1 - beta1 * y2_1 );
110 x2_1 = x1_1;
111 x1_1 = x_1;
112 y2_1 = y1_1;
113 y1_1 = y_1;
114 spl0 = y_1;
115
116 M > 1 ? (
117 x_2 = spl0;
118 y_2 = 2.0 * ( alpha2 * ( x_2 - 2.0 * cos(w) * x1_2 + x2_2 ) + gamma2 * y1_2 - beta2 * y2_2 );
119 x2_2 = x1_2;
120 x1_2 = x_2;
121 y2_2 = y1_2;
122 y1_2 = y_2;
123 spl0 = y_2;
124 );
125
126 M > 2 ? (
127 x_3 = spl0;
128 y_3 = 2.0 * ( alpha3 * ( x_3 - 2.0 * cos(w) * x1_3 + x2_3 ) + gamma3 * y1_3 - beta3 * y2_3 );
129 x2_3 = x1_3;
130 x1_3 = x_3;
131 y2_3 = y1_3;
132 y1_3 = y_3;
133 spl0 = y_3;
134 );
135
136 M > 3 ? (
137 x_4 = spl0;
138 y_4 = 2.0 * ( alpha4 * ( x_4 - 2.0 * cos(w) * x1_4 + x2_4 ) + gamma4 * y1_4 - beta4 * y2_4 );
139 x2_4 = x1_4;
140 x1_4 = x_4;
141 y2_4 = y1_4;
142 y1_4 = y_4;
143 spl0 = y_4;
144 );
145
EQ, 2nd-Order Notch
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:EQ, Notch 2nd-Order, v1.0.1
24
25 slider1:2000<20,20000,1>Cutoff [Hz]
26
27 @init
28 x=0;
29 x1=0;
30 x2=0;
31 y=0;
32 y1=0;
33 y2=0;
34 q=3.16;
35
36 @slider
37 slider1 > 19 ? (
38 w = 2.0 * $pi * slider1 / srate;
39 beta = 0.5 * (( 1.0 - tan(w/2.0/q) ) / ( 1.0 + tan(w/2.0/q) ));
40 gamma = ( 0.5 + beta ) * cos(w);
41 alpha = ( 0.5 + beta ) / 2.0;
42 )
43
44 @sample
45 x = spl0;
46 y = 2.0 * ( alpha * x - gamma * x1 + alpha* x2 + gamma * y1 - beta * y2 );
47 x2 = x1;
48 x1 = x;
49 y2 = y1;
50 y1 = y;
51 spl0 = y;
52
EQ, Nth-Order Bandpass
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:EQ, Bandpass Nth-Order, v1.0.1
24
25 slider1:2000<40,16000,1>Cutoff [Hz]
26 slider2:2<2,8,2>Order [N]
27
28 @init
29 M = 1;
30 Q = sqrt(2);
31
32
33 @slider
34
35 function find_Dk(index stages)
36 (
37 _k = index;
38 _M = stages;
39 2.0 * sin($pi*(2*_k-1)/(2*_M));
40 );
41
42 slider1 > 39 ? (
43 slider2 > 1 ? (
44 N = slider2; // order N, 2 < N < 8
45 M = N / 2; // # of cascaded elements M, 1 < M < 4
46 w = 2.0 * $pi * slider1 / srate;
47 dE = 2.0 * tan( w / (2.0 * Q)) / sin(w);
48
49 k = 1;
50 j = 1;
51 Dk = find_Dk(k, M);
52 Ak = (1 + sqr(dE / 2.0)) / (Dk * dE / 2.0);
53 dk = sqrt(( dE * Dk ) / (Ak + sqrt(sqr(Ak) - 1) ));
54 Bk = Dk * (dE / 2.0) / dk;
55 Wk = Bk + sqrt(sqr(Bk) - 1);
56 theta_1k = 2.0 * atan(tan(w/2.0) / Wk);
57
58 beta1 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_1k) ) / ( 1.0 + dk / 2.0 * sin(theta_1k) ));
59 gamma1 = ( 0.5 + beta1 ) * cos(theta_1k);
60 alpha1 = 0.5 * (0.5 - beta1) * sqrt(1+ sqr(de * Dk / ( Ak + sqrt( Ak*Ak -1 ) )));
61
62 M > 1 ? (
63 k = 1;
64 j = 2;
65 theta_2k = 2.0 * atan( Wk * tan(w/2.0) );
66
67 beta2 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_2k) ) / ( 1.0 + dk / 2.0 * sin(theta_2k) ));
68 gamma2 = ( 0.5 + beta2 ) * cos(theta_2k);
69 alpha2 = 0.5 * (0.5 - beta2) * sqrt(1+ sqr(de * Dk / ( Ak + sqrt( Ak*Ak -1 ) )));
70 );
71
72 M > 2 ? (
73 k = 2;
74 j = 1;
75 Dk = find_Dk(k, M);
76 Ak = (1 + sqr(dE / 2.0)) / (Dk * dE / 2.0);
77 dk = sqrt(( dE * Dk ) / (Ak + sqrt(sqr(Ak) - 1) ));
78 Bk = Dk * (dE / 2.0) / dk;
79 Wk = Bk + sqrt(sqr(Bk) - 1);
80 theta_1k = 2.0 * atan(tan(w/2.0) / Wk);
81
82 beta3 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_1k) ) / ( 1.0 + dk / 2.0 * sin(theta_1k) ));
83 gamma3 = ( 0.5 + beta3 ) * cos(theta_1k);
84 alpha3 = 0.5 * (0.5 - beta3) * sqrt(1+ sqr(de * Dk / ( Ak + sqrt( Ak*Ak -1 ) )));
85 );
86
87 M > 3 ? (
88 k = 2;
89 j = 2;
90 theta_2k = 2.0 * atan( Wk * tan(w/2.0) );
91
92 beta4 = 0.5 * (( 1.0 - dk / 2.0 * sin(theta_2k) ) / ( 1.0 + dk / 2.0 * sin(theta_2k) ));
93 gamma4 = ( 0.5 + beta4 ) * cos(theta_2k);
94 alpha4 = 0.5 * (0.5 - beta4) * sqrt(1+ sqr(de * Dk / ( Ak + sqrt( Ak*Ak -1 ) )));
95 );
96
97 );
98 );
99
100 @sample
101 x_1 = spl0;
102 y_1 = 2.0 * ( alpha1 * ( x_1 - x2_1 ) + gamma1 * y1_1 - beta1 * y2_1 );
103 x2_1 = x1_1;
104 x1_1 = x_1;
105 y2_1 = y1_1;
106 y1_1 = y_1;
107 spl0 = y_1;
108
109 M > 1 ? (
110 x_2 = spl0;
111 y_2 = 2.0 * ( alpha2 * ( x_2 - x2_2 ) + gamma2 * y1_2 - beta2 * y2_2 );
112 x2_2 = x1_2;
113 x1_2 = x_2;
114 y2_2 = y1_2;
115 y1_2 = y_2;
116 spl0 = y_2 * 2.0;
117 );
118
119 M > 2 ? (
120 x_3 = spl0;
121 y_3 = 2.0 * ( alpha3 * ( x_3 - x2_3 ) + gamma3 * y1_3 - beta3 * y2_3 );
122 x2_3 = x1_3;
123 x1_3 = x_3;
124 y2_3 = y1_3;
125 y1_3 = y_3;
126 spl0 = y_3 * sqrt(2);
127 );
128
129 M > 3 ? (
130 x_4 = spl0;
131 y_4 = 2.0 * ( alpha4 * ( x_4 - x2_4 ) + gamma4 * y1_4 - beta4 * y2_4 );
132 x2_4 = x1_4;
133 x1_4 = x_4;
134 y2_4 = y1_4;
135 y1_4 = y_4;
136 spl0 = y_4 * 2;
137 );
138
EQ, 2nd-Order Bandpass
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:EQ, Bandpass 2nd-Order, v1.0.0
24
25 slider1:2000<80,12000,1>Cutoff [Hz]
26
27 @init
28 x=0;
29 x1=0;
30 x2=0;
31 y=0;
32 y1=0;
33 y2=0;
34 q=3.16;
35
36 @slider
37 w = 2.0 * $pi * slider1 / srate;
38 mBeta = 0.5 * (( 1.0 - tan(w/2.0/q) ) / ( 1.0 + tan(w/2.0/q) ));
39 mGamma = ( 0.5 + mBeta ) * cos(w);
40 mAlpha = ( 0.5 - mBeta ) / 2.0;
41
42 @sample
43 x = spl0;
44 y = 2.0 * ( mAlpha * ( x - x2 ) + mGamma * y1 - mBeta * y2 );
45 x2 = x1;
46 x1 = x;
47 y2 = y1;
48 y1 = y;
49 spl0 = y;
50
EQ, Hi-Shelf
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:EQ, Hi-Shelf, v1.0.0
24
25 slider1:10000<100,20000,1>Cutoff [Hz]
26 slider2:0<-15,15,0.1>Gain [dB]
27
28 @init
29 x=0;
30 x1=0;
31 y=0;
32 y1=0;
33 mu=1.0;
34
35 @slider
36 w = 2.0 * $pi * slider1 / srate;
37 mu = pow( 10, slider2 / 20.0 );
38 mGamma = ( 1.0 - ((1.0+mu)/4.0) * tan(w/2.0) ) / ( 1.0 + ((1.0+mu)/4.0) * tan(w/2.0) );
39 mAlpha = ( 1.0 + mGamma ) / 2.0;
40
41 @sample
42 x = spl0;
43 y = mAlpha * ( x - x1 ) + mGamma * y1;
44 x1 = x;
45 y1 = y;
46 spl0 = y * ( mu - 1.0 ) + x;
47
EQ, Lo-Shelf
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:EQ, Lo-Shelf, v1.0.0
24
25 slider1:100<20,1000,1>Cutoff [Hz]
26 slider2:0<-15,15,0.1>Gain [dB]
27
28 @init
29 x=0;
30 x2=0;
31 y=0;
32 y1=0;
33 mu=1.0;
34
35 @slider
36 w = 2.0 * $pi * slider1 / srate;
37 mu = pow( 10, slider2 / 20.0 );
38 mGamma = ( 1.0 - (4.0/(1.0+mu)) * tan(w/2.0) ) / ( 1.0 + (4.0/(1.0+mu)) * tan(w/2.0) );
39 mAlpha = ( 1.0 - mGamma ) / 2.0;
40
41 @sample
42 x = spl0;
43 y = mAlpha * ( x + x1 ) + mGamma * y1;
44 x1 = x;
45 y1 = y;
46 spl0 = y * ( mu - 1.0 ) + x;
47
EQ, Nth-Order Low-Pass
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:EQ, Low-Pass Nth-Order, v1.0.1
24 // slope = (M * -12 dB) / Octave
25
26 slider1:1000<20,16000,1>Cutoff [Hz]
27 slider2:2<2,12,2>Order [N]
28
29 @init
30 M = 1;
31
32 @slider
33
34 function find_D(index stages)
35 (
36 _k = index;
37 _M = stages;
38 2.0 * sin($pi*(2*_k-1)/(4*_M));
39 );
40
41 slider1 > 19 ? (
42 slider2 > 1 ? (
43 N = slider2; // order N, 2 < N < 12
44 M = N / 2; // # of cascaded elements M, 1 < M < 6
45 w = 2.0 * $pi * slider1 / srate;
46
47 d = find_D(1, M);
48 beta1 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
49 gamma1 = ( 0.5 + beta1 ) * cos(w);
50 alpha1 = ( 0.5 + beta1 - gamma1 ) / 4.0;
51
52 M > 1 ? (
53 d = find_D(2, M);
54 beta2 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
55 gamma2 = ( 0.5 + beta2 ) * cos(w);
56 alpha2 = ( 0.5 + beta2 - gamma2 ) / 4.0;
57 );
58
59 M > 2 ? (
60 d = find_D(3, M);
61 beta3 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
62 gamma3 = ( 0.5 + beta3 ) * cos(w);
63 alpha3 = ( 0.5 + beta3 - gamma3 ) / 4.0;
64 );
65
66 M > 3 ? (
67 d = find_D(4, M);
68 beta4 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
69 gamma4 = ( 0.5 + beta4 ) * cos(w);
70 alpha4 = ( 0.5 + beta4 - gamma4 ) / 4.0;
71 );
72
73 M > 4 ? (
74 d = find_D(5, M);
75 beta5 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
76 gamma5 = ( 0.5 + beta5 ) * cos(w);
77 alpha5 = ( 0.5 + beta5 - gamma5 ) / 4.0;
78 );
79
80 M > 5 ? (
81 d = find_D(6, M);
82 beta6 = 0.5 * (( 1.0 - d / 2.0 * sin(w) ) / ( 1.0 + d / 2.0 * sin(w) ));
83 gamma6 = ( 0.5 + beta6 ) * cos(w);
84 alpha6 = ( 0.5 + beta6 - gamma6 ) / 4.0;
85 );
86
87 )
88 );
89
90 @sample
91 x_1 = spl0;
92 y_1 = 2.0 * ( alpha1 * ( x_1 + 2.0 * x1_1 + x2_1 ) + gamma1 * y1_1 - beta1 * y2_1 );
93 x2_1 = x1_1;
94 x1_1 = x_1;
95 y2_1 = y1_1;
96 y1_1 = y_1;
97 spl0 = y_1;
98
99 M > 1 ? (
100 x_2 = spl0;
101 y_2 = 2.0 * ( alpha2 * ( x_2 + 2.0 * x1_2 + x2_2 ) + gamma2 * y1_2 - beta2 * y2_2 );
102 x2_2 = x1_2;
103 x1_2 = x_2;
104 y2_2 = y1_2;
105 y1_2 = y_2;
106 spl0 = y_2;
107 );
108
109 M > 2 ? (
110 x_3 = spl0;
111 y_3 = 2.0 * ( alpha3 * ( x_3 + 2.0 * x1_3 + x2_3 ) + gamma3 * y1_3 - beta3 * y2_3 );
112 x2_3 = x1_3;
113 x1_3 = x_3;
114 y2_3 = y1_3;
115 y1_3 = y_3;
116 spl0 = y_3;
117 );
118
119 M > 3 ? (
120 x_4 = spl0;
121 y_4 = 2.0 * ( alpha4 * ( x_4 + 2.0 * x1_4 + x2_4 ) + gamma4 * y1_4 - beta4 * y2_4 );
122 x2_4 = x1_4;
123 x1_4 = x_4;
124 y2_4 = y1_4;
125 y1_4 = y_4;
126 spl0 = y_4;
127 );
128
129 M > 4 ? (
130 x_5 = spl0;
131 y_5 = 2.0 * ( alpha5 * ( x_5 + 2.0 * x1_5 + x2_5 ) + gamma5 * y1_5 - beta5 * y2_5 );
132 x2_5 = x1_5;
133 x1_5 = x_5;
134 y2_5 = y1_5;
135 y1_5 = y_5;
136 spl0 = y_5;
137 );
138
139 M > 5 ? (
140 x_6 = spl0;
141 y_6 = 2.0 * ( alpha6 * ( x_6 + 2.0 * x1_6 + x2_6 ) + gamma6 * y1_6 - beta6 * y2_6 );
142 x2_6 = x1_6;
143 x1_6 = x_6;
144 y2_6 = y1_6;
145 y1_6 = y_6;
146 spl0 = y_6;
147 );
148