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 CHANGE LOG:
23 v1.1.0 - added GUI
24 v1.0.0 - initial release
25
26 **********************************************************************/
27
Disclaimer...
28 desc:Pan: Linear [-6dB], v1.1.0
29
30 slider1:0<-120,120,0.1>Pan Angle [degrees]
31
32 @init
33 gfx_clear = 256*256*256-1;
34 m = 0.5;
35
36 @slider
37 m = (120 + slider1) / 240.0;
38
39 @sample
40 spl1 *= m;
41 x = 1.0 - m;
42 spl0 *= x;
43
Graphics...
45 @gfx 256 256
46 gfx_setfont(1, "Arial", 10);
47 gfx_a = 1;
48
49 gfx_r = gfx_g = gfx_b = 0.1;
50 gfx_line(0, 0, gfx_w, 0, 0.5); // outline our GUI box
51 gfx_line(0, 0, 0, gfx_h, 0.5);
52 gfx_line(gfx_w-1, 0, gfx_w-1, gfx_h, 0.5);
53 gfx_line(0, gfx_h-2, gfx_w, gfx_h-2, 0.5);
54
55 x_step = gfx_w / 10;
56 y_step = gfx_h / 10;
57
58 i = 1;
59 loop(9, // y-axiis
60 x = i*x_step;
61 gfx_line(x, y_step, x, y_step*7, 0.5);
62 i += 1;
63 );
64
65 gfx_x = x_step - 15;
66 gfx_y = gfx_h - 3*y_step + 9;
67 sprintf(str, "%.1f˚", -120);
68 gfx_drawstr(str);
69
70 gfx_x = 3*x_step - 11;
71 gfx_y = gfx_h - 3*y_step + 9;
72 sprintf(str, "%.1f˚", -60);
73 gfx_drawstr(str);
74
75 gfx_x = 5*x_step - 7;
76 gfx_y = gfx_h - 3*y_step + 9;
77 sprintf(str, "%.1f˚", 0);
78 gfx_drawstr(str);
79
80 gfx_x = 7*x_step - 11;
81 gfx_y = gfx_h - 3*y_step + 9;
82 sprintf(str, "+%.1f˚", 60);
83 gfx_drawstr(str);
84
85 gfx_x = 9*x_step - 15;
86 gfx_y = gfx_h - 3*y_step + 9;
87 sprintf(str, "+%.1f˚", 120);
88 gfx_drawstr(str);
89
90 i = 1;
91 loop(7, // x-axiis
92 y = i*y_step;
93 gfx_line(x_step-2, y, x_step*9, y, 0.5);
94 i += 1;
95 );
96
97 gfx_x = x_step - 32;
98 gfx_y = y_step - 6;
99 gfx_drawchar($' ');
100 gfx_drawchar($'0');
101 gfx_drawchar($' ');
102 gfx_drawchar($'d');
103 gfx_drawchar($'B');
104
105 gfx_x = x_step - 33;
106 gfx_y = 2*y_step - 7;
107 gfx_drawchar($'-');
108 gfx_drawchar($' ');
109 gfx_drawchar($'3');
110 gfx_drawchar($'d');
111 gfx_drawchar($'B');
112
113 gfx_x = x_step - 33;
114 gfx_y = 3*y_step - 7;
115 gfx_drawchar($'-');
116 gfx_drawchar($' ');
117 gfx_drawchar($'6');
118 gfx_drawchar($'d');
119 gfx_drawchar($'B');
120
121 gfx_x = x_step - 33;
122 gfx_y = 4*y_step - 7;
123 gfx_drawchar($'-');
124 gfx_drawchar($' ');
125 gfx_drawchar($'9');
126 gfx_drawchar($'d');
127 gfx_drawchar($'B');
128
129 gfx_x = x_step - 36;
130 gfx_y = 5*y_step - 7;
131 gfx_drawchar($'-');
132 gfx_drawchar($'1');
133 gfx_drawchar($'2');
134 gfx_drawchar($'d');
135 gfx_drawchar($'B');
136
137 gfx_x = x_step - 36;
138 gfx_y = 6*y_step - 7;
139 gfx_drawchar($'-');
140 gfx_drawchar($'1');
141 gfx_drawchar($'5');
142 gfx_drawchar($'d');
143 gfx_drawchar($'B');
144
145 gfx_x = x_step - 36;
146 gfx_y = 7*y_step - 7;
147 gfx_drawchar($'-');
148 gfx_drawchar($'1');
149 gfx_drawchar($'8');
150 gfx_drawchar($'d');
151 gfx_drawchar($'B');
152
153 pos = slider1 + 120;
154 gfx_r = gfx_g = 0.1;
155 gfx_b = 0.9;
156 dB = 20 * log10(m);
157 dB *= -1;
158 pos == 0 ? dB = 99.9;
159 m == 0 ? dB = 99.9;
160 y = y_step*dB/3 + y_step;
161 y > y_step*7 - 1 ? y = y_step*7 - 1;
162 gfx_rect(x_step+2, y, x_step*8-3, 2, 0.5); // horizontal line
163 gfx_rect(x_step+pos/240*x_step*8, y_step+2, 1, y_step*6-3, 0.5);// vertical line
164 gfx_rect(x_step+pos/240*x_step*8-3, y-2, 7, 6, 0.5); // hilite box
165 gfx_x = gfx_w*.9+8;
166 gfx_y = y-6;
167 sprintf(str, "%.1fdB", -dB);
168 gfx_drawstr(str);
169 gfx_x = x_step+pos/240*x_step*8-9;
170 gfx_y = y_step - 17;
171 sprintf(str, "%.1f˚", slider1);
172 gfx_drawstr(str);
173
174 gfx_g = 0.2;
175 gfx_b = gfx_r = 0.9;
176 RES = 100; // min = 8
177 x_step1 = x_step * 8/RES;
178
179 i = 1;
180 loop(RES, //8, // main curve
181 x = i*x_step1;
182
183 c=(240*(i-1)/RES)-120;
184 m1 = (120 + c) / 240.0;
185 dB1 = -20 * log10(m1);
186 dB1 > 18 ? dB1 = 18;
187 i == 1 ? dB1 = 18;
188 y = y_step*dB1/3 + y_step;
189
190 c=(240*(i)/RES)-120;
191 m2 = (120 + c) / 240.0;
192 dB2 = -20 * log10(m2);
193 dB2 > 18 ? dB2 = 18;
194 i == 1 ? dB2 = 18;
195 y1 = y_step*dB2 /3 + y_step;
196
197 gfx_line(x_step+x-x_step1, y, x_step+x, y1, 0.5);
198 i += 1;
199 );
200
201 gfx_setfont(1, "Arial", 12); // main title
202 gfx_r = gfx_g = gfx_b = 0.0;
203 gfx_x = x_step;
204 gfx_y = gfx_h - y_step - 7;
205 gfx_drawstr("Linear Pan: Gain (dB) - vs - Pan Angle (degrees)");
206
207 // mouse
208 mouse_cap == 1 ? (
209 xx = mouse_x;
210 xx > gfx_w * 0.1 ? (
211 xx < gfx_w * 0.9 ? (
212 yy = mouse_y;
213 yy > gfx_h * 0.1 ? (
214 yy < gfx_h * 0.7 ? (
215 slider1 = 240 * (xx - gfx_w*.1) / (gfx_w*.9 - gfx_w*.1) - 120;
216 // slider1 < 0.3 ? slider1 = floor(slider1);
217 // slider1 > 99.7 ? slider1 = ceil(slider1);
218 slider1 = floor(slider1*10);
219 slider1 /= 10;
220 sliderchange(slider1);
221 slider_automate(slider1);
222 m = (120 + slider1) / 240.0;
223 slider1 < -119 ? ( m = 0.0; slider1 = -120; );
224 slider1 > 119 ? ( m = 1.0; slider1 = 120; );
225 );
226 );
227 );
228 );
229 );
230
231