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