1
2 /*
3 * Diverse Bristol audio routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22
23 #include <fcntl.h>
24
25 #include "brighton.h"
26 #include "brightonMini.h"
27 #include "brightoninternals.h"
28
29 static int dxInit();
30 static int dxConfigure();
31 static int dxCallback(brightonWindow * , int, int, float);
32 static int dxMidiCallback(brightonWindow * , int, int, float);
33
34 extern guimain global;
35
36 #include "brightonKeys.h"
37
38 #define DX7
39
40 #ifdef DX7
41 #define BLUEPRINT "bitmaps/blueprints/dx7.xpm"
42 #else
43 #define BLUEPRINT "bitmaps/blueprints/dx.xpm"
44 #endif
45
46 #define OP_COUNT 6
47 #define FIRST_DEV 0
48 #define PARAM_COUNT 20
49 #define ALGOS_COUNT 29
50 #define MEM_COUNT 17
51 #define ACTIVE_DEVS (PARAM_COUNT * OP_COUNT + ALGOS_COUNT + FIRST_DEV)
52
53 #define DISPLAY_DEV (MEM_COUNT - 3)
54 #define DISPLAY_PANEL 7
55
56 #define OP_START FIRST_DEV
57 #define OP1_START FIRST_DEV
58 #define OP2_START (OP1_START + PARAM_COUNT)
59 #define OP3_START (OP2_START + PARAM_COUNT)
60 #define OP4_START (OP3_START + PARAM_COUNT)
61 #define OP5_START (OP4_START + PARAM_COUNT)
62 #define OP6_START (OP5_START + PARAM_COUNT)
63 #define ALGO_START (PARAM_COUNT * OP_COUNT + FIRST_DEV)
64 #define MEM_START ACTIVE_DEVS
65
66 #define OP_PANEL 0
67 #define ALGOS_PANEL OP_COUNT
68 #define MEM_PANEL (ALGOS_PANEL + 1)
69
70 #define KEY_PANEL 8
71
72 #define DEVICE_COUNT (ACTIVE_DEVS + MEM_COUNT)
73
74 /*
75 * This structure is for device definition. The structure is defined in
76 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
77 * include/brightoninternals.h
78 *
79 * typedef int (*brightonCallback)(int, float);
80 * typedef struct BrightonLocations {
81 * int device; 0=rotary, 1=scale, etc.
82 * float relx, rely; relative position with regards to 1000 by 1000 window
83 * float relw, relh; relative height.
84 * int from, to;
85 * brightonCallback callback; specific to this dev
86 * char *image; bitmap. If zero take a device default.
87 * int flags;
88 * } brightonLocations;
89 *
90 * This example is for a dxBristol type synth interface.
91 */
92 #define OP1XPM "bitmaps/images/op1.xpm"
93 #define OP2XPM "bitmaps/images/op2.xpm"
94 #define OP3XPM "bitmaps/images/op3.xpm"
95 #define OP4XPM "bitmaps/images/op4.xpm"
96 #define OP5XPM "bitmaps/images/op5.xpm"
97 #define OP6XPM "bitmaps/images/op6.xpm"
98
99 #define R1 150
100 #define R2 665
101
102 #define D3 90
103
104 #ifdef DX7
105 #define D1 123
106
107 #define C0 35
108 #define C1 (C0 + D1)
109 #define C2 (C1 + D1)
110 #define C3 (C2 + D1)
111 #define C4 (C3 + D1)
112 #define C5 (C4 + D1)
113 #define C6 (C5 + D1)
114 #define C7 (C6 + D1)
115 #else
116 #define D1 139
117
118 #define C0 35
119 #define C1 (C0 + D1)
120 #define C2 (C1 + D1)
121 #define C3 (C2 + D1)
122 #define C4 (C3 + D1)
123 #define C5 (C4 + D1)
124 #define C6 (C5 + D1)
125 #endif
126
127 #define S1 300
128 #define S2 40
129 #define S3 250
130
131 /*
132 * This needs to be changed for a 7 parameter envelope, A-L1-A-L2-D-S-R.
133 * Rework is non trivial, need to rework the env, which is ok, the GUI, also
134 * easy, but it requires extra operator parameters.
135 */
136 #ifdef DX7
137 static brightonLocations locations[PARAM_COUNT] = {
138 /* in gain */
139 {"", 0, C1, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
140 "bitmaps/knobs/alpharotary.xpm", 0},
141 /* tune */
142 {"", 0, C3, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
143 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOTCH},
144 /* transpose */
145 {"", 0, C4, R2, S1, S1, 0, 5, 0, "bitmaps/knobs/knobgreynew.xpm",
146 "bitmaps/knobs/alpharotary.xpm", 0},
147 /* out gain */
148 {"", 0, C2, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
149 "bitmaps/knobs/alpharotary.xpm", 0},
150
151 /* lfo */
152 {"", 2, C5, R2, S2, S3, 0, 1.01, 0,
153 "bitmaps/buttons/pressoffg.xpm",
154 "bitmaps/buttons/pressong.xpm", 0},
155
156 /* attack */
157 {"", 0, C1, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
158 "bitmaps/knobs/alpharotary.xpm", 0},
159 {"", 0, C5, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
160 "bitmaps/knobs/alpharotary.xpm", 0},
161 {"", 0, C6, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
162 "bitmaps/knobs/alpharotary.xpm", 0},
163 {"", 0, C7, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
164 "bitmaps/knobs/alpharotary.xpm", 0},
165
166 /* touch */
167 {"", 0, C0, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
168 "bitmaps/knobs/alpharotary.xpm", 0},
169 /* pan */
170 {"", 0, C7, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobyellownew.xpm",
171 "bitmaps/knobs/alpharotary.xpm",
172 BRIGHTON_NOTCH},
173
174 /* igc, ogc */
175 {"", 2, C5 + D3, R2, S2, S3, 0, 1.01, 0,
176 "bitmaps/buttons/pressoff.xpm",
177 "bitmaps/buttons/presson.xpm", 0},
178 {"", 2, C5 + D3 + D3, R2, S2, S3, 0, 1.01, 0,
179 "bitmaps/buttons/pressoff.xpm",
180 "bitmaps/buttons/presson.xpm", 0},
181
182 /* L1-A-L2 */
183 {"", 0, C2, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
184 "bitmaps/knobs/alpharotary.xpm", 0},
185 {"", 0, C3, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
186 "bitmaps/knobs/alpharotary.xpm", 0},
187 {"", 0, C4, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
188 "bitmaps/knobs/alpharotary.xpm", 0},
189 /* spares */
190 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
191 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
192 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
193
194 {"", 4, 0, 200, 140, 250, 0, 1, 0, OP1XPM, 0, 0}
195 };
196 #else
197 static brightonLocations locations[PARAM_COUNT] = {
198 /* in gain */
199 {"", 0, C0, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobred.xpm", 0, 0},
200 /* tune */
201 {"", 0, C2, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knoborange.xpm", 0, 0},
202 /* transpose */
203 {"", 0, C3, R1, S1, S1, 0, 5, 0, "bitmaps/knobs/knoborange.xpm", 0, 0},
204 /* out gain */
205 {"", 0, C6, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobred.xpm", 0, 0},
206
207 /* lfo */
208 {"", 2, C4, R1, S2, S3, 0, 1.01, 0,
209 "bitmaps/buttons/pressoffg.xpm",
210 "bitmaps/buttons/pressong.xpm", 0},
211
212 /* attack */
213 {"", 0, C2, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobblue.xpm", 0, 0},
214 {"", 0, C3, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobblue.xpm", 0, 0},
215 {"", 0, C4, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobblue.xpm", 0, 0},
216 {"", 0, C5, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knobblue.xpm", 0, 0},
217
218 /* touch */
219 {"", 0, C1, R2, S1, S1, 0, 1, 0, 0, 0, 0},
220 /* pan */
221 {"", 0, C6, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knobyellow.xpm", 0, 0},
222
223 /* igc, ogc */
224 {"", 2, C4 + D3, R1, S2, S3, 0, 1.01, 0,
225 "bitmaps/buttons/pressoff.xpm",
226 "bitmaps/buttons/presson.xpm", 0},
227 {"", 2, C4 + D3 + D3, R1, S2, S3, 0, 1.01, 0,
228 "bitmaps/buttons/pressoff.xpm",
229 "bitmaps/buttons/presson.xpm", 0},
230
231 /* spares */
232 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
233 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
234 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
235 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
236 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
237 {"", -1, C6, R1, S1, S1, 0, 1, 0, 0, 0, 0},
238
239 {"", 4, 60, 100, 150, 300, 0, 1, 0, OP1XPM, 0, 0}
240 };
241 #endif
242
243 #define D2 50
244
245 #define S4 45
246 #define S5 250
247
248 #define AR1 150
249 #define AR2 425
250 #define AR3 700
251
252 #define AC0 50
253 #define AC1 (AC0 + D2)
254 #define AC2 (AC1 + D2)
255 #define AC3 (AC2 + D2)
256 #define AC4 (AC3 + D2)
257 #define AC5 (AC4 + D2)
258 #define AC6 (AC5 + D2)
259 #define AC7 (AC6 + D2)
260 #define AC8 (AC7 + D2 + 253)
261 #define AC9 (AC8 + D2 + 142)
262 #define AC10 (AC9 + D2 + 10)
263
264 static brightonLocations algopanel[ALGOS_COUNT] = {
265 {"", 2, AC0, AR1, S4, S5, 0, 1, 0,
266 "bitmaps/buttons/pressoff.xpm",
267 "bitmaps/buttons/presson.xpm", 0},
268 {"", 2, AC1, AR1, S4, S5, 0, 1, 0,
269 "bitmaps/buttons/pressoff.xpm",
270 "bitmaps/buttons/presson.xpm", 0},
271 {"", 2, AC2, AR1, S4, S5, 0, 1, 0,
272 "bitmaps/buttons/pressoff.xpm",
273 "bitmaps/buttons/presson.xpm", 0},
274 {"", 2, AC3, AR1, S4, S5, 0, 1, 0,
275 "bitmaps/buttons/pressoff.xpm",
276 "bitmaps/buttons/presson.xpm", 0},
277 {"", 2, AC4, AR1, S4, S5, 0, 1, 0,
278 "bitmaps/buttons/pressoff.xpm",
279 "bitmaps/buttons/presson.xpm", 0},
280 {"", 2, AC5, AR1, S4, S5, 0, 1, 0,
281 "bitmaps/buttons/pressoff.xpm",
282 "bitmaps/buttons/presson.xpm", 0},
283 {"", 2, AC6, AR1, S4, S5, 0, 1, 0,
284 "bitmaps/buttons/pressoff.xpm",
285 "bitmaps/buttons/presson.xpm", 0},
286 {"", 2, AC7, AR1, S4, S5, 0, 1, 0,
287 "bitmaps/buttons/pressoff.xpm",
288 "bitmaps/buttons/presson.xpm", 0},
289 {"", 2, AC0, AR2, S4, S5, 0, 1, 0,
290 "bitmaps/buttons/pressoff.xpm",
291 "bitmaps/buttons/presson.xpm", 0},
292 {"", 2, AC1, AR2, S4, S5, 0, 1, 0,
293 "bitmaps/buttons/pressoff.xpm",
294 "bitmaps/buttons/presson.xpm", 0},
295 {"", 2, AC2, AR2, S4, S5, 0, 1, 0,
296 "bitmaps/buttons/pressoff.xpm",
297 "bitmaps/buttons/presson.xpm", 0},
298 {"", 2, AC3, AR2, S4, S5, 0, 1, 0,
299 "bitmaps/buttons/pressoff.xpm",
300 "bitmaps/buttons/presson.xpm", 0},
301 {"", 2, AC4, AR2, S4, S5, 0, 1, 0,
302 "bitmaps/buttons/pressoff.xpm",
303 "bitmaps/buttons/presson.xpm", 0},
304 {"", 2, AC5, AR2, S4, S5, 0, 1, 0,
305 "bitmaps/buttons/pressoff.xpm",
306 "bitmaps/buttons/presson.xpm", 0},
307 {"", 2, AC6, AR2, S4, S5, 0, 1, 0,
308 "bitmaps/buttons/pressoff.xpm",
309 "bitmaps/buttons/presson.xpm", 0},
310 {"", 2, AC7, AR2, S4, S5, 0, 1, 0,
311 "bitmaps/buttons/pressoff.xpm",
312 "bitmaps/buttons/presson.xpm", 0},
313 {"", 2, AC0, AR3, S4, S5, 0, 1, 0,
314 "bitmaps/buttons/pressoff.xpm",
315 "bitmaps/buttons/presson.xpm", 0},
316 {"", 2, AC1, AR3, S4, S5, 0, 1, 0,
317 "bitmaps/buttons/pressoff.xpm",
318 "bitmaps/buttons/presson.xpm", 0},
319 {"", 2, AC2, AR3, S4, S5, 0, 1, 0,
320 "bitmaps/buttons/pressoff.xpm",
321 "bitmaps/buttons/presson.xpm", 0},
322 {"", 2, AC3, AR3, S4, S5, 0, 1, 0,
323 "bitmaps/buttons/pressoff.xpm",
324 "bitmaps/buttons/presson.xpm", 0},
325 {"", 2, AC4, AR3, S4, S5, 0, 1, 0,
326 "bitmaps/buttons/pressoff.xpm",
327 "bitmaps/buttons/presson.xpm", 0},
328 {"", 2, AC5, AR3, S4, S5, 0, 1, 0,
329 "bitmaps/buttons/pressoff.xpm",
330 "bitmaps/buttons/presson.xpm", 0},
331 {"", 2, AC6, AR3, S4, S5, 0, 1, 0,
332 "bitmaps/buttons/pressoff.xpm",
333 "bitmaps/buttons/presson.xpm", 0},
334 {"", 2, AC7, AR3, S4, S5, 0, 1, 0,
335 "bitmaps/buttons/pressoff.xpm",
336 "bitmaps/buttons/presson.xpm", 0},
337 {"", 0, AC8, R1, S1 + 10, S1 + 10, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
338 "bitmaps/knobs/alpharotary.xpm", 0},
339 {"", 0, AC8, R2, S1 + 10, S1 + 10, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
340 "bitmaps/knobs/alpharotary.xpm", 0},
341 /* Volume */
342 {"", 0, AC9 - 20, R2, S1 + 10, S1 + 10, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
343 "bitmaps/knobs/alpharotary.xpm", 0},
344 {"", 2, AC9, R1 + 40, S4, S5, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
345 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
346 {"", 4, AC7 + 90, AR1, 190, 800, 0, 1, 0, 0, 0, 0},
347 };
348
349 #define MS1 75
350 #define MS2 200
351
352 #define MD1 210
353 #define MD2 80
354
355 #define MR0 100
356 #define MR1 (MR0 + MD1)
357 #define MR2 (MR1 + MD1)
358 #define MR3 (MR2 + MD1)
359
360 #define MC0 500
361 #define MC1 (MC0 + MD2)
362 #define MC2 (MC1 + MD2)
363
364 static brightonLocations mempanel[MEM_COUNT] = {
365 /* Memory buttons from 0 */
366 {"", 2, MC1, MR3, MS1, MS2, 0, 1, 0,
367 "bitmaps/buttons/touchnlw.xpm",
368 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
369 /* from 1 */
370 {"", 2, MC0, MR0, MS1, MS2, 0, 1, 0,
371 "bitmaps/buttons/touchnlw.xpm",
372 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
373 {"", 2, MC1, MR0, MS1, MS2, 0, 1, 0,
374 "bitmaps/buttons/touchnlw.xpm",
375 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
376 {"", 2, MC2, MR0, MS1, MS2, 0, 1, 0,
377 "bitmaps/buttons/touchnlw.xpm",
378 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
379 /* from 4 */
380 {"", 2, MC0, MR1, MS1, MS2, 0, 1, 0,
381 "bitmaps/buttons/touchnlw.xpm",
382 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
383 {"", 2, MC1, MR1, MS1, MS2, 0, 1, 0,
384 "bitmaps/buttons/touchnlw.xpm",
385 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
386 {"", 2, MC2, MR1, MS1, MS2, 0, 1, 0,
387 "bitmaps/buttons/touchnlw.xpm",
388 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
389 /* from 7 */
390 {"", 2, MC0, MR2, MS1, MS2, 0, 1, 0,
391 "bitmaps/buttons/touchnlw.xpm",
392 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
393 {"", 2, MC1, MR2, MS1, MS2, 0, 1, 0,
394 "bitmaps/buttons/touchnlw.xpm",
395 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
396 {"", 2, MC2, MR2, MS1, MS2, 0, 1, 0,
397 "bitmaps/buttons/touchnlw.xpm",
398 "bitmaps/buttons/touchnlw.xpm", BRIGHTON_CHECKBUTTON},
399
400 /* load save */
401 {"", 2, 290, MR3, 45, MS2, 0, 1, 0,
402 "bitmaps/buttons/pressoffg.xpm",
403 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
404 {"", 2, 410, MR3, 45, MS2, 0, 1, 0,
405 "bitmaps/buttons/pressoffo.xpm",
406 "bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
407
408 /* midi up/down */
409 {"", 2, 60, MR3, 45, MS2, 0, 1, 0,
410 "bitmaps/buttons/pressoff.xpm",
411 "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
412 {"", 2, 175, MR3, 45, MS2, 0, 1, 0,
413 "bitmaps/buttons/pressoff.xpm",
414 "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
415
416 {"", 3, 15, 100, 485, 310, 0, 1, 0, 0,
417 "bitmaps/images/alphadisplay3.xpm", 0},
418
419 /* up/down */
420 {"", 2, MC0, MR3, MS1, MS2, 0, 1, 0,
421 "bitmaps/buttons/touchnl.xpm",
422 "bitmaps/buttons/touchnl.xpm", BRIGHTON_CHECKBUTTON},
423 {"", 2, MC2, MR3, MS1, MS2, 0, 1, 0,
424 "bitmaps/buttons/touchnl.xpm",
425 "bitmaps/buttons/touchnl.xpm", BRIGHTON_CHECKBUTTON},
426 };
427
428 /*
429 * This is a set of globals for the main window rendering. Again taken from
430 * include/brighton.h
431 */
432 brightonApp dxApp = {
433 "dx",
434 0, /* no blueprint on wood background. */
435 "bitmaps/textures/metal6.xpm",
436 BRIGHTON_STRETCH,
437 dxInit,
438 dxConfigure, /* 3 callbacks, unused? */
439 dxMidiCallback,
440 destroySynth,
441 {8, 0, 2, 2, 5, 520, 0, 0},
442 820, 300, 0, 0,
443 15, /* one panel only */
444 {
445 {
446 "DX",
447 BLUEPRINT,
448 "bitmaps/textures/metal5.xpm",
449 0, /* flags */
450 0,
451 0,
452 dxCallback,
453 20, 15, 310, 230,
454 PARAM_COUNT,
455 locations
456 },
457 {
458 "DX",
459 BLUEPRINT,
460 "bitmaps/textures/metal5.xpm",
461 0, /* flags */
462 0,
463 0,
464 dxCallback,
465 345, 15, 310, 230,
466 PARAM_COUNT,
467 0
468 },
469 {
470 "DX",
471 BLUEPRINT,
472 "bitmaps/textures/metal5.xpm",
473 0, /* flags */
474 0,
475 0,
476 dxCallback,
477 666, 15, 310, 230,
478 PARAM_COUNT,
479 locations
480 },
481 {
482 "DX",
483 BLUEPRINT,
484 "bitmaps/textures/metal5.xpm",
485 0, /* flags */
486 0,
487 0,
488 dxCallback,
489 20, 254, 310, 230,
490 PARAM_COUNT,
491 locations
492 },
493 {
494 "DX",
495 BLUEPRINT,
496 "bitmaps/textures/metal5.xpm",
497 0, /* flags */
498 0,
499 0,
500 dxCallback,
501 345, 254, 310, 230,
502 PARAM_COUNT,
503 locations
504 },
505 {
506 "DX",
507 BLUEPRINT,
508 "bitmaps/textures/metal5.xpm",
509 0, /* flags */
510 0,
511 0,
512 dxCallback,
513 666, 254, 310, 230,
514 PARAM_COUNT,
515 locations
516 },
517 {
518 "DX",
519 "bitmaps/blueprints/dxalgo.xpm",
520 "bitmaps/textures/metal5.xpm",
521 0, /* flags */
522 0,
523 0,
524 dxCallback,
525 20, 508, 310, 220,
526 ALGOS_COUNT,
527 algopanel
528 },
529 {
530 "DX",
531 "bitmaps/blueprints/dxmem.xpm",
532 "bitmaps/textures/metal5.xpm",
533 0, /* flags */
534 0,
535 0,
536 dxCallback,
537 666, 508, 310, 220,
538 MEM_COUNT,
539 mempanel
540 },
541 {
542 "Keyboard",
543 0,
544 "bitmaps/newkeys/dkbg.xpm", /* flags */
545 0x020|BRIGHTON_STRETCH,
546 0,
547 0,
548 keyCallback,
549 110, 735, 870, 260,
550 KEY_COUNT_6_OCTAVE,
551 keys6octave
552 },
553 {
554 "Mods",
555 "bitmaps/blueprints/mods.xpm",
556 "bitmaps/textures/metal5.xpm",
557 0,
558 0,
559 0,
560 modCallback,
561 19, 745, 90, 230,
562 2,
563 mods
564 },
565 /* Wood rim */
566 {
567 "Wood",
568 0,
569 "bitmaps/textures/wood2.xpm",
570 0,
571 0,
572 0,
573 0,
574 0, 0, 15, 1000,
575 0,
576 0
577 },
578 {
579 "Wood",
580 0,
581 "bitmaps/textures/wood2.xpm",
582 0,
583 0,
584 0,
585 0,
586 985, 0, 15, 1000,
587 0,
588 0
589 },
590 {
591 "Wood",
592 0,
593 "bitmaps/textures/wood.xpm",
594 0,
595 0,
596 0,
597 0,
598 2, 495, 13, 490,
599 0,
600 0
601 },
602 {
603 "Wood",
604 0,
605 "bitmaps/textures/wood.xpm",
606 0,
607 0,
608 0,
609 0,
610 986, 495, 13, 490,
611 0,
612 0
613 },
614 {
615 "Envelope",
616 0,
617 "bitmaps/textures/metal5.xpm",
618 0, /* flags */
619 0,
620 0,
621 0,
622 330, 508, 337, 223,
623 0,
624 0
625 },
626 }
627 };
628
629 /*static dispatcher dispatch[DEVICE_COUNT]; */
630
631 static int
dxMidiSendMsg(void * synth,int fd,int chan,int c,int o,int v)632 dxMidiSendMsg(void *synth, int fd, int chan, int c, int o, int v)
633 {
634 /*printf("%i, %i, %i\n", c, o, v); */
635 bristolMidiSendMsg(fd, chan, c, o, v);
636 return(0);
637 }
638
639 int
dxLoadMem(guiSynth * synth,char * algo,char * name,int location,int active,int skip,int flags)640 dxLoadMem(guiSynth *synth, char *algo, char *name, int location, int active,
641 int skip, int flags)
642 {
643 brightonEvent event;
644 int op;
645 float mo, fmop[OP_COUNT][2];
646
647 /*
648 * See if the memory actually exists. This is a bit of file system overhead
649 * but prevents attempting to load non-existant memories
650 */
651 op = loadMemory(synth, algo, name, location, active, skip, BRISTOL_STAT);
652
653 if (flags == 2)
654 return(op);
655
656 if (op < 0)
657 return(op);
658
659 event.type = BRIGHTON_FLOAT;
660 event.value = 0.0;
661
662 /*
663 * Zero out diverse gain functions to prevent a noisy transition.
664 * What happens is that as the parameters change and the algorithm alters
665 * we get a LOT of FM noise. We can dump this by zeroing the output
666 * parameters. We have to be careful, since if the memory does not load,
667 * for example it does not exist, then we have to reset the parameters
668 * afterwards.
669 *
670 * Start with main out.
671 */
672 mo = synth->mem.param[OP_COUNT * PARAM_COUNT + 26];
673 brightonParamChange(synth->win, ALGOS_PANEL, 26, &event);
674
675 for (op = 0; op < 6; op++)
676 {
677 /*
678 * Output gain
679 */
680 fmop[op][0] = synth->mem.param[op * PARAM_COUNT];
681 brightonParamChange(synth->win, op, 0, &event);
682 /*
683 * Input gain
684 */
685 fmop[op][1] = synth->mem.param[op * PARAM_COUNT + 3];
686 brightonParamChange(synth->win, op, 3, &event);
687 }
688
689 if (loadMemory(synth, algo, name, location, active, skip, flags) == 0)
690 return(0);
691
692 /*
693 * Load failed, return the gain parameters to their previous values.
694 */
695 event.value = mo;
696 brightonParamChange(synth->win, ALGOS_PANEL, 26, &event);
697
698 for (op = 0; op < 6; op++)
699 {
700 /*
701 * Output gain
702 */
703 event.value = fmop[op][0];
704 brightonParamChange(synth->win, op, 0, &event);
705 /*
706 * Input gain
707 */
708 event.value = fmop[op][1];
709 brightonParamChange(synth->win, op, 3, &event);
710 }
711 return(-1);
712 }
713
714 static int
dxMidiCallback(brightonWindow * win,int command,int value,float v)715 dxMidiCallback(brightonWindow *win, int command, int value, float v)
716 {
717 guiSynth *synth = findSynth(global.synths, win);
718
719 printf("midi callback: %x, %i\n", command, value);
720
721 switch(command)
722 {
723 case MIDI_PROGRAM:
724 printf("midi program: %x, %i\n", command, value);
725 synth->location = value;
726 dxLoadMem(synth, "dx", 0, synth->location,
727 synth->mem.active, FIRST_DEV, 0);
728 break;
729 case MIDI_BANK_SELECT:
730 printf("midi banksel: %x, %i\n", command, value);
731 synth->bank = value;
732 break;
733 }
734 return(0);
735 }
736
737 static void
dxMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)738 dxMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
739 {
740 switch (c) {
741 default:
742 case 0:
743 synth->location = synth->location * 10 + o;
744
745 if (synth->location >= 1000)
746 synth->location = o;
747 if (dxLoadMem(synth, "dx", 0, synth->location,
748 synth->mem.active, FIRST_DEV, BRISTOL_STAT) < 0)
749 displayPanelText(synth, "FRE", synth->location,
750 DISPLAY_PANEL, DISPLAY_DEV);
751 else
752 displayPanelText(synth, "PRG", synth->location,
753 DISPLAY_PANEL, DISPLAY_DEV);
754 break;
755 case 1:
756 if (dxLoadMem(synth, "dx", 0, synth->location,
757 synth->mem.active, FIRST_DEV, 0) < 0)
758 displayPanelText(synth, "FRE", synth->location,
759 DISPLAY_PANEL, DISPLAY_DEV);
760 else
761 displayPanelText(synth, "PRG", synth->location,
762 DISPLAY_PANEL, DISPLAY_DEV);
763 break;
764 case 2:
765 saveMemory(synth, "dx", 0, synth->location, FIRST_DEV);
766 displayPanelText(synth, "PRG", synth->location,
767 DISPLAY_PANEL, DISPLAY_DEV);
768 break;
769 case 3:
770 while (dxLoadMem(synth, "dx", 0, --synth->location,
771 synth->mem.active, FIRST_DEV, 0) < 0)
772 {
773 if (synth->location < 0)
774 synth->location = 999;
775 }
776 displayPanelText(synth, "PRG", synth->location,
777 DISPLAY_PANEL, DISPLAY_DEV);
778 break;
779 case 4:
780 while (dxLoadMem(synth, "dx", 0, ++synth->location,
781 synth->mem.active, FIRST_DEV, 0) < 0)
782 {
783 if (synth->location > 999)
784 synth->location = -1;
785 }
786 displayPanelText(synth, "PRG", synth->location,
787 DISPLAY_PANEL, DISPLAY_DEV);
788 break;
789 }
790 }
791
792 static int
dxMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)793 dxMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
794 {
795 int newchan;
796
797 if ((synth->flags & OPERATIONAL) == 0)
798 return(0);
799
800 if (c == 1) {
801 if ((newchan = synth->midichannel - 1) < 0)
802 {
803 synth->midichannel = 0;
804 return(0);
805 }
806 } else {
807 if ((newchan = synth->midichannel + 1) >= 16)
808 {
809 synth->midichannel = 15;
810 return(0);
811 }
812 }
813
814 if (global.libtest == 0)
815 bristolMidiSendMsg(global.controlfd, synth->sid,
816 127, 0, BRISTOL_MIDICHANNEL|newchan);
817
818 synth->midichannel = newchan;
819
820 displayPanelText(synth, "MIDI", synth->midichannel + 1,
821 DISPLAY_PANEL, DISPLAY_DEV);
822
823 return(0);
824 }
825
826 /*
827 * For the sake of ease of use, links have been placed here to be called
828 * by any of the devices created. They would be better in some other file,
829 * perhaps with this as a dispatch.
830 *
831 * Param refers to the device index in the locations table given below.
832 */
833 static int
dxCallback(brightonWindow * win,int panel,int index,float value)834 dxCallback(brightonWindow * win, int panel, int index, float value)
835 {
836 guiSynth *synth = findSynth(global.synths, win);
837 int sendvalue;
838
839 if (synth == 0)
840 return(0);
841
842 if (dxApp.resources[panel].devlocn[index].to == 1)
843 sendvalue = value * C_RANGE_MIN_1;
844 else
845 sendvalue = value;
846
847 switch (panel) {
848 case OP_PANEL:
849 case OP_PANEL + 1:
850 case OP_PANEL + 2:
851 case OP_PANEL + 3:
852 case OP_PANEL + 4:
853 case OP_PANEL + 5:
854 index += panel * PARAM_COUNT;
855 break;
856 case ALGOS_PANEL:
857 index += ALGO_START;
858 break;
859 case MEM_PANEL:
860 index += MEM_START;
861 break;
862 default:
863 printf("unknown panel\n");
864 break;
865 }
866
867 if ((synth->flags & OPERATIONAL) == 0)
868 return(0);
869
870 /* printf("dxCallback(%i, %f): %x\n", index, value, synth); */
871
872 synth->mem.param[index] = value;
873
874 synth->dispatch[index].routine(synth,
875 global.controlfd, synth->sid,
876 synth->dispatch[index].controller,
877 synth->dispatch[index].operator,
878 sendvalue);
879 #ifdef DEBUG
880 else
881 printf("dispatch[%x,%i](%i, %i, %i, %i, %i)\n", (size_t) synth, index,
882 global.controlfd, synth->sid,
883 synth->dispatch[index].controller,
884 synth->dispatch[index].operator,
885 sendvalue);
886 #endif
887
888 return(0);
889 }
890
891 static void
dxAlgo(guiSynth * synth,int fd,int chan,int c,int o,int v)892 dxAlgo(guiSynth *synth, int fd, int chan, int c, int o, int v)
893 {
894 brightonEvent event;
895
896 /* printf("dxAlgo(%x, %i, %i, %i, %i, %i): %i\n", */
897 /* synth, fd, chan, c, o, v, synth->mem.param[v - 1]); */
898
899 /*
900 * These will be radio buttons
901 */
902 if (synth->dispatch[ALGO_START].other2)
903 {
904 synth->dispatch[ALGO_START].other2 = 0;
905 return;
906 }
907
908 if (v == 0)
909 return;
910
911 if (synth->dispatch[ALGO_START].other1 >= 0)
912 {
913 synth->dispatch[ALGO_START].other2 = 1;
914
915 if (synth->dispatch[ALGO_START].other1 != o)
916 event.value = 0;
917 else
918 event.value = 1;
919
920 /*printf("other one is %i\n", synth->dispatch[ALGO_START].other1); */
921 brightonParamChange(synth->win, ALGOS_PANEL,
922 synth->dispatch[ALGO_START].other1, &event);
923 }
924
925 if (v != 0)
926 {
927 char bitmap[128];
928
929 event.type = BRIGHTON_MEM;
930
931 sprintf(bitmap, "bitmaps/images/algo%i.xpm", o);
932 event.m = bitmap;
933
934 /*printf("%i %i: RECONFIGURING BITMAP\n", v, synth->mem.param[ALGO_START + o]); */
935 brightonParamChange(synth->win,
936 ALGOS_PANEL, ALGOS_COUNT - 1, &event);
937 }
938
939 bristolMidiSendMsg(global.controlfd, synth->sid,
940 126, 101, o);
941
942 synth->dispatch[ALGO_START].other1 = o;
943 }
944
945 static void
dxTune(guiSynth * synth)946 dxTune(guiSynth *synth)
947 {
948 brightonEvent event;
949
950 printf("dxTune(%p, %i, %i)\n", synth->win, OP_PANEL, OP1_START);
951
952 event.value = 0.5;
953 brightonParamChange(synth->win, 0, 1, &event);
954 brightonParamChange(synth->win, 1, 1, &event);
955 brightonParamChange(synth->win, 2, 1, &event);
956 brightonParamChange(synth->win, 3, 1, &event);
957 brightonParamChange(synth->win, 4, 1, &event);
958 brightonParamChange(synth->win, 5, 1, &event);
959 }
960
961 /*
962 * Any location initialisation required to run the callbacks. For bristol, this
963 * will connect to the engine, and give it some base parameters.
964 * May need to generate some application specific menus.
965 * Will also then make specific requests to some of the devices to alter their
966 * rendering.
967 */
968 static int
dxInit(brightonWindow * win)969 dxInit(brightonWindow *win)
970 {
971 guiSynth *synth = findSynth(global.synths, win);
972 dispatcher *dispatch;
973 int i;
974 /*
975 brightonEvent event;
976 char bitmap[128];
977
978 event.type = BRIGHTON_MEM;
979 event.m = OP2XPM;
980 brightonParamChange(synth->win,
981 ALGOS_PANEL, ALGOS_COUNT - 1, &event);
982 */
983
984 if (synth == 0)
985 {
986 synth = findSynth(global.synths, 0);
987 if (synth == 0)
988 {
989 printf("cannot init\n");
990 return(0);
991 }
992 }
993
994 synth->win = win;
995
996 printf("Initialise the dx link to bristol: %p\n", synth->win);
997
998 synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
999 synth->mem.count = DEVICE_COUNT;
1000 synth->mem.active = ACTIVE_DEVS;
1001 synth->dispatch = (dispatcher *)
1002 brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
1003 dispatch = synth->dispatch;
1004
1005 /*
1006 * We really want to have three connection mechanisms. These should be
1007 * 1. Unix named sockets.
1008 * 2. UDP sockets.
1009 * 3. MIDI pipe.
1010 */
1011 if (!global.libtest)
1012 if ((synth->sid = initConnection(&global, synth)) < 0)
1013 return(-1);
1014
1015 for (i = 0; i < DEVICE_COUNT; i++)
1016 synth->dispatch[i].routine = dxMidiSendMsg;
1017
1018 /* algo panel */
1019 dispatch[ALGO_START].operator = 0;
1020 dispatch[ALGO_START + 1].operator = 1;
1021 dispatch[ALGO_START + 2].operator = 2;
1022 dispatch[ALGO_START + 3].operator = 3;
1023 dispatch[ALGO_START + 4].operator = 4;
1024 dispatch[ALGO_START + 5].operator = 5;
1025 dispatch[ALGO_START + 6].operator = 6;
1026 dispatch[ALGO_START + 7].operator = 7;
1027 dispatch[ALGO_START + 8].operator = 8;
1028 dispatch[ALGO_START + 9].operator = 9;
1029 dispatch[ALGO_START + 10].operator = 10;
1030 dispatch[ALGO_START + 11].operator = 11;
1031 dispatch[ALGO_START + 12].operator = 12;
1032 dispatch[ALGO_START + 13].operator = 13;
1033 dispatch[ALGO_START + 14].operator = 14;
1034 dispatch[ALGO_START + 15].operator = 15;
1035 dispatch[ALGO_START + 16].operator = 16;
1036 dispatch[ALGO_START + 17].operator = 17;
1037 dispatch[ALGO_START + 18].operator = 18;
1038 dispatch[ALGO_START + 19].operator = 19;
1039 dispatch[ALGO_START + 20].operator = 20;
1040 dispatch[ALGO_START + 21].operator = 21;
1041 dispatch[ALGO_START + 22].operator = 22;
1042 dispatch[ALGO_START + 23].operator = 23;
1043 dispatch[ALGO_START].routine = dispatch[ALGO_START + 1].routine =
1044 dispatch[ALGO_START + 2].routine = dispatch[ALGO_START + 3].routine =
1045 dispatch[ALGO_START + 4].routine = dispatch[ALGO_START + 5].routine =
1046 dispatch[ALGO_START + 6].routine = dispatch[ALGO_START + 7].routine =
1047 dispatch[ALGO_START + 8].routine = dispatch[ALGO_START + 9].routine =
1048 dispatch[ALGO_START + 10].routine = dispatch[ALGO_START + 11].routine =
1049 dispatch[ALGO_START + 12].routine = dispatch[ALGO_START + 13].routine =
1050 dispatch[ALGO_START + 14].routine = dispatch[ALGO_START + 15].routine =
1051 dispatch[ALGO_START + 16].routine = dispatch[ALGO_START + 17].routine =
1052 dispatch[ALGO_START + 18].routine = dispatch[ALGO_START + 19].routine =
1053 dispatch[ALGO_START + 20].routine = dispatch[ALGO_START + 21].routine =
1054 dispatch[ALGO_START + 22].routine = dispatch[ALGO_START + 23].routine =
1055 (synthRoutine) dxAlgo;
1056
1057 dispatch[ALGO_START + 24].controller = 126;
1058 dispatch[ALGO_START + 24].operator = 99;
1059 dispatch[ALGO_START + 25].controller = 126;
1060 dispatch[ALGO_START + 25].operator = 100;
1061 dispatch[ALGO_START + 27].routine = (synthRoutine) dxTune;
1062
1063 /* Main volume */
1064 dispatch[ALGO_START + 26].controller = 126;
1065 dispatch[ALGO_START + 26].operator = 102;
1066
1067 /* operator = 1 */
1068 dispatch[OP1_START].controller = 126;
1069 dispatch[OP1_START].operator = 0;
1070 dispatch[OP1_START + 1].controller = 0;
1071 dispatch[OP1_START + 1].operator = 1;
1072 dispatch[OP1_START + 2].controller = 0;
1073 dispatch[OP1_START + 2].operator = 0;
1074 /* envelope */
1075 dispatch[OP1_START + 5].controller = 0;
1076 dispatch[OP1_START + 5].operator = 2;
1077 dispatch[OP1_START + 6].controller = 0;
1078 dispatch[OP1_START + 6].operator = 3;
1079 dispatch[OP1_START + 7].controller = 0;
1080 dispatch[OP1_START + 7].operator = 4;
1081 dispatch[OP1_START + 8].controller = 0;
1082 dispatch[OP1_START + 8].operator = 5;
1083 dispatch[OP1_START + 3].controller = 0;
1084 dispatch[OP1_START + 3].operator = 6;
1085 dispatch[OP1_START + 9].controller = 0;
1086 dispatch[OP1_START + 9].operator = 7;
1087 dispatch[OP1_START + 4].controller = 126;
1088 dispatch[OP1_START + 4].operator = 1;
1089 dispatch[OP1_START + 10].controller = 126;
1090 dispatch[OP1_START + 10].operator = 2;
1091 dispatch[OP1_START + 11].controller = 126;
1092 dispatch[OP1_START + 11].operator = 3;
1093 dispatch[OP1_START + 12].controller = 0;
1094 dispatch[OP1_START + 12].operator = 8;
1095 /* L1-A-L2 */
1096 dispatch[OP1_START + 13].controller = 0;
1097 dispatch[OP1_START + 13].operator = 9;
1098 dispatch[OP1_START + 14].controller = 0;
1099 dispatch[OP1_START + 14].operator = 10;
1100 dispatch[OP1_START + 15].controller = 0;
1101 dispatch[OP1_START + 15].operator = 11;
1102
1103 /* operator = 2 */
1104 dispatch[OP2_START].controller = 126;
1105 dispatch[OP2_START].operator = 10;
1106 dispatch[OP2_START + 1].controller = 1;
1107 dispatch[OP2_START + 1].operator = 1;
1108 dispatch[OP2_START + 2].controller = 1;
1109 dispatch[OP2_START + 2].operator = 0;
1110 /* envelope */
1111 dispatch[OP2_START + 5].controller = 1;
1112 dispatch[OP2_START + 5].operator = 2;
1113 dispatch[OP2_START + 6].controller = 1;
1114 dispatch[OP2_START + 6].operator = 3;
1115 dispatch[OP2_START + 7].controller = 1;
1116 dispatch[OP2_START + 7].operator = 4;
1117 dispatch[OP2_START + 8].controller = 1;
1118 dispatch[OP2_START + 8].operator = 5;
1119 dispatch[OP2_START + 3].controller = 1;
1120 dispatch[OP2_START + 3].operator = 6;
1121 dispatch[OP2_START + 9].controller = 1;
1122 dispatch[OP2_START + 9].operator = 7;
1123 dispatch[OP2_START + 4].controller = 126;
1124 dispatch[OP2_START + 4].operator = 11;
1125 dispatch[OP2_START + 10].controller = 126;
1126 dispatch[OP2_START + 10].operator = 12;
1127 dispatch[OP2_START + 11].controller = 126;
1128 dispatch[OP2_START + 11].operator = 13;
1129 dispatch[OP2_START + 12].controller = 1;
1130 dispatch[OP2_START + 12].operator = 8;
1131 /* L1-A-L2 */
1132 dispatch[OP2_START + 13].controller = 1;
1133 dispatch[OP2_START + 13].operator = 9;
1134 dispatch[OP2_START + 14].controller = 1;
1135 dispatch[OP2_START + 14].operator = 10;
1136 dispatch[OP2_START + 15].controller = 1;
1137 dispatch[OP2_START + 15].operator = 11;
1138
1139 /* operator = 3 */
1140 dispatch[OP3_START].controller = 126;
1141 dispatch[OP3_START].operator = 20;
1142 dispatch[OP3_START + 1].controller = 2;
1143 dispatch[OP3_START + 1].operator = 1;
1144 dispatch[OP3_START + 2].controller = 2;
1145 dispatch[OP3_START + 2].operator = 0;
1146 /* envelope */
1147 dispatch[OP3_START + 5].controller = 2;
1148 dispatch[OP3_START + 5].operator = 2;
1149 dispatch[OP3_START + 6].controller = 2;
1150 dispatch[OP3_START + 6].operator = 3;
1151 dispatch[OP3_START + 7].controller = 2;
1152 dispatch[OP3_START + 7].operator = 4;
1153 dispatch[OP3_START + 8].controller = 2;
1154 dispatch[OP3_START + 8].operator = 5;
1155 dispatch[OP3_START + 3].controller = 2;
1156 dispatch[OP3_START + 3].operator = 6;
1157 dispatch[OP3_START + 9].controller = 2;
1158 dispatch[OP3_START + 9].operator = 7;
1159 dispatch[OP3_START + 4].controller = 126;
1160 dispatch[OP3_START + 4].operator = 21;
1161 dispatch[OP3_START + 10].controller = 126;
1162 dispatch[OP3_START + 10].operator = 22;
1163 dispatch[OP3_START + 11].controller = 126;
1164 dispatch[OP3_START + 11].operator = 23;
1165 dispatch[OP3_START + 12].controller = 2;
1166 dispatch[OP3_START + 12].operator = 8;
1167 /* L1-A-L2 */
1168 dispatch[OP3_START + 13].controller = 2;
1169 dispatch[OP3_START + 13].operator = 9;
1170 dispatch[OP3_START + 14].controller = 2;
1171 dispatch[OP3_START + 14].operator = 10;
1172 dispatch[OP3_START + 15].controller = 2;
1173 dispatch[OP3_START + 15].operator = 11;
1174
1175 /* operator = 4 */
1176 dispatch[OP4_START].controller = 126;
1177 dispatch[OP4_START].operator = 30;
1178 dispatch[OP4_START + 1].controller = 3;
1179 dispatch[OP4_START + 1].operator = 1;
1180 dispatch[OP4_START + 2].controller = 3;
1181 dispatch[OP4_START + 2].operator = 0;
1182 /* envelope */
1183 dispatch[OP4_START + 5].controller = 3;
1184 dispatch[OP4_START + 5].operator = 2;
1185 dispatch[OP4_START + 6].controller = 3;
1186 dispatch[OP4_START + 6].operator = 3;
1187 dispatch[OP4_START + 7].controller = 3;
1188 dispatch[OP4_START + 7].operator = 4;
1189 dispatch[OP4_START + 8].controller = 3;
1190 dispatch[OP4_START + 8].operator = 5;
1191 dispatch[OP4_START + 3].controller = 3;
1192 dispatch[OP4_START + 3].operator = 6;
1193 dispatch[OP4_START + 9].controller = 3;
1194 dispatch[OP4_START + 9].operator = 7;
1195 dispatch[OP4_START + 4].controller = 126;
1196 dispatch[OP4_START + 4].operator = 31;
1197 dispatch[OP4_START + 10].controller = 126;
1198 dispatch[OP4_START + 10].operator = 32;
1199 dispatch[OP4_START + 11].controller = 126;
1200 dispatch[OP4_START + 11].operator = 33;
1201 dispatch[OP4_START + 12].controller = 3;
1202 dispatch[OP4_START + 12].operator = 8;
1203 /* L1-A-L2 */
1204 dispatch[OP4_START + 13].controller = 3;
1205 dispatch[OP4_START + 13].operator = 9;
1206 dispatch[OP4_START + 14].controller = 3;
1207 dispatch[OP4_START + 14].operator = 10;
1208 dispatch[OP4_START + 15].controller = 3;
1209 dispatch[OP4_START + 15].operator = 11;
1210
1211 /* operator = 5 */
1212 dispatch[OP5_START].controller = 126;
1213 dispatch[OP5_START].operator = 40;
1214 dispatch[OP5_START + 1].controller = 4;
1215 dispatch[OP5_START + 1].operator = 1;
1216 dispatch[OP5_START + 2].controller = 4;
1217 dispatch[OP5_START + 2].operator = 0;
1218 /* envelope */
1219 dispatch[OP5_START + 5].controller = 4;
1220 dispatch[OP5_START + 5].operator = 2;
1221 dispatch[OP5_START + 6].controller = 4;
1222 dispatch[OP5_START + 6].operator = 3;
1223 dispatch[OP5_START + 7].controller = 4;
1224 dispatch[OP5_START + 7].operator = 4;
1225 dispatch[OP5_START + 8].controller = 4;
1226 dispatch[OP5_START + 8].operator = 5;
1227 dispatch[OP5_START + 3].controller = 4;
1228 dispatch[OP5_START + 3].operator = 6;
1229 dispatch[OP5_START + 9].controller = 4;
1230 dispatch[OP5_START + 9].operator = 7;
1231 dispatch[OP5_START + 4].controller = 126;
1232 dispatch[OP5_START + 4].operator = 41;
1233 dispatch[OP5_START + 10].controller = 126;
1234 dispatch[OP5_START + 10].operator = 42;
1235 dispatch[OP5_START + 11].controller = 126;
1236 dispatch[OP5_START + 11].operator = 43;
1237 dispatch[OP5_START + 12].controller = 4;
1238 dispatch[OP5_START + 12].operator = 8;
1239 /* L1-A-L2 */
1240 dispatch[OP5_START + 13].controller = 4;
1241 dispatch[OP5_START + 13].operator = 9;
1242 dispatch[OP5_START + 14].controller = 4;
1243 dispatch[OP5_START + 14].operator = 10;
1244 dispatch[OP5_START + 15].controller = 4;
1245 dispatch[OP5_START + 15].operator = 11;
1246
1247 /* operator = 6 */
1248 dispatch[OP6_START].controller = 126;
1249 dispatch[OP6_START].operator = 50;
1250 dispatch[OP6_START + 1].controller = 5;
1251 dispatch[OP6_START + 1].operator = 1;
1252 dispatch[OP6_START + 2].controller = 5;
1253 dispatch[OP6_START + 2].operator = 0;
1254 /* envelope */
1255 dispatch[OP6_START + 5].controller = 5;
1256 dispatch[OP6_START + 5].operator = 2;
1257 dispatch[OP6_START + 6].controller = 5;
1258 dispatch[OP6_START + 6].operator = 3;
1259 dispatch[OP6_START + 7].controller = 5;
1260 dispatch[OP6_START + 7].operator = 4;
1261 dispatch[OP6_START + 8].controller = 5;
1262 dispatch[OP6_START + 8].operator = 5;
1263 dispatch[OP6_START + 3].controller = 5;
1264 dispatch[OP6_START + 3].operator = 6;
1265 dispatch[OP6_START + 9].controller = 5;
1266 dispatch[OP6_START + 9].operator = 7;
1267 dispatch[OP6_START + 4].controller = 126;
1268 dispatch[OP6_START + 4].operator = 51;
1269 dispatch[OP6_START + 10].controller = 126;
1270 dispatch[OP6_START + 10].operator = 52;
1271 dispatch[OP6_START + 11].controller = 126;
1272 dispatch[OP6_START + 11].operator = 53;
1273 dispatch[OP6_START + 12].controller = 5;
1274 dispatch[OP6_START + 12].operator = 8;
1275 /* L1-A-L2 */
1276 dispatch[OP6_START + 13].controller = 5;
1277 dispatch[OP6_START + 13].operator = 9;
1278 dispatch[OP6_START + 14].controller = 5;
1279 dispatch[OP6_START + 14].operator = 10;
1280 dispatch[OP6_START + 15].controller = 5;
1281 dispatch[OP6_START + 15].operator = 11;
1282
1283 /* memories */
1284 dispatch[MEM_START].operator = 0;
1285 dispatch[MEM_START + 1].operator = 1;
1286 dispatch[MEM_START + 2].operator = 2;
1287 dispatch[MEM_START + 3].operator = 3;
1288 dispatch[MEM_START + 4].operator = 4;
1289 dispatch[MEM_START + 5].operator = 5;
1290 dispatch[MEM_START + 6].operator = 6;
1291 dispatch[MEM_START + 7].operator = 7;
1292 dispatch[MEM_START + 8].operator = 8;
1293 dispatch[MEM_START + 9].operator = 9;
1294 dispatch[MEM_START].routine = dispatch[MEM_START + 1].routine =
1295 dispatch[MEM_START + 2].routine = dispatch[MEM_START + 3].routine =
1296 dispatch[MEM_START + 4].routine = dispatch[MEM_START + 5].routine =
1297 dispatch[MEM_START + 6].routine = dispatch[MEM_START + 7].routine =
1298 dispatch[MEM_START + 8].routine = dispatch[MEM_START + 9].routine =
1299 dispatch[MEM_START + 10].routine = dispatch[MEM_START + 11].routine =
1300 dispatch[MEM_START + 15].routine = dispatch[MEM_START + 16].routine =
1301 (synthRoutine) dxMemory;
1302 dispatch[MEM_START + 10].controller = 1;
1303 dispatch[MEM_START + 11].controller = 2;
1304 dispatch[MEM_START + 15].controller = 3;
1305 dispatch[MEM_START + 16].controller = 4;
1306
1307 /* Midi */
1308 dispatch[MEM_START + 12].controller = 2;
1309 dispatch[MEM_START + 13].controller = 1;
1310 dispatch[MEM_START + 12].routine = dispatch[MEM_START + 13].routine =
1311 (synthRoutine) dxMidi;
1312
1313 /*
1314 * We need to hack in the correct bitmaps for each op. They are all copies
1315 * of the same locations structure, but they need a unique image bitmap
1316 * for the "OP X" text.
1317 */
1318 if (dxApp.resources[1].devlocn == 0)
1319 {
1320 int index;
1321
1322 for (index = 1; index < 6; index++)
1323 {
1324 dxApp.resources[index].devlocn = (brightonLocations *)
1325 brightonmalloc(sizeof(locations));
1326 bcopy(dxApp.resources[0].devlocn, dxApp.resources[index].devlocn,
1327 sizeof(locations));
1328 }
1329
1330 dxApp.resources[1].devlocn[PARAM_COUNT - 1].image = OP2XPM;
1331 dxApp.resources[2].devlocn[PARAM_COUNT - 1].image = OP3XPM;
1332 dxApp.resources[3].devlocn[PARAM_COUNT - 1].image = OP4XPM;
1333 dxApp.resources[4].devlocn[PARAM_COUNT - 1].image = OP5XPM;
1334 dxApp.resources[5].devlocn[PARAM_COUNT - 1].image = OP6XPM;
1335 }
1336
1337 return(0);
1338 }
1339
1340 /*
1341 * This will be called to make any routine specific parameters available.
1342 */
1343 static int
dxConfigure(brightonWindow * win)1344 dxConfigure(brightonWindow *win)
1345 {
1346 guiSynth *synth = findSynth(global.synths, win);
1347 brightonEvent event;
1348
1349 if (synth == 0)
1350 {
1351 printf("problems going operational\n");
1352 return(-1);
1353 }
1354
1355 if (synth->flags & OPERATIONAL)
1356 return(0);
1357
1358 printf("going operational %p %p\n", synth, synth->win);
1359
1360 synth->flags |= OPERATIONAL;
1361 synth->keypanel = 8;
1362 synth->keypanel2 = -1;
1363 synth->transpose = 36;
1364 synth->dispatch[ALGO_START].other2 = 0;
1365 synth->dispatch[ALGO_START].other1 = -1;
1366
1367 dxLoadMem(synth, "dx", 0, 0, synth->mem.active,
1368 FIRST_DEV, BRISTOL_FORCE);
1369
1370 brightonPut(win,
1371 "bitmaps/blueprints/dxshade.xpm", 0, 0, win->width, win->height);
1372
1373 /*
1374 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
1375 * occurs on first paint, so we suppress the first paint, and then request
1376 * an expose here.
1377 */
1378 event.type = BRIGHTON_EXPOSE;
1379 event.intvalue = 1;
1380 brightonParamChange(synth->win, KEY_PANEL, -1, &event);
1381 configureGlobals(synth);
1382
1383 return(0);
1384 }
1385
1386