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 hammondInit();
30 static int hammondConfigure();
31 static int hammondCallback(brightonWindow * , int, int, float);
32 
33 extern guimain global;
34 
35 #define FIRST_DEV 0
36 
37 #define OPTS_PANEL 0
38 #define SLIDER_PANEL 1
39 #define MOD_PANEL 2
40 #define VOL_PANEL 3
41 #define MEM_PANEL 4
42 
43 #define OPTS_COUNT 27
44 #define SLIDER_COUNT 9
45 #define MOD_COUNT 14
46 #define VOL_COUNT 1
47 #define MEM_COUNT 18
48 
49 #define OPTS_START FIRST_DEV
50 #define SLIDER_START (OPTS_START + OPTS_COUNT)
51 #define MOD_START (SLIDER_START + SLIDER_COUNT)
52 #define VOL_START (MOD_START + MOD_COUNT)
53 #define MEM_START (VOL_START + VOL_COUNT)
54 
55 #define DEVICE_COUNT (SLIDER_COUNT + MOD_COUNT + MEM_COUNT + VOL_COUNT + OPTS_COUNT + FIRST_DEV)
56 #define ACTIVE_DEVS (SLIDER_COUNT + MOD_COUNT + VOL_COUNT + OPTS_COUNT + FIRST_DEV)
57 
58 #define DISPLAY (MEM_COUNT - 1)
59 #define DISPLAYPANEL 2
60 
61 #define R1 60
62 #define D1 100
63 
64 #define C1 75
65 #define C2 (C1 + D1)
66 #define C3 (C2 + D1)
67 #define C4 (C3 + D1)
68 #define C5 (C4 + D1)
69 #define C6 (C5 + D1)
70 #define C7 (C6 + D1)
71 #define C8 (C7 + D1)
72 #define C9 (C8 + D1)
73 
74 #define W1 70
75 #define L1 800
76 
77 /*
78  * This structure is for device definition. The structure is defined in
79  * include/brighton.h, further definitions in brighton/brightonDevtable.h and
80  * include/brightoninternals.h
81  *
82  *	typedef int (*brightonCallback)(int, float);
83  *	typedef struct BrightonLocations {
84  *		int device; 0=rotary, 1=scale, etc.
85  *		float relx, rely; relative position with regards to 1000 by 1000 window
86  *		float relw, relh; relative height.
87  *		int from, to;
88  *		brightonCallback callback; specific to this dev
89  *		char *image; bitmap. If zero take a device default.
90  *		int flags;
91  *	} brightonLocations;
92  *
93  * This example is for a hammondBristol type synth interface.
94  */
95 static brightonLocations sliders[SLIDER_COUNT] = {
96 	{"", 1, C1, R1, W1, L1, 0, 7, 0,
97 		"bitmaps/knobs/hammondbrown.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
98 	{"", 1, C2, R1, W1, L1, 0, 7, 0,
99 		"bitmaps/knobs/hammondbrown.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
100 	{"", 1, C3, R1, W1, L1, 0, 7, 0,
101 		"bitmaps/knobs/hammondwhite.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
102 	{"", 1, C4, R1, W1, L1, 0, 7, 0,
103 		"bitmaps/knobs/hammondwhite.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
104 	{"", 1, C5, R1, W1, L1, 0, 7, 0,
105 		"bitmaps/knobs/hammondblack.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
106 	{"", 1, C6, R1, W1, L1, 0, 7, 0,
107 		"bitmaps/knobs/hammondwhite.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
108 	{"", 1, C7, R1, W1, L1, 0, 7, 0,
109 		"bitmaps/knobs/hammondblack.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
110 	{"", 1, C8, R1, W1, L1, 0, 7, 0,
111 		"bitmaps/knobs/hammondblack.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE},
112 	{"", 1, C9, R1, W1, L1, 0, 7, 0,
113 		"bitmaps/knobs/hammondwhite.xpm", 0, BRIGHTON_REVERSE|BRIGHTON_HSCALE}
114 };
115 
116 #define MR1 150
117 #define MR2 550
118 
119 #define MD1 80
120 
121 #define MC1 100
122 #define MC2 (MC1 + MD1)
123 #define MC3 (MC2 + MD1)
124 #define MC4 (MC3 + MD1)
125 #define MC5 (MC4 + MD1)
126 
127 #define MC6 (500 + MC1)
128 #define MC7 (500 + MC2)
129 #define MC8 (500 + MC3)
130 #define MC9 (500 + MC4)
131 #define MC10 (500 + MC5)
132 
133 #define S4 35
134 #define S5 200
135 
136 static brightonLocations memories[MEM_COUNT] = {
137 /* Memory tablet */
138 	{"", 2, MC10, MR2, S4, S5, 0, 1, 0,
139 		"bitmaps/buttons/pressoffg.xpm",
140 		"bitmaps/buttons/pressong.xpm", 0},
141 	{"", 2, MC6, MR1, S4, S5, 0, 1, 0,
142 		"bitmaps/buttons/pressoffg.xpm",
143 		"bitmaps/buttons/pressong.xpm", 0},
144 	{"", 2, MC7, MR1, S4, S5, 0, 1, 0,
145 		"bitmaps/buttons/pressoffg.xpm",
146 		"bitmaps/buttons/pressong.xpm", 0},
147 	{"", 2, MC8, MR1, S4, S5, 0, 1, 0,
148 		"bitmaps/buttons/pressoffg.xpm",
149 		"bitmaps/buttons/pressong.xpm", 0},
150 	{"", 2, MC9, MR1, S4, S5, 0, 1, 0,
151 		"bitmaps/buttons/pressoffg.xpm",
152 		"bitmaps/buttons/pressong.xpm", 0},
153 	{"", 2, MC10, MR1, S4, S5, 0, 1, 0,
154 		"bitmaps/buttons/pressoffg.xpm",
155 		"bitmaps/buttons/pressong.xpm", 0},
156 	{"", 2, MC6, MR2, S4, S5, 0, 1, 0,
157 		"bitmaps/buttons/pressoffg.xpm",
158 		"bitmaps/buttons/pressong.xpm", 0},
159 	{"", 2, MC7, MR2, S4, S5, 0, 1, 0,
160 		"bitmaps/buttons/pressoffg.xpm",
161 		"bitmaps/buttons/pressong.xpm", 0},
162 	{"", 2, MC8, MR2, S4, S5, 0, 1, 0,
163 		"bitmaps/buttons/pressoffg.xpm",
164 		"bitmaps/buttons/pressong.xpm", 0},
165 	{"", 2, MC9, MR2, S4, S5, 0, 1, 0,
166 		"bitmaps/buttons/pressoffg.xpm",
167 		"bitmaps/buttons/pressong.xpm", 0},
168 	{"", 2, MC1 - 50, MR2, S4, S5, 0, 1, 0, /* panel switch */
169 		"bitmaps/buttons/pressoffg.xpm",
170 		"bitmaps/buttons/pressong.xpm", 0},
171 	/* midi U, D, Load, Save */
172 	{"", 2, MC2, MR2, S4, S5, 0, 1, 0,
173 		"bitmaps/buttons/pressoff.xpm",
174 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
175 	{"", 2, MC3, MR2, S4, S5, 0, 1, 0,
176 		"bitmaps/buttons/pressoff.xpm",
177 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
178 	{"", 2, MC4, MR2, S4, S5, 0, 1, 0,
179 		"bitmaps/buttons/pressoffg.xpm",
180 		"bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
181 	{"", 2, MC5, MR2, S4, S5, 0, 1, 0,
182 		"bitmaps/buttons/pressoffo.xpm",
183 		"bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
184 	/* mem up down */
185 	{"", 2, 520, MR1, S4, S5, 0, 1, 0,
186 		"bitmaps/buttons/pressoff.xpm",
187 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
188 	{"", 2, 520, MR2, S4, S5, 0, 1, 0,
189 		"bitmaps/buttons/pressoff.xpm",
190 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
191 	/* display */
192 	{"", 3, MC2, MR1, 275, 250, 0, 1, 0, 0, 0, 0}
193 };
194 
195 #define MODD1 200
196 #define MODD2 300
197 
198 #define MODC1 50
199 #define MODC2 (MODC1 + MODD1)
200 #define MODC3 (MODC2 + MODD1)
201 #define MODC4 (MODC3 + MODD1)
202 #define MODC5 (MODC4 + MODD1)
203 
204 #define MODR1 100
205 #define MODR2 (MODR1 + MODD2)
206 #define MODR3 (MODR2 + MODD2)
207 
208 #define MW1 80
209 #define MH1 150
210 
211 static brightonLocations mods[MOD_COUNT] = {
212 	/* Leslie */
213 	{"", 2, MODC1, MODR1, MW1, MH1, 0, 1, 0,
214 		"bitmaps/buttons/rockerblue.xpm", 0, 0},
215 	{"", 2, MODC2, MODR1, MW1, MH1, 0, 1, 0,
216 		"bitmaps/buttons/rockerblue.xpm", 0, 0},
217 	/* Vibra */
218 	{"", 0, MODC3 - 30, MODR1, MW1 + 150, MH1 + 150, 0, 2, 0,
219 		0, 0, 0},
220 	{"", 2, MODC4, MODR1, MW1, MH1, 0, 1, 0,
221 		"bitmaps/buttons/rockerred.xpm", 0, 0},
222 	{"", 2, MODC5, MODR1, MW1, MH1, 0, 1, 0,
223 		"bitmaps/buttons/rockerred.xpm", 0, 0},
224 	/* Percussives */
225 	{"", 2, MODC1, MODR3, MW1, MH1, 0, 1, 0,
226 		"bitmaps/buttons/rockerwhite.xpm", 0, 0},
227 	{"", 2, MODC2, MODR3, MW1, MH1, 0, 1, 0,
228 		"bitmaps/buttons/rockerwhite.xpm", 0, 0},
229 	{"", 2, MODC4, MODR2, MW1, MH1, 0, 1, 0,
230 		"bitmaps/buttons/rockerwhite.xpm", 0, 0},
231 	{"", 2, MODC3, MODR3, MW1, MH1, 0, 1, 0,
232 		"bitmaps/buttons/rockerwhite.xpm", 0, 0},
233 	/* diverse */
234 	{"", 2, MODC1, MODR2, MW1, MH1, 0, 1, 0,
235 		"bitmaps/buttons/rockerblue.xpm", 0, 0},
236 	{"", 2, MODC2, MODR2, MW1, MH1, 0, 1, 0,
237 		"bitmaps/buttons/rockerblue.xpm", 0, 0},
238 
239 	{"", 2, MODC5, MODR2, MW1, MH1, 0, 1, 0,
240 		"bitmaps/buttons/rockerwhite.xpm", 0, 0},
241 
242 	{"", 2, MODC4, MODR3, MW1, MH1, 0, 1, 0,
243 		"bitmaps/buttons/rockerred.xpm", 0, 0},
244 	{"", 2, MODC5, MODR3, MW1, MH1, 0, 1, 0,
245 		"bitmaps/buttons/rockerred.xpm", 0, 0}
246 };
247 
248 static brightonLocations volumes[VOL_COUNT] = {
249 	{"", 0, 0, 0, 1000, 800, 0, 1, 0, 0, 0, 0},
250 };
251 
252 #define OD1 140
253 #define OD2 70
254 #define OD3 70
255 
256 #define OC1 150
257 #define OC2 (OC1 + OD1 + 50)
258 #define OC3 (OC2 + OD1)
259 #define OC4 (OC3 + OD1)
260 #define OC5 (OC4 + OD1)
261 #define OC6 (OC5 + OD1)
262 
263 #define OR1 20
264 #define OR2 (OR1 + OD2)
265 #define OR3 (OR2 + OD2)
266 #define OR4 (OR3 + OD2)
267 
268 #define OR5 (OR4 + 150)
269 #define OR6 (OR5 + 200)
270 #define OR7 (OR6 + 200)
271 
272 #define OS1 25
273 #define OS2 60
274 #define OS3 100
275 
276 static brightonLocations opts[OPTS_COUNT] = {
277 	{"", 2, OC1, OR1, OS1, OS2, 0, 1, 0,
278 		"bitmaps/buttons/pressoff.xpm",
279 		"bitmaps/buttons/presson.xpm", 0},
280 	{"", 2, OC1, OR2, OS1, OS2, 0, 1, 0,
281 		"bitmaps/buttons/pressoff.xpm",
282 		"bitmaps/buttons/presson.xpm", 0},
283 	{"", 2, OC1, OR3, OS1, OS2, 0, 1, 0,
284 		"bitmaps/buttons/pressoff.xpm",
285 		"bitmaps/buttons/presson.xpm", 0},
286 	{"", 2, OC1, OR4, OS1, OS2, 0, 1, 0,
287 		"bitmaps/buttons/pressoffg.xpm",
288 		"bitmaps/buttons/pressong.xpm", 0},
289 	{"", 0, OC2, OR1 + 75, OS3, OS3, 0, 1, 0, 0, 0, 0},
290 	{"", 0, OC3, OR1, OS3, OS3, 0, 1, 0, 0, 0, 0},
291 	{"", 0, OC4, OR1, OS3, OS3, 0, 1, 0, 0, 0, 0},
292 	{"", 0, OC5, OR1, OS3, OS3, 0, 1, 0, 0, 0, 0},
293 	{"", 0, OC6, OR1, OS3, OS3, 0, 1, 0, 0, 0, 0},
294 	{"", 0, OC3, OR1 + 150, OS3, OS3, 0, 1, 0, 0, 0, 0},
295 	{"", 0, OC4, OR1 + 150, OS3, OS3, 0, 1, 0, 0, 0, 0},
296 	{"", 0, OC5, OR1 + 150, OS3, OS3, 0, 1, 0, 0, 0, 0},
297 	{"", 0, OC6, OR1 + 150, OS3, OS3, 0, 1, 0, 0, 0, 0},
298 	{"", 0, OC4, OR5, OS3, OS3, 0, 1, 0, 0, 0, 0},
299 	{"", 0, OC5, OR5, OS3, OS3, 0, 1, 0, 0, 0, 0},
300 	{"", 0, OC6, OR5, OS3, OS3, 0, 1, 0, 0, 0, 0},
301 	{"", 0, OC3, OR6, OS3, OS3, 0, 1, 0, 0, 0, 0},
302 	{"", 0, OC4, OR6, OS3, OS3, 0, 1, 0, 0, 0, 0},
303 	{"", 0, OC5, OR6, OS3, OS3, 0, 1, 0, 0, 0, 0},
304 	{"", 0, OC6, OR6, OS3, OS3, 0, 1, 0, 0, 0, 0},
305 	{"", 2, OC1, OR7, OS1, OS2, 0, 1, 0,
306 		"bitmaps/buttons/pressoff.xpm",
307 		"bitmaps/buttons/presson.xpm", 0},
308 	{"", 2, OC1, OR7 + OD2, OS1, OS2, 0, 1, 0,
309 		"bitmaps/buttons/pressoffg.xpm",
310 		"bitmaps/buttons/pressong.xpm", 0},
311 	{"", 0, OC2, OR7, OS3, OS3, 0, 7, 0, 0, 0, 0},
312 	{"", 0, OC3, OR7, OS3, OS3, 0, 1, 0, 0, 0, 0},
313 	{"", 0, OC4, OR7, OS3, OS3, 0, 1, 0, 0, 0, 0},
314 	{"", 0, OC5, OR7, OS3, OS3, 0, 1, 0, 0, 0, 0},
315 	{"", 0, OC6, OR7, OS3, OS3, 0, 1, 0, 0, 0, 0},
316 };
317 
318 /*
319  * This is a set of globals for the main window rendering. Again taken from
320  * include/brighton.h
321  */
322 brightonApp hammondApp = {
323 	"hammond",
324 	0, /* no blueprint on wood background. */
325 	"bitmaps/textures/wood2.xpm",
326 	0, /* or BRIGHTON_STRETCH, default is tesselate */
327 	hammondInit,
328 	hammondConfigure, /* 3 callbacks, unused? */
329 	0,
330 	destroySynth,
331 	{32, 0, 2, 2, 5, 520, 0, 0},
332 	808, 259, 0, 0,
333 	5, /* four panels */
334 	{
335 		{
336 			"Options",
337 			"bitmaps/blueprints/hammondopts.xpm",
338 			"bitmaps/textures/metal5.xpm",
339 			0x020, /* flags - 0x020 withdraws */
340 			0,
341 			0,
342 			hammondCallback,
343 			/*900, 700, 70, 250, */
344 			20, 50, 460, 900,
345 			OPTS_COUNT,
346 			opts
347 		},
348 		{
349 			"Harmonics",
350 			"bitmaps/blueprints/hammond.xpm",
351 			"bitmaps/textures/metal6.xpm",
352 			BRIGHTON_STRETCH, /* flags */
353 			0,
354 			0,
355 			hammondCallback,
356 			20, 50, 460, 900,
357 			SLIDER_COUNT,
358 			sliders
359 		},
360 		{
361 			"Modulations",
362 			"bitmaps/blueprints/hammondmods.xpm",
363 			"bitmaps/textures/metal6.xpm",
364 			BRIGHTON_STRETCH, /* flags */
365 			0,
366 			0,
367 			hammondCallback,
368 			500, 50, 480, 600,
369 			MOD_COUNT,
370 			mods
371 		},
372 		{
373 			"Volume",
374 			"bitmaps/blueprints/hammondvol.xpm",
375 			0,
376 			0, /* flags */
377 			0,
378 			0,
379 			hammondCallback,
380 			900, 700, 70, 250,
381 			VOL_COUNT,
382 			volumes
383 		},
384 		{
385 			"Memories",
386 			"bitmaps/blueprints/hammondmem.xpm",
387 			"bitmaps/textures/metal6.xpm",
388 			BRIGHTON_STRETCH, /* flags */
389 			0,
390 			0,
391 			hammondCallback,
392 			500, 700, 375, 250,
393 			MEM_COUNT,
394 			memories
395 		}
396 	}
397 };
398 
399 static void
hammondMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)400 hammondMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
401 {
402 /*	printf("hammondMemory(%i %i %i %i %i)\n", fd, chan, c, o, v); */
403 
404 	/*
405 	 * radio button exception
406 	 */
407 	if (synth->dispatch[MEM_START].other2)
408 	{
409 		synth->dispatch[MEM_START].other2 = 0;
410 		return;
411 	}
412 
413 	switch (c) {
414 		default:
415 		case 0:
416 			if (synth->dispatch[MEM_START].other2 == 0)
417 			{
418 				brightonEvent event;
419 
420 				if (synth->dispatch[MEM_START].other1 != o)
421 					event.value = 0;
422 				else
423 					event.value = 1;
424 
425 				synth->dispatch[MEM_START].other2 = 1;
426 
427 				brightonParamChange(synth->win, MEM_PANEL,
428 					synth->dispatch[MEM_START].other1,
429 					&event);
430 			}
431 			synth->dispatch[MEM_START].other1 = o;
432 
433 			synth->location = synth->location * 10 + o;
434 
435 			if (synth->location > 1000)
436 				synth->location = o;
437 /*printf("location is now %i\n", synth->location); */
438 			if (loadMemory(synth, "hammond", 0, synth->location,
439 				synth->mem.active, FIRST_DEV, BRISTOL_STAT) < 0)
440 				displayPanelText(synth, "FRE", synth->location, MEM_PANEL,
441 					DISPLAY);
442 			else
443 				displayPanelText(synth, "PRG", synth->location, MEM_PANEL,
444 					DISPLAY);
445 			break;
446 		case 1:
447 			synth->flags |= MEM_LOADING;
448 			if (loadMemory(synth, "hammond", 0, synth->location,
449 				synth->mem.active, FIRST_DEV, 0) < 0)
450 				displayPanelText(synth, "FRE", synth->location, MEM_PANEL,
451 					DISPLAY);
452 			else
453 				displayPanelText(synth, "PRG", synth->location, MEM_PANEL,
454 					DISPLAY);
455 			synth->flags &= ~MEM_LOADING;
456 /*			synth->location = 0; */
457 			break;
458 		case 2:
459 			saveMemory(synth, "hammond", 0, synth->location, FIRST_DEV);
460 			displayPanelText(synth, "PRG", synth->location, MEM_PANEL, DISPLAY);
461 /*			synth->location = 0; */
462 			break;
463 		case 3:
464 			while (loadMemory(synth, "hammond", 0, ++synth->location,
465 				synth->mem.active, FIRST_DEV, 0) < 0)
466 			{
467 				if (synth->location > 999)
468 					synth->location = -1;
469 			}
470 			displayPanelText(synth, "PRG", synth->location, MEM_PANEL, DISPLAY);
471 			break;
472 		case 4:
473 			while (loadMemory(synth, "hammond", 0, --synth->location,
474 				synth->mem.active, FIRST_DEV, 0) < 0)
475 			{
476 				if (synth->location < 0)
477 					synth->location = 1000;
478 			}
479 			displayPanelText(synth, "PRG", synth->location, MEM_PANEL, DISPLAY);
480 			break;
481 	}
482 }
483 
484 static void
hammondMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)485 hammondMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
486 {
487 	int newchan;
488 
489 	if ((synth->flags & OPERATIONAL) == 0)
490 		return;
491 
492 	if (c == 1) {
493 		if ((newchan = synth->midichannel - 1) < 0)
494 		{
495 			synth->midichannel = 0;
496 			return;
497 		}
498 	} else {
499 		if ((newchan = synth->midichannel + 1) >= 16)
500 		{
501 			synth->midichannel = 15;
502 			return;
503 		}
504 	}
505 
506 	if (global.libtest == 0)
507 		bristolMidiSendMsg(global.controlfd, synth->sid,
508 			127, 0, BRISTOL_MIDICHANNEL|newchan);
509 
510 	synth->midichannel = newchan;
511 
512 	displayPanelText(synth, "MIDI", synth->midichannel + 1, MEM_PANEL, DISPLAY);
513 }
514 
515 /*
516  * For the sake of ease of use, links have been placed here to be called
517  * by any of the devices created. They would be better in some other file,
518  * perhaps with this as a dispatch.
519  *
520  * Param refers to the device index in the locations table given below.
521  */
522 static int
hammondCallback(brightonWindow * win,int panel,int index,float value)523 hammondCallback(brightonWindow * win, int panel, int index, float value)
524 {
525 	guiSynth *synth = findSynth(global.synths, win);
526 	int sendvalue;
527 
528 	if (synth == 0)
529 		return(0);
530 
531 	if ((synth->flags & OPERATIONAL) == 0)
532 		return(0);
533 
534 	switch (panel) {
535 		case SLIDER_PANEL:
536 			index += SLIDER_START;
537 			break;
538 		case MOD_PANEL:
539 			index += MOD_START;
540 			break;
541 		case VOL_PANEL:
542 			index += VOL_START;
543 			break;
544 		case OPTS_PANEL:
545 			index += OPTS_START;
546 			break;
547 		case MEM_PANEL:
548 			index += MEM_START;
549 			break;
550 	}
551 
552 /*	printf("hammondCallback(%i, %i, %f): %x\n", panel, index, value, synth); */
553 
554 	if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
555 		return(0);
556 	if (synth->dispatch[index].controller >= DEVICE_COUNT)
557 		return(0);
558 
559 	if (hammondApp.resources[0].devlocn[index].to == 1.0)
560 		sendvalue = value * C_RANGE_MIN_1;
561 	else
562 		sendvalue = value;
563 
564 	synth->mem.param[index] = value;
565 
566 /*printf("index is now %i %i %i\n", index, DEVICE_COUNT, ACTIVE_DEVS); */
567 
568 /*	if ((!global.libtest) || (index >= ACTIVE_DEVS)) */
569 		synth->dispatch[index].routine(synth,
570 			global.controlfd, synth->sid,
571 			synth->dispatch[index].controller,
572 			synth->dispatch[index].operator,
573 			sendvalue);
574 #define DEBUG
575 #ifdef DEBUG
576 	printf("dispatch[%p,%i](%i, %i, %i, %i, %i)\n", synth, index,
577 		global.controlfd, synth->sid,
578 		synth->dispatch[index].controller,
579 		synth->dispatch[index].operator,
580 		sendvalue);
581 #endif
582 
583 	return(0);
584 }
585 
586 static int
hammondNull()587 hammondNull()
588 {
589 	return(0);
590 }
591 
592 static void
doSlider(guiSynth * synth,int fd,int chan,int cont,int op,int value)593 doSlider(guiSynth *synth, int fd, int chan, int cont, int op, int value)
594 {
595 	int slidervalue;
596 
597 	/*printf("doSlider(%x, %i, %i, %i, %i, %i)\n", */
598 	/*	synth, fd, chan, cont, op, value); */
599 
600 	slidervalue = cont * 8 + value;
601 
602 	bristolMidiSendMsg(global.controlfd, synth->sid, 0, 2,
603 		slidervalue);
604 }
605 
606 static void
doOverdrive(guiSynth * synth)607 doOverdrive(guiSynth *synth)
608 {
609 	if (synth->mem.param[MOD_START + MOD_COUNT - 1] == 0)
610 		bristolMidiSendMsg(global.controlfd, synth->sid, 100, 5, 0);
611 	else
612 		bristolMidiSendMsg(global.controlfd, synth->sid, 100, 5,
613 			(int) (synth->mem.param[OPTS_START + 9] * C_RANGE_MIN_1));
614 }
615 
616 static void
doReverb(guiSynth * synth)617 doReverb(guiSynth *synth)
618 {
619 	int revlevel = 0;
620 
621 	/*printf("doReverb\n"); */
622 
623 	if (synth->mem.param[MOD_START + 9] != 0)
624 		revlevel++;
625 	if (synth->mem.param[MOD_START + 10] != 0)
626 		revlevel+=2;
627 
628 	switch (revlevel) {
629 		default:
630 		case 0:
631 			bristolMidiSendMsg(global.controlfd, synth->sid, 100, 4, 0);
632 			break;
633 		case 1:
634 			bristolMidiSendMsg(global.controlfd, synth->sid, 100, 4,
635 				(int) (synth->mem.param[OPTS_START + 24] * C_RANGE_MIN_1));
636 			break;
637 		case 2:
638 			bristolMidiSendMsg(global.controlfd, synth->sid, 100, 4,
639 				(int) (synth->mem.param[OPTS_START + 25] * C_RANGE_MIN_1));
640 			break;
641 		case 3:
642 			bristolMidiSendMsg(global.controlfd, synth->sid, 100, 4,
643 				(int) (synth->mem.param[OPTS_START + 26] * C_RANGE_MIN_1));
644 			break;
645 	}
646 }
647 
648 static void
doBright(guiSynth * synth)649 doBright(guiSynth *synth)
650 {
651 	if (synth->mem.param[MOD_START + 12] == 0)
652 	{
653 		/*
654 		 * Once to the hammond manager
655 		 */
656 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 1, 0);
657 		/*
658 		 * And to the sine oscillator
659 		 */
660 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 0);
661 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 8);
662 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 16);
663 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 24);
664 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 32);
665 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 40);
666 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 48);
667 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 56);
668 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 64);
669 	} else {
670 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 1,
671 			(int) (synth->mem.param[OPTS_START + 22]));
672 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 0 +
673 			(int) (synth->mem.param[OPTS_START + 22]));
674 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 8 +
675 			(int) (synth->mem.param[OPTS_START + 22]));
676 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 16 +
677 			(int) (synth->mem.param[OPTS_START + 22]));
678 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 24 +
679 			(int) (synth->mem.param[OPTS_START + 22]));
680 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 32 +
681 			(int) (synth->mem.param[OPTS_START + 22]));
682 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 40 +
683 			(int) (synth->mem.param[OPTS_START + 22]));
684 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 48 +
685 			(int) (synth->mem.param[OPTS_START + 22]));
686 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 56 +
687 			(int) (synth->mem.param[OPTS_START + 22]));
688 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 0, 64 +
689 			(int) (synth->mem.param[OPTS_START + 22]));
690 	}
691 }
692 
693 static void
doClick(guiSynth * synth)694 doClick(guiSynth *synth)
695 {
696 	if (synth->mem.param[MOD_START + 11] == 0)
697 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 6, 0);
698 	else
699 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 6,
700 			(int) (synth->mem.param[OPTS_START + 23] * C_RANGE_MIN_1));
701 }
702 
703 static void
doCompress(guiSynth * synth)704 doCompress(guiSynth *synth)
705 {
706 	if (synth->mem.param[OPTS_START + 21] == 0)
707 	{
708 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 2, 0);
709 	} else {
710 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 2, 1);
711 	}
712 }
713 
714 static void
doPreacher(guiSynth * synth)715 doPreacher(guiSynth *synth)
716 {
717 	if (synth->mem.param[OPTS_START + 20] == 0)
718 	{
719 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 3, 0);
720 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 7, 0);
721 	} else {
722 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 3, 1);
723 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 7, 1);
724 	}
725 }
726 
727 static void
doGrooming(guiSynth * synth)728 doGrooming(guiSynth *synth)
729 {
730 	if (synth->mem.param[MOD_START + 7] != 0)
731 		bristolMidiSendMsg(global.controlfd, synth->sid, 1, 0,
732 			(int) (synth->mem.param[OPTS_START + 18] * C_RANGE_MIN_1));
733 	else
734 		bristolMidiSendMsg(global.controlfd, synth->sid, 1, 0,
735 			(int) (synth->mem.param[OPTS_START + 19] * C_RANGE_MIN_1));
736 }
737 
738 static void
doPerc(guiSynth * synth)739 doPerc(guiSynth *synth)
740 {
741 	if (synth->mem.param[MOD_START + 5] == 0)
742 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 3, 24);
743 	else
744 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 3, 25);
745 
746 	if (synth->mem.param[MOD_START + 6] == 0)
747 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 3, 32);
748 	else
749 		bristolMidiSendMsg(global.controlfd, synth->sid, 0, 3, 33);
750 
751 	if (synth->mem.param[MOD_START + 8] == 0)
752 		bristolMidiSendMsg(global.controlfd, synth->sid, 4, 1,
753 			(int) (synth->mem.param[OPTS_START + 16] * C_RANGE_MIN_1));
754 	else
755 		bristolMidiSendMsg(global.controlfd, synth->sid, 4, 1,
756 			(int) (synth->mem.param[OPTS_START + 17] * C_RANGE_MIN_1));
757 }
758 
759 static void
doVibra(guiSynth * synth)760 doVibra(guiSynth *synth)
761 {
762 	if (synth->mem.param[MOD_START + 3] == 0)
763 	{
764 		bristolMidiSendMsg(global.controlfd, synth->sid, 126, 0, 0);
765 		return;
766 	}
767 
768 	bristolMidiSendMsg(global.controlfd, synth->sid, 126, 0, 1);
769 
770 	if (synth->mem.param[MOD_START + 4] == 0)
771 		bristolMidiSendMsg(global.controlfd, synth->sid, 6, 2, 0);
772 	else
773 		bristolMidiSendMsg(global.controlfd, synth->sid, 6, 2, 1);
774 
775 	switch ((int) synth->mem.param[MOD_START + 2])
776 	{
777 		case 0:
778 		default:
779 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 0,
780 				(int) ((1 - synth->mem.param[OPTS_START + 13])
781 					* C_RANGE_MIN_1));
782 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 1,
783 				(int) ((1 - synth->mem.param[OPTS_START + 13])
784 					* C_RANGE_MIN_1));
785 			break;
786 		case 1:
787 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 0,
788 				(int) ((1 - synth->mem.param[OPTS_START + 14])
789 					* C_RANGE_MIN_1));
790 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 1,
791 				(int) ((1 - synth->mem.param[OPTS_START + 14])
792 					* C_RANGE_MIN_1));
793 			break;
794 		case 2:
795 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 0,
796 				(int) ((1 - synth->mem.param[OPTS_START + 15])
797 					* C_RANGE_MIN_1));
798 			bristolMidiSendMsg(global.controlfd, synth->sid, 6, 1,
799 				(int) ((1 - synth->mem.param[OPTS_START + 14])
800 					* C_RANGE_MIN_1));
801 			break;
802 	}
803 }
804 
805 static void
doVolume(guiSynth * synth)806 doVolume(guiSynth *synth)
807 {
808 	bristolMidiSendMsg(global.controlfd, synth->sid, 0, 4,
809 		(int) (synth->mem.param[VOL_START] * C_RANGE_MIN_1));
810 }
811 
812 static void
doLeslieSpeed(guiSynth * synth)813 doLeslieSpeed(guiSynth *synth)
814 {
815 	int speed, depth, phase;
816 
817 	if (synth->mem.param[MOD_START] == 0)
818 	{
819 		bristolMidiSendMsg(global.controlfd, synth->sid, 100, 7, 0);
820 		return;
821 	}
822 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 7,
823 		(int) (synth->dispatch[OPTS_START + 1].other1));
824 
825 	if (synth->mem.param[MOD_START + 1] != 0)
826 	{
827 		speed = synth->mem.param[OPTS_START + 6] * C_RANGE_MIN_1;
828 		depth = synth->mem.param[OPTS_START + 7] * C_RANGE_MIN_1;
829 		phase = synth->mem.param[OPTS_START + 8] * C_RANGE_MIN_1;
830 	} else {
831 		speed = synth->mem.param[OPTS_START + 10] * C_RANGE_MIN_1;
832 		depth = synth->mem.param[OPTS_START + 11] * C_RANGE_MIN_1;
833 		phase = synth->mem.param[OPTS_START + 12] * C_RANGE_MIN_1;
834 	}
835 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 0, speed);
836 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 3, depth);
837 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 2, phase);
838 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 6,
839 		(int) (synth->mem.param[OPTS_START + 4] * C_RANGE_MIN_1));
840 	bristolMidiSendMsg(global.controlfd, synth->sid, 100, 1,
841 		(int) (synth->mem.param[OPTS_START + 5] * C_RANGE_MIN_1));
842 }
843 
844 static void
hammondPanelSwitch(guiSynth * id,int fd,int chan,int cont,int op,int value)845 hammondPanelSwitch(guiSynth *id, int fd, int chan, int cont, int op, int value)
846 {
847 	brightonEvent event;
848 
849 /*	printf("hammondPanelSwitch(%x, %i, %i, %i, %i, %i)\n", */
850 /*		id, fd, chan, cont, op, value); */
851 
852 	/*
853 	 * If the sendvalue is zero, then withdraw the opts window, draw the
854 	 * slider window, and vice versa.
855 	 */
856 	if (value == 0)
857 	{
858 		event.type = BRIGHTON_EXPOSE;
859 		event.intvalue = 0;
860 		brightonParamChange(id->win, OPTS_PANEL, -1, &event);
861 		event.intvalue = 1;
862 		brightonParamChange(id->win, SLIDER_PANEL, -1, &event);
863 	} else {
864 		event.type = BRIGHTON_EXPOSE;
865 		event.intvalue = 0;
866 		brightonParamChange(id->win, SLIDER_PANEL, -1, &event);
867 		event.intvalue = 1;
868 		brightonParamChange(id->win, OPTS_PANEL, -1, &event);
869 	}
870 }
871 
872 static void
hammondOption(guiSynth * synth,int fd,int chan,int cont,int op,int value)873 hammondOption(guiSynth *synth, int fd, int chan, int cont, int op, int value)
874 {
875 	brightonEvent event;
876 
877 	/*printf("hammondOption(%x, %i, %i, %i, %i, %i)\n", */
878 	/*	synth, fd, chan, cont, op, value); */
879 
880 	switch (cont) {
881 		case OPTS_START:
882 			/*
883 			 * Rotation type. Send 100.7 becomes op;
884 			 */
885 			if ((synth->flags & MEM_LOADING) == 0)
886 			{
887 				if (synth->dispatch[OPTS_START].other2)
888 				{
889 					synth->dispatch[OPTS_START].other2 = 0;
890 					return;
891 				}
892 				synth->dispatch[OPTS_START].other2 = 1;
893 				if (synth->dispatch[OPTS_START].other1 >= 0)
894 				{
895 					event.command = BRIGHTON_PARAMCHANGE;
896 					if (synth->dispatch[OPTS_START].other1 != (op - 1))
897 						event.value = 0;
898 					else
899 						event.value = 1;
900 					brightonParamChange(synth->win,
901 						OPTS_PANEL, synth->dispatch[OPTS_START].other1, &event);
902 				}
903 			}
904 
905 			if (synth->mem.param[OPTS_START + op - 1] != 0)
906 			{
907 				synth->dispatch[OPTS_START].other1 = op - 1;
908 				synth->dispatch[OPTS_START + 1].other1 = op;
909 
910 				if (synth->mem.param[MOD_START] == 0)
911 					bristolMidiSendMsg(global.controlfd, chan, 100, 7, 0);
912 				else {
913 					bristolMidiSendMsg(global.controlfd, chan, 100, 7, op);
914 					bristolMidiSendMsg(global.controlfd, chan, 100, 1,
915 						(int) (synth->mem.param[OPTS_START + 5]
916 							* C_RANGE_MIN_1));
917 				}
918 			}
919 			break;
920 		case OPTS_START + 3:
921 			/*
922 			 * Rotor break. Send 100.7 = 4 off, 100.7 = 5 on.
923 			 */
924 			if (value == 0)
925 				bristolMidiSendMsg(global.controlfd, chan, 100, 7, 4);
926 			else
927 				bristolMidiSendMsg(global.controlfd, chan, 100, 7, 5);
928 			break;
929 		case OPTS_START + 4:
930 		case OPTS_START + 5:
931 		case OPTS_START + 6:
932 		case OPTS_START + 7:
933 		case OPTS_START + 8:
934 		case OPTS_START + 10:
935 		case OPTS_START + 11:
936 		case OPTS_START + 12:
937 			doLeslieSpeed(synth);
938 			break;
939 		case OPTS_START + 9:
940 			/* overdrive */
941 			doOverdrive(synth);
942 			break;
943 		case OPTS_START + 13:
944 		case OPTS_START + 14:
945 		case OPTS_START + 15:
946 			doVibra(synth);
947 			break;
948 		case OPTS_START + 16:
949 		case OPTS_START + 17:
950 			doPerc(synth);
951 			break;
952 		case OPTS_START + 18:
953 		case OPTS_START + 19:
954 			doGrooming(synth);
955 			break;
956 		case OPTS_START + 20:
957 			doPreacher(synth);
958 			break;
959 		case OPTS_START + 21:
960 			doCompress(synth);
961 			break;
962 		case OPTS_START + 22:
963 			doBright(synth);
964 			break;
965 		case OPTS_START + 23:
966 			doClick(synth);
967 			break;
968 		case OPTS_START + 24:
969 		case OPTS_START + 25:
970 		case OPTS_START + 26:
971 			doReverb(synth);
972 			break;
973 		default:
974 			break;
975 	}
976 }
977 
978 /*
979  * Any location initialisation required to run the callbacks. For bristol, this
980  * will connect to the engine, and give it some base parameters.
981  * May need to generate some application specific menus.
982  * Will also then make specific requests to some of the devices to alter their
983  * rendering.
984  */
985 static int
hammondInit(brightonWindow * win)986 hammondInit(brightonWindow *win)
987 {
988 	guiSynth *synth = findSynth(global.synths, win);
989 	dispatcher *dispatch;
990 	int i;
991 
992 	if (synth == 0)
993 	{
994 		synth = findSynth(global.synths, 0);
995 		if (synth == 0)
996 		{
997 			printf("cannot init\n");
998 			return(0);
999 		}
1000 	}
1001 
1002 	synth->win = win;
1003 
1004 	printf("Initialise the hammond link to bristol: %p\n", synth->win);
1005 
1006 	synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
1007 	synth->mem.count = DEVICE_COUNT;
1008 	synth->mem.active = ACTIVE_DEVS;
1009 	synth->dispatch = (dispatcher *)
1010 		brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
1011 	dispatch = synth->dispatch;
1012 
1013 	/*
1014 	 * We really want to have three connection mechanisms. These should be
1015 	 *	1. Unix named sockets.
1016 	 *	2. UDP sockets.
1017 	 *	3. MIDI pipe.
1018 	 */
1019 	if (!global.libtest)
1020 		if ((synth->sid = initConnection(&global, synth)) < 0)
1021 			return(-1);
1022 
1023 	for (i = 0; i < DEVICE_COUNT; i++)
1024 		synth->dispatch[i].routine = hammondNull; /*hammondMidiSendMsg; */
1025 
1026 /*
1027 	dispatch[FIRST_DEV + 0].controller = 10;
1028 	dispatch[FIRST_DEV + 0].operator = 0;
1029 	dispatch[FIRST_DEV + 1].controller = 9;
1030 	dispatch[FIRST_DEV + 1].operator = 0;
1031 	dispatch[FIRST_DEV + 2].controller = 11;
1032 	dispatch[FIRST_DEV + 2].operator = 1;
1033 */
1034 
1035 	dispatch[OPTS_START].routine = (synthRoutine) hammondOption;
1036 	dispatch[OPTS_START].controller = OPTS_START;
1037 	dispatch[OPTS_START].operator = 1;
1038 	dispatch[OPTS_START + 1].routine = (synthRoutine) hammondOption;
1039 	dispatch[OPTS_START + 1].controller = OPTS_START;
1040 	dispatch[OPTS_START + 1].operator = 2;
1041 	dispatch[OPTS_START + 2].routine = (synthRoutine) hammondOption;
1042 	dispatch[OPTS_START + 2].controller = OPTS_START;
1043 	dispatch[OPTS_START + 2].operator = 3;
1044 	dispatch[OPTS_START].other1 = -1;
1045 	dispatch[OPTS_START].other2 = 0;
1046 	dispatch[OPTS_START + 3].routine = (synthRoutine) hammondOption;
1047 	dispatch[OPTS_START + 3].controller = OPTS_START + 3;
1048 
1049 	dispatch[OPTS_START + 4].routine = (synthRoutine) hammondOption;
1050 	dispatch[OPTS_START + 4].controller = OPTS_START + 4;
1051 	dispatch[OPTS_START + 5].routine = (synthRoutine) hammondOption;
1052 	dispatch[OPTS_START + 5].controller = OPTS_START + 5;
1053 	dispatch[OPTS_START + 6].routine = (synthRoutine) hammondOption;
1054 	dispatch[OPTS_START + 6].controller = OPTS_START + 6;
1055 	dispatch[OPTS_START + 7].routine = (synthRoutine) hammondOption;
1056 	dispatch[OPTS_START + 7].controller = OPTS_START + 7;
1057 	dispatch[OPTS_START + 8].routine = (synthRoutine) hammondOption;
1058 	dispatch[OPTS_START + 8].controller = OPTS_START + 8;
1059 	dispatch[OPTS_START + 9].routine = (synthRoutine) hammondOption;
1060 	dispatch[OPTS_START + 9].controller = OPTS_START + 9;
1061 	dispatch[OPTS_START + 10].routine = (synthRoutine) hammondOption;
1062 	dispatch[OPTS_START + 10].controller = OPTS_START + 10;
1063 	dispatch[OPTS_START + 11].routine = (synthRoutine) hammondOption;
1064 	dispatch[OPTS_START + 11].controller = OPTS_START + 11;
1065 	dispatch[OPTS_START + 12].routine = (synthRoutine) hammondOption;
1066 	dispatch[OPTS_START + 12].controller = OPTS_START + 12;
1067 
1068 	/* vibra */
1069 	dispatch[OPTS_START + 13].routine = (synthRoutine) hammondOption;
1070 	dispatch[OPTS_START + 13].controller = OPTS_START + 13;
1071 	dispatch[OPTS_START + 14].routine = (synthRoutine) hammondOption;
1072 	dispatch[OPTS_START + 14].controller = OPTS_START + 14;
1073 	dispatch[OPTS_START + 15].routine = (synthRoutine) hammondOption;
1074 	dispatch[OPTS_START + 15].controller = OPTS_START + 15;
1075 
1076 	dispatch[OPTS_START + 16].routine = (synthRoutine) hammondOption;
1077 	dispatch[OPTS_START + 16].controller = OPTS_START + 16;
1078 	dispatch[OPTS_START + 17].routine = (synthRoutine) hammondOption;
1079 	dispatch[OPTS_START + 17].controller = OPTS_START + 17;
1080 	dispatch[OPTS_START + 18].routine = (synthRoutine) hammondOption;
1081 	dispatch[OPTS_START + 18].controller = OPTS_START + 18;
1082 	dispatch[OPTS_START + 19].routine = (synthRoutine) hammondOption;
1083 	dispatch[OPTS_START + 19].controller = OPTS_START + 19;
1084 
1085 	/* preacher */
1086 	dispatch[OPTS_START + 20].routine = (synthRoutine) hammondOption;
1087 	dispatch[OPTS_START + 20].controller = OPTS_START + 20;
1088 	dispatch[OPTS_START + 21].routine = (synthRoutine) hammondOption;
1089 	dispatch[OPTS_START + 21].controller = OPTS_START + 21;
1090 	dispatch[OPTS_START + 22].routine = (synthRoutine) hammondOption;
1091 	dispatch[OPTS_START + 22].controller = OPTS_START + 22;
1092 	dispatch[OPTS_START + 23].routine = (synthRoutine) hammondOption;
1093 	dispatch[OPTS_START + 23].controller = OPTS_START + 23;
1094 
1095 	/* reverb */
1096 	dispatch[OPTS_START + 24].routine = (synthRoutine) hammondOption;
1097 	dispatch[OPTS_START + 24].controller = OPTS_START + 24;
1098 	dispatch[OPTS_START + 25].routine = (synthRoutine) hammondOption;
1099 	dispatch[OPTS_START + 25].controller = OPTS_START + 25;
1100 	dispatch[OPTS_START + 26].routine = (synthRoutine) hammondOption;
1101 	dispatch[OPTS_START + 26].controller = OPTS_START + 26;
1102 
1103 	/* Memory/Midi buttons */
1104 	dispatch[MEM_START + 10].routine = (synthRoutine) hammondPanelSwitch;
1105 	dispatch[MEM_START + 10].controller = MEM_COUNT;
1106 	dispatch[MEM_START + 10].operator = 0;
1107 
1108 	/*
1109 	 * These are for the memory radio buttons
1110 	 */
1111 	dispatch[MEM_START].other1 = 0;
1112 	dispatch[MEM_START].other2 = 0;
1113 
1114 	dispatch[MEM_START].operator = 0;
1115 	dispatch[MEM_START + 1].operator = 1;
1116 	dispatch[MEM_START + 2].operator = 2;
1117 	dispatch[MEM_START + 3].operator = 3;
1118 	dispatch[MEM_START + 4].operator = 4;
1119 	dispatch[MEM_START + 5].operator = 5;
1120 	dispatch[MEM_START + 6].operator = 6;
1121 	dispatch[MEM_START + 7].operator = 7;
1122 	dispatch[MEM_START + 8].operator = 8;
1123 	dispatch[MEM_START + 9].operator = 9;
1124 
1125 	dispatch[MEM_START].routine = dispatch[MEM_START + 1].routine =
1126 	dispatch[MEM_START + 2].routine = dispatch[MEM_START + 3].routine =
1127 	dispatch[MEM_START + 4].routine = dispatch[MEM_START + 5].routine =
1128 	dispatch[MEM_START + 6].routine = dispatch[MEM_START + 7].routine =
1129 	dispatch[MEM_START + 8].routine = dispatch[MEM_START + 9].routine =
1130 		(synthRoutine) hammondMemory;
1131 	/*
1132 	 * Mem load and save
1133 	 */
1134 	dispatch[MEM_START + 13].controller = 1;
1135 	dispatch[MEM_START + 14].controller = 2;
1136 	dispatch[MEM_START + 15].controller = 3;
1137 	dispatch[MEM_START + 16].controller = 4;
1138 	dispatch[MEM_START + 13].routine = dispatch[MEM_START + 14].routine
1139 		= dispatch[MEM_START + 15].routine = dispatch[MEM_START + 16].routine
1140 		= (synthRoutine) hammondMemory;
1141 
1142 	/*
1143 	 * Midi up/down
1144 	 */
1145 	dispatch[MEM_START + 11].controller = 2;
1146 	dispatch[MEM_START + 12].controller = 1;
1147 	dispatch[MEM_START + 11].routine = dispatch[MEM_START + 12].routine =
1148 		(synthRoutine) hammondMidi;
1149 
1150 	/*
1151 	 * Then we do the mods, starting with leslie
1152 	 */
1153 	dispatch[MOD_START].routine = (synthRoutine) doLeslieSpeed;
1154 	dispatch[MOD_START + 1].routine = (synthRoutine) doLeslieSpeed;
1155 
1156 	dispatch[MOD_START + 2].routine = (synthRoutine) doVibra;
1157 	dispatch[MOD_START + 3].routine = (synthRoutine) doVibra;
1158 	dispatch[MOD_START + 4].routine = (synthRoutine) doVibra;
1159 	/* Perc */
1160 	dispatch[MOD_START + 5].routine = (synthRoutine) doPerc;
1161 	dispatch[MOD_START + 6].routine = (synthRoutine) doPerc;
1162 	dispatch[MOD_START + 8].routine = (synthRoutine) doPerc;
1163 	/* grooming */
1164 	dispatch[MOD_START + 7].routine = (synthRoutine) doGrooming;
1165 	/* reverb */
1166 	dispatch[MOD_START + 9].routine = (synthRoutine) doReverb;
1167 	dispatch[MOD_START + 10].routine = (synthRoutine) doReverb;
1168 	dispatch[MOD_START + 11].routine = (synthRoutine) doClick;
1169 	dispatch[MOD_START + 12].routine = (synthRoutine) doBright;
1170 	dispatch[MOD_START + 13].routine = (synthRoutine) doOverdrive;
1171 
1172 	dispatch[VOL_START].routine = (synthRoutine) doVolume;
1173 
1174 	dispatch[SLIDER_START].routine =
1175 	dispatch[SLIDER_START + 1].routine =
1176 	dispatch[SLIDER_START + 2].routine =
1177 	dispatch[SLIDER_START + 3].routine =
1178 	dispatch[SLIDER_START + 4].routine =
1179 	dispatch[SLIDER_START + 5].routine =
1180 	dispatch[SLIDER_START + 6].routine =
1181 	dispatch[SLIDER_START + 7].routine =
1182 	dispatch[SLIDER_START + 8].routine = (synthRoutine) doSlider;
1183 
1184 	dispatch[SLIDER_START].controller = 0;
1185 	dispatch[SLIDER_START + 1].controller = 1;
1186 	dispatch[SLIDER_START + 2].controller = 2;
1187 	dispatch[SLIDER_START + 3].controller = 3;
1188 	dispatch[SLIDER_START + 4].controller = 4;
1189 	dispatch[SLIDER_START + 5].controller = 5;
1190 	dispatch[SLIDER_START + 6].controller = 6;
1191 	dispatch[SLIDER_START + 7].controller = 7;
1192 	dispatch[SLIDER_START + 8].controller = 8;
1193 
1194 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 0, 2);
1195 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 1, 3);
1196 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 2, 16383);
1197 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 3, 10);
1198 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 4, 13000);
1199 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 5, 0);
1200 
1201 	bristolMidiSendMsg(global.controlfd, synth->sid, 12, 7, 1);
1202 	bristolMidiSendMsg(global.controlfd, synth->sid, 10, 0, 4);
1203 
1204 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 0, 0);
1205 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 1, 10);
1206 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 2, 13000);
1207 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 3, 20);
1208 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 4, 13000);
1209 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 5, 0);
1210 
1211 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 0, 2);
1212 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 1, 1200);
1213 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 2, 0);
1214 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 3, 20);
1215 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 4, 13000);
1216 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 5, 0);
1217 
1218 	return(0);
1219 }
1220 
1221 /*
1222  * This will be called to make any routine specific parameters available.
1223  */
1224 static int
hammondConfigure(brightonWindow * win)1225 hammondConfigure(brightonWindow *win)
1226 {
1227 	guiSynth *synth = findSynth(global.synths, win);
1228 
1229 	if (synth == 0)
1230 	{
1231 		printf("problems going operational\n");
1232 		return(-1);
1233 	}
1234 
1235 	synth->keypanel = synth->keypanel2 = -1;
1236 
1237 	if (synth->flags & OPERATIONAL)
1238 		return(0);
1239 
1240 	synth->flags |= OPERATIONAL;
1241 	loadMemory(synth, "hammond", 0, synth->location, synth->mem.active,
1242 		FIRST_DEV, 0);
1243 	configureGlobals(synth);
1244 
1245 	return(0);
1246 }
1247 
1248