Category Archives: Knobs
Knob, Cos [±12dB]
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 MERCHANT-
16 ABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
17 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.1 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Knob: Cos [±12dB], v1.0.1
29
30 slider1: 50 <0, 100, 0.1> Position [mm]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 1;
35
36 @slider
37 c = slider1 / 100.0;
38 d = -12.0 * cos(c * $PI);
39 m = pow( 10, d / 20.0 );
40
41 @sample
42 spl0 *= m;
43 spl1 *= m;
44
Graphics...
46 @gfx 256 256
47 gfx_setfont(1, "Arial", 10);
48 gfx_a = 1;
49
50 gfx_r = gfx_g = gfx_b = 0.1;
51 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
52 gfx_line(0, 0, 0, gfx_h, 0.5);
53 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
54 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
55
56 x_step = gfx_w / 10;
57 y_step = gfx_h / 10;
58
59 i = 1;
60 loop(9, // y-axiis
61 x = i*x_step;
62 gfx_line(x, y_step, x, y_step*7, 0.5);
63 i += 1;
64 );
65
66 gfx_x = x_step - 2;
67 gfx_y = gfx_h - 3*y_step + 9;
68 gfx_drawchar($'0');
69 gfx_drawchar($'m');gfx_drawchar($'m');
70
71 gfx_x = 3*x_step - 7;
72 gfx_y = gfx_h - 3*y_step + 9;
73 gfx_drawchar($'2');
74 gfx_drawchar($'5');
75 gfx_drawchar($'m');gfx_drawchar($'m');
76
77 gfx_x = 5*x_step - 7;
78 gfx_y = gfx_h - 3*y_step + 9;
79 gfx_drawchar($'5');
80 gfx_drawchar($'0');
81 gfx_drawchar($'m');gfx_drawchar($'m');
82
83 gfx_x = 7*x_step - 7;
84 gfx_y = gfx_h - 3*y_step + 9;
85 gfx_drawchar($'7');
86 gfx_drawchar($'5');
87 gfx_drawchar($'m');gfx_drawchar($'m');
88
89 gfx_x = 9*x_step - 12;
90 gfx_y = gfx_h - 3*y_step + 9;
91 gfx_drawchar($'1');
92 gfx_drawchar($'0');
93 gfx_drawchar($'0');
94 gfx_drawchar($'m');gfx_drawchar($'m');
95
96 i = 1;
97 loop(7, // x-axiis
98 y = i*y_step;
99 gfx_line(x_step-2, y, x_step*9, y, 0.5);
100 i += 1;
101 );
102
103 gfx_x = x_step - 38;
104 gfx_y = y_step - 6;
105 gfx_drawchar($'+');
106 gfx_drawchar($'1');
107 gfx_drawchar($'2');
108 gfx_drawchar($'d');
109 gfx_drawchar($'B');
110
111 gfx_x = x_step - 36;
112 gfx_y = 2*y_step - 7;
113 gfx_drawchar($'+');
114 gfx_drawchar($' ');
115 gfx_drawchar($'8');
116 gfx_drawchar($'d');
117 gfx_drawchar($'B');
118
119 gfx_x = x_step - 36;
120 gfx_y = 3*y_step - 7;
121 gfx_drawchar($'+');
122 gfx_drawchar($' ');
123 gfx_drawchar($'4');
124 gfx_drawchar($'d');
125 gfx_drawchar($'B');
126
127 gfx_x = x_step - 32;
128 gfx_y = 4*y_step - 7;
129 gfx_drawchar($' ');
130 gfx_drawchar($' ');
131 gfx_drawchar($'0');
132 gfx_drawchar($'d');
133 gfx_drawchar($'B');
134
135 gfx_x = x_step - 36;
136 gfx_y = 5*y_step - 7;
137 gfx_drawchar($'-');
138 gfx_drawchar($' ');
139 gfx_drawchar($'4');
140 gfx_drawchar($'d');
141 gfx_drawchar($'B');
142
143 gfx_x = x_step - 36;
144 gfx_y = 6*y_step - 7;
145 gfx_drawchar($'-');
146 gfx_drawchar($' ');
147 gfx_drawchar($'8');
148 gfx_drawchar($'d');
149 gfx_drawchar($'B');
150
151 gfx_x = x_step - 38;
152 gfx_y = 7*y_step - 7;
153 gfx_drawchar($'-');
154 gfx_drawchar($'1');
155 gfx_drawchar($'2');
156 gfx_drawchar($'d');
157 gfx_drawchar($'B');
158
159 gfx_r = gfx_g = 0.1;
160 gfx_b = 0.9;
161 dB = 20.01 * log10(m) + 12;
162 y = y_step*7 - y_step*dB/4;// + y_step;
163 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
164 gfx_rect(x_step+slider1/100*x_step*8, y_step+2, 1, y_step*6-2, 0.5);// vertical line
165 gfx_rect(x_step+slider1/100*x_step*8-3, y-2, 6, 6, 0.5); // hilite box
166 gfx_x = gfx_w*.9+8;
167 gfx_y = y-6;
168 sprintf(str, "%.1fdB", dB-12);
169 gfx_drawstr(str);
170 gfx_x = x_step+slider1/100*x_step*8-9;
171 gfx_y = y_step - 17;
172 sprintf(str, "%.1fmm", slider1);
173 gfx_drawstr(str);
174
175 gfx_g = 0.2;
176 gfx_b = gfx_r = 0.9;
177 RES = 100; // min = 8
178 x_step1 = x_step * 8/RES;
179
180 i = 1;
181 loop(RES, //8, // main curve
182 x = i*x_step1;
183
184 c=(i-1)/RES;
185 d = -12.0 * cos(c * $PI);
186 m1 = pow( 10, d / 20.0 );
187 dB = 20 * log10(m1);
188 dB += 12;
189 y = y_step*7 - y_step*dB/4;
190
191 c=(i)/RES;
192 d = -12.0 * cos(c * $PI);
193 m2 = pow( 10, d / 20.0 );
194 dB1 = 20 * log10(m2);
195 dB1 += 12;
196 y1 = y_step*7 - y_step*dB1/4;
197
198 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
199 i += 1;
200 );
201
202 gfx_setfont(1, "Arial", 12); // main title
203 gfx_r = gfx_g = gfx_b = 0.0;
204 gfx_x = x_step;
205 gfx_y = gfx_h - y_step - 7;
206 gfx_drawstr("Cos Knob: Gain (dB) - vs - Fader Travel (mm)");
207
208 // mouse
209 mouse_cap == 1 ? (
210 xx = mouse_x;
211 xx > gfx_w * 0.1 ? (
212 xx < gfx_w * 0.9 ? (
213 yy = mouse_y;
214 yy > gfx_h * 0.1 ? (
215 yy < gfx_h * 0.7 ? (
216 slider1 = 100 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1);
217 slider1 < 0.3 ? slider1 = floor(slider1);
218 slider1 > 99.7 ? slider1 = ceil(slider1);
219 slider1 = floor(slider1*10);
220 slider1 /= 10;
221 sliderchange(slider1);
222 slider_automate(slider1);
223 c = slider1 / 100.0;
224 d = -12.0 * cos(c * $PI);
225 m = pow( 10, d / 20.0 );
226 )
227 );
228 );
229 );
230 );
Knob, Linear [±12dB]
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 MERCHANT-
16 ABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
17 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.1 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Knob: Linear [±12dB], v1.0.1
29
30 slider1: 50 <0, 100, 0.1> Position [mm]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 1;
35
36 @slider
37 c = slider1 / 100.0;
38 m = 1.0 / (4.0 - (c * 6.0));
39 c > 0.5 ? m = ((c - 0.5) * 6.0) + 1.0;
40
41 @sample
42 spl0 *= m;
43 spl1 *= m;
44
Graphics...
46 @gfx 256 256
47 gfx_setfont(1, "Arial", 10);
48 gfx_a = 1;
49
50 gfx_r = gfx_g = gfx_b = 0.1;
51 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
52 gfx_line(0, 0, 0, gfx_h, 0.5);
53 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
54 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
55
56 x_step = gfx_w / 10;
57 y_step = gfx_h / 10;
58
59 i = 1;
60 loop(9, // y-axiis
61 x = i*x_step;
62 gfx_line(x, y_step, x, y_step*7, 0.5);
63 i += 1;
64 );
65
66 gfx_x = x_step - 2;
67 gfx_y = gfx_h - 3*y_step + 9;
68 gfx_drawchar($'0');
69 gfx_drawchar($'m');gfx_drawchar($'m');
70
71 gfx_x = 3*x_step - 7;
72 gfx_y = gfx_h - 3*y_step + 9;
73 gfx_drawchar($'2');
74 gfx_drawchar($'5');
75 gfx_drawchar($'m');gfx_drawchar($'m');
76
77 gfx_x = 5*x_step - 7;
78 gfx_y = gfx_h - 3*y_step + 9;
79 gfx_drawchar($'5');
80 gfx_drawchar($'0');
81 gfx_drawchar($'m');gfx_drawchar($'m');
82
83 gfx_x = 7*x_step - 7;
84 gfx_y = gfx_h - 3*y_step + 9;
85 gfx_drawchar($'7');
86 gfx_drawchar($'5');
87 gfx_drawchar($'m');gfx_drawchar($'m');
88
89 gfx_x = 9*x_step - 12;
90 gfx_y = gfx_h - 3*y_step + 9;
91 gfx_drawchar($'1');
92 gfx_drawchar($'0');
93 gfx_drawchar($'0');
94 gfx_drawchar($'m');gfx_drawchar($'m');
95
96 i = 1;
97 loop(7, // x-axiis
98 y = i*y_step;
99 gfx_line(x_step-2, y, x_step*9, y, 0.5);
100 i += 1;
101 );
102
103 gfx_x = x_step - 38;
104 gfx_y = y_step - 6;
105 gfx_drawchar($'+');
106 gfx_drawchar($'1');
107 gfx_drawchar($'2');
108 gfx_drawchar($'d');
109 gfx_drawchar($'B');
110
111 gfx_x = x_step - 36;
112 gfx_y = 2*y_step - 7;
113 gfx_drawchar($'+');
114 gfx_drawchar($' ');
115 gfx_drawchar($'8');
116 gfx_drawchar($'d');
117 gfx_drawchar($'B');
118
119 gfx_x = x_step - 36;
120 gfx_y = 3*y_step - 7;
121 gfx_drawchar($'+');
122 gfx_drawchar($' ');
123 gfx_drawchar($'4');
124 gfx_drawchar($'d');
125 gfx_drawchar($'B');
126
127 gfx_x = x_step - 32;
128 gfx_y = 4*y_step - 7;
129 gfx_drawchar($' ');
130 gfx_drawchar($' ');
131 gfx_drawchar($'0');
132 gfx_drawchar($'d');
133 gfx_drawchar($'B');
134
135 gfx_x = x_step - 36;
136 gfx_y = 5*y_step - 7;
137 gfx_drawchar($'-');
138 gfx_drawchar($' ');
139 gfx_drawchar($'4');
140 gfx_drawchar($'d');
141 gfx_drawchar($'B');
142
143 gfx_x = x_step - 36;
144 gfx_y = 6*y_step - 7;
145 gfx_drawchar($'-');
146 gfx_drawchar($' ');
147 gfx_drawchar($'8');
148 gfx_drawchar($'d');
149 gfx_drawchar($'B');
150
151 gfx_x = x_step - 38;
152 gfx_y = 7*y_step - 7;
153 gfx_drawchar($'-');
154 gfx_drawchar($'1');
155 gfx_drawchar($'2');
156 gfx_drawchar($'d');
157 gfx_drawchar($'B');
158
159 gfx_r = gfx_g = 0.1;
160 gfx_b = 0.9;
161 dB = 20.01 * log10(m) + 12;
162 y = y_step*7 - y_step*dB/4;// + y_step;
163 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
164 gfx_rect(x_step+slider1/100*x_step*8, y_step+2, 1, y_step*6-2, 0.5);// vertical line
165 gfx_rect(x_step+slider1/100*x_step*8-3, y-2, 6, 6, 0.5); // hilite box
166 gfx_x = gfx_w*.9+8;
167 gfx_y = y-6;
168 sprintf(str, "%.1fdB", dB-12);
169 gfx_drawstr(str);
170 gfx_x = x_step+slider1/100*x_step*8-9;
171 gfx_y = y_step - 17;
172 sprintf(str, "%.1fmm", slider1);
173 gfx_drawstr(str);
174
175 gfx_g = 0.2;
176 gfx_b = gfx_r = 0.9;
177 RES = 100; // min = 8
178 x_step1 = x_step * 8/RES;
179
180 i = 1;
181 loop(RES, //8, // main curve
182 x = i*x_step1;
183
184 c=(i-1)/RES;
185 m1 = 1.0 / (4.0 - (c * 6.0));
186 c > 0.5 ? m1 = ((c - 0.5) * 6.0) + 1.0;
187 dB = 20 * log10(m1);
188 dB += 12;
189 y = y_step*7 - y_step*dB/4;
190
191 c=(i)/RES;
192 m2 = 1.0 / (4.0 - (c * 6.0));
193 c > 0.5 ? m2 = ((c - 0.5) * 6.0) + 1.0;
194 dB1 = 20 * log10(m2);
195 dB1 += 12;
196 y1 = y_step*7 - y_step*dB1/4;
197
198 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
199 i += 1;
200 );
201
202 gfx_setfont(1, "Arial", 12); // main title
203 gfx_r = gfx_g = gfx_b = 0.0;
204 gfx_x = x_step;
205 gfx_y = gfx_h - y_step - 7;
206 gfx_drawstr("Linear Knob: Gain (dB) - vs - Fader Travel (mm)");
207
208 // mouse
209 mouse_cap == 1 ? (
210 xx = mouse_x;
211 xx > gfx_w * 0.1 ? (
212 xx < gfx_w * 0.9 ? (
213 yy = mouse_y;
214 yy > gfx_h * 0.1 ? (
215 yy < gfx_h * 0.7 ? (
216 slider1 = 100 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1);
217 slider1 < 0.3 ? slider1 = floor(slider1);
218 slider1 > 99.7 ? slider1 = ceil(slider1);
219 slider1 = floor(slider1*10);
220 slider1 /= 10;
221 sliderchange(slider1);
222 slider_automate(slider1);
223 c = slider1 / 100.0;
224 m = 1.0 / (4.0 - (c * 6.0));
225 c > 0.5 ? m = ((c - 0.5) * 6.0) + 1.0;
226 )
227 );
228 );
229 );
230 );
231
232
Knob, Narrow [±12dB]
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 MERCHANT-
16 ABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
17 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.1 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Knob: Narrow [±12dB], v1.0.1
29
30 slider1: 50 <0, 100, 0.1> Position [mm]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 1;
35
36 @slider
37 c = 2 * ((slider1 / 100.0) - 0.5); // -1 < c < 1
38 c < 0 ? (
39 d = sqrt(abs(c+1)) * 12 - 12
40 ) : (
41 d = sqrt(abs(c-1)) * -12 + 12
42 );
43 m = pow( 10, d / 20.0 );
44
45 @sample
46 spl0 *= m;
47 spl1 *= m;
48
Graphics...
50 @gfx 256 256
51 gfx_setfont(1, "Arial", 10);
52 gfx_a = 1;
53
54 gfx_r = gfx_g = gfx_b = 0.1;
55 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
56 gfx_line(0, 0, 0, gfx_h, 0.5);
57 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
58 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
59
60 x_step = gfx_w / 10;
61 y_step = gfx_h / 10;
62
63 i = 1;
64 loop(9, // y-axiis
65 x = i*x_step;
66 gfx_line(x, y_step, x, y_step*7, 0.5);
67 i += 1;
68 );
69
70 gfx_x = x_step - 2;
71 gfx_y = gfx_h - 3*y_step + 9;
72 gfx_drawchar($'0');
73 gfx_drawchar($'m');gfx_drawchar($'m');
74
75 gfx_x = 3*x_step - 7;
76 gfx_y = gfx_h - 3*y_step + 9;
77 gfx_drawchar($'2');
78 gfx_drawchar($'5');
79 gfx_drawchar($'m');gfx_drawchar($'m');
80
81 gfx_x = 5*x_step - 7;
82 gfx_y = gfx_h - 3*y_step + 9;
83 gfx_drawchar($'5');
84 gfx_drawchar($'0');
85 gfx_drawchar($'m');gfx_drawchar($'m');
86
87 gfx_x = 7*x_step - 7;
88 gfx_y = gfx_h - 3*y_step + 9;
89 gfx_drawchar($'7');
90 gfx_drawchar($'5');
91 gfx_drawchar($'m');gfx_drawchar($'m');
92
93 gfx_x = 9*x_step - 12;
94 gfx_y = gfx_h - 3*y_step + 9;
95 gfx_drawchar($'1');
96 gfx_drawchar($'0');
97 gfx_drawchar($'0');
98 gfx_drawchar($'m');gfx_drawchar($'m');
99
100 i = 1;
101 loop(7, // x-axiis
102 y = i*y_step;
103 gfx_line(x_step-2, y, x_step*9, y, 0.5);
104 i += 1;
105 );
106
107 gfx_x = x_step - 38;
108 gfx_y = y_step - 6;
109 gfx_drawchar($'+');
110 gfx_drawchar($'1');
111 gfx_drawchar($'2');
112 gfx_drawchar($'d');
113 gfx_drawchar($'B');
114
115 gfx_x = x_step - 36;
116 gfx_y = 2*y_step - 7;
117 gfx_drawchar($'+');
118 gfx_drawchar($' ');
119 gfx_drawchar($'8');
120 gfx_drawchar($'d');
121 gfx_drawchar($'B');
122
123 gfx_x = x_step - 36;
124 gfx_y = 3*y_step - 7;
125 gfx_drawchar($'+');
126 gfx_drawchar($' ');
127 gfx_drawchar($'4');
128 gfx_drawchar($'d');
129 gfx_drawchar($'B');
130
131 gfx_x = x_step - 32;
132 gfx_y = 4*y_step - 7;
133 gfx_drawchar($' ');
134 gfx_drawchar($' ');
135 gfx_drawchar($'0');
136 gfx_drawchar($'d');
137 gfx_drawchar($'B');
138
139 gfx_x = x_step - 36;
140 gfx_y = 5*y_step - 7;
141 gfx_drawchar($'-');
142 gfx_drawchar($' ');
143 gfx_drawchar($'4');
144 gfx_drawchar($'d');
145 gfx_drawchar($'B');
146
147 gfx_x = x_step - 36;
148 gfx_y = 6*y_step - 7;
149 gfx_drawchar($'-');
150 gfx_drawchar($' ');
151 gfx_drawchar($'8');
152 gfx_drawchar($'d');
153 gfx_drawchar($'B');
154
155 gfx_x = x_step - 38;
156 gfx_y = 7*y_step - 7;
157 gfx_drawchar($'-');
158 gfx_drawchar($'1');
159 gfx_drawchar($'2');
160 gfx_drawchar($'d');
161 gfx_drawchar($'B');
162
163 gfx_r = gfx_g = 0.1;
164 gfx_b = 0.9;
165 dB = 20.01 * log10(m) + 12;
166 y = y_step*7 - y_step*dB/4;// + y_step;
167 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
168 gfx_rect(x_step+slider1/100*x_step*8, y_step+2, 1, y_step*6-2, 0.5);// vertical line
169 gfx_rect(x_step+slider1/100*x_step*8-3, y-2, 6, 6, 0.5); // hilite box
170 gfx_x = gfx_w*.9+8;
171 gfx_y = y-6;
172 sprintf(str, "%.1fdB", dB-12);
173 gfx_drawstr(str);
174 gfx_x = x_step+slider1/100*x_step*8-9;
175 gfx_y = y_step - 17;
176 sprintf(str, "%.1fmm", slider1);
177 gfx_drawstr(str);
178
179 gfx_g = 0.2;
180 gfx_b = gfx_r = 0.9;
181 RES = 100; // min = 8
182 x_step1 = x_step * 8/RES;
183
184 i = 1;
185 loop(RES, //8, // main curve
186 x = i*x_step1;
187
188 c=(i-1)/RES;
189 d = 2 * ((c) - 0.5);
190 d < 0 ? (
191 dB = sqrt(abs(d+1)) * 12 - 12
192 ) : (
193 dB = sqrt(abs(d-1)) * -12 + 12
194 );
195 dB += 12;
196 y = y_step*7 - y_step*dB/4;
197
198 c=(i)/RES;
199 d = 2 * ((c) - 0.5);
200 d < 0 ? (
201 dB1 = sqrt(abs(d+1)) * 12 - 12
202 ) : (
203 dB1 = sqrt(abs(d-1)) * -12 + 12
204 );
205 dB1 += 12;
206 y1 = y_step*7 - y_step*dB1/4;
207
208 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
209 i += 1;
210 );
211
212 gfx_setfont(1, "Arial", 12); // main title
213 gfx_r = gfx_g = gfx_b = 0.0;
214 gfx_x = x_step;
215 gfx_y = gfx_h - y_step - 7;
216 gfx_drawstr("Narrow Knob: Gain (dB) - vs - Fader Travel (mm)");
217
218 // mouse
219 mouse_cap == 1 ? (
220 xx = mouse_x;
221 xx > gfx_w * 0.1 ? (
222 xx < gfx_w * 0.9 ? (
223 yy = mouse_y;
224 yy > gfx_h * 0.1 ? (
225 yy < gfx_h * 0.7 ? (
226 slider1 = 100 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1);
227 slider1 < 0.3 ? slider1 = floor(slider1);
228 slider1 > 99.7 ? slider1 = ceil(slider1);
229 slider1 = floor(slider1*10);
230 slider1 /= 10;
231 sliderchange(slider1);
232 slider_automate(slider1);
233 c = 2 * ((slider1 / 100.0) - 0.5); // -1 < c < 1
234 c < 0 ? (
235 d = sqrt(abs(c+1)) * 12 - 12
236 ) : (
237 d = sqrt(abs(c-1)) * -12 + 12
238 );
239 m = pow( 10, d / 20.0 );
240 )
241 );
242 );
243 );
244 );
Knob, Wide [±12dB]
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 MERCHANT-
16 ABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
17 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.1 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Knob: Wide [±12dB], v1.0.1
29
30 slider1: 50 <0, 100, 0.1> Position [mm]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 1;
35
36 @slider
37 c = 2 * ((slider1 / 100.0) - 0.5); // -1 < c < 1
38 d = sqrt(abs(c)) * 12;
39 c < 0 ? d *= -1;
40 m = pow( 10, d / 20.0 );
41
42 @sample
43 spl0 *= m;
44 spl1 *= m;
45
Graphics...
47 @gfx 256 256
48 gfx_setfont(1, "Arial", 10);
49 gfx_a = 1;
50
51 gfx_r = gfx_g = gfx_b = 0.1;
52 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
53 gfx_line(0, 0, 0, gfx_h, 0.5);
54 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
55 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
56
57 x_step = gfx_w / 10;
58 y_step = gfx_h / 10;
59
60 i = 1;
61 loop(9, // y-axiis
62 x = i*x_step;
63 gfx_line(x, y_step, x, y_step*7, 0.5);
64 i += 1;
65 );
66
67 gfx_x = x_step - 2;
68 gfx_y = gfx_h - 3*y_step + 9;
69 gfx_drawchar($'0');
70 gfx_drawchar($'m');gfx_drawchar($'m');
71
72 gfx_x = 3*x_step - 7;
73 gfx_y = gfx_h - 3*y_step + 9;
74 gfx_drawchar($'2');
75 gfx_drawchar($'5');
76 gfx_drawchar($'m');gfx_drawchar($'m');
77
78 gfx_x = 5*x_step - 7;
79 gfx_y = gfx_h - 3*y_step + 9;
80 gfx_drawchar($'5');
81 gfx_drawchar($'0');
82 gfx_drawchar($'m');gfx_drawchar($'m');
83
84 gfx_x = 7*x_step - 7;
85 gfx_y = gfx_h - 3*y_step + 9;
86 gfx_drawchar($'7');
87 gfx_drawchar($'5');
88 gfx_drawchar($'m');gfx_drawchar($'m');
89
90 gfx_x = 9*x_step - 12;
91 gfx_y = gfx_h - 3*y_step + 9;
92 gfx_drawchar($'1');
93 gfx_drawchar($'0');
94 gfx_drawchar($'0');
95 gfx_drawchar($'m');gfx_drawchar($'m');
96
97 i = 1;
98 loop(7, // x-axiis
99 y = i*y_step;
100 gfx_line(x_step-2, y, x_step*9, y, 0.5);
101 i += 1;
102 );
103
104 gfx_x = x_step - 38;
105 gfx_y = y_step - 6;
106 gfx_drawchar($'+');
107 gfx_drawchar($'1');
108 gfx_drawchar($'2');
109 gfx_drawchar($'d');
110 gfx_drawchar($'B');
111
112 gfx_x = x_step - 36;
113 gfx_y = 2*y_step - 7;
114 gfx_drawchar($'+');
115 gfx_drawchar($' ');
116 gfx_drawchar($'8');
117 gfx_drawchar($'d');
118 gfx_drawchar($'B');
119
120 gfx_x = x_step - 36;
121 gfx_y = 3*y_step - 7;
122 gfx_drawchar($'+');
123 gfx_drawchar($' ');
124 gfx_drawchar($'4');
125 gfx_drawchar($'d');
126 gfx_drawchar($'B');
127
128 gfx_x = x_step - 32;
129 gfx_y = 4*y_step - 7;
130 gfx_drawchar($' ');
131 gfx_drawchar($' ');
132 gfx_drawchar($'0');
133 gfx_drawchar($'d');
134 gfx_drawchar($'B');
135
136 gfx_x = x_step - 36;
137 gfx_y = 5*y_step - 7;
138 gfx_drawchar($'-');
139 gfx_drawchar($' ');
140 gfx_drawchar($'4');
141 gfx_drawchar($'d');
142 gfx_drawchar($'B');
143
144 gfx_x = x_step - 36;
145 gfx_y = 6*y_step - 7;
146 gfx_drawchar($'-');
147 gfx_drawchar($' ');
148 gfx_drawchar($'8');
149 gfx_drawchar($'d');
150 gfx_drawchar($'B');
151
152 gfx_x = x_step - 38;
153 gfx_y = 7*y_step - 7;
154 gfx_drawchar($'-');
155 gfx_drawchar($'1');
156 gfx_drawchar($'2');
157 gfx_drawchar($'d');
158 gfx_drawchar($'B');
159
160 gfx_r = gfx_g = 0.1;
161 gfx_b = 0.9;
162 dB = 20.01 * log10(m) + 12;
163 y = y_step*7 - y_step*dB/4;// + y_step;
164 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
165 gfx_rect(x_step+slider1/100*x_step*8, y_step+2, 1, y_step*6-2, 0.5);// vertical line
166 gfx_rect(x_step+slider1/100*x_step*8-3, y-2, 6, 6, 0.5); // hilite box
167 gfx_x = gfx_w*.9+8;
168 gfx_y = y-6;
169 sprintf(str, "%.1fdB", dB-12);
170 gfx_drawstr(str);
171 gfx_x = x_step+slider1/100*x_step*8-9;
172 gfx_y = y_step - 17;
173 sprintf(str, "%.1fmm", slider1);
174 gfx_drawstr(str);
175
176 gfx_g = 0.2;
177 gfx_b = gfx_r = 0.9;
178 RES = 100; // min = 8
179 x_step1 = x_step * 8/RES;
180
181 i = 1;
182 loop(RES, //8, // main curve
183 x = i*x_step1;
184
185 c=(i-1)/RES;
186 d = 2 * ((c) - 0.5);
187 dB = sqrt(abs(d)) * 12;
188 d < 0 ? dB *= -1;
189 dB += 12;
190 y = y_step*7 - y_step*dB/4;
191
192 c=(i)/RES;
193 d = 2 * ((c) - 0.5);
194 dB1 = sqrt(abs(d)) * 12;
195 d < 0 ? dB1 *= -1;
196 dB1 += 12;
197 y1 = y_step*7 - y_step*dB1/4;
198
199 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
200 i += 1;
201 );
202
203 gfx_setfont(1, "Arial", 12); // main title
204 gfx_r = gfx_g = gfx_b = 0.0;
205 gfx_x = x_step;
206 gfx_y = gfx_h - y_step - 7;
207 gfx_drawstr("Wide Knob: Gain (dB) - vs - Fader Travel (mm)");
208
209 // mouse
210 mouse_cap == 1 ? (
211 xx = mouse_x;
212 xx > gfx_w * 0.1 ? (
213 xx < gfx_w * 0.9 ? (
214 yy = mouse_y;
215 yy > gfx_h * 0.1 ? (
216 yy < gfx_h * 0.7 ? (
217 slider1 = 100 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1);
218 slider1 < 0.3 ? slider1 = floor(slider1);
219 slider1 > 99.7 ? slider1 = ceil(slider1);
220 slider1 = floor(slider1*10);
221 slider1 /= 10;
222 sliderchange(slider1);
223 slider_automate(slider1);
224 c = 2 * ((slider1 / 100.0) - 0.5); // -1 < c < 1
225 d = sqrt(abs(c)) * 12;
226 c < 0 ? d *= -1;
227 m = pow( 10, d / 20.0 );
228 )
229 );
230 );
231 );
232 );
Knob, LOG [±12dB]
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 MERCHANT-
16 ABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT. IN NO
17 EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM,
18 DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR
19 OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR
20 THE USE OR OTHER DEALINGS IN THE SOFTWARE.
21
22 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.1 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Knob: LOG [±12dB], v1.0.1
29
30 slider1: 50 <0, 100, 0.1> Position [mm]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 1;
35
36 @slider
37 c = slider1 / 100.0;
38 z = (c * 24) - 12; // -12 < z < 12
39 m = pow( 10, z / 20.0 );
40
41 @sample
42 spl0 *= m;
43 spl1 *= m;
44
Graphics...
46 @gfx 256 256
47 gfx_setfont(1, "Arial", 10);
48 gfx_a = 1;
49
50 gfx_r = gfx_g = gfx_b = 0.1;
51 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
52 gfx_line(0, 0, 0, gfx_h, 0.5);
53 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
54 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
55
56 x_step = gfx_w / 10;
57 y_step = gfx_h / 10;
58
59 i = 1;
60 loop(9, // y-axiis
61 x = i*x_step;
62 gfx_line(x, y_step, x, y_step*7, 0.5);
63 i += 1;
64 );
65
66 gfx_x = x_step - 2;
67 gfx_y = gfx_h - 3*y_step + 9;
68 gfx_drawchar($'0');
69 gfx_drawchar($'m');gfx_drawchar($'m');
70
71 gfx_x = 3*x_step - 7;
72 gfx_y = gfx_h - 3*y_step + 9;
73 gfx_drawchar($'2');
74 gfx_drawchar($'5');
75 gfx_drawchar($'m');gfx_drawchar($'m');
76
77 gfx_x = 5*x_step - 7;
78 gfx_y = gfx_h - 3*y_step + 9;
79 gfx_drawchar($'5');
80 gfx_drawchar($'0');
81 gfx_drawchar($'m');gfx_drawchar($'m');
82
83 gfx_x = 7*x_step - 7;
84 gfx_y = gfx_h - 3*y_step + 9;
85 gfx_drawchar($'7');
86 gfx_drawchar($'5');
87 gfx_drawchar($'m');gfx_drawchar($'m');
88
89 gfx_x = 9*x_step - 12;
90 gfx_y = gfx_h - 3*y_step + 9;
91 gfx_drawchar($'1');
92 gfx_drawchar($'0');
93 gfx_drawchar($'0');
94 gfx_drawchar($'m');gfx_drawchar($'m');
95
96 i = 1;
97 loop(7, // x-axiis
98 y = i*y_step;
99 gfx_line(x_step-2, y, x_step*9, y, 0.5);
100 i += 1;
101 );
102
103 gfx_x = x_step - 38;
104 gfx_y = y_step - 6;
105 gfx_drawchar($'+');
106 gfx_drawchar($'1');
107 gfx_drawchar($'2');
108 gfx_drawchar($'d');
109 gfx_drawchar($'B');
110
111 gfx_x = x_step - 36;
112 gfx_y = 2*y_step - 7;
113 gfx_drawchar($'+');
114 gfx_drawchar($' ');
115 gfx_drawchar($'8');
116 gfx_drawchar($'d');
117 gfx_drawchar($'B');
118
119 gfx_x = x_step - 36;
120 gfx_y = 3*y_step - 7;
121 gfx_drawchar($'+');
122 gfx_drawchar($' ');
123 gfx_drawchar($'4');
124 gfx_drawchar($'d');
125 gfx_drawchar($'B');
126
127 gfx_x = x_step - 32;
128 gfx_y = 4*y_step - 7;
129 gfx_drawchar($' ');
130 gfx_drawchar($' ');
131 gfx_drawchar($'0');
132 gfx_drawchar($'d');
133 gfx_drawchar($'B');
134
135 gfx_x = x_step - 36;
136 gfx_y = 5*y_step - 7;
137 gfx_drawchar($'-');
138 gfx_drawchar($' ');
139 gfx_drawchar($'4');
140 gfx_drawchar($'d');
141 gfx_drawchar($'B');
142
143 gfx_x = x_step - 36;
144 gfx_y = 6*y_step - 7;
145 gfx_drawchar($'-');
146 gfx_drawchar($' ');
147 gfx_drawchar($'8');
148 gfx_drawchar($'d');
149 gfx_drawchar($'B');
150
151 gfx_x = x_step - 38;
152 gfx_y = 7*y_step - 7;
153 gfx_drawchar($'-');
154 gfx_drawchar($'1');
155 gfx_drawchar($'2');
156 gfx_drawchar($'d');
157 gfx_drawchar($'B');
158
159 gfx_r = gfx_g = 0.1;
160 gfx_b = 0.9;
161 dB = 20.01 * log10(m) + 12;
162 y = y_step*7 - y_step*dB/4;// + y_step;
163 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
164 gfx_rect(x_step+slider1/100*x_step*8, y_step+2, 1, y_step*6-2, 0.5);// vertical line
165 gfx_rect(x_step+slider1/100*x_step*8-3, y-2, 6, 6, 0.5); // hilite box
166 gfx_x = gfx_w*.9+8;
167 gfx_y = y-6;
168 sprintf(str, "%.1fdB", dB-12);
169 gfx_drawstr(str);
170 gfx_x = x_step+slider1/100*x_step*8-9;
171 gfx_y = y_step - 17;
172 sprintf(str, "%.1fmm", slider1);
173 gfx_drawstr(str);
174
175 gfx_g = 0.2;
176 gfx_b = gfx_r = 0.9;
177 RES = 100; // min = 8
178 x_step1 = x_step * 8/RES;
179
180 i = 1;
181 loop(RES, //8, // main curve
182 x = i*x_step1;
183
184 c=(i-1)/RES;
185 dB = (c * 24);// - 12;
186 y = y_step*7 - y_step*dB/4;
187
188 c=(i)/RES;
189 dB1 = (c * 24);// - 12;
190 y1 = y_step*7 - y_step*dB1/4;
191
192 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
193 i += 1;
194 );
195
196 gfx_setfont(1, "Arial", 12); // main title
197 gfx_r = gfx_g = gfx_b = 0.0;
198 gfx_x = x_step;
199 gfx_y = gfx_h - y_step - 7;
200 gfx_drawstr("LOG Knob: Gain (dB) - vs - Fader Travel (mm)");
201
202 // mouse
203 mouse_cap == 1 ? (
204 xx = mouse_x;
205 xx > gfx_w * 0.1 ? (
206 xx < gfx_w * 0.9 ? (
207 yy = mouse_y;
208 yy > gfx_h * 0.1 ? (
209 yy < gfx_h * 0.7 ? (
210 slider1 = 100 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1);
211 slider1 < 0.3 ? slider1 = floor(slider1);
212 slider1 > 99.7 ? slider1 = ceil(slider1);
213 slider1 = floor(slider1*10);
214 slider1 /= 10;
215 sliderchange(slider1);
216 slider_automate(slider1);
217 c = slider1 / 100.0;
218 z = (c * 24) -12;
219 m = pow( 10, z / 20.0 );
220 )
221 );
222 );
223 );
224 );