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 #include <fcntl.h>
23 
24 #include "brighton.h"
25 #include "brightonMini.h"
26 #include "brightoninternals.h"
27 
28 static int bitoneInit();
29 static int bitoneConfigure();
30 static int bitoneCallback(brightonWindow *, int, int, float);
31 static int midiCallback(brightonWindow *, int, int, float);
32 static int bitoneExtendedEntry(guiSynth *, int, int, int, int, int);
33 static int bitoneKeyCallback(brightonWindow *, int, int, float);
34 
35 extern guimain global;
36 static guimain manual;
37 
38 #include "brightonKeys.h"
39 
40 /*
41  * This will be changed for an eventual release however this allows me to test
42  * all the emulations with the same memories.
43 #define SYNTH_NAME "bitone"
44  */
45 #define SYNTH_NAME synth->resources->name
46 
47 /*
48  * We have 75 controls, will generate 150 for voice parameters. After that:
49  *	2 + 2 + 1 + 10 + 3 + 8 + 8 = 184 and then a few for inc/dec buttons, etc.
50  */
51 #define ACTIVE_DEVS 200
52 #define DEVICE_COUNT (ACTIVE_DEVS + 39)
53 #define DISPLAY_DEV (ACTIVE_DEVS + 30)
54 #define MEM_MGT ACTIVE_DEVS
55 #define MIDI_MGT (MEM_MGT + 12)
56 #define KEY_HOLD (7)
57 
58 #define KEY_PANEL 1
59 
60 #define SAVE_MODE (ACTIVE_DEVS - 4)
61 #define SAVE_STEREO (ACTIVE_DEVS - 3)
62 #define SAVE_PEER (ACTIVE_DEVS - 2)
63 
64 #define STEREO_BUTTON (ACTIVE_DEVS + 2)
65 #define PARK_BUTTON (ACTIVE_DEVS + 22)
66 #define COMPARE_BUTTON (ACTIVE_DEVS + 23)
67 
68 #define DCO_1_EXCLUSIVE 95
69 #define DCO_2_EXCLUSIVE 96
70 #define EXTENDED_BUTTON 00
71 #define NON_EXTENDED_BUTTON 100
72 
73 #define RADIOSET_1 (ACTIVE_DEVS + 9)
74 #define RADIOSET_2 (ACTIVE_DEVS + 19)
75 #define RADIOSET_3 ACTIVE_DEVS
76 
77 #define MODE_SINGLE	0
78 #define MODE_SPLIT	1
79 #define MODE_LAYER	2
80 
81 #define ENTER_ADDRESS 0
82 #define ENTER_LOWER 1
83 #define ENTER_UPPER 2
84 
85 static int mode = MODE_SINGLE, setsplit = 0.0, selectExtended = 0;
86 #define DEF_SPLIT 72
87 
88 /*
89  * Max data entry identifier for bit-1 parameters. Extended data entry needs
90  * to be handled separately.
91  */
92 #define ENTRY_MAX 100
93 #define ENTRY_POT (ACTIVE_DEVS + 8)
94 
95 static int entryPoint = ENTER_ADDRESS;
96 static int B1display[5];
97 
98 /*
99  * This is the scratchpad memory - we have on disk memories, on synth memories
100  * with potentially one loaded memory per layer, then we have the prePark mem
101  * where changes are made temporarily until parkted into the loaded memory.
102  *
103  * All parameter changes go into these layers and can be used as a quick compare
104  * to the last loaded memories. If the settings are parked they become semi
105  * permanant (as they have not actually been written to disk yet). We should
106  * have a double click on Park to save both memories to disk as well.
107  *
108  * We need 5 scratchpads, one for each layer, a backup for each layer, and
109  * a final one for memory copies.
110  */
111 static float scratchpad0[ACTIVE_DEVS];
112 static float scratchpad1[ACTIVE_DEVS];
113 static float scratchpad2[ACTIVE_DEVS];
114 static float scratchpad3[ACTIVE_DEVS];
115 static float scratchpad4[ACTIVE_DEVS];
116 static float scratchpad5[DEVICE_COUNT];
117 
118 /*
119  * We are going to require 4 to cover upper and lower shadows, a fifth to
120  * cover park/compare shadow of active memory, and we will take a sixth for
121  * saving other memory types
122  */
123 static guiSynth prePark[6];
124 
125 static int memLower = 0, memUpper = -1;
126 
127 static int dc;
128 
129 /*
130  * This structure is for device definition. The structure is defined in
131  * include/brighton.h, further definitions in brighton/brightonDevtable.h and
132  * include/brightoninternals.h
133  *
134  *	typedef int (*brightonCallback)(int, float);
135  *	typedef struct BrightonLocations {
136  *		int device; 0=rotary, 1=scale, etc.
137  *		float relx, rely; relative position with regards to 1000 by 1000 window
138  *		float relw, relh; relative height.
139  *		int from, to;
140  *		brightonCallback callback; specific to this dev
141  *		char *image; bitmap. If zero take a device default.
142  *		int flags;
143  *	} brightonLocations;
144  *
145  * This example is for a bitoneBristol type synth interface.
146  */
147 #define S1 418
148 #define S2 312
149 #define S3 228
150 #define S4 644
151 #define S5 262
152 #define S6 558
153 #define S7 644
154 #define S8 600
155 #define D1 42
156 #define W1 33
157 
158 /*
159  * We really need to define parameter types and ranges here to make the
160  * interface complete. For example, the midi channels only go from 1 to 16 and
161  * when selected as the input then the pot should configure this range.
162  *
163  * Similarly, if this is a button it should be 0 for the first half and 1 for
164  * the second half.
165  *
166  * This only applies to the displays, not to the parameters.
167  *
168  * Continuous controllers actually deliver a value between 0 and 1 to the
169  * engine - the Inc/Dec buttons actually do the steps emulating the original
170  * by going from 0.0 to 1.0 in the given number of stages. The pot, however,
171  * is continuous. Memories save the floating point value between 0 and 1.0,
172  * the stepped values are firstly put on the display and sent to the engine
173  * as the last stage of interpretation.
174  *
175  * The stepped controllers deliver integer values along the given range.
176  */
177 #define BITONE_CONTINUOUS 0
178 #define BITONE_STEPPED 1
179 
180 #define B1_INACTIVE			0x001 /* Skip this parameter */
181 #define B1_INHERIT_PRI		0x002 /* Copy from the primary layer when loading */
182 #define B1_INACTIVE_PEER	0x004 /* Not active in upper (second load) layer */
183 #define B1_USE_PRI			0x008 /* Take value from primary only */
184 #define B1_ALWAYS			0x010 /* All editing in double/split mode */
185 #define B1_INHERIT_SEC		0x020 /* Copy to the primary layer when changing */
186 #define B1_NO_LOAD			0x040 /* All editing in double/split mode */
187 #define B1_INHERIT_120		0x080 /* Copy to the primary layer when changing */
188 #define B1_INHERIT_121		0x100 /* Copy to the primary layer when changing */
189 #define B1_INHERIT_122		0x200 /* Copy to the primary layer when changing */
190 
191 typedef struct B1range {
192 	int type;
193 	float min;
194 	float max;
195 	int op, cont;  /* link to the engine code */
196 	int flags;
197 } b1range;
198 
199 /*
200  * STEPPED controllers are sent as that integer value. CONTINUOUS are sent
201  * as values from 0 to 1.0 but the range values specify how they are displayed
202  * on the LEDs.
203  */
204 b1range bitoneRange[ACTIVE_DEVS] = {
205 	{BITONE_STEPPED, 0, 1, 126, 126, B1_NO_LOAD}, /* Dummy entry */
206 	/* LFO-1 */
207 	{BITONE_STEPPED,    0, 1, 126, 13, 0},
208 	{BITONE_STEPPED,    0, 1, 126, 14, 0},
209 	{BITONE_STEPPED,    0, 1, 126, 15, 0},
210 	{BITONE_CONTINUOUS, 0, 1, 126, 17, 0},
211 	{BITONE_CONTINUOUS, 0, 1, 126, 18, 0},
212 	{BITONE_CONTINUOUS, 0, 1, 126, 19, 0},
213 	{BITONE_CONTINUOUS, 0, 1, 126, 20, 0},
214 	{BITONE_CONTINUOUS, 0, 31, 2, 0, 0},
215 	{BITONE_CONTINUOUS, 0, 63, 0, 0, 0},
216 	{BITONE_CONTINUOUS, 0, 31, 0, 2, 0},
217 	{BITONE_CONTINUOUS, 1, 32, 2, 4, 0},
218 	{BITONE_CONTINUOUS, 0, 31, 126, 12, 0},
219 	/* VCF - 13 */
220 	{BITONE_CONTINUOUS, 0, 63, 7, 0, 0},
221 	{BITONE_CONTINUOUS, 0, 63, 7, 1, 0},
222 	{BITONE_CONTINUOUS, 0, 63, 7, 2, 0},
223 	{BITONE_CONTINUOUS, 0, 63, 7, 3, 0},
224 	{BITONE_CONTINUOUS, 0, 63, 7, 5, 0},
225 	{BITONE_CONTINUOUS, 0,  1, 6, 3, 0},
226 	{BITONE_CONTINUOUS, 0, 63, 6, 0, 0},
227 	{BITONE_CONTINUOUS, 0, 63, 6, 1, 0},
228 	{BITONE_CONTINUOUS, 0, 63, 6, 2, 0},
229 	{BITONE_CONTINUOUS, 0, 63, 7, 8, 0},
230 	{BITONE_STEPPED, 0, 1, 126, 39, 0}, /* invert */
231 	/* DCO 1 - 24 */
232 	{BITONE_CONTINUOUS, 0,  1, 4, 0, 0},
233 	{BITONE_CONTINUOUS, 0,  1, 4, 1, 0},
234 	{BITONE_CONTINUOUS, 0,  1, 4, 2, 0},
235 	{BITONE_CONTINUOUS, 0,  1, 4, 3, 0},
236 	{BITONE_CONTINUOUS, 0,  1, 4, 4, 0},
237 	{BITONE_CONTINUOUS, 0,  1, 4, 5, 0},
238 	{BITONE_CONTINUOUS, 0,  1, 4, 6, 0},
239 	{BITONE_STEPPED,    0, 24, 4, 8, 0},
240 	{BITONE_CONTINUOUS, 0, 31, 4, 7, 0},
241 	{BITONE_CONTINUOUS, 0, 63, 4, 10, 0},
242 	{BITONE_CONTINUOUS, 0, 63, 126, 8, 0},
243 	/* DCO 2 - 35 */
244 	{BITONE_CONTINUOUS, 0,  1, 5, 0, 0},
245 	{BITONE_CONTINUOUS, 0,  1, 5, 1, 0},
246 	{BITONE_CONTINUOUS, 0,  1, 5, 2, 0},
247 	{BITONE_CONTINUOUS, 0,  1, 5, 3, 0},
248 	{BITONE_CONTINUOUS, 0,  1, 5, 4, 0},
249 	{BITONE_CONTINUOUS, 0,  1, 5, 5, 0},
250 	{BITONE_CONTINUOUS, 0,  1, 5, 6, 0},
251 	{BITONE_STEPPED,    0, 24, 5, 8, 0},
252 	{BITONE_CONTINUOUS, 0, 31, 5, 7, 0},
253 	{BITONE_CONTINUOUS, 0, 63, 5, 10, 0},
254 	{BITONE_CONTINUOUS, 0, 63, 5, 9, 0},
255 	/* VCA - 46 */
256 	{BITONE_CONTINUOUS, 0, 63, 9, 5, 0},
257 	{BITONE_CONTINUOUS, 0, 63, 9, 8, 0},
258 	{BITONE_CONTINUOUS, 0, 63, 9, 4, 0},
259 	{BITONE_CONTINUOUS, 0, 63, 9, 0, 0},
260 	{BITONE_CONTINUOUS, 0, 63, 9, 1, 0},
261 	{BITONE_CONTINUOUS, 0, 63, 9, 2, 0},
262 	{BITONE_CONTINUOUS, 0, 63, 9, 3, 0},
263 	/* LFO-2 - 53 */
264 	{BITONE_STEPPED,    0, 1, 126, 21, 0},
265 	{BITONE_STEPPED,    0, 1, 126, 22, 0},
266 	{BITONE_STEPPED,    0, 1, 126, 23, 0},
267 	{BITONE_CONTINUOUS, 0, 1, 126, 25, 0},
268 	{BITONE_CONTINUOUS, 0, 1, 126, 26, 0},
269 	{BITONE_CONTINUOUS, 0, 1, 126, 27, 0},
270 	{BITONE_CONTINUOUS, 0, 1, 126, 28, 0},
271 	{BITONE_CONTINUOUS, 0, 31, 3, 0, 0},
272 	{BITONE_CONTINUOUS, 0, 63, 1, 0, 0},
273 	{BITONE_CONTINUOUS, 0, 31, 1, 2, 0},
274 	{BITONE_CONTINUOUS, 1, 32, 3, 4, 0},
275 	/* Split Point, transpose and layer volumes - 64 */
276 	{BITONE_STEPPED, 1, 60, 126, 101, B1_ALWAYS|B1_INHERIT_121},
277 	{BITONE_STEPPED, 1, 60, 126, 101, B1_ALWAYS|B1_INHERIT_122},
278 	{BITONE_CONTINUOUS, 0, 63, 126, 101, B1_USE_PRI|B1_ALWAYS},
279 	{BITONE_CONTINUOUS, 0, 63, 126, 101, B1_USE_PRI|B1_ALWAYS},
280 	/* MIDI REC - 68 */
281 	{BITONE_CONTINUOUS, 0, 63, 126, 43, 0},
282 	{BITONE_STEPPED, 0, 25, 126, 42, 0}, /* sensitivity */
283 	{BITONE_STEPPED, 0, 2, 126, 101, 0}, /* debug */
284 	{BITONE_STEPPED, 0, 1, 126, 101, 0}, /* Accept Program Change */
285 	{BITONE_STEPPED, 0, 1, 126, 101, 0}, /* OMNI */
286 	{BITONE_STEPPED, 1, 16, 126, 101, B1_ALWAYS|B1_INHERIT_120},
287 	/* MIDI TRS - 74 */
288 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD}, /* MEM SEARCH UP */
289 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD}, /* MEM SEARCH DOWN */
290 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD}, /* release */
291 	/* BIT-99 FM DCO-1->2, SYNC 2-<1, GLIDE, Unison - 77 */
292 	{BITONE_CONTINUOUS, 0, 31, 126, 40, 0},
293 	{BITONE_STEPPED, 0, 1, 126, 38, 0},
294 	{BITONE_CONTINUOUS, 0, 63, 126, 0,
295 		B1_INHERIT_SEC|B1_USE_PRI|B1_INACTIVE_PEER|B1_ALWAYS},
296 	{BITONE_STEPPED, 0, 1, 126, 7, B1_ALWAYS},
297 	/* 81 upwards are bit-100 options */
298 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
299 	{BITONE_CONTINUOUS, 0, 31, 126, 34, 0},
300 	{BITONE_CONTINUOUS, 0, 31, 126, 35, 0},
301 	{BITONE_CONTINUOUS, 0, 64, 0, 3, 0},
302 	{BITONE_CONTINUOUS, 0, 63, 2, 5, 0},
303 	{BITONE_STEPPED, 0, 1, 126, 29, 0},
304 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
305 	{BITONE_CONTINUOUS, 0, 31, 126, 36, 0},
306 	{BITONE_CONTINUOUS, 0, 31, 126, 37, 0},
307 	{BITONE_CONTINUOUS, 0, 64, 1, 3, 0},
308 	{BITONE_CONTINUOUS, 0, 63, 3, 5, 0},
309 	{BITONE_STEPPED, 0, 1, 126, 30, 0},
310 	{BITONE_CONTINUOUS, 0, 63, 126, 32, 0},
311 	{BITONE_CONTINUOUS, 0, 63, 126, 33, 0},
312 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
313 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
314 	{BITONE_STEPPED, 0, 2, 6, 4, 0},
315 	{BITONE_CONTINUOUS, 0, 63, 126, 41, 0},
316 	{BITONE_STEPPED, 0, 1, 126, 31, 0},
317 	/* 100 is the extended entry deselector */
318 	{BITONE_STEPPED, 0, 1, 0, 0, B1_NO_LOAD},
319 	/* 101 is the writethru scratchpad */
320 	{BITONE_STEPPED, 0, 1, 0, 0, 0},
321 	{BITONE_STEPPED, 0, 1, 0, 0, 0},
322 	/* LFO Sync */
323 	{BITONE_STEPPED, 0, 1, 0, 1, 0},
324 	{BITONE_STEPPED, 0, 1, 1, 1, 0},
325 	/* Env rezero - 105 */
326 	{BITONE_STEPPED, 0, 1, 7, 6, 0},
327 	{BITONE_STEPPED, 0, 1, 9, 6, 0},
328 	/* LFO rezero */
329 	{BITONE_STEPPED, 0, 1, 2, 6, 0},
330 	{BITONE_STEPPED, 0, 1, 3, 6, 0},
331 	/* DEBUG debug Debug dbg 3 levels - 109 */
332 	{BITONE_STEPPED, 0, 5, 126, 101, 0},
333 	/* Channel gains - LR Mono LR Stereo, first lower then upper - 110*/
334 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
335 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
336 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
337 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
338 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
339 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
340 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
341 	{BITONE_CONTINUOUS, 0, 99, 0, 0, 0},
342 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
343 	{BITONE_STEPPED, 0, 99, 126, 101, 0},
344 	/* Channel/split/transpose coherency - holders only - 120 */
345 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
346 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
347 	{BITONE_STEPPED, 0, 1, 126, 101, 0},
348 	{BITONE_STEPPED, 0, 1, 126, 101, 0}, /* NRP Enable */
349 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
350 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
351 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
352 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
353 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
354 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
355 	/* Search Up/Down - 130 */
356 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
357 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
358 	/* Env conditional -  132 */
359 	{BITONE_STEPPED, 0, 1, 7, 7, 0},
360 	{BITONE_STEPPED, 0, 1, 9, 7, 0},
361 	{BITONE_STEPPED, 0, 1, 2, 7, 0},
362 	{BITONE_STEPPED, 0, 1, 3, 7, 0},
363 	{BITONE_STEPPED, 0, 1, 10, 1, 0},
364 	{BITONE_CONTINUOUS, 0, 63, 10, 2, 0},
365 	{BITONE_CONTINUOUS, 0, 63, 126, 101, 0}, /* GLIDE */
366 	{BITONE_CONTINUOUS, 0, 63, 126, 101, 0}, /* Gain */
367 	/* Square wave - 140 */
368 	{BITONE_CONTINUOUS, 0, 63, 4, 11, 0},
369 	{BITONE_CONTINUOUS, 0, 63, 4, 12, 0},
370 	{BITONE_CONTINUOUS, 0, 63, 5, 11, 0},
371 	{BITONE_CONTINUOUS, 0, 63, 5, 12, 0},
372 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
373 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
374 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
375 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
376 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
377 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
378 	/* Arpeggiator - 150 */
379 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_ARPEG_ENABLE, B1_INACTIVE},
380 	{BITONE_STEPPED, 0, 3, 125, BRISTOL_ARPEG_DIR, B1_INACTIVE},
381 	{BITONE_STEPPED, 0, 3, 125, BRISTOL_ARPEG_RANGE, B1_INACTIVE},
382 	{BITONE_CONTINUOUS, 0, 99, 125, BRISTOL_ARPEG_RATE, B1_INACTIVE},
383 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_ARPEG_CLOCK, B1_INACTIVE},
384 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_ARPEG_TRIGGER, B1_INACTIVE},
385 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_ARPEG_POLY_2, B1_INACTIVE},
386 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_CHORD_ENABLE, B1_INACTIVE},
387 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_CHORD_RESEQ, B1_INACTIVE},
388 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_SEQ_ENABLE, B1_INACTIVE},
389 	{BITONE_STEPPED, 0, 3, 125, BRISTOL_SEQ_DIR, B1_INACTIVE},
390 	{BITONE_STEPPED, 0, 3, 125, BRISTOL_SEQ_RANGE, B1_INACTIVE},
391 	{BITONE_CONTINUOUS, 0, 99, 125, BRISTOL_SEQ_RATE, B1_INACTIVE},
392 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_SEQ_CLOCK, B1_INACTIVE},
393 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_SEQ_TRIGGER, B1_INACTIVE},
394 	{BITONE_STEPPED, 0, 1, 125, BRISTOL_SEQ_RESEQ, B1_INACTIVE},
395 	/* Free 166 */
396 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
397 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
398 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
399 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
400 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
401 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
402 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
403 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
404 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
405 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
406 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
407 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
408 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
409 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
410 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
411 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
412 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
413 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
414 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
415 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
416 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
417 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
418 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
419 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
420 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
421 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
422 	{BITONE_STEPPED, 0, 1, 126, 101, B1_INACTIVE},
423 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
424 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
425 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
426 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
427 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
428 	{BITONE_STEPPED, 0, 1, 126, 101, B1_NO_LOAD},
429 	/* This should be 199, the wheel controller for the second LFO */
430 	{BITONE_CONTINUOUS, 0, 31, 126, 12, B1_NO_LOAD},
431 
432 };
433 
434 static
435 brightonLocations locations[DEVICE_COUNT] = {
436 	/*
437 	 * 100 withdrawn buttons for later use
438 	 *
439 	 * The first one was just to look at some stuff with use of the transparency
440 	 * layer to highlight entry, exit and button click so that this panel of
441 	 * parameters can be used to select data entry address selections.
442 	 *
443 	 * The first is a dummy here since the parameters start from '1'.
444 	 */
445 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
446 
447 	/* LFO-1 - 1 */
448 	{"", 9, 291, S1, W1, 39, 0, 1, 0,
449 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
450 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
451 	{"", 9, 291, S1 + D1, W1, 39, 0, 1, 0,
452 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
453 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
454 	{"", 9, 291, S1 + D1 * 2, W1, 39, 0, 1, 0,
455 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
456 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
457 	{"", 9, 291, S1 + D1 * 3, W1, 39, 0, 1, 0,
458 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
459 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
460 	{"", 9, 291, S1 + D1 * 4, W1, 39, 0, 1, 0,
461 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
462 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
463 	{"", 9, 291, S1 + D1 * 5, W1, 39, 0, 1, 0,
464 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
465 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
466 
467 	{"", 9, 362, S1, W1, 39, 0, 1, 0,
468 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
469 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
470 	{"", 9, 362, S1 + D1, W1, 39, 0, 1, 0,
471 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
472 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
473 	{"", 9, 362, S1 + D1 * 2, W1, 39, 0, 1, 0,
474 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
475 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
476 	{"", 9, 362, S1 + D1 * 3, W1, 39, 0, 1, 0,
477 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
478 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
479 	{"", 9, 362, S1 + D1 * 4, W1, 39, 0, 1, 0,
480 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
481 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
482 	{"", 9, 362, S1 + D1 * 5, W1, 39, 0, 1, 0,
483 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
484 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
485 
486 	/* VCF - 13 */
487 	{"", 9, 409, S2, W1, 39, 0, 1, 0,
488 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
489 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
490 	{"", 9, 409, S2 + D1, W1, 39, 0, 1, 0,
491 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
492 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
493 	{"", 9, 409, S2 + D1 * 2, W1, 39, 0, 1, 0,
494 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
495 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
496 	{"", 9, 409, S2 + D1 * 3, W1, 39, 0, 1, 0,
497 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
498 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
499 	{"", 9, 409, S2 + D1 * 4, W1, 39, 0, 1, 0,
500 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
501 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
502 
503 	{"", 9, 478, S2, W1, 39, 0, 1, 0,
504 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
505 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
506 	{"", 9, 478, S2 + D1, W1, 39, 0, 1, 0,
507 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
508 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
509 	{"", 9, 478, S2 + D1 * 2, W1, 39, 0, 1, 0,
510 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
511 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
512 	{"", 9, 478, S2 + D1 * 3, W1, 39, 0, 1, 0,
513 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
514 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
515 	{"", 9, 478, S2 + D1 * 4, W1, 39, 0, 1, 0,
516 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
517 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
518 	{"", 9, 478, S2 + D1 * 5, W1, 39, 0, 1, 0,
519 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
520 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
521 
522 	/* DCO 1 - 24 */
523 	{"", 9, 524, S3, W1, 39, 0, 1, 0,
524 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
525 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
526 	{"", 9, 524, S3 + D1, W1, 39, 0, 1, 0,
527 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
528 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
529 	{"", 9, 524, S3 + D1 * 2, W1, 39, 0, 1, 0,
530 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
531 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
532 	{"", 9, 524, S3 + D1 * 3, W1, 39, 0, 1, 0,
533 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
534 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
535 
536 	{"", 9, 576, S3 + D1, 23, 39, 0, 1, 0,
537 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
538 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
539 	{"", 9, 576, S3 + D1 * 2, 23, 39, 0, 1, 0,
540 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
541 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
542 	{"", 9, 576, S3 + D1 * 3, 23, 39, 0, 1, 0,
543 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
544 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
545 
546 	{"", 9, 636, S3, W1, 39, 0, 1, 0,
547 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
548 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
549 	{"", 9, 636, S3 + D1, W1, 39, 0, 1, 0,
550 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
551 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
552 	{"", 9, 636, S3 + D1 * 2, W1, 39, 0, 1, 0,
553 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
554 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
555 	{"", 9, 636, S3 + D1 * 3, W1, 39, 0, 1, 0,
556 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
557 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
558 
559 	/* DCO 2 - 35 */
560 	{"", 9, 524, S4, W1, 39, 0, 1, 0,
561 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
562 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
563 	{"", 9, 524, S4 + D1, W1, 39, 0, 1, 0,
564 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
565 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
566 	{"", 9, 524, S4 + D1 * 2, W1, 39, 0, 1, 0,
567 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
568 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
569 	{"", 9, 524, S4 + D1 * 3, W1, 39, 0, 1, 0,
570 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
571 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
572 
573 	{"", 9, 576, S4, 23, 39, 0, 1, 0,
574 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
575 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
576 	{"", 9, 576, S4 + D1 * 1, 23, 39, 0, 1, 0,
577 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
578 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
579 	{"", 9, 576, S4 + D1 * 2, 23, 39, 0, 1, 0,
580 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
581 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
582 
583 	{"", 9, 636, S4, W1, 39, 0, 1, 0,
584 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
585 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
586 	{"", 9, 636, S4 + D1, W1, 39, 0, 1, 0,
587 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
588 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
589 	{"", 9, 636, S4 + D1 * 2, W1, 39, 0, 1, 0,
590 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
591 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
592 	{"", 9, 636, S4 + D1 * 3, W1, 39, 0, 1, 0,
593 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
594 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
595 
596 	/* VCA - 46 */
597 	{"", 9, 681, S5, W1, 39, 0, 1, 0,
598 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
599 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
600 	{"", 9, 681, S5 + D1, W1, 39, 0, 1, 0,
601 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
602 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
603 	{"", 9, 681, S5 + D1 * 2, W1, 39, 0, 1, 0,
604 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
605 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
606 
607 	{"", 9, 751, S5, W1, 39, 0, 1, 0,
608 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
609 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
610 	{"", 9, 751, S5 + D1, W1, 39, 0, 1, 0,
611 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
612 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
613 	{"", 9, 751, S5 + D1 * 2, W1, 39, 0, 1, 0,
614 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
615 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
616 	{"", 9, 751, S5 + D1 * 3, W1, 39, 0, 1, 0,
617 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
618 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
619 
620 	/* LFO-2 - 53 */
621 	{"", 9, 681, S6, W1, 39, 0, 1, 0,
622 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
623 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
624 	{"", 9, 681, S6 + D1, W1, 39, 0, 1, 0,
625 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
626 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
627 	{"", 9, 681, S6 + D1 * 2, W1, 39, 0, 1, 0,
628 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
629 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
630 	{"", 9, 681, S6 + D1 * 3, W1, 39, 0, 1, 0,
631 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
632 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
633 	{"", 9, 681, S6 + D1 * 4, W1, 39, 0, 1, 0,
634 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
635 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
636 	{"", 9, 681, S6 + D1 * 5, W1, 39, 0, 1, 0,
637 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
638 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
639 
640 	{"", 9, 751, S6, W1, 39, 0, 1, 0,
641 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
642 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
643 	{"", 9, 751, S6 + D1, W1, 39, 0, 1, 0,
644 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
645 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
646 	{"", 9, 751, S6 + D1 * 2, W1, 39, 0, 1, 0,
647 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
648 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
649 	{"", 9, 751, S6 + D1 * 3, W1, 39, 0, 1, 0,
650 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
651 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
652 	{"", 9, 751, S6 + D1 * 4, W1, 39, 0, 1, 0,
653 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
654 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
655 
656 	/* Split Double - 64 */
657 	{"", 9, 409, S7, W1, 39, 0, 1, 0,
658 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
659 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
660 	{"", 9, 409, S7 + D1, W1, 39, 0, 1, 0,
661 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
662 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
663 	/* Layer volumes */
664 	{"", 9, 478, S7, W1, 39, 0, 1, 0,
665 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
666 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
667 	{"", 9, 478, S7 + D1, W1, 39, 0, 1, 0,
668 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
669 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
670 
671 	/* MIDI - 68 */
672 	{"", 9, 811, S5, W1, 39, 0, 1, 0,
673 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
674 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
675 	{"", 9, 811, S5 + D1, W1, 39, 0, 1, 0,
676 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
677 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
678 	{"", 9, 811, S5 + D1 * 2, W1, 39, 0, 1, 0,
679 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
680 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
681 	{"", 9, 811, S5 + D1 * 3, W1, 39, 0, 1, 0,
682 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
683 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
684 	{"", 9, 811, S5 + D1 * 4, W1, 39, 0, 1, 0,
685 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
686 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
687 	{"", 9, 811, S5 + D1 * 5, W1, 39, 0, 1, 0,
688 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
689 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
690 
691 	{"", 9, 811, S8, W1, 39, 0, 1, 0,
692 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
693 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
694 	{"", 9, 811, S8 + D1, W1, 39, 0, 1, 0,
695 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
696 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
697 	{"", 9, 811, S8 + D1 * 2, W1, 39, 0, 1, 0,
698 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
699 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
700 
701 	/*
702 	 * Bit-99: FM 1->2,SYNC,GLIDE L/U - 77/78/79/80
703 	 */
704 	{"", 9, 0, 0, 23, 39, 0, 1, 0,
705 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
706 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
707 	{"", 9, 576, S4 + D1 * 3, 23, 39, 0, 1, 0,
708 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
709 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
710 	{"", 9, 409, S7 + D1 * 2, W1, 39, 0, 1, 0,
711 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
712 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
713 	{"", 9, 478, S7 + D1 * 2, W1, 39, 0, 1, 0,
714 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
715 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
716 	/* These are unison - 81 and 82 */
717 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
718 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
719 	/* PWM DCO-2 - 83 */
720 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
721 	/* DCO harmonics - 84 */
722 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
723 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
724 	/* Dummies - 86 */
725 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
726 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
727 	{"", 9, 576, S3, 23, 39, 0, 1, 0,
728 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
729 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
730 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
731 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
732 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
733 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
734 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
735 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
736 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
737 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
738 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
739 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
740 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
741 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
742 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
743 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
744 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
745 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
746 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
747 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
748 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
749 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
750 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
751 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
752 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
753 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
754 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
755 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
756 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
757 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
758 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
759 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
760 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
761 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
762 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
763 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
764 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
765 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
766 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
767 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
768 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
769 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
770 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
771 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
772 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
773 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
774 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
775 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
776 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
777 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
778 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
779 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
780 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
781 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
782 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
783 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
784 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
785 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
786 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
787 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
788 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
789 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
790 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
791 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
792 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
793 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
794 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
795 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
796 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
797 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
798 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
799 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
800 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
801 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
802 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
803 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
804 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
805 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
806 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
807 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
808 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
809 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
810 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
811 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
812 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
813 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
814 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
815 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
816 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
817 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
818 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
819 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
820 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
821 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
822 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
823 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
824 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
825 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
826 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
827 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
828 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
829 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
830 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
831 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
832 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
833 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
834 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
835 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
836 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
837 	/* 196 is the split/double placeholder */
838 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
839 	/* This is 197 and may be the stereo placeholder */
840 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
841 	/* This is 198 and will be the peer layer placeholder */
842 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
843 	/*
844 	 * This needed to move as it is parameter 12, not 64 - now at 199. The
845 	 * withdrawn flag is only removed if the bit-99 is requested.
846 	 */
847 	{"", 9, 751, S6 + D1 * 5, W1, 39, 0, 1, 0,
848 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
849 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
850 
851 	/* split double - 200 */
852 	{"", 2, 217, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
853 		"bitmaps/buttons/presson.xpm", 0},
854 	{"", 2, 217, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
855 		"bitmaps/buttons/presson.xpm", 0},
856 	/* Stereo - 202 */
857 	{"", 2, 257, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
858 		"bitmaps/buttons/presson.xpm", 0},
859 	/* Pot for tune */
860 	{"", 0, 250, 150, 80, 80, 0, 1, 0, "bitmaps/knobs/knob1.xpm", 0,
861 		BRIGHTON_NOTCH},
862 	/*
863 	 * The following two are in the memory as non-visible placeholder for
864 	 * combined patches upper/lower/split/layer, etc. It should use the same
865 	 * peer memory logic employed by the Jupiter GUI. Moved to within first 100
866 	 */
867 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
868 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
869 
870 	/* Two sliders for volume controls - 206 */
871 	{"", 1, 51, 570, 10, 260, 0, 1, 0, "bitmaps/knobs/sliderblack5.xpm", 0, 0},
872 	{"", 1, 72, 570, 10, 260, 0, 1, 0, "bitmaps/knobs/sliderblack5.xpm", 0, 0},
873 
874 	/* Pot for entry - 208 */
875 	{"", 0, 54, 330, 80, 80, 0, 1, 0, "bitmaps/knobs/knob1.xpm", 0, 0},
876 
877 	/* Ten data entry buttons - 209 */
878 	{"", 2, 100, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
879 		"bitmaps/buttons/presson.xpm", 0},
880 	{"", 2, 120, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
881 		"bitmaps/buttons/presson.xpm", 0},
882 	{"", 2, 140, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
883 		"bitmaps/buttons/presson.xpm", 0},
884 	{"", 2, 160, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
885 		"bitmaps/buttons/presson.xpm", 0},
886 	{"", 2, 180, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
887 		"bitmaps/buttons/presson.xpm", 0},
888 
889 	{"", 2, 100, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
890 		"bitmaps/buttons/presson.xpm", 0},
891 	{"", 2, 120, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
892 		"bitmaps/buttons/presson.xpm", 0},
893 	{"", 2, 140, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
894 		"bitmaps/buttons/presson.xpm", 0},
895 	{"", 2, 160, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
896 		"bitmaps/buttons/presson.xpm", 0},
897 	{"", 2, 180, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
898 		"bitmaps/buttons/presson.xpm", 0},
899 
900 	/* Addr, lower, upper - 219 */
901 	{"", 2, 100, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
902 		"bitmaps/buttons/presson.xpm", 0},
903 	{"", 2, 140, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
904 		"bitmaps/buttons/presson.xpm", 0},
905 	{"", 2, 180, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
906 		"bitmaps/buttons/presson.xpm", 0},
907 
908 	/* Park, Compare - 222 */
909 	{"", 2, 217, 150, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
910 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
911 	{"", 2, 217, 320, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
912 		"bitmaps/buttons/presson.xpm", 0},
913 
914 	/* Prog load - 224 */
915 	{"", 2, 257, 320, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
916 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
917 
918 	/* save - 225 */
919 	{"", 2, 257, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
920 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
921 
922 	/* Two sliders for bend and mod - 226 */
923 	{"", 1, 17, 150, 10, 280, 0, 1, 0, "bitmaps/knobs/sliderblack4.xpm", 0,
924 		BRIGHTON_HALFSHADOW|BRIGHTON_REVERSE},
925 	{"", 1, 17, 500, 10, 280, 0, 1, 0, "bitmaps/knobs/sliderblack4.xpm", 0,
926 		BRIGHTON_HALFSHADOW|BRIGHTON_CENTER|BRIGHTON_REVERSE},
927 
928 	/* Inc/Dec for data entry - 228 */
929 	{"", 2, 50, 430, 13, 60, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
930 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
931 	{"", 2, 70, 430, 13, 60, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
932 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
933 
934 	/* 8 LED displays - 230 */
935 	{"", 8, 52, 150, 15, 80, 0, 9, 0, 0, 0, 0},
936 	{"", 8, 67, 150, 15, 80, 0, 9, 0, 0, 0, 0},
937 
938 	{"", 8, 97, 150, 15, 80, 0, 9, 0, 0, 0, 0},
939 	{"", 8, 111, 150, 15, 80, 0, 9, 0, 0, 0, 0},
940 
941 	{"", 8, 133, 150, 15, 80, 0, 9, 0, 0, 0, 0},
942 	{"", 8, 148, 150, 15, 80, 0, 9, 0, 0, 0, 0},
943 
944 	{"", 8, 172, 150, 15, 80, 0, 9, 0, 0, 0, 0},
945 	{"", 8, 187, 150, 15, 80, 0, 9, 0, 0, 0, 0},
946 
947 	/* The Bit-1 had a Unison button, not stereo - 238 */
948 	{"", 2, 257, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
949 		"bitmaps/buttons/presson.xpm", BRIGHTON_WITHDRAWN},
950 };
951 
952 #define SS1 155
953 #define SS2 580
954 #define SS3 240
955 #define SS4 253
956 #define S5 262
957 #define SS6 580
958 #define S7 644
959 #define S8 600
960 
961 static
962 brightonLocations locations100[DEVICE_COUNT] = {
963 	/*
964 	 * 100 withdrawn buttons for later use
965 	 *
966 	 * The first one was just to look at some stuff with use of the transparency
967 	 * layer to highlight entry, exit and button click so that this panel of
968 	 * parameters can be used to select data entry address selections.
969 	 *
970 	 * The first is a dummy here since the parameters start from '1'.
971 	 */
972 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
973 
974 	/* LFO-1 - 1 */
975 	{"", 9, 293, SS1, W1, 39, 0, 1, 0,
976 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
977 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
978 	{"", 9, 293, SS1 + D1, W1, 39, 0, 1, 0,
979 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
980 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
981 	{"", 9, 293, SS1 + D1 * 2, W1, 39, 0, 1, 0,
982 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
983 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
984 	{"", 9, 293, SS1 + D1 * 3, W1, 39, 0, 1, 0,
985 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
986 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
987 	{"", 9, 293, SS1 + D1 * 4, W1, 39, 0, 1, 0,
988 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
989 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
990 	{"", 9, 293, SS1 + D1 * 5, W1, 39, 0, 1, 0,
991 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
992 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
993 
994 	{"", 9, 345, SS1, W1, 39, 0, 1, 0,
995 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
996 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
997 	{"", 9, 345, SS1 + D1, W1, 39, 0, 1, 0,
998 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
999 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1000 	{"", 9, 345, SS1 + D1 * 2, W1, 39, 0, 1, 0,
1001 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1002 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1003 	{"", 9, 345, SS1 + D1 * 3, W1, 39, 0, 1, 0,
1004 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1005 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1006 	{"", 9, 345, SS1 + D1 * 4, W1, 39, 0, 1, 0,
1007 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1008 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1009 	{"", 9, 345, SS1 + D1 * 5, W1, 39, 0, 1, 0,
1010 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1011 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
1012 
1013 	/* VCF - 13 */
1014 	{"", 9, 763, SS4 + D1, W1, 39, 0, 1, 0,
1015 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1016 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1017 	{"", 9, 763, SS4 + D1 * 2, W1, 39, 0, 1, 0,
1018 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1019 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1020 	{"", 9, 763, SS4 + D1 * 3, W1, 39, 0, 1, 0,
1021 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1022 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1023 	{"", 9, 763, SS4 + D1 * 4, W1, 39, 0, 1, 0,
1024 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1025 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1026 	{"", 9, 763, SS4 + D1 * 5, W1, 39, 0, 1, 0,
1027 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1028 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1029 
1030 	{"", 9, 833, SS4 + D1, W1, 39, 0, 1, 0,
1031 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1032 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1033 	{"", 9, 833, SS4 + D1 * 2, W1, 39, 0, 1, 0,
1034 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1035 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1036 	{"", 9, 833, SS4 + D1 * 3, W1, 39, 0, 1, 0,
1037 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1038 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1039 	{"", 9, 833, SS4 + D1 * 4, W1, 39, 0, 1, 0,
1040 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1041 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1042 	{"", 9, 833, SS4 + D1 * 5, W1, 39, 0, 1, 0,
1043 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1044 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1045 	{"", 9, 833, SS4 + D1 * 6, W1, 39, 0, 1, 0,
1046 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1047 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1048 
1049 	/* DCO 1 - 24 */
1050 	{"", 9, 456, SS4 + D1 * 1, W1, 39, 0, 1, 0,
1051 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1052 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1053 	{"", 9, 456, SS4 + D1 * 2, W1, 39, 0, 1, 0,
1054 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1055 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1056 	{"", 9, 456, SS4 + D1 * 3, W1, 39, 0, 1, 0,
1057 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1058 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1059 	{"", 9, 456, SS4 + D1 * 4, W1, 39, 0, 1, 0,
1060 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1061 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1062 
1063 	{"", 9, 508, SS4 + D1 * 2, 23, 39, 0, 1, 0,
1064 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1065 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1066 	{"", 9, 508, SS4 + D1 * 3, 23, 39, 0, 1, 0,
1067 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1068 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1069 	{"", 9, 508, SS4 + D1 * 4, 23, 39, 0, 1, 0,
1070 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1071 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1072 
1073 	{"", 9, 568, SS4 + D1, W1, 39, 0, 1, 0,
1074 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1075 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1076 	{"", 9, 568, SS4 + D1 * 2, W1, 39, 0, 1, 0,
1077 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1078 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1079 	{"", 9, 568, SS4 + D1 * 3, W1, 39, 0, 1, 0,
1080 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1081 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1082 	{"", 9, 568, SS4 + D1 * 4, W1, 39, 0, 1, 0,
1083 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1084 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1085 
1086 	/* DCO 2 - 35 */
1087 	{"", 9, 610, SS3 + D1 * 0, W1, 39, 0, 1, 0,
1088 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1089 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1090 	{"", 9, 610, SS3 + D1 * 1, W1, 39, 0, 1, 0,
1091 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1092 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1093 	{"", 9, 610, SS3 + D1 * 2, W1, 39, 0, 1, 0,
1094 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1095 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1096 	{"", 9, 610, SS3 + D1 * 3, W1, 39, 0, 1, 0,
1097 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1098 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1099 
1100 	{"", 9, 662, SS3 + D1 * 1, 23, 39, 0, 1, 0,
1101 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1102 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1103 	{"", 9, 662, SS3 + D1 * 2, 23, 39, 0, 1, 0,
1104 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1105 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1106 	{"", 9, 662, SS3 + D1 * 3, 23, 39, 0, 1, 0,
1107 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1108 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1109 
1110 	{"", 9, 721, SS3 + D1 * 0, W1, 39, 0, 1, 0,
1111 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1112 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1113 	{"", 9, 721, SS3 + D1 * 1, W1, 39, 0, 1, 0,
1114 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1115 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1116 	{"", 9, 721, SS3 + D1 * 2, W1, 39, 0, 1, 0,
1117 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1118 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1119 	{"", 9, 721, SS3 + D1 * 3, W1, 39, 0, 1, 0,
1120 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1121 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1122 
1123 	/* VCA - 46 */
1124 	{"", 9, 876, SS3 + D1 * 2, W1, 39, 0, 1, 0,
1125 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1126 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1127 	{"", 9, 876, SS3 + D1 * 3, W1, 39, 0, 1, 0,
1128 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1129 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1130 	{"", 9, 876, SS3 + D1 * 4, W1, 39, 0, 1, 0,
1131 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1132 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1133 
1134 	{"", 9, 946, SS3 + D1 * 2, W1, 39, 0, 1, 0,
1135 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1136 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1137 	{"", 9, 946, SS3 + D1 * 3, W1, 39, 0, 1, 0,
1138 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1139 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1140 	{"", 9, 946, SS3 + D1 * 4, W1, 39, 0, 1, 0,
1141 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1142 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1143 	{"", 9, 946, SS3 + D1 * 5, W1, 39, 0, 1, 0,
1144 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1145 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1146 
1147 	/* LFO-2 - 53 */
1148 	{"", 9, 293, SS2, W1, 39, 0, 1, 0,
1149 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1150 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1151 	{"", 9, 293, SS2 + D1, W1, 39, 0, 1, 0,
1152 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1153 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1154 	{"", 9, 293, SS2 + D1 * 2, W1, 39, 0, 1, 0,
1155 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1156 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1157 	{"", 9, 293, SS2 + D1 * 3, W1, 39, 0, 1, 0,
1158 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1159 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1160 	{"", 9, 293, SS2 + D1 * 4, W1, 39, 0, 1, 0,
1161 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1162 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1163 	{"", 9, 293, SS2 + D1 * 5, W1, 39, 0, 1, 0,
1164 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1165 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1166 
1167 	{"", 9, 345, SS2, W1, 39, 0, 1, 0,
1168 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1169 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1170 	{"", 9, 345, SS2 + D1, W1, 39, 0, 1, 0,
1171 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1172 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1173 	{"", 9, 345, SS2 + D1 * 2, W1, 39, 0, 1, 0,
1174 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1175 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1176 	{"", 9, 345, SS2 + D1 * 3, W1, 39, 0, 1, 0,
1177 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1178 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1179 	{"", 9, 345, SS2 + D1 * 4, W1, 39, 0, 1, 0,
1180 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1181 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1182 
1183 	/* Split/Transpose - 64 */
1184 	{"", 9, 763, SS6 + D1 * 3, W1, 39, 0, 1, 0,
1185 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1186 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1187 	{"", 9, 833, SS6 + D1 * 3, W1, 39, 0, 1, 0,
1188 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1189 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1190 	/* Layer volumes */
1191 	{"", 9, 833, SS6 + D1 * 2, W1, 39, 0, 1, 0,
1192 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1193 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1194 	{"", 9, 50, 50 + D1 * 4, W1, 39, 0, 1, 0,
1195 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1196 		BRIGHTON_NOSHADOW|BRIGHTON_WITHDRAWN|BRIGHTON_TRACKING},
1197 
1198 	/* MIDI - 68 */
1199 	{"", 9, 876, SS6 + D1 * 2, W1, 39, 0, 1, 0,
1200 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1201 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1202 	{"", 9, 876, SS6 + D1 * 3, W1, 39, 0, 1, 0,
1203 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1204 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1205 	{"", 9, 876, SS6 + D1 * 4, W1, 39, 0, 1, 0,
1206 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1207 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1208 
1209 	{"", 9, 946, SS6 + D1 * 2, W1, 39, 0, 1, 0,
1210 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1211 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1212 	{"", 9, 946, SS6 + D1 * 3, W1, 39, 0, 1, 0,
1213 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1214 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1215 	{"", 9, 946, SS6 + D1 * 4, W1, 39, 0, 1, 0,
1216 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1217 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1218 
1219 	{"", 9, 607, SS6 + D1, W1, 39, 0, 1, 0,
1220 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1221 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1222 	{"", 9, 607, SS6 + D1 * 2, W1, 39, 0, 1, 0,
1223 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1224 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1225 	{"", 9, 763, SS6 + D1 * 2, W1, 39, 0, 1, 0,
1226 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1227 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1228 
1229 	/*
1230 	 * Bit-99: FM 1->2,SYNC,GLIDE L/U - 77/78/79/80
1231 	 */
1232 	{"", 9, 508, SS3 + D1, 23, 39, 0, 1, 0,
1233 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1234 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1235 	{"", 9, 662, SS3 + D1 * 4, 23, 39, 0, 1, 0,
1236 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1237 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1238 	{"", 9, 763, SS6 + D1 * 4, W1, 39, 0, 1, 0,
1239 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1240 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1241 	{"", 9, 833, SS6 + D1 * 4, W1, 39, 0, 1, 0,
1242 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1243 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1244 
1245 	/* LFO 1/2 options 81 - 92 */
1246 	{"", 9, 397, SS1 + D1 * 0, W1, 39, 0, 1, 0,
1247 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1248 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1249 	{"", 9, 397, SS1 + D1 * 1, W1, 39, 0, 1, 0,
1250 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1251 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1252 	{"", 9, 397, SS1 + D1 * 2, W1, 39, 0, 1, 0,
1253 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1254 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1255 	{"", 9, 397, SS1 + D1 * 3, W1, 39, 0, 1, 0,
1256 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1257 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1258 	{"", 9, 397, SS1 + D1 * 4, W1, 39, 0, 1, 0,
1259 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1260 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1261 	{"", 9, 397, SS1 + D1 * 5, W1, 39, 0, 1, 0,
1262 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1263 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1264 
1265 	{"", 9, 397, SS2 + D1 * 0, W1, 39, 0, 1, 0,
1266 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1267 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1268 	{"", 9, 397, SS2 + D1 * 1, W1, 39, 0, 1, 0,
1269 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1270 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1271 	{"", 9, 397, SS2 + D1 * 2, W1, 39, 0, 1, 0,
1272 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1273 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1274 	{"", 9, 397, SS2 + D1 * 3, W1, 39, 0, 1, 0,
1275 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1276 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1277 	{"", 9, 397, SS2 + D1 * 4, W1, 39, 0, 1, 0,
1278 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1279 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1280 	{"", 9, 397, SS2 + D1 * 5, W1, 39, 0, 1, 0,
1281 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1282 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1283 
1284 	/* 93 ENV->PWM */
1285 	{"", 9, 456, SS4 + D1 * 5, W1, 39, 0, 1, 0,
1286 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1287 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1288 	{"", 9, 610, SS3 + D1 * 4, W1, 39, 0, 1, 0,
1289 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1290 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1291 	{"", 9, 568, SS4 + D1 * 5, W1, 39, 0, 1, 0,
1292 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1293 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1294 	{"", 9, 721, SS3 + D1 * 4, W1, 39, 0, 1, 0,
1295 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1296 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1297 	/* Filter type */
1298 	{"", 9, 763, SS4 + D1 * 6, W1, 39, 0, 2, 0,
1299 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1300 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1301 	/* DCO-1 vol - 98 */
1302 	{"", 9, 508, SS4 + D1 * 5, 23, 39, 0, 1, 0,
1303 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1304 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1305 	/* Noise per layer */
1306 	{"", 9, 650, SS2 + D1 * 1, W1, 39, 0, 1, 0,
1307 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1308 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1309 
1310 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1311 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1312 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1313 
1314 	/* LFO/ENV options - 103 */
1315 	{"", 9, 650, SS2 + D1 * 3, W1, 39, 0, 1, 0,
1316 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1317 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1318 	{"", 9, 650, SS2 + D1 * 4, W1, 39, 0, 1, 0,
1319 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1320 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1321 	{"", 9, 720, SS2 + D1 * 3, W1, 39, 0, 1, 0,
1322 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1323 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1324 	{"", 9, 720, SS2 + D1 * 4, W1, 39, 0, 1, 0,
1325 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1326 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1327 	{"", 9, 720, SS2 + D1 * 1, W1, 39, 0, 1, 0,
1328 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1329 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1330 	{"", 9, 720, SS2 + D1 * 2, W1, 39, 0, 1, 0,
1331 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1332 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1333 
1334 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1335 
1336 	/* Volumes - 110  */
1337 	{"", 9, 525, SS6 + D1 * 3, 17, 39, 0, 1, 0,
1338 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1339 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1340 	{"", 9, 580, SS6 + D1 * 3, 17, 39, 0, 1, 0,
1341 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1342 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1343 	{"", 9, 525, SS6 + D1 * 4, 17, 39, 0, 1, 0,
1344 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1345 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1346 	{"", 9, 580, SS6 + D1 * 4, 17, 39, 0, 1, 0,
1347 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1348 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1349 	{"", 9, 525, SS6 + D1 * 1, 17, 39, 0, 1, 0,
1350 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1351 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1352 	{"", 9, 580, SS6 + D1 * 1, 17, 39, 0, 1, 0,
1353 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1354 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1355 	{"", 9, 525, SS6 + D1 * 2, 17, 39, 0, 1, 0,
1356 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1357 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1358 	{"", 9, 580, SS6 + D1 * 2, 17, 39, 0, 1, 0,
1359 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1360 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1361 
1362 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1363 
1364 	/* Temperature - 118 */
1365 	{"", 9, 650, SS2 + D1 * 2, W1, 39, 0, 1, 0,
1366 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1367 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1368 
1369 	/* 120 */
1370 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1371 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1372 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1373 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1374 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1375 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1376 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1377 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1378 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1379 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1380 
1381 	/* MEM Free Search - 130 */
1382 	{"", 9, 607, SS6 + D1 * 3, W1, 39, 0, 1, 0,
1383 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1384 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1385 	{"", 9, 607, SS6 + D1 * 4, W1, 39, 0, 1, 0,
1386 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1387 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1388 
1389 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1390 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1391 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1392 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1393 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1394 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1395 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1396 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1397 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1398 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1399 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1400 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1401 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1402 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1403 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1404 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1405 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1406 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1407 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1408 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1409 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1410 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1411 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1412 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1413 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1414 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1415 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1416 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1417 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1418 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1419 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1420 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1421 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1422 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1423 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1424 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1425 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1426 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1427 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1428 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1429 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1430 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1431 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1432 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1433 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1434 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1435 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1436 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1437 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1438 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1439 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1440 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1441 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1442 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1443 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1444 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1445 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1446 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1447 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1448 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1449 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1450 	/* Save -1 and -99 */
1451 	{"", 9, 876, SS6 + D1 * 1, W1, 39, 0, 1, 0,
1452 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1453 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1454 	{"", 9, 946, SS6 + D1 * 1, W1, 39, 0, 1, 0,
1455 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1456 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING},
1457 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1458 	/* 196 is the split/double placeholder */
1459 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1460 	/* This is 197 and may be the stereo placeholder */
1461 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1462 	/* This is 148 and will be the peer layer placeholder */
1463 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1464 	/*
1465 	 * This needed to move as it is parameter 12, not 64 - now at 199. The
1466 	 * withdrawn flag is only removed if the bit-99 is requested.
1467 	 */
1468 	{"", 9, 345, SS6 + D1 * 5, W1, 39, 0, 1, 0,
1469 		"bitmaps/buttons/blue.xpm", "bitmaps/buttons/green.xpm",
1470 		BRIGHTON_NOSHADOW|BRIGHTON_CHECKBUTTON|BRIGHTON_TRACKING|BRIGHTON_WITHDRAWN},
1471 
1472 	/* split double - 200 */
1473 	{"", 2, 217, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1474 		"bitmaps/buttons/presson.xpm", 0},
1475 	{"", 2, 217, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1476 		"bitmaps/buttons/presson.xpm", 0},
1477 	/* Stereo - 202 */
1478 	{"", 2, 257, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1479 		"bitmaps/buttons/presson.xpm", 0},
1480 	/* Pot for tune */
1481 	{"", 0, 250, 150, 80, 80, 0, 1, 0, "bitmaps/knobs/knob1.xpm", 0,
1482 		BRIGHTON_NOTCH},
1483 	/*
1484 	 * The following two are in the memory as non-visible placeholder for
1485 	 * combined patches upper/lower/split/layer, etc. It should use the same
1486 	 * peer memory logic employed by the Jupiter GUI. Moved to within first 100
1487 	 */
1488 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1489 	{"", 2, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
1490 
1491 	/* Two sliders for volume controls - 206 */
1492 	{"", 1, 51, 570, 10, 260, 0, 1, 0, "bitmaps/knobs/sliderblack5.xpm", 0, 0},
1493 	{"", 1, 72, 570, 10, 260, 0, 1, 0, "bitmaps/knobs/sliderblack5.xpm", 0, 0},
1494 
1495 	/* Pot for entry - 208 */
1496 	{"", 0, 54, 330, 80, 80, 0, 1, 0, "bitmaps/knobs/knob1.xpm", 0, 0},
1497 
1498 	/* Ten data entry buttons - 209 */
1499 	{"", 2, 100, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1500 		"bitmaps/buttons/presson.xpm", 0},
1501 	{"", 2, 120, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1502 		"bitmaps/buttons/presson.xpm", 0},
1503 	{"", 2, 140, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1504 		"bitmaps/buttons/presson.xpm", 0},
1505 	{"", 2, 160, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1506 		"bitmaps/buttons/presson.xpm", 0},
1507 	{"", 2, 180, 350, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1508 		"bitmaps/buttons/presson.xpm", 0},
1509 
1510 	{"", 2, 100, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1511 		"bitmaps/buttons/presson.xpm", 0},
1512 	{"", 2, 120, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1513 		"bitmaps/buttons/presson.xpm", 0},
1514 	{"", 2, 140, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1515 		"bitmaps/buttons/presson.xpm", 0},
1516 	{"", 2, 160, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1517 		"bitmaps/buttons/presson.xpm", 0},
1518 	{"", 2, 180, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1519 		"bitmaps/buttons/presson.xpm", 0},
1520 
1521 	/* Addr, lower, upper - 219 */
1522 	{"", 2, 100, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1523 		"bitmaps/buttons/presson.xpm", 0},
1524 	{"", 2, 140, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1525 		"bitmaps/buttons/presson.xpm", 0},
1526 	{"", 2, 180, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1527 		"bitmaps/buttons/presson.xpm", 0},
1528 
1529 	/* Park, Compare - 222 */
1530 	{"", 2, 217, 150, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1531 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
1532 	{"", 2, 217, 320, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1533 		"bitmaps/buttons/presson.xpm", 0},
1534 
1535 	/* Prog load - 224 */
1536 	{"", 2, 257, 320, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1537 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
1538 
1539 	/* save - 225 */
1540 	{"", 2, 257, 700, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1541 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
1542 
1543 	/* Two sliders for bend and mod - 226 */
1544 	{"", 1, 17, 150, 10, 280, 0, 1, 0, "bitmaps/knobs/sliderblack4.xpm", 0,
1545 		BRIGHTON_HALFSHADOW|BRIGHTON_REVERSE},
1546 	{"", 1, 17, 500, 10, 280, 0, 1, 0, "bitmaps/knobs/sliderblack4.xpm", 0,
1547 		BRIGHTON_HALFSHADOW|BRIGHTON_CENTER|BRIGHTON_REVERSE},
1548 
1549 	/* Inc/Dec for data entry - 228 */
1550 	{"", 2, 50, 430, 13, 60, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1551 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
1552 	{"", 2, 70, 430, 13, 60, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1553 		"bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
1554 
1555 	/* 8 LED displays - 230 */
1556 	{"", 8, 52, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1557 	{"", 8, 67, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1558 
1559 	{"", 8, 97, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1560 	{"", 8, 111, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1561 
1562 	{"", 8, 133, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1563 	{"", 8, 148, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1564 
1565 	{"", 8, 172, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1566 	{"", 8, 187, 150, 15, 80, 0, 9, 0, 0, 0, 0},
1567 
1568 	/* The Bit-1 had a Unison button, not stereo - 238 */
1569 	{"", 2, 257, 490, 15, 80, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
1570 		"bitmaps/buttons/presson.xpm", BRIGHTON_WITHDRAWN},
1571 };
1572 
1573 #define PSIZE 680
1574 
1575 /*
1576  * This is a set of globals for the main window rendering. Again taken from
1577  * include/brighton.h
1578  * Hm, the bit-1 was black, and the bit 99 was in various builds including a
1579  * white one, but also a black one and a black one with wood panels. I would
1580  * like the black one with wood panels, so that will have to be the bit-1, the
1581  * bit-99 will be white with thin metal panels.
1582  */
1583 brightonApp bitoneApp = {
1584 	"bitone",
1585 	0, /* no blueprint on wood background. */
1586 	"bitmaps/textures/metal6.xpm",
1587 	BRIGHTON_STRETCH,
1588 	bitoneInit,
1589 	bitoneConfigure, /* 3 callbacks, unused? */
1590 	midiCallback,
1591 	destroySynth,
1592 	{6, 100, 2, 2, 5, 520, 0, 0},
1593 	788, 350, 0, 0,
1594 	4, /* one panel only */
1595 	{
1596 		{
1597 			"BitOne",
1598 			"bitmaps/blueprints/bitone.xpm",
1599 			"bitmaps/textures/metal6.xpm",
1600 			BRIGHTON_STRETCH, /* flags */
1601 			0,
1602 			0,
1603 			bitoneCallback,
1604 			12, 4, 978, PSIZE - 3,
1605 			DEVICE_COUNT,
1606 			locations
1607 		},
1608 		{
1609 			"Keyboard",
1610 			0,
1611 			"bitmaps/newkeys/kbg.xpm", /* flags */
1612 			0x020|BRIGHTON_STRETCH,
1613 			0,
1614 			0,
1615 			bitoneKeyCallback,
1616 			14, PSIZE, 1000, 1000 - PSIZE - 3,
1617 			KEY_COUNT,
1618 			keysprofile
1619 		},
1620 		{
1621 			"Wood Panel",
1622 			0,
1623 			"bitmaps/textures/wood6.xpm",
1624 			BRIGHTON_STRETCH, /* flags */
1625 			0,
1626 			0,
1627 			0,
1628 			2, 4, 10, 996,
1629 			0,
1630 			0
1631 		},
1632 		{
1633 			"Wood Panel",
1634 			0,
1635 			"bitmaps/textures/wood6.xpm",
1636 			BRIGHTON_STRETCH, /* flags */
1637 			0,
1638 			0,
1639 			0,
1640 			991, 4, 10, 996,
1641 			0,
1642 			0
1643 		},
1644 	}
1645 };
1646 
1647 /*
1648  * This may need some reworks to make sure the bit-1 screenprint displays
1649  * correctly.
1650  */
1651 brightonApp bit99App = {
1652 	"bit99",
1653 	0, /* no blueprint on wood background. */
1654 	"bitmaps/textures/metal6.xpm",
1655 	BRIGHTON_STRETCH,
1656 	bitoneInit,
1657 	bitoneConfigure, /* 3 callbacks, unused? */
1658 	midiCallback,
1659 	destroySynth,
1660 	{6, 100, 2, 2, 5, 520, 0, 0},
1661 	788, 350, 0, 0,
1662 	4, /* one panel only */
1663 	{
1664 		{
1665 			"Bit99",
1666 			"bitmaps/blueprints/bit99.xpm",
1667 			"bitmaps/textures/white.xpm",
1668 			BRIGHTON_STRETCH, /* flags */
1669 			0,
1670 			0,
1671 			bitoneCallback,
1672 			12, 0, 978, PSIZE - 3,
1673 			DEVICE_COUNT,
1674 			locations
1675 		},
1676 		{
1677 			"Keyboard",
1678 			0,
1679 			"bitmaps/newkeys/kbg.xpm", /* flags */
1680 			0x020|BRIGHTON_STRETCH,
1681 			0,
1682 			0,
1683 			bitoneKeyCallback,
1684 			12, PSIZE, 1006, 997 - PSIZE,
1685 			KEY_COUNT,
1686 			keysprofile
1687 		},
1688 		{
1689 			"Metal Panel",
1690 			0,
1691 			"bitmaps/textures/metal7.xpm",
1692 			BRIGHTON_STRETCH, /* flags */
1693 			0,
1694 			0,
1695 			0,
1696 			1, 0, 8, 1000,
1697 			0,
1698 			0
1699 		},
1700 		{
1701 			"Metal Panel",
1702 			0,
1703 			"bitmaps/textures/metal7.xpm",
1704 			BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
1705 			0,
1706 			0,
1707 			0,
1708 			991, 0, 7, 1000,
1709 			0,
1710 			0
1711 		},
1712 	}
1713 };
1714 
1715 brightonApp bit100App = {
1716 	"bit100",
1717 	0, /* no blueprint on wood background. */
1718 	"bitmaps/textures/metal6.xpm",
1719 	BRIGHTON_STRETCH,
1720 	bitoneInit,
1721 	bitoneConfigure, /* 3 callbacks, unused? */
1722 	midiCallback,
1723 	destroySynth,
1724 	{6, 100, 2, 2, 5, 520, 0, 0},
1725 	788, 350, 0, 0,
1726 	4, /* one panel only */
1727 	{
1728 		{
1729 			"BitOne",
1730 			"bitmaps/blueprints/bit100.xpm",
1731 			"bitmaps/textures/metal6.xpm",
1732 			BRIGHTON_STRETCH, /* flags */
1733 			0,
1734 			0,
1735 			bitoneCallback,
1736 			12, 4, 978, PSIZE - 3,
1737 			DEVICE_COUNT,
1738 			locations100
1739 		},
1740 		{
1741 			"Keyboard",
1742 			0,
1743 			"bitmaps/newkeys/kbg.xpm", /* flags */
1744 			0x020|BRIGHTON_STRETCH,
1745 			0,
1746 			0,
1747 			bitoneKeyCallback,
1748 			14, PSIZE, 1000, 1000 - PSIZE - 3,
1749 			KEY_COUNT,
1750 			keysprofile
1751 		},
1752 		{
1753 			"Wood Panel",
1754 			0,
1755 			"bitmaps/textures/wood6.xpm",
1756 			BRIGHTON_STRETCH, /* flags */
1757 			0,
1758 			0,
1759 			0,
1760 			2, 4, 10, 996,
1761 			0,
1762 			0
1763 		},
1764 		{
1765 			"Wood Panel",
1766 			0,
1767 			"bitmaps/textures/wood6.xpm",
1768 			BRIGHTON_STRETCH, /* flags */
1769 			0,
1770 			0,
1771 			0,
1772 			991, 4, 10, 996,
1773 			0,
1774 			0
1775 		},
1776 	}
1777 };
1778 
1779 static int
b1decimal(int index,float value)1780 b1decimal(int index, float value)
1781 {
1782 	return(bitoneRange[index].min +
1783 		(int) (value *
1784 			((float) (bitoneRange[index].max - bitoneRange[index].min + 1))));
1785 }
1786 
1787 static int
b1debug(guiSynth * synth,int level)1788 b1debug(guiSynth *synth, int level)
1789 {
1790 	if (b1decimal(109, synth->mem.param[109]) >= level)
1791 		return(1);
1792 	return(0);
1793 }
1794 
1795 /*
1796  * These will return just the prePark memory, not the actual synth.
1797  */
1798 static guiSynth *
b1getScratch(guiSynth * synth)1799 b1getScratch(guiSynth *synth)
1800 {
1801 	if (synth->mem.param[101] != 0) {
1802 		if (entryPoint == ENTER_UPPER)
1803 			return ((guiSynth *) synth->second);
1804 		else
1805 			return (synth);
1806 	} else {
1807 		if (entryPoint == ENTER_UPPER)
1808 			return (&prePark[1]);
1809 		else
1810 			return (&prePark[0]);
1811 	}
1812 }
1813 
1814 /*
1815  * Param is a float from 0 to 1.0, turn it into a value in the range of the
1816  * parameter
1817  */
1818 static float
b1GetRangeValue(guiSynth * synth,int index)1819 b1GetRangeValue(guiSynth *synth, int index)
1820 {
1821 	switch (bitoneRange[index].type) {
1822 		default:
1823 		case BITONE_CONTINUOUS:
1824 			return(synth->mem.param[index]);
1825 		case BITONE_STEPPED:
1826 			return(bitoneRange[index].min + synth->mem.param[index]
1827 				* (bitoneRange[index].max - bitoneRange[index].min + 1));
1828 	}
1829 }
1830 
1831 static void
b1SetSplit(guiSynth * synth)1832 b1SetSplit(guiSynth *synth)
1833 {
1834 	int lsp, usp;
1835 
1836 	if (b1debug(synth, 1))
1837 		printf("setSplit: %i/%i\n",
1838 			b1decimal(64, prePark[0].mem.param[64]),
1839 			b1decimal(64, prePark[1].mem.param[64]));
1840 
1841 	if (mode == MODE_SINGLE)
1842 		/* We could consider clearing any splitpoints here as well */
1843 		return;
1844 
1845 	/*
1846 	 * Find and apply split points
1847 	 * We need to consider DE-121 for multiple splits.
1848 	 */
1849 	if (mode == MODE_SPLIT) {
1850 		if (synth->mem.param[121] != 0) {
1851 			lsp = b1GetRangeValue(&prePark[0], 64) + synth->transpose;
1852 			usp = b1GetRangeValue(&prePark[1], 64) + 1 + synth->transpose;
1853 		} else {
1854 			lsp = b1GetRangeValue(&prePark[0], 64) + synth->transpose;
1855 			usp = b1GetRangeValue(&prePark[0], 64) + 1 + synth->transpose;
1856 		}
1857 	} else {
1858 		if (synth->mem.param[121] != 0) {
1859 			lsp = b1GetRangeValue(&prePark[0], 64) + synth->transpose;
1860 			usp = b1GetRangeValue(&prePark[1], 64) + 1 + synth->transpose;
1861 		} else {
1862 			lsp = 127;
1863 			usp = 0;
1864 		}
1865 	}
1866 
1867 	if (global.libtest == 0) {
1868 		bristolMidiSendMsg(global.controlfd, synth->sid, 127, 0,
1869 			BRISTOL_HIGHKEY|lsp);
1870 		bristolMidiSendMsg(global.controlfd, synth->sid2, 127, 0,
1871 			BRISTOL_LOWKEY|usp);
1872 	}
1873 
1874 	setsplit = 0.0;
1875 }
1876 
1877 /*
1878  * The next two should come out of here and go into a separate arpeggiator file
1879  * or failing that into brightonRoutines.c
1880  */
1881 int
seqInsert(arpeggiatorMemory * seq,int note,int transpose)1882 seqInsert(arpeggiatorMemory *seq, int note, int transpose)
1883 {
1884 printf("arpeg %i + %i at %i\n", note, transpose, (int) seq->s_max);
1885 	if (seq->s_max == 0)
1886 		seq->s_dif = note + transpose;
1887 
1888 	seq->sequence[(int) (seq->s_max)] = (float) (note + transpose - seq->s_dif);
1889 
1890 	if ((seq->s_max += 1) >= BRISTOL_SEQ_MAX) {
1891 		seq->s_max = BRISTOL_SEQ_MAX;
1892 		return(-1);
1893 	}
1894 
1895 	return(0);
1896 }
1897 
1898 int
chordInsert(arpeggiatorMemory * seq,int note,int transpose)1899 chordInsert(arpeggiatorMemory *seq, int note, int transpose)
1900 {
1901 printf("chord %i + %i at %i\n", note, transpose, (int) seq->c_count);
1902 	if (seq->c_count == 0)
1903 		seq->c_dif = note + transpose;
1904 
1905 	seq->chord[(int) (seq->c_count)] = (float) (note + transpose - seq->c_dif);
1906 
1907 	if ((seq->c_count += 1) >= BRISTOL_CHORD_MAX) {
1908 		seq->c_count = BRISTOL_CHORD_MAX;
1909 		return(-1);
1910 	}
1911 
1912 	return(0);
1913 }
1914 
1915 /*
1916  * We really want to just use one midi channel and let the midi library decide
1917  * that we have multiple synths on the channel with their own split points.
1918  * The lower layer should define the midi channel, split point and transpose
1919  * of upper layer.
1920  */
1921 static int
bitoneKeyCallback(brightonWindow * win,int panel,int index,float value)1922 bitoneKeyCallback(brightonWindow *win, int panel, int index, float value)
1923 {
1924 	guiSynth *synth = findSynth(global.synths, win);
1925 	guiSynth *layer = b1getScratch(synth);
1926 
1927 	if ((synth->mem.param[155] != 0) && (value != 0))
1928 	{
1929 		if (entryPoint == ENTER_UPPER)
1930 			seqInsert((arpeggiatorMemory *) synth->seq2.param,
1931 				(int) index, synth->transpose);
1932 		else
1933 			seqInsert((arpeggiatorMemory *) synth->seq1.param,
1934 				(int) index, synth->transpose);
1935 	}
1936 
1937 	if ((synth->mem.param[157] != 0) && (value != 0))
1938 	{
1939 		if (entryPoint == ENTER_UPPER)
1940 			chordInsert((arpeggiatorMemory *) synth->seq2.param,
1941 				(int) index, synth->transpose);
1942 		else
1943 			chordInsert((arpeggiatorMemory *) synth->seq1.param,
1944 				(int) index, synth->transpose);
1945 	}
1946 
1947 	if (global.libtest)
1948 		return(0);
1949 
1950 	if (b1debug(synth, 4))
1951 		printf("b1keycallback(%i, %i, %f): %i %i\n",
1952 			panel, index, value, synth->transpose, global.controlfd);
1953 
1954 	if (setsplit != 0.0)
1955 	{
1956 		if (b1debug(synth, 1))
1957 			printf("setting (1) splitpoint to %i\n", index);
1958 		layer->mem.param[64] = index + synth->transpose;
1959 		setsplit = 0;
1960 
1961 		b1SetSplit(synth);
1962 	}
1963 
1964 	if ((mode == MODE_SINGLE) || (synth->mem.param[120] == 0)
1965 		|| (synth->midichannel == ((guiSynth *) synth->second)->midichannel)) {
1966 		/*
1967 		 * Want to send a note event, on or off, for this index + transpose only
1968 		 * on the lower layer midichannel. This actually suffices for all cases
1969 		 * where we use a single midi channel hence the logic.
1970 		 */
1971 		if (value)
1972 			bristolMidiSendMsg(global.controlfd, synth->midichannel,
1973 				BRISTOL_EVENT_KEYON, 0, index + synth->transpose);
1974 		else
1975 			bristolMidiSendMsg(global.controlfd, synth->midichannel,
1976 				BRISTOL_EVENT_KEYOFF, 0, index + synth->transpose);
1977 
1978 		return(0);
1979 	}
1980 
1981 	if (b1debug(synth, 2))
1982 		printf("key event to chan %i/%i (%0.0f)\n", synth->midichannel,
1983 			((guiSynth *) synth->second)->midichannel, synth->mem.param[120]);
1984 
1985 	/*
1986 	 * So we have a single key event and two MIDI channels. Just send the
1987 	 * event on both channels, no need to be difficult about it since if this
1988 	 * was a split configuration the library filters out the events.
1989 	 */
1990 	if (value) {
1991 		bristolMidiSendMsg(global.controlfd, synth->midichannel,
1992 			BRISTOL_EVENT_KEYON, 0, index + synth->transpose);
1993 		bristolMidiSendMsg(global.controlfd,
1994 			((guiSynth *) synth->second)->midichannel, BRISTOL_EVENT_KEYON, 0,
1995 			index + synth->transpose);
1996 	} else {
1997 		bristolMidiSendMsg(global.controlfd, synth->midichannel,
1998 			BRISTOL_EVENT_KEYOFF, 0, index + synth->transpose);
1999 		bristolMidiSendMsg(global.controlfd,
2000 			((guiSynth *) synth->second)->midichannel, BRISTOL_EVENT_KEYOFF, 0,
2001 			index + synth->transpose);
2002 	}
2003 
2004 	return(0);
2005 }
2006 
2007 static void
bitoneCompareOff(guiSynth * synth)2008 bitoneCompareOff(guiSynth *synth)
2009 {
2010 	brightonEvent event;
2011 
2012 	/*
2013 	 * If we are changing entryPoint we should first disactivate any compare
2014 	 * button to ensure we have the correct scratchpad, etc.
2015 	 */
2016 	if (synth->mem.param[COMPARE_BUTTON] != 0.0)
2017 	{
2018 		event.type = BRIGHTON_FLOAT;
2019 		event.value = 0.0;
2020 		brightonParamChange(synth->win, 0, COMPARE_BUTTON, &event);
2021 	}
2022 }
2023 
2024 /*
2025  * At this point we have loaded a memory so we need to send those actual new
2026  * parameters to the engine. This is an issue for MIDI program load, perhaps
2027  * we should consider dual load above memory 74 as per the original?
2028  *
2029  * The path of least resistance here is to scan through the the memory table
2030  * incrementing the input selector and delivering the memory value to the
2031  * data entry pot.....
2032  */
2033 static void
bitoneMemoryShim(guiSynth * synth,int from)2034 bitoneMemoryShim(guiSynth *synth, int from)
2035 {
2036 	int i, uh, lh;
2037 	brightonEvent event;
2038 	guiSynth *layer = synth, *scratch = b1getScratch(synth), *scratch2;
2039 
2040 	/*
2041 	 * Clear any mem search flags.
2042 	 */
2043 	synth->mem.param[74] = prePark[0].mem.param[74]
2044 		= prePark[1].mem.param[74] = 0;
2045 	synth->mem.param[75] = prePark[0].mem.param[75]
2046 		= prePark[1].mem.param[75] = 0;
2047 	synth->mem.param[130] = prePark[0].mem.param[130]
2048 		= prePark[1].mem.param[130] = 0;
2049 	synth->mem.param[131] = prePark[0].mem.param[131]
2050 		= prePark[1].mem.param[131] = 0;
2051 
2052 	if (b1debug(synth, 2))
2053 		printf("bitoneMemoryShim(%i)\n", from);
2054 
2055 	/*
2056 	 * Save the current display settings
2057 	 */
2058 	uh = synth->mem.param[DISPLAY_DEV + 2];
2059 	lh = synth->mem.param[DISPLAY_DEV + 3];
2060 
2061 	/*
2062 	 * Select layer
2063 	 */
2064 	event.type = BRIGHTON_FLOAT;
2065 	if (entryPoint == ENTER_UPPER)
2066 	{
2067 		layer = (guiSynth *) synth->second;
2068 		scratch2 = &prePark[0];
2069 	} else
2070 		scratch2 = &prePark[1];
2071 
2072 	synth->flags |= MEM_LOADING;
2073 	layer->flags |= MEM_LOADING;
2074 
2075 	/*
2076 	 * scan through all the parameters backwards. We go backwards since the
2077 	 * higher numbers parameter are hidden but may actually affect the operation
2078 	 * of the lower ordered ones - the higher parameters may override the
2079 	 * default Bit features.
2080 	 */
2081 	for (i = from - 1; i >= 0 ; i--)
2082 	{
2083 		if ((bitoneRange[i].flags & B1_INACTIVE) != 0)
2084 			continue;
2085 		if ((bitoneRange[i].flags & B1_NO_LOAD) != 0)
2086 			continue;
2087 
2088 		synth->mem.param[DISPLAY_DEV + 2] = i / 10;
2089 		synth->mem.param[DISPLAY_DEV + 3] = i % 10;
2090 
2091 		if (i >= 100) {
2092 			synth->mem.param[DISPLAY_DEV + 2] -= 10;
2093 			synth->mem.param[EXTENDED_BUTTON] = 1.0;
2094 		} else
2095 			synth->mem.param[EXTENDED_BUTTON] = 0;
2096 
2097 		/*
2098 		 * We really ought to consider rounding here? No, the entry pot will
2099 		 * do that for us, that is the whole point of dispatching these events.
2100 		 */
2101 		event.value = scratch->mem.param[i] = layer->mem.param[i];
2102 
2103 		/*
2104 		 * Check for the DC flag, then check the bitoneRange flags for whether
2105 		 * this parameter should be put into effect, should be inherrited from
2106 		 * the lower layer, etc.
2107 		 *
2108 		 * The inherit flags need to be reviewed since they depend on the
2109 		 * DE 120/121/122 options for dual settings.....
2110 		 */
2111 		if ((dc != 0) || (entryPoint == ENTER_UPPER))
2112 		{
2113 			if (bitoneRange[i].flags & B1_INHERIT_PRI)
2114 			{
2115 				if (b1debug(synth, 2))
2116 					printf("inherrit %i\n", i);
2117 				event.value = scratch->mem.param[i] = prePark[0].mem.param[i];
2118 			}
2119 
2120 			if ((bitoneRange[i].flags & B1_INACTIVE_PEER) != 0)
2121 				continue;
2122 			if ((bitoneRange[i].flags & B1_USE_PRI) != 0)
2123 				event.value = prePark[0].mem.param[i];
2124 		}
2125 
2126 		brightonParamChange(synth->win, 0, ENTRY_POT, &event);
2127 	}
2128 
2129 	synth->flags &= ~MEM_LOADING;
2130 	layer->flags &= ~MEM_LOADING;
2131 
2132 	/*
2133 	 * Return the previous values to display.
2134 	 */
2135 	synth->mem.param[DISPLAY_DEV + 2] = uh;
2136 	synth->mem.param[DISPLAY_DEV + 3] = lh;
2137 
2138 	synth->mem.param[EXTENDED_BUTTON] = 0;
2139 
2140 	/*
2141 	 * Since the memory was loaded with NOCALLS we have to request our
2142 	 * arpeggiation stuffing manually too.
2143 	 */
2144 	if (synth->seq1.param == NULL) {
2145 		loadSequence(&synth->seq1, SYNTH_NAME, 0, 0);
2146 		if (synth->seq2.param == NULL)
2147 			loadSequence(&synth->seq2, SYNTH_NAME, 0, BRISTOL_SID2);
2148 	} else {
2149 		if (entryPoint == ENTER_UPPER)
2150 			fillSequencer(synth,
2151 				(arpeggiatorMemory *) synth->seq2.param, BRISTOL_SID2);
2152 		else
2153 			fillSequencer(synth, (arpeggiatorMemory *) synth->seq1.param, 0);
2154 	}
2155 
2156 	if (b1debug(synth, 2))
2157 		printf("bitoneMemoryShim done\n");
2158 }
2159 
2160 static int
midiCallback(brightonWindow * win,int controller,int value,float n)2161 midiCallback(brightonWindow *win, int controller, int value, float n)
2162 {
2163 	guiSynth *synth = findSynth(global.synths, win);
2164 
2165 	if (b1debug(synth, 3))
2166 		printf("midi callback: %x, %i\n", controller, value);
2167 
2168 	switch(controller)
2169 	{
2170 		case MIDI_PROGRAM:
2171 			if (synth->mem.param[71] != 0)
2172 			{
2173 				if (b1debug(synth, 0))
2174 					printf("midi program change not active\n");
2175 				return(0);
2176 			}
2177 			/*
2178 			 * We should accept 0..74 as lower layer and above that as dual
2179 			 * loading requests.
2180 			 */
2181 			printf("midi program: %x, %i\n", controller, value);
2182 			synth->location = value;
2183 			loadMemory(synth, SYNTH_NAME, 0,
2184 				synth->bank * 100 + synth->location,
2185 				synth->mem.active, 0, BRISTOL_NOCALLS|BRISTOL_FORCE);
2186 			bitoneMemoryShim(synth, ENTRY_MAX);
2187 			break;
2188 		case MIDI_BANK_SELECT:
2189 			if (synth->mem.param[71] != 0)
2190 			{
2191 				if (b1debug(synth, 0))
2192 					printf("midi program change not active\n");
2193 				return(0);
2194 			}
2195 			printf("midi banksel: %x, %i\n", controller, value);
2196 			synth->location %= 100;
2197 			synth->bank = value;
2198 			loadMemory(synth, SYNTH_NAME, 0,
2199 				synth->bank * 100 + synth->location,
2200 				synth->mem.active, 0, BRISTOL_NOCALLS|BRISTOL_FORCE);
2201 			break;
2202 	}
2203 	return(0);
2204 }
2205 
2206 static int
bitoneUpdateDisplayDec(guiSynth * synth,int fd,int chan,int c,int o,int v)2207 bitoneUpdateDisplayDec(guiSynth *synth, int fd, int chan, int c, int o, int v)
2208 {
2209 	int ho, lo, dev = DISPLAY_DEV + o;
2210 	brightonEvent event;
2211 
2212 	if (v < 0)
2213 	{
2214 		ho = lo = -10;
2215 	} else {
2216 		lo = v % 10;
2217 		ho = v / 10;
2218 	}
2219 
2220 	event.type = BRIGHTON_FLOAT;
2221 	event.value = (float) ho;
2222 
2223 	brightonParamChange(synth->win, 0, dev, &event);
2224 
2225 	event.value = (float) lo;
2226 	brightonParamChange(synth->win, 0, dev + 1, &event);
2227 
2228 	return(0);
2229 }
2230 
2231 static int
bitoneUpdateDisplay(guiSynth * synth,int fd,int chan,int c,int o,int v)2232 bitoneUpdateDisplay(guiSynth *synth, int fd, int chan, int c, int o, int v)
2233 {
2234 	int ho, lo, dev = DISPLAY_DEV + o;
2235 	brightonEvent event;
2236 
2237 	if (v < 0)
2238 	{
2239 		ho = lo = -10;
2240 	} else {
2241 		ho = v * 100 / (CONTROLLER_RANGE + 1);
2242 		lo = ho % 10;
2243 		ho = ho / 10;
2244 	}
2245 
2246 	event.type = BRIGHTON_FLOAT;
2247 	event.value = (float) ho;
2248 
2249 	brightonParamChange(synth->win, 0, dev, &event);
2250 
2251 	event.value = (float) lo;
2252 	brightonParamChange(synth->win, 0, dev + 1, &event);
2253 
2254 	return(0);
2255 }
2256 
2257 /*
2258  * Double/Split has certain logical requirements. Two two buttons are mutally
2259  * exclusive, so when one goes on we have to disable the other.
2260  */
2261 static int
bitoneSplitDouble(guiSynth * synth,int fd,int chan,int c,int o,int v)2262 bitoneSplitDouble(guiSynth *synth, int fd, int chan, int c, int o, int v)
2263 {
2264 	brightonEvent event;
2265 	guiSynth *layer = &prePark[1];
2266 
2267 	if (synth->dispatch[RADIOSET_3].other2 != 0)
2268 	{
2269 		synth->dispatch[RADIOSET_3].other2 = 0;
2270 		return(0);
2271 	}
2272 
2273 	if (b1debug(synth, 4))
2274 		printf("SD %i %i\n",c,o);
2275 
2276 	event.type = BRIGHTON_FLOAT;
2277 	event.value = 0.0;
2278 
2279 	/*
2280 	 * If we are going to zero and peer is zero then the operating mode is
2281 	 * now SINGLE.
2282 	 */
2283 	if ((v == 0) && (synth->mem.param[RADIOSET_3 + (1 - c)] == 0))
2284 	{
2285 		mode = MODE_SINGLE;
2286 
2287 		if (b1debug(synth, 1))
2288 			printf("mode single\n");
2289 
2290 		bitoneUpdateDisplay(synth, fd, chan, c, 6, -10);
2291 
2292 		if (entryPoint == ENTER_UPPER)
2293 		{
2294 			event.value = 1.0;
2295 			brightonParamChange(synth->win, 0, RADIOSET_2 + 1, &event);
2296 		}
2297 
2298 		/*
2299 		 * Actions are to mute the upper layer and revoice the lower layer to
2300 		 * full count, remove splits.
2301 		 */
2302 		bristolMidiSendMsg(fd, synth->sid2, 126, 5, 0);
2303 		bristolMidiSendMsg(fd, synth->sid2, 126, 6, 0);
2304 		/* Raise voices on lower layer, lower them on upper to reduce CPU */
2305 		bristolMidiSendMsg(fd, synth->sid, 126, 2, 1);
2306 		bristolMidiSendMsg(fd, synth->sid2, 126, 2, 0);
2307 		/* Split */
2308 		if (global.libtest == 0) {
2309 			bristolMidiSendMsg(global.controlfd, synth->sid,
2310 				127, 0, BRISTOL_HIGHKEY|127);
2311 			bristolMidiSendMsg(global.controlfd, synth->sid2,
2312 				127, 0, BRISTOL_LOWKEY|126);
2313 		}
2314 
2315 		return(0);
2316 	}
2317 
2318 	if (c == 0)
2319 	{
2320 		float lvol, rvol;
2321 
2322 		if ((synth->mem.param[RADIOSET_3 + 1] != 0)
2323 			&& (b1debug(synth, 3)))
2324 			printf("reset peer 1 and exclude\n");
2325 
2326 		synth->dispatch[RADIOSET_3].other2 = 1;
2327 		brightonParamChange(synth->win, 0, RADIOSET_3 + 1, &event);
2328 
2329 		mode = MODE_SPLIT;
2330 
2331 		if (b1debug(synth, 1))
2332 			printf("mode split\n");
2333 
2334 		bitoneUpdateDisplay(synth, fd, chan, c, 6,
2335 			(B1display[2] + 1) * CONTROLLER_RANGE / 100);
2336 
2337 		/*
2338 		 * Actions are to unmute the upper layer, revoice the lower layer to
2339 		 * half count, apply splits. The layer volumes have to take into
2340 		 * account the stereo button status and configured volume:
2341 		 *
2342 		 * We have issues here regarding the bit100 and its single volume
2343 		 * control.
2344 		 *
2345 		 * We we are a bit-100 then take the layer volumes. Other models will
2346 		 * take the synth volume unless otherwise denoted.
2347 		 */
2348 		if (synth->mem.param[118] == 0) {
2349 			if (synth->mem.param[202] != 0) {
2350 				/* Stereo */
2351 				lvol = prePark[0].mem.param[67] * synth->mem.param[116];
2352 				rvol = prePark[0].mem.param[67] * synth->mem.param[117];
2353 			} else {
2354 				/* Mono, ie, take a stereo panned position */
2355 				lvol = prePark[0].mem.param[67] * synth->mem.param[114];
2356 				rvol = prePark[0].mem.param[67] * synth->mem.param[115];
2357 			}
2358 			if (b1debug(synth, 4))
2359 				printf("split: %f %f, %f %f %f %f\n", lvol, rvol,
2360 					prePark[0].mem.param[67], synth->mem.param[114],
2361 					prePark[0].mem.param[67], synth->mem.param[115]);
2362 		} else {
2363 			if (synth->mem.param[202] != 0) {
2364 				/* Stereo */
2365 				lvol = layer->mem.param[67] * synth->mem.param[116];
2366 				rvol = layer->mem.param[67] * synth->mem.param[117];
2367 			} else {
2368 				/* Mono, ie, take a stereo panned position */
2369 				lvol = layer->mem.param[67] * synth->mem.param[114];
2370 				rvol = layer->mem.param[67] * synth->mem.param[115];
2371 			}
2372 			if (b1debug(synth, 4))
2373 				printf("split: %f %f, %f %f %f %f\n", lvol, rvol,
2374 					layer->mem.param[67], synth->mem.param[114],
2375 					layer->mem.param[67], synth->mem.param[115]);
2376 		}
2377 
2378 		bristolMidiSendMsg(fd, synth->sid2, 126, 5,
2379 			(int) (C_RANGE_MIN_1 * lvol));
2380 		bristolMidiSendMsg(fd, synth->sid2, 126, 6,
2381 			(int) (C_RANGE_MIN_1 * rvol));
2382 		/* Lower voices on lower layer, raise them on upper to reduce CPU */
2383 		bristolMidiSendMsg(fd, synth->sid, 126, 2, 0);
2384 		bristolMidiSendMsg(fd, synth->sid2, 126, 2, 1);
2385 
2386 		if (synth->mem.param[64] == 0)
2387 			setsplit = 1.0;
2388 		else
2389 			b1SetSplit(synth);
2390 
2391 		return(0);
2392 	}
2393 
2394 	if (c == 1)
2395 	{
2396 		float lvol, rvol;
2397 
2398 		if (synth->mem.param[RADIOSET_3] != 0)
2399 			printf("reset peer 2 and exclude\n");
2400 
2401 		synth->dispatch[RADIOSET_3].other2 = 1;
2402 		brightonParamChange(synth->win, 0, RADIOSET_3, &event);
2403 
2404 		mode = MODE_LAYER;
2405 
2406 		if (b1debug(synth, 1))
2407 			printf("mode layer\n");
2408 
2409 		bitoneUpdateDisplay(synth, fd, chan, c, 6,
2410 			(B1display[2] + 1) * CONTROLLER_RANGE / 100);
2411 
2412 		/*
2413 		 * Actions are to unmute the upper layer, revoice the lower layer to
2414 		 * half count, remove splits.
2415 		 */
2416 		if (synth->mem.param[118] == 0) {
2417 			if (synth->mem.param[202] != 0) {
2418 				/* Stereo */
2419 				lvol = prePark[0].mem.param[67] * synth->mem.param[116];
2420 				rvol = prePark[0].mem.param[67] * synth->mem.param[117];
2421 			} else {
2422 				/* Mono, ie, take a stereo panned position */
2423 				lvol = prePark[0].mem.param[67] * synth->mem.param[114];
2424 				rvol = prePark[0].mem.param[67] * synth->mem.param[115];
2425 			}
2426 			if (b1debug(synth, 4))
2427 				printf("split: %f %f, %f %f %f %f\n", lvol, rvol,
2428 					prePark[0].mem.param[67], synth->mem.param[114],
2429 					prePark[0].mem.param[67], synth->mem.param[115]);
2430 		} else {
2431 			if (synth->mem.param[202] != 0) {
2432 				/* Stereo */
2433 				lvol = layer->mem.param[67] * synth->mem.param[116];
2434 				rvol = layer->mem.param[67] * synth->mem.param[117];
2435 			} else {
2436 				/* Mono, ie, take a stereo panned position */
2437 				lvol = layer->mem.param[67] * synth->mem.param[114];
2438 				rvol = layer->mem.param[67] * synth->mem.param[115];
2439 			}
2440 			if (b1debug(synth, 4))
2441 				printf("split: %f %f, %f %f %f %f\n", lvol, rvol,
2442 					layer->mem.param[67], synth->mem.param[114],
2443 					layer->mem.param[67], synth->mem.param[115]);
2444 		}
2445 
2446 		bristolMidiSendMsg(fd, synth->sid2, 126, 5,
2447 			(int) (C_RANGE_MIN_1 * lvol));
2448 		bristolMidiSendMsg(fd, synth->sid2, 126, 6,
2449 			(int) (C_RANGE_MIN_1 * rvol));
2450 		/* Lower voices on lower layer, raise them on upper to reduce CPU */
2451 		bristolMidiSendMsg(fd, synth->sid, 126, 2, 0);
2452 		bristolMidiSendMsg(fd, synth->sid2, 126, 2, 1);
2453 		/* Split */
2454 		if (global.libtest == 0) {
2455 			bristolMidiSendMsg(global.controlfd, synth->sid,
2456 				127, 0, BRISTOL_HIGHKEY|127);
2457 			bristolMidiSendMsg(global.controlfd, synth->sid2,
2458 				127, 0, BRISTOL_LOWKEY|0);
2459 		}
2460 	}
2461 
2462 	return(0);
2463 }
2464 
2465 /*
2466  * This will take a value out of the scratchpad unless it is negative.
2467  */
2468 static void
bitoneDAUpdate(guiSynth * synth)2469 bitoneDAUpdate(guiSynth *synth)
2470 {
2471 	brightonEvent event;
2472 	guiSynth *layer = b1getScratch(synth);
2473 	int address = 0;
2474 
2475 	/*
2476 	 * Update the display for the given data entry point
2477 	 */
2478 	address = synth->mem.param[DISPLAY_DEV + 2] * 10 +
2479 		synth->mem.param[DISPLAY_DEV + 3];
2480 
2481 	if (synth->mem.param[EXTENDED_BUTTON] != 0)
2482 	{
2483 		address += 100;
2484 		event.value = synth->mem.param[address];
2485 	} else
2486 		event.value = layer->mem.param[address];
2487 
2488 	event.type = BRIGHTON_FLOAT;
2489 
2490 	brightonParamChange(synth->win, 0, ENTRY_POT, &event);
2491 }
2492 
2493 static int
bitoneALU(guiSynth * synth,int fd,int chan,int c,int o,int v)2494 bitoneALU(guiSynth *synth, int fd, int chan, int c, int o, int v)
2495 {
2496 	brightonEvent event;
2497 
2498 	/*
2499 	 * So, these are radio buttons, first force exclusion
2500 	 */
2501 	if (synth->dispatch[RADIOSET_2].other2)
2502 	{
2503 		synth->dispatch[RADIOSET_2].other2 = 0;
2504 		return(0);
2505 	}
2506 
2507 	/*
2508 	 * See if we are trying to select Data Entry whilst in Split/Double without
2509 	 * DE 102 enabled.
2510 	 *
2511 	 * Pan that, we do need to be able to select DE but only actually edit a
2512 	 * few of the under control of the range flags.
2513 	if ((o == 0) && (mode != MODE_SINGLE) && (synth->mem.param[102] == 0))
2514 	{
2515 		synth->dispatch[RADIOSET_2].other2 = 1;
2516 
2517 		event.type = BRIGHTON_FLOAT;
2518 		event.value = 0.0;
2519 		brightonParamChange(synth->win, 0, 219, &event);
2520 		bitoneUpdateDisplay(synth, fd, chan, c, 2, -10);
2521 
2522 		return(0);
2523 	}
2524 	 */
2525 
2526 	if ((mode == MODE_SINGLE) && (o == 2))
2527 	{
2528 		/*
2529 		 * This is 6 voice, do not allow selection of the upper layer
2530 		 */
2531 		event.type = BRIGHTON_FLOAT;
2532 		event.value = 0.0;
2533 		synth->dispatch[RADIOSET_2].other2 = 1;
2534 		brightonParamChange(synth->win, 0, 221, &event);
2535 
2536 		bitoneUpdateDisplay(synth, fd, chan, c, 6, -10);
2537 
2538 		return(0);
2539 	}
2540 
2541 	bitoneCompareOff(synth);
2542 
2543 	if (synth->dispatch[RADIOSET_2].other1 != -1)
2544 	{
2545 		synth->dispatch[RADIOSET_2].other2 = 1;
2546 
2547 		event.type = BRIGHTON_FLOAT;
2548 		if (synth->dispatch[RADIOSET_2].other1 != o)
2549 			event.value = 0;
2550 		else
2551 			event.value = 1;
2552 
2553 		brightonParamChange(synth->win, synth->panel,
2554 			synth->dispatch[RADIOSET_2].other1 + RADIOSET_2, &event);
2555 	}
2556 	synth->dispatch[RADIOSET_2].other1 = o;
2557 
2558 	entryPoint = o;
2559 
2560 	/*
2561 	 * Update the data entry for the currently selected parameter plus show
2562 	 * the active memories
2563 	 */
2564 	bitoneDAUpdate(synth);
2565 	bitoneUpdateDisplay(synth, fd, chan, c, 4, memLower * C_RANGE_MIN_1 / 99);
2566 	if (mode == MODE_SINGLE)
2567 		bitoneUpdateDisplay(synth, fd, chan, c, 6, -10);
2568 	else
2569 		bitoneUpdateDisplay(synth, fd, chan, c, 6,
2570 			memUpper * C_RANGE_MIN_1 / 99);
2571 
2572 	return(0);
2573 }
2574 
2575 /*
2576  * These are the 10 digit buttons for selecting addresses and memories
2577  */
2578 static int
bitoneEntry(guiSynth * synth,int fd,int chan,int c,int o,int v)2579 bitoneEntry(guiSynth *synth, int fd, int chan, int c, int o, int v)
2580 {
2581 	brightonEvent event;
2582 	int ho, lo;
2583 
2584 	/*
2585 	 * So, these are radio buttons, first force exclusion
2586 	 */
2587 	if (synth->dispatch[RADIOSET_1].other2)
2588 	{
2589 		synth->dispatch[RADIOSET_1].other2 = 0;
2590 		return(0);
2591 	}
2592 
2593 	if (synth->dispatch[RADIOSET_1].other1 != -1)
2594 	{
2595 		synth->dispatch[RADIOSET_1].other2 = 1;
2596 
2597 		event.type = BRIGHTON_FLOAT;
2598 		if (synth->dispatch[RADIOSET_1].other1 != o)
2599 			event.value = 0;
2600 		else
2601 			event.value = 1;
2602 
2603 		brightonParamChange(synth->win, synth->panel,
2604 			synth->dispatch[RADIOSET_1].other1 + RADIOSET_1, &event);
2605 	}
2606 	synth->dispatch[RADIOSET_1].other1 = o;
2607 
2608 	/*
2609 	 * What I want to happen here is that the numbers just rotate through those
2610 	 * being pressed, no effective start or endpoint.
2611 	 */
2612 
2613 	if (B1display[4] < 0)
2614 		B1display[4] = c;
2615 	else {
2616 		ho = synth->mem.param[DISPLAY_DEV + entryPoint * 2 + 2]
2617 			= synth->mem.param[DISPLAY_DEV + entryPoint * 2 + 3];
2618 		lo = synth->mem.param[DISPLAY_DEV + entryPoint * 2 + 3] = c;
2619 		B1display[4] = ho * 10 + lo;
2620 		if (entryPoint == ENTER_ADDRESS)
2621 		{
2622 			if (B1display[4] > ENTRY_MAX)
2623 				B1display[4] = c;
2624 		} else {
2625 			while (B1display[4] >= 100)
2626 				B1display[4] = c;
2627 		}
2628 
2629 		/*
2630 		 * Unset the compare button?
2631 		 */
2632 		bitoneCompareOff(synth);
2633 	}
2634 
2635 	B1display[entryPoint] = B1display[4];
2636 
2637 	bitoneUpdateDisplay(synth, fd, chan, c, entryPoint * 2 + 2,
2638 		(B1display[4] + 1) * CONTROLLER_RANGE / 100);
2639 	bitoneDAUpdate(synth);
2640 
2641 	/*
2642 	 * This should happen early and the extended interface should take care
2643 	 * of all of this.
2644 	if (synth->mem.param[EXTENDED_BUTTON] != 0)
2645 		return(bitoneExtendedEntry(synth, fd, chan, 2, o, v));
2646 	 */
2647 
2648 	return(0);
2649 }
2650 
2651 static int
bitoneMidiNull(void * synth,int fd,int chan,int c,int o,int v)2652 bitoneMidiNull(void *synth, int fd, int chan, int c, int o, int v)
2653 {
2654 	if (global.libtest)
2655 		printf("This is a null callback on panel 0 id 0\n");
2656 
2657 	return(0);
2658 }
2659 
2660 static void
bitoneMidiShim(guiSynth * synth,int fd,int chan,int c,int o,int v)2661 bitoneMidiShim(guiSynth *synth, int fd, int chan, int c, int o, int v)
2662 {
2663 	if (b1debug(synth, 3))
2664 		printf("bitoneMidiShim(%i, %i, %i)\n", c, o, v);
2665 	bristolMidiSendMsg(fd, synth->sid, c, o, v);
2666 }
2667 
2668 static int
bitoneMidiSendMsg(guiSynth * synth,int fd,int chan,int c,int o,int v)2669 bitoneMidiSendMsg(guiSynth *synth, int fd, int chan, int c, int o, int v)
2670 {
2671 	if ((c == 0) && (o == 0))
2672 		return(0);
2673 
2674 	o = bitoneRange[c].cont;
2675 	c = bitoneRange[c].op;
2676 
2677 	if (global.libtest)
2678 	{
2679 		if (b1debug(synth, 3))
2680 			printf("bristolMidiSendMsg(%i, %i, %i)\n", c, o, v);
2681 		return(0);
2682 	}
2683 
2684 	if (b1debug(synth, 4))
2685 		printf("bitoneMidiSendMsg(%i, %i, %i) %i\n", c, o, v, entryPoint);
2686 
2687 	if (entryPoint == ENTER_UPPER)
2688 		bristolMidiSendMsg(fd, synth->sid2, c, o, v);
2689 	else
2690 		bristolMidiSendMsg(fd, synth->sid, c, o, v);
2691 
2692 	return(0);
2693 }
2694 
2695 static int
bitoneExtendedEntry(guiSynth * synth,int fd,int chan,int c,int o,int v)2696 bitoneExtendedEntry(guiSynth *synth, int fd, int chan, int c, int o, int v) {
2697 	int index;
2698 	float decimal;
2699 	guiSynth *scratch = b1getScratch(synth);
2700 
2701 	/*
2702 	 * If c = 0 we have come from entryPot
2703 	 * if c = 1 we have come from IncDec
2704 	 * if c = 2 we have come from entry buttons
2705 	if (synth->flags & MEM_LOADING)
2706 		return(0);
2707 	 */
2708 	index = synth->mem.param[DISPLAY_DEV + 2] * 10
2709 		+ synth->mem.param[DISPLAY_DEV + 3];
2710 
2711 	if (b1debug(synth, 5))
2712 		printf("Extended 1 index %i %f (%i)\n", index,
2713 			synth->mem.param[EXTENDED_BUTTON], v);
2714 
2715 	if ((index == EXTENDED_BUTTON) && (v != 0)
2716 		&& (synth->mem.param[EXTENDED_BUTTON] != 0))
2717 	{
2718 		if (b1debug(synth, 1))
2719 			printf("Exit extended data entry\n");
2720 
2721 		synth->mem.param[EXTENDED_BUTTON] = 0;
2722 		synth->mem.param[NON_EXTENDED_BUTTON] = 0;
2723 		scratch->mem.param[EXTENDED_BUTTON] = 0;
2724 		scratch->mem.param[NON_EXTENDED_BUTTON] = 0;
2725 
2726 		/*
2727 		 * Return second display to blank
2728 		 */
2729 		bitoneUpdateDisplay(synth, fd, chan, 6, 6, -10);
2730 
2731 		return(0);
2732 	}
2733 
2734 	index += 100;
2735 
2736 	/*
2737 	 * We have a value for the pot position and that has to be worked into
2738 	 * the entry range.
2739 	 */
2740 	decimal = bitoneRange[index].min +
2741 		v * (bitoneRange[index].max - bitoneRange[index].min + 1)
2742 		/ CONTROLLER_RANGE;
2743 
2744 	if (b1debug(synth, 5))
2745 		printf("Extended 2 index/decimal %i: %f\n", index, decimal);
2746 
2747 	if (index == NON_EXTENDED_BUTTON)
2748 	{
2749 		if (b1debug(synth, 1))
2750 			printf("ExtendedEntry(%i, %i = %1.0f)\n", index, v, decimal);
2751 
2752 	if (b1debug(synth, 5))
2753 		printf("Extended 3 index/decimal %i: %f (%i)\n", index, decimal, mode);
2754 		if (mode == MODE_SINGLE)
2755 		{
2756 			if ((synth->mem.param[EXTENDED_BUTTON] = v) != 0.0)
2757 			{
2758 				brightonEvent event;
2759 
2760 				if (b1debug(synth, 1))
2761 					printf("Enter extended data entry\n");
2762 
2763 				event.type = BRIGHTON_FLOAT;
2764 				event.value = 10.0;
2765 				/* Set last display to some value.
2766 				bitoneUpdateDisplay(synth, fd, chan, 6, 6,
2767 					100 * C_RANGE_MIN_1 / 99);
2768 				*/
2769 				brightonParamChange(synth->win, 0, DISPLAY_DEV + 6, &event);
2770 				brightonParamChange(synth->win, 0, DISPLAY_DEV + 7, &event);
2771 			}
2772 		} else {
2773 			if ((v != 0) && (b1debug(synth, 1)))
2774 				printf("Extended DE (addr=00) not in split or double\n");
2775 			synth->mem.param[EXTENDED_BUTTON] = 0;
2776 			synth->mem.param[NON_EXTENDED_BUTTON] = 0;
2777 			scratch->mem.param[EXTENDED_BUTTON] = 0;
2778 			scratch->mem.param[NON_EXTENDED_BUTTON] = 0;
2779 			v = 0;
2780 		}
2781 	}
2782 
2783 	/* No scratchpad for compare/park with extended data sets */
2784 	synth->mem.param[index] = scratch->mem.param[index] =
2785 		((float) v) / CONTROLLER_RANGE;
2786 
2787 /*
2788 	if (bitoneRange[index].type == BITONE_STEPPED)
2789 		v = decimal;
2790 */
2791 
2792 	/*
2793 	 * We might not be able to send directly. The first 100 buttons are not
2794 	 * handled directly to the dispatcher but passed through to the select code.
2795 	 * If they had dispatchers configured they are now called here on data
2796 	 * entry. If none is available then I just send the parameter index/value
2797 	 */
2798 	if (synth->dispatch[index].routine != NULL)
2799 		synth->dispatch[index].routine(synth,
2800 			global.controlfd, synth->sid,
2801 			synth->dispatch[index].controller,
2802 			synth->dispatch[index].operator,
2803 			v);
2804 	else
2805 		bitoneMidiSendMsg(synth,
2806 			global.controlfd, synth->sid,
2807 			synth->dispatch[index].controller,
2808 			synth->dispatch[index].operator,
2809 			v);
2810 
2811 	if ((synth->flags & MEM_LOADING) == 0)
2812 		bitoneUpdateDisplayDec(synth, fd, chan, 0, 0, decimal);
2813 
2814 	return(0);
2815 }
2816 
2817 static int
bitoneEntryPot(guiSynth * synth,int fd,int chan,int c,int o,int v)2818 bitoneEntryPot(guiSynth *synth, int fd, int chan, int c, int o, int v)
2819 {
2820 	int index;
2821 	float decimal;
2822 	guiSynth *layer = synth, *scratch = b1getScratch(synth);
2823 
2824 	/*
2825 	 * Get the index from the second display
2826 	 */
2827 	index = synth->mem.param[DISPLAY_DEV + 2] * 10
2828 		+ synth->mem.param[DISPLAY_DEV + 3];
2829 
2830 	if (b1debug(synth, 5))
2831 		printf("EntryPot %i, %f\n", index, synth->mem.param[EXTENDED_BUTTON]);
2832 
2833 	/*
2834 	 * This should happen early and the extended interface should take care
2835 	 * of all of this.
2836 	 */
2837 	if ((synth->mem.param[EXTENDED_BUTTON] != 0) || (index == EXTENDED_BUTTON))
2838 		return(bitoneExtendedEntry(synth, fd, chan, 0, o, v));
2839 
2840 	if (entryPoint == ENTER_UPPER)
2841 		layer = (guiSynth *) synth->second;
2842 
2843 	if ((synth->mem.param[102] == 0) && (mode != MODE_SINGLE)
2844 		&& ((bitoneRange[index].flags & B1_ALWAYS) == 0)
2845 		&& ((synth->flags & MEM_LOADING) == 0))
2846 		v = scratch->mem.param[index] * CONTROLLER_RANGE;
2847 
2848 	/*
2849 	 * We have a value for the pot position and that has to be worked into
2850 	 * the entry range.
2851 	 */
2852 	decimal = bitoneRange[index].min +
2853 		v * (bitoneRange[index].max - bitoneRange[index].min + 1)
2854 		/ CONTROLLER_RANGE;
2855 
2856 	if (bitoneRange[index].flags & B1_INACTIVE) {
2857 		v = 0;
2858 		decimal = 0;
2859 	}
2860 
2861 	if ((synth->mem.param[102] == 0) && (mode != MODE_SINGLE)
2862 		&& ((bitoneRange[index].flags & B1_ALWAYS) == 0)
2863 		&& ((synth->flags & MEM_LOADING) == 0))
2864 	{
2865 		bitoneUpdateDisplayDec(synth, fd, chan, c, 0, decimal);
2866 		return(0);
2867 	}
2868 
2869 	if (b1debug(synth, 2))
2870 		printf("entryPot(%i, %i, %i): %i %2.0f, %x\n",
2871 			c, o, v, index, decimal, synth->flags);
2872 
2873 	/*
2874 	 * What we now have to do is decide into which register to put this
2875 	 * parameter - upper or lower manual, and also to send the value.
2876 	 *
2877 	 * We have to be careful with Park here since this is also used to load
2878 	 * memories and if we don't park stuff now then we lose the load. What we
2879 	 * need to do is check for the MEM_LOADING flag and if set then we need to
2880 	 * always park the values.
2881 	 */
2882 	if ((synth->flags & MEM_LOADING) == 0) {
2883 		bitoneUpdateDisplayDec(synth, fd, chan, c, 0, decimal);
2884 		/*
2885 		 * We should make considerations here for some B1_INHERIT options. We
2886 		 * are not loading but then we have have to pass it to the primary layer
2887 		 * event though the layer is secondary. We just override 'scratch'.
2888 		 */
2889 		scratch->mem.param[index] = ((float) v) / CONTROLLER_RANGE;
2890 		if (bitoneRange[index].flags & B1_INHERIT_120) {
2891 			if (synth->mem.param[120] == 0)
2892 				prePark[0].mem.param[index] = ((float) v) / CONTROLLER_RANGE;
2893 		} else if (bitoneRange[index].flags & B1_INHERIT_121) {
2894 			if (synth->mem.param[121] == 0)
2895 				prePark[0].mem.param[index] = ((float) v) / CONTROLLER_RANGE;
2896 		} else if (bitoneRange[index].flags & B1_INHERIT_122) {
2897 			if (synth->mem.param[122] == 0)
2898 				prePark[0].mem.param[index] = ((float) v) / CONTROLLER_RANGE;
2899 		} else if (bitoneRange[index].flags & B1_INHERIT_SEC)
2900 			prePark[0].mem.param[index] = ((float) v) / CONTROLLER_RANGE;
2901 		else if (bitoneRange[index].flags & B1_INHERIT_PRI)
2902 			layer->mem.param[index] = scratch->mem.param[index] =
2903 				prePark[0].mem.param[index];
2904 	} else {
2905 		/*
2906 		 * Else we are loading a memory. See if we have 'INHERIT_PRI' set
2907 		 * which would override this value. We cheat a little here, put the
2908 		 * value into the layer then see about inherit primary. If this is the
2909 		 * primary layer then there is little effect, if not though we will
2910 		 * inherit its value....
2911 		 *
2912 		 * We also need to consider the diverse INHERIT flags here too. If we
2913 		 * have separate split/transpose requested then do not inherit those
2914 		 * flags.
2915 		 */
2916 		layer->mem.param[index] = scratch->mem.param[index] =
2917 			((float) v) / CONTROLLER_RANGE;
2918 
2919 		if (bitoneRange[index].flags & B1_INHERIT_120) {
2920 			if (synth->mem.param[120] == 0)
2921 				layer->mem.param[index] = scratch->mem.param[index] =
2922 					prePark[0].mem.param[index];
2923 		} else if (bitoneRange[index].flags & B1_INHERIT_121) {
2924 			if (synth->mem.param[121] == 0)
2925 				layer->mem.param[index] = scratch->mem.param[index] =
2926 					prePark[0].mem.param[index];
2927 		} else if (bitoneRange[index].flags & B1_INHERIT_122) {
2928 			if (synth->mem.param[122] == 0)
2929 				layer->mem.param[index] = scratch->mem.param[index] =
2930 					prePark[0].mem.param[index];
2931 		} else if (bitoneRange[index].flags & B1_INHERIT_PRI)
2932 			layer->mem.param[index] = scratch->mem.param[index] =
2933 				prePark[0].mem.param[index];
2934 	}
2935 
2936 	if (bitoneRange[index].type == BITONE_STEPPED)
2937 		v = (int) decimal;
2938 
2939 	/*
2940 	 * We might not be able to send directly. The first 100 buttons are not
2941 	 * handled directly to the dispatcher but passed through to the select code.
2942 	 * If they had dispatchers configured they are now called here on data
2943 	 * entry. If none is available then I just send the parameter index/value
2944 	 */
2945 	if (synth->dispatch[index].routine != NULL)
2946 		synth->dispatch[index].routine(synth,
2947 			global.controlfd, synth->sid,
2948 			synth->dispatch[index].controller,
2949 			synth->dispatch[index].operator,
2950 			v);
2951 	else
2952 		bitoneMidiSendMsg(synth,
2953 			global.controlfd, synth->sid,
2954 			synth->dispatch[index].controller,
2955 			synth->dispatch[index].operator,
2956 			v);
2957 
2958 	return(0);
2959 }
2960 
2961 static int
bitoneIncDec(guiSynth * synth,int fd,int chan,int c,int o,int v)2962 bitoneIncDec(guiSynth *synth, int fd, int chan, int c, int o, int v)
2963 {
2964 	brightonEvent event;
2965 	float value = v;
2966 	int index;
2967 
2968 	/*
2969 	 * Get the index from the second display
2970 	 */
2971 	index = synth->mem.param[DISPLAY_DEV + 2] * 10
2972 		+ synth->mem.param[DISPLAY_DEV + 3];
2973 
2974 	event.type = BRIGHTON_FLOAT;
2975 
2976 	if (synth->mem.param[EXTENDED_BUTTON] != 0)
2977 		index += 100;
2978 
2979 	if ((v = synth->mem.param[DISPLAY_DEV + 0] * 10) < 0)
2980 		v = 0;
2981 	else if (v > 100)
2982 		v = 0;
2983 	v += synth->mem.param[DISPLAY_DEV + 1];
2984 
2985 	if (c == 0) {
2986 		/*
2987 		 * Decrement.
2988 		 */
2989 		if (--v < bitoneRange[index].min)
2990 			v = bitoneRange[index].min;
2991 	} else {
2992 		/*
2993 		 * Increment.
2994 		 */
2995 		if (++v > bitoneRange[index].max)
2996 			v = bitoneRange[index].max;
2997 	}
2998 
2999 	if ((value = (v - bitoneRange[index].min)
3000 		/ (bitoneRange[index].max - bitoneRange[index].min)) > 1.0)
3001 		value = 1.0;
3002 	if (value < 0.0)
3003 		value = 0.0;
3004 
3005 	/*
3006 	 * This should happen early and the extended interface should take care
3007 	 * of all of this.
3008 	if ((synth->mem.param[EXTENDED_BUTTON] != 0) || (index == EXTENDED_BUTTON))
3009 		return(bitoneExtendedEntry(synth, fd, chan, 1, c, v));
3010 	 */
3011 
3012 	event.value = value;
3013 	brightonParamChange(synth->win, 0, ENTRY_POT, &event);
3014 
3015 	return(0);
3016 }
3017 
3018 static int
bitoneSelectExtended(guiSynth * synth,int fd,int chan,int c,int o,int v)3019 bitoneSelectExtended(guiSynth *synth, int fd, int chan, int c, int o, int v)
3020 {
3021 	brightonEvent event;
3022 	guiSynth *layer = b1getScratch(synth);
3023 
3024 	if (b1debug(synth, 1))
3025 		printf("SelectExtended data entry %i %i\n", c, v);
3026 
3027 	selectExtended = 100;
3028 	synth->mem.param[EXTENDED_BUTTON] = 1.0;
3029 
3030 	bitoneUpdateDisplay(synth, fd, chan, c - 100, 2,
3031 		(c - 99) * C_RANGE_MIN_1 / 100);
3032 
3033 	event.type = BRIGHTON_FLOAT;
3034 	event.value = layer->mem.param[c];
3035 	brightonParamChange(synth->win, 0, ENTRY_POT, &event);
3036 
3037 	return(0);
3038 }
3039 
3040 static int
bitoneSelect(guiSynth * synth,int fd,int chan,int c,int o,int v)3041 bitoneSelect(guiSynth *synth, int fd, int chan, int c, int o, int v)
3042 {
3043 	brightonEvent event;
3044 	guiSynth *layer = b1getScratch(synth);
3045 
3046 	if (synth->mem.param[EXTENDED_BUTTON] != 0)
3047 	{
3048 		if (b1debug(synth, 1))
3049 			printf("Extended data entry on address only\n");
3050 
3051 		if (selectExtended != 0) {
3052 			selectExtended = 0;
3053 			synth->mem.param[EXTENDED_BUTTON] = 0;
3054 		}
3055 		return(0);
3056 	}
3057 
3058 	selectExtended = 0;
3059 	synth->mem.param[EXTENDED_BUTTON] = 0.0;
3060 
3061 	bitoneUpdateDisplay(synth, fd, chan, c, 2,
3062 		(c + 1) * CONTROLLER_RANGE / 100);
3063 
3064 	event.type = BRIGHTON_FLOAT;
3065 	event.value = layer->mem.param[c];
3066 	brightonParamChange(synth->win, 0, ENTRY_POT, &event);
3067 
3068 	return(0);
3069 }
3070 
3071 static void
bitoneSaveMemory(guiSynth * synth)3072 bitoneSaveMemory(guiSynth *synth)
3073 {
3074 	guiSynth *layer = synth;
3075 	int loc, oloc = 0; /* This does not need to be initted but GCC complains */
3076 	float dbg;
3077 
3078 	if (entryPoint == ENTER_UPPER)
3079 	{
3080 		if (synth->mem.param[102] == 0)
3081 		{
3082 			if (b1debug(synth, 1))
3083 				printf("No save upper layer (DE 102)\n");
3084 			return;
3085 		}
3086 		layer = (guiSynth *) synth->second;
3087 		if ((loc = synth->mem.param[DISPLAY_DEV + 6] * 10 +
3088 			synth->mem.param[DISPLAY_DEV + 7]) >= 100)
3089 			oloc %= 100;
3090 		if ((oloc = synth->mem.param[DISPLAY_DEV + 4] * 10 +
3091 			synth->mem.param[DISPLAY_DEV + 5]) >= 100)
3092 			oloc = -1;
3093 	} else {
3094 		if ((loc = synth->mem.param[DISPLAY_DEV + 4] * 10 +
3095 			synth->mem.param[DISPLAY_DEV + 5]) >= 100)
3096 			loc %= 100;
3097 		if ((oloc = synth->mem.param[DISPLAY_DEV + 6] * 10 +
3098 			synth->mem.param[DISPLAY_DEV + 7]) >= 100)
3099 			oloc = -1;
3100 	}
3101 
3102 	layer->mem.param[SAVE_MODE] = mode;
3103 	if (mode != MODE_SINGLE)
3104 		layer->mem.param[SAVE_PEER] = oloc;
3105 	else
3106 		layer->mem.param[SAVE_PEER] = -1;
3107 	layer->mem.param[SAVE_STEREO] = synth->mem.param[STEREO_BUTTON];
3108 
3109 	/*
3110 	 * Clear extended and non-extended flags, we don't want either at
3111 	 * startup.
3112 	 */
3113 	layer->mem.param[EXTENDED_BUTTON] = 0.0;
3114 	layer->mem.param[74] = 0.0;
3115 	layer->mem.param[75] = 0.0;
3116 	layer->mem.param[130] = 0.0;
3117 	layer->mem.param[131] = 0.0;
3118 	layer->mem.param[NON_EXTENDED_BUTTON] = 0.0;
3119 
3120 	if ((dbg = synth->mem.param[109]) != 0)
3121 		printf("saving %i, peer %i\n", loc, oloc);
3122 	if (b1debug(synth, 5) == 0)
3123 		synth->mem.param[109] = 0;
3124 
3125 	saveMemory(layer, SYNTH_NAME, 0, loc, 0);
3126 
3127 	if (entryPoint == ENTER_UPPER)
3128 		saveSequence(synth, SYNTH_NAME, loc, BRISTOL_SID2);
3129 	else
3130 		saveSequence(synth, SYNTH_NAME, loc, 0);
3131 
3132 	synth->mem.param[109] = dbg;
3133 
3134 	return;
3135 }
3136 
3137 int
bitoneMemoryKey(guiSynth * synth,char * algo,char * name,int location,int active,int skip,int flags)3138 bitoneMemoryKey(guiSynth *synth, char *algo, char *name, int location,
3139 int active, int skip, int flags)
3140 {
3141 	float dbgH = synth->mem.param[109];
3142 	guiSynth *layer = synth;
3143 	brightonEvent event;
3144 
3145 	if (entryPoint == ENTER_UPPER)
3146 	{
3147 		layer = (guiSynth *) synth->second;
3148 		memUpper = location;
3149 	} else {
3150 		memLower = location;
3151 		if (mode == MODE_SINGLE)
3152 			memUpper = -1;
3153 	}
3154 
3155 	/*
3156 	 * Load memory - need to look at layers and selections.
3157 	 */
3158 	loadMemory(layer, SYNTH_NAME, 0, location, layer->mem.active, 0,
3159 		BRISTOL_FORCE|BRISTOL_NOCALLS|BRISTOL_SEQLOAD|BRISTOL_SEQFORCE);
3160 
3161 	if (b1debug(synth, 1))
3162 		printf("First load: %i: mode %2.0f, peer %2.0f, %i\n", location,
3163 			layer->mem.param[SAVE_MODE],
3164 			layer->mem.param[SAVE_PEER], entryPoint);
3165 
3166 	synth->mem.param[109] = dbgH;
3167 
3168 	/* call a second shim first for extended data parameters? */
3169 	if (entryPoint == ENTER_UPPER)
3170 		bitoneMemoryShim(synth, ENTRY_MAX);
3171 	else
3172 		bitoneMemoryShim(synth, ACTIVE_DEVS - 10);
3173 
3174 	bitoneDAUpdate(synth);
3175 
3176 	/*
3177 	 * Set the stereo from the placeholder.
3178 	 */
3179 	event.type = BRIGHTON_FLOAT;
3180 	event.value = synth->mem.param[SAVE_STEREO];
3181 	brightonParamChange(synth->win, 0, STEREO_BUTTON, &event);
3182 
3183 	return(0);
3184 }
3185 
3186 static void
bitoneMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)3187 bitoneMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
3188 {
3189 	guiSynth *layer = synth, *other = (guiSynth *) synth->second;
3190 	brightonEvent event;
3191 	int loc;
3192 
3193 	if (synth->flags & MEM_LOADING)
3194 		return;
3195 	if ((synth->flags & OPERATIONAL) == 0)
3196 		return;
3197 
3198 	/*
3199 	 * Saving memories requires that we take a peek at the split/double settings
3200 	 * and then select the memory location accordingly. These are not going to
3201 	 * be performance parameters so we only save a single memory at a time.
3202 	 */
3203 	if (c == 0) {
3204 		if (brightonDoubleClick(dc) != 0)
3205 			bitoneSaveMemory(synth);
3206 
3207 		return;
3208 	}
3209 
3210 	if (c == 1) {
3211 		/*
3212 		 * What we want to do here is have a single click load the current
3213 		 * layer, and a double click load the other layer IF we are in split
3214 		 * or double mode
3215 		 */
3216 		if (brightonDoubleClick(dc) == 0)
3217 		{
3218 			float dbgH = synth->mem.param[109];
3219 
3220 			if (entryPoint == ENTER_UPPER)
3221 			{
3222 				layer = (guiSynth *) synth->second;
3223 				memUpper = loc = synth->mem.param[DISPLAY_DEV + 6] * 10 +
3224 					synth->mem.param[DISPLAY_DEV + 7];
3225 			} else {
3226 				memLower = loc = synth->mem.param[DISPLAY_DEV + 4] * 10 +
3227 					synth->mem.param[DISPLAY_DEV + 5];
3228 				if (mode == MODE_SINGLE)
3229 					memUpper = -1;
3230 			}
3231 
3232 			/*
3233 			 * Load memory - need to look at layers and selections.
3234 			 */
3235 			loadMemory(layer, SYNTH_NAME, 0, synth->bank * 100 + loc,
3236 				layer->mem.active, 0,
3237 				BRISTOL_FORCE|BRISTOL_NOCALLS|BRISTOL_SEQLOAD|BRISTOL_SEQFORCE);
3238 
3239 			if (b1debug(synth, 1))
3240 				printf("First load: %i: mode %2.0f, peer %2.0f, %i\n", loc,
3241 					layer->mem.param[SAVE_MODE],
3242 					layer->mem.param[SAVE_PEER], entryPoint);
3243 
3244 			synth->mem.param[109] = dbgH;
3245 
3246 			/* call a second shim first for extended data parameters? */
3247 			if (entryPoint == ENTER_UPPER)
3248 				bitoneMemoryShim(synth, ENTRY_MAX);
3249 			else
3250 				bitoneMemoryShim(synth, ACTIVE_DEVS - 10);
3251 
3252 			bitoneDAUpdate(synth);
3253 
3254 			/*
3255 			 * Set the stereo from the placeholder.
3256 			 */
3257 			event.type = BRIGHTON_FLOAT;
3258 			event.value = synth->mem.param[SAVE_STEREO];
3259 			brightonParamChange(synth->win, 0, STEREO_BUTTON, &event);
3260 		} else {
3261 			int peer;
3262 
3263 			if (entryPoint == ENTER_UPPER)
3264 			{
3265 				layer = synth;
3266 				other = ((guiSynth *) synth->second);
3267 				memLower = loc =
3268 					((guiSynth *) synth->second)->mem.param[SAVE_PEER];
3269 				peer = 1;
3270 			} else {
3271 				layer = (guiSynth *) synth->second;
3272 				other = synth;
3273 				memUpper = loc = synth->mem.param[SAVE_PEER];
3274 				peer = 2;
3275 			}
3276 
3277 			/*
3278 			 * See if we have a dual loadable memory:
3279 			 */
3280 			if ((other->mem.param[SAVE_MODE] <= 0) ||
3281 				(other->mem.param[SAVE_MODE] > MODE_LAYER) ||
3282 				(other->mem.param[SAVE_PEER] < 0))
3283 			{
3284 				if (b1debug(synth, 1))
3285 					printf("not a dual loadable memory\n");
3286 				return;
3287 			}
3288 
3289 			if (b1debug(synth, 1))
3290 				printf("Dual load %1.0f, %1.0f: %f\n",
3291 					other->mem.param[SAVE_MODE],
3292 					other->mem.param[SAVE_PEER],
3293 					synth->mem.param[202]);
3294 			/*
3295 			 * Set the operative mode
3296 			 */
3297 			event.type = BRIGHTON_FLOAT;
3298 			event.value = 1.0;
3299 			brightonParamChange(synth->win, 0,
3300 				RADIOSET_3 + (int) other->mem.param[SAVE_MODE] - 1, &event);
3301 			/* And select a layer */
3302 			brightonParamChange(synth->win, 0, RADIOSET_2 + peer, &event);
3303 
3304 			if (b1debug(synth, 1))
3305 				printf("Dual load now %i\n", entryPoint);
3306 			loadMemory(layer, SYNTH_NAME, 0, synth->bank * 100 + loc,
3307 				ENTRY_MAX, 0,
3308 				BRISTOL_NOCALLS|BRISTOL_FORCE|BRISTOL_SEQLOAD|BRISTOL_SEQFORCE);
3309 
3310 			bitoneMemoryShim(synth, ENTRY_MAX);
3311 
3312 			bitoneUpdateDisplay(synth, fd, chan, c, entryPoint * 2 + 2,
3313 				(loc + 1) * CONTROLLER_RANGE / 100);
3314 
3315 			bitoneDAUpdate(synth);
3316 		}
3317 
3318 		/*
3319 		 * And update parameters on the display to reflect both memories and
3320 		 * the selected entry parameter
3321 		 */
3322 	}
3323 }
3324 
3325 /*
3326  * This currently (12/02/08) implements a single channel for both layers. It
3327  * needs to be extended based on DE-120 to support different channels.
3328  */
3329 static void
bitoneMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)3330 bitoneMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
3331 {
3332 	guiSynth *layer = synth, *scratch = &prePark[0];
3333 	int newchan;
3334 
3335 	if (b1debug(synth, 1))
3336 		printf("bitoneMidi(%i, %i) %i\n",
3337 			b1decimal(73, prePark[0].mem.param[73]),
3338 			b1decimal(73, prePark[1].mem.param[73]),
3339 			entryPoint);
3340 
3341 	if ((synth->flags & OPERATIONAL) == 0)
3342 		return;
3343 
3344 	if (entryPoint == ENTER_UPPER) {
3345 		if (b1debug(synth, 5))
3346 			printf("BitOne MIDI Upper: %i, %i, %i (%i)\n", c, o, v, entryPoint);
3347 		layer = (guiSynth *) synth->second;
3348 		scratch = &prePark[1];
3349 	} else
3350 		if (b1debug(synth, 5))
3351 			printf("BitOne MIDI Lower: %i, %i, %i (%i)\n", c, o, v, entryPoint);
3352 
3353 /*
3354 	newchan = synth->mem.param[DISPLAY_DEV] * 10 +
3355 		synth->mem.param[DISPLAY_DEV + 1];
3356 */
3357 	newchan = v;
3358 
3359 	/*
3360 	 * Logically we want to take the lower layer midi channel in all cases
3361 	 * except when on upper layer with DE 120 set
3362 	 */
3363 	if ((entryPoint == ENTER_UPPER) && (synth->mem.param[120] == 0))
3364 		newchan = b1decimal(73, prePark[0].mem.param[73]);
3365 
3366 	if (newchan < 1)
3367 		newchan = 1;
3368 	newchan--;
3369 
3370 	if (newchan < 0)
3371 		newchan = 0;
3372 	if (newchan > 15)
3373 		newchan = 15;
3374 
3375 	if (layer->mem.param[72] != 0)
3376 	{
3377 		layer->midichannel = newchan;
3378 
3379 		if (b1debug(synth, 2))
3380 			printf("Midi channel request not active in OMNI: %i\n", newchan);
3381 		return;
3382 	}
3383 
3384 	/*
3385 	 * See if we have separate MIDI channel by layer (not the default).
3386 	 */
3387 	if  (synth->mem.param[120] == 0)
3388 	{
3389 		if (b1debug(synth, 2))
3390 			printf("dual send %i\n", newchan);
3391 
3392 		/*
3393 		 * Send this to both channels. This is not always intuitive, we may
3394 		 * only be using one layer however we have to keep both on same channel.
3395 		 */
3396 		if (global.libtest == 0)
3397 		{
3398 			bristolMidiSendMsg(global.controlfd, synth->sid,
3399 				127, 0, BRISTOL_MIDICHANNEL|newchan);
3400 
3401 			bristolMidiSendMsg(global.controlfd, synth->sid2,
3402 				127, 0, BRISTOL_MIDICHANNEL|newchan);
3403 		}
3404 	} else {
3405 		if (b1debug(synth, 2))
3406 			printf("single send %i on %i\n", newchan, entryPoint);
3407 		/*
3408 		 * If we get here then we are only going to configure the channel for
3409 		 * the one layer and they can then be different.
3410 		 */
3411 		if (global.libtest == 0)
3412 		{
3413 			if (entryPoint == ENTER_UPPER)
3414 				bristolMidiSendMsg(global.controlfd, layer->sid2,
3415 					127, 0, BRISTOL_MIDICHANNEL|newchan);
3416 			else
3417 				bristolMidiSendMsg(global.controlfd, layer->sid,
3418 					127, 0, BRISTOL_MIDICHANNEL|newchan);
3419 		}
3420 	}
3421 
3422 	layer->midichannel = newchan;
3423 
3424 	return;
3425 }
3426 
3427 /*
3428  * For the sake of ease of use, links have been placed here to be called
3429  * by any of the devices created. They would be better in some other file,
3430  * perhaps with this as a dispatch.
3431  *
3432  * Param refers to the device index in the locations table given below.
3433  */
3434 static int
bitoneCallback(brightonWindow * win,int panel,int index,float value)3435 bitoneCallback(brightonWindow * win, int panel, int index, float value)
3436 {
3437 	guiSynth *synth = findSynth(global.synths, win);
3438 	int sendvalue;
3439 
3440 /*	printf("bitoneCallback(%i, %f): %x\n", index, value, synth); */
3441 
3442 	if (synth == 0)
3443 		return(0);
3444 
3445 	if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
3446 		return(0);
3447 
3448 	if (bitoneApp.resources[0].devlocn[index].to == 1)
3449 		sendvalue = value * C_RANGE_MIN_1;
3450 	else
3451 		sendvalue = value;
3452 
3453 	/*
3454 	 * See how the Split/Double is organised. If we are under the first 100
3455 	 * memories and we are not split or double then we should set both synth
3456 	 * layers?
3457 	 */
3458 	if (index >= ACTIVE_DEVS)
3459 	{
3460 		synth->mem.param[index] = value;
3461 
3462 		if (synth->dispatch[index].routine == NULL)
3463 			return(0);
3464 
3465 		synth->dispatch[index].routine(synth,
3466 			global.controlfd, synth->sid,
3467 			synth->dispatch[index].controller,
3468 			synth->dispatch[index].operator,
3469 			sendvalue);
3470 	} else {
3471 		if (index < 100)
3472 			bitoneSelect(synth,
3473 				global.controlfd, synth->sid,
3474 				synth->dispatch[index].controller,
3475 				synth->dispatch[index].operator,
3476 				sendvalue);
3477 		else
3478 			bitoneSelectExtended(synth,
3479 				global.controlfd, synth->sid,
3480 				synth->dispatch[index].controller,
3481 				synth->dispatch[index].operator,
3482 				sendvalue);
3483 	}
3484 
3485 	return(0);
3486 }
3487 
3488 /*
3489  * Park will first copy the scratchpads (both of them) to the synth memory
3490  * structures. A double click will save them (both?) to memories.
3491  *
3492  * I don't think we should do both at once, just the current layer.....
3493  */
3494 static void
bitonePark(guiSynth * synth,int fd,int chan,int c,int o,int v)3495 bitonePark(guiSynth *synth, int fd, int chan, int c, int o, int v)
3496 {
3497 	int i;
3498 	guiSynth *scratch = &prePark[0], *layer = synth;
3499 
3500 	if (brightonDoubleClick(dc) != 0)
3501 	{
3502 		/*
3503 		 * We should save and exit here. We do allow saving of the current
3504 		 * memory only if it is the lower layer in some circumstances.
3505 		 */
3506 		if ((entryPoint != ENTER_UPPER) || (synth->mem.param[102] != 0))
3507 			bitoneSaveMemory(synth);
3508 		else if (b1debug(synth, 1))
3509 			printf("No save upper layers (DE 102)\n");
3510 		return;
3511 	}
3512 
3513 	if ((synth->mem.param[102] == 0) && (mode != MODE_SINGLE))
3514 	{
3515 		if (b1debug(synth, 1))
3516 			printf("no parking layer edits (DE 102)\n");
3517 		return;
3518 	}
3519 
3520 	if (synth->mem.param[101] != 0)
3521 	{
3522 		if (b1debug(synth, 1))
3523 			printf("no park/compare scratchpad\n");
3524 		return;
3525 	}
3526 
3527 	if (b1debug(synth, 2))
3528 		printf("bitonePark(%i)\n", v);
3529 
3530 	if (entryPoint == ENTER_UPPER) {
3531 		scratch = &prePark[1];
3532 		layer = (guiSynth *) synth->second;
3533 	}
3534 
3535 	/*
3536 	 * Turn off the Compare button if lit. Oops, no, if we park when compared
3537 	 * then there we should revert back to the previous memory and discard the
3538 	 * changes - we are currently listening to the original sound, that is the
3539 	 * one we want to park.
3540 	 */
3541 	if (synth->mem.param[223] != 0)
3542 	{
3543 		guiSynth *p1 = &prePark[0], *p2 = &prePark[2];
3544 
3545 		if (b1debug(synth, 1))
3546 			printf("Parking with Compare, discard edits, keep original\n");
3547 
3548 		/*
3549 		 * Parking when compared means dump the edits we made. Copy 0->2 or
3550 		 * 1->3 then turn off compare.
3551 		 */
3552 		if (entryPoint == ENTER_UPPER) {
3553 			p1 = &prePark[1];
3554 			p2 = &prePark[3];
3555 		}
3556 
3557 		for (i = 0; i < ENTRY_MAX; i++)
3558 			p2->mem.param[i] = p1->mem.param[i];
3559 
3560 		bitoneCompareOff(synth);
3561 	}
3562 
3563 	/*
3564 	 * Copy over respective memories. We only copy the first 100 since they are
3565 	 * the only ones that use the prePark cache - to compare the audio. The
3566 	 * Extended Entry are put directly into the synth memory bypassing the
3567 	 * cache.
3568 	 */
3569 	for (i = 0; i < ENTRY_MAX; i++)
3570 		layer->mem.param[i] = scratch->mem.param[i];
3571 }
3572 
3573 static void
bitoneCompare(guiSynth * synth,int fd,int chan,int c,int o,int v)3574 bitoneCompare(guiSynth *synth, int fd, int chan, int c, int o, int v)
3575 {
3576 	int i;
3577 	guiSynth *scratch, *scratch2, *layer;
3578 
3579 	if ((synth->flags & MEM_LOADING) != 0)
3580 		return;
3581 
3582 	if (synth->mem.param[101] != 0)
3583 	{
3584 		if (b1debug(synth, 1))
3585 			printf("no park/compare scratchpad\n");
3586 		return;
3587 	}
3588 
3589 	if (b1debug(synth, 2))
3590 		printf("bitoneCompare(%i)\n", v);
3591 
3592 	if (v != 0) {
3593 		/*
3594 		 * We want to reactivate the loaded memory, not the scratchpad.
3595 		 */
3596 		if (entryPoint == ENTER_UPPER)
3597 		{
3598 			scratch2 = &prePark[3];
3599 			layer = (guiSynth *) synth->second;
3600 		} else {
3601 			scratch2 = &prePark[2];
3602 			layer = synth;
3603 		}
3604 		scratch = b1getScratch(synth);
3605 
3606 		/* Save current scratchpad */
3607 		for (i = 0; i < ENTRY_MAX; i++)
3608 			scratch2->mem.param[i] = scratch->mem.param[i];
3609 
3610 		/* Call the memory shim to activate the memory values */
3611 		bitoneMemoryShim(synth, ENTRY_MAX);
3612 
3613 		bitoneDAUpdate(synth);
3614 
3615 		return;
3616 	}
3617 
3618 	/*
3619 	 * Compare is going off so we want to active the layer scratchpad.
3620 	 *
3621 	 * Find the layer.
3622 	 * Copy layer memory to the 5th scratchpad.
3623 	 * Copy the layer scratch to the memory.
3624 	 * Shim it.
3625 	 * Copy 5th scratch back to memory.
3626 	 * Copy saved scratch back to scratch
3627 	 */
3628 	if (entryPoint == ENTER_UPPER) {
3629 		layer = (guiSynth *) synth->second;
3630 		scratch = &prePark[3];
3631 	} else {
3632 		layer = synth;
3633 		scratch = &prePark[2];
3634 	}
3635 	scratch2 = &prePark[4];
3636 
3637 	/* Save a copy of the real memory */
3638 	for (i = 0; i < ENTRY_MAX; i++)
3639 		scratch2->mem.param[i] = layer->mem.param[i];
3640 
3641 	/* Copy the layer scratch to the memory */
3642 	for (i = 0; i < ENTRY_MAX; i++)
3643 		layer->mem.param[i] = scratch->mem.param[i];
3644 
3645 	/* Call the memory shim to activate this stuff */
3646 	bitoneMemoryShim(synth, ENTRY_MAX);
3647 
3648 	/* Restore a copy of the real memory */
3649 	for (i = 0; i < ENTRY_MAX; i++)
3650 		layer->mem.param[i] = scratch2->mem.param[i];
3651 
3652 	/* Restore a copy of original scratch */
3653 	if (entryPoint == ENTER_UPPER)
3654 		scratch2 = &prePark[3];
3655 	else
3656 		scratch2 = &prePark[2];
3657 	scratch = b1getScratch(synth);
3658 	scratch = &prePark[0];
3659 	for (i = 0; i < ENTRY_MAX; i++)
3660 		scratch->mem.param[i] = scratch2->mem.param[i];
3661 
3662 	bitoneDAUpdate(synth);
3663 }
3664 
3665 /*
3666  * The LFO waveform is exclusive and that needs to be managed here. There are
3667  * some issues related to the parking of parameters that gets kind of side-
3668  * stepped here.
3669  *
3670  * The LFO has three active waveforms, tri, ramp/saw and square. If all are
3671  * unselected I will have the LFO generate sine.
3672  */
3673 static void
bitoneLFO(guiSynth * synth,int fd,int chan,int c,int o,int v)3674 bitoneLFO(guiSynth *synth, int fd, int chan, int c, int o, int v)
3675 {
3676 	guiSynth *layer = b1getScratch(synth);
3677 	int c0, c1, c2, c3;
3678 
3679 	if (v == 0)
3680 		return;
3681 
3682 	/*
3683 	 * Now we have to form exclusions
3684 	 */
3685 	switch (o) {
3686 		case 0:
3687 		default:
3688 			c0 = c < 4? 13:21;
3689 			c1 = c < 4? 2:54;
3690 			c2 = c < 4? 3:55;
3691 			c3 = c < 4? 81:87;
3692 			break;
3693 		case 1:
3694 			c0 = c < 4? 14:22;
3695 			c1 = c < 4? 1:53;
3696 			c2 = c < 4? 3:55;
3697 			c3 = c < 4? 81:87;
3698 			break;
3699 		case 2:
3700 			c0 = c < 4? 15:23;
3701 			c1 = c < 4? 1:53;
3702 			c2 = c < 4? 2:54;
3703 			c3 = c < 4? 81:87;
3704 			break;
3705 		case 3:
3706 			c0 = c == 81? 16:24;
3707 			c1 = c == 81? 1:53;
3708 			c2 = c == 81? 2:54;
3709 			c3 = c == 81? 3:55;
3710 			break;
3711 	}
3712 
3713 	bristolMidiSendMsg(fd, synth->sid, 126, c0, C_RANGE_MIN_1);
3714 
3715 	layer->mem.param[c1] = 0;
3716 	layer->mem.param[c2] = 0;
3717 	layer->mem.param[c3] = 0;
3718 }
3719 
3720 static void
bitoneStereo(guiSynth * synth,int fd,int chan,int c,int o,int v)3721 bitoneStereo(guiSynth *synth, int fd, int chan, int c, int o, int v)
3722 {
3723 	guiSynth *llayer = &prePark[0];
3724 	guiSynth *ulayer = &prePark[0];
3725 	int lli = 66, uli = 67;
3726 
3727 	float ll, lr, ul, ur;
3728 
3729 	if (b1debug(synth, 1))
3730 		printf("bitoneStereo(%i, %i, %i)\n", c, o, v);
3731 
3732 	/* Intercept the requests to see if we want to rework the settings? */
3733 	if (o == 1) {
3734 		/*
3735 		 * Stereo/Mono button
3736 		 */
3737 	} else {
3738 		/*
3739 		 * Upper/Lower layer gains
3740 		 */
3741 	}
3742 
3743 	if (synth->mem.param[118] != 0)
3744 	{
3745 		/*
3746 		 * The bit-100 flag, separate layer volumes but from the single param.
3747 		 */
3748 		ulayer = &prePark[1];
3749 		uli = 66;
3750 	}
3751 
3752 	/*
3753 	 * Check layer volumes and set them. The defaults will be 0.7 even panning
3754 	 * for Mono and hard 1.0 panning for Stereo.
3755 	 */
3756 	if (synth->mem.param[202] == 0) {
3757 		/*
3758 		 * Mono panning.
3759 		 */
3760 		ll = llayer->mem.param[lli] * synth->mem.param[110];
3761 		lr = llayer->mem.param[lli] * synth->mem.param[111];
3762 		ul = ulayer->mem.param[uli] * synth->mem.param[114];
3763 		ur = ulayer->mem.param[uli] * synth->mem.param[115];
3764 	} else {
3765 		/*
3766 		 * Stereo panning.
3767 		 */
3768 		ll = llayer->mem.param[lli] * synth->mem.param[112];
3769 		lr = llayer->mem.param[lli] * synth->mem.param[113];
3770 		ul = ulayer->mem.param[uli] * synth->mem.param[116];
3771 		ur = ulayer->mem.param[uli] * synth->mem.param[117];
3772 	}
3773 
3774 	if (b1debug(synth, 3))
3775 	{
3776 		printf("M: %f %f %f %f\n",
3777 			synth->mem.param[110],synth->mem.param[111],
3778 			synth->mem.param[114],synth->mem.param[115]);
3779 		printf("S: %f %f %f %f\n",
3780 			synth->mem.param[112],synth->mem.param[113],
3781 			synth->mem.param[116],synth->mem.param[117]);
3782 		printf("C: %f %f %f %f\n", ll,  lr, ul, ur);
3783 	}
3784 
3785 	/*
3786 	 * Always send the lower layer volumes.
3787 	 * Send the upper layer volumes if MODE_SINGLE is not in operation
3788 	 */
3789 	bristolMidiSendMsg(fd, synth->sid, 126, 5, (int) (C_RANGE_MIN_1 * ll));
3790 	bristolMidiSendMsg(fd, synth->sid, 126, 6, (int) (C_RANGE_MIN_1 * lr));
3791 
3792 	if (mode != MODE_SINGLE) {
3793 		if (b1debug(synth, 1))
3794 			printf("mode dual\n");
3795 		bristolMidiSendMsg(fd, synth->sid2, 126, 5, (int) (C_RANGE_MIN_1 * ul));
3796 		bristolMidiSendMsg(fd, synth->sid2, 126, 6, (int) (C_RANGE_MIN_1 * ur));
3797 	} else {
3798 		if (b1debug(synth, 1))
3799 			printf("mode single\n");
3800 		bristolMidiSendMsg(fd, synth->sid2, 126, 5, 0);
3801 		bristolMidiSendMsg(fd, synth->sid2, 126, 6, 0);
3802 	}
3803 }
3804 
3805 /*
3806  * This is joint unison from the bit-01 controls. There are separate selectors
3807  * for the emulations per layer, control ID 80 which is consequently set here.
3808  * The value would have to be parked to be saved in memory.
3809  */
3810 static void
bitoneUnison(guiSynth * synth,int fd,int chan,int c,int o,int v)3811 bitoneUnison(guiSynth *synth, int fd, int chan, int c, int o, int v)
3812 {
3813 	if (v == 0)
3814 	{
3815 		prePark[0].mem.param[80]= 0.0;
3816 		prePark[1].mem.param[80]= 0.0;
3817 	} else {
3818 		prePark[0].mem.param[80]= 1.0;
3819 		prePark[1].mem.param[80]= 1.0;
3820 	}
3821 	bristolMidiSendMsg(fd, synth->sid, 126, 7, v);
3822 	bristolMidiSendMsg(fd, synth->sid2, 126, 7, v);
3823 }
3824 
3825 static void
bitoneDualSend(guiSynth * synth,int fd,int chan,int c,int o,int v)3826 bitoneDualSend(guiSynth *synth, int fd, int chan, int c, int o, int v)
3827 {
3828 	bristolMidiSendMsg(fd, synth->sid, c, o, v);
3829 	bristolMidiSendMsg(fd, synth->sid2, c, o, v);
3830 }
3831 
3832 static void
bitoneHarmonics(guiSynth * synth,int fd,int chan,int c,int o,int v)3833 bitoneHarmonics(guiSynth *synth, int fd, int chan, int c, int o, int v)
3834 {
3835 	guiSynth *layer = b1getScratch(synth);
3836 	float value;
3837 	int oscIndex = 24, i;
3838 	int sid = synth->sid;
3839 
3840 	if (c == DCO_1_EXCLUSIVE)
3841 	{
3842 		c = 2;
3843 		o = 0;
3844 	} else if (c == DCO_2_EXCLUSIVE) {
3845 		c = 2;
3846 		o = 1;
3847 	}
3848 
3849 	if (entryPoint == 2)
3850 		sid = synth->sid2;
3851 
3852 	if (b1debug(synth, 2))
3853 		printf("bitoneHarmonics(%i, %i, %i)\n", c, o, v);
3854 
3855 	/*
3856 	 * If we have the value 0 then we need to force exclusion on the different
3857 	 * harmonics of the DCO.
3858 	 */
3859 	if (c == 0)
3860 	{
3861 		if (b1debug(synth, 3))
3862 			printf("control\n");
3863 
3864 		/*
3865 		 * Select which osc to manipulate
3866 		 */
3867 		if (o != 0)
3868 			oscIndex = 35;
3869 
3870 		/*
3871 		 * This is the controlling boolean. If this goes to one we need to
3872 		 * start enforcing exclusion - take the first harmonic and clear the
3873 		 * rest
3874 		 */
3875 		if (v != 0) {
3876 			value =  1.0;
3877 
3878 			/* Remove all but the first harmonic */
3879 			for (i = 0;i < 4; i++)
3880 			{
3881 				if (layer->mem.param[oscIndex + i] != 0)
3882 				{
3883 					layer->mem.param[oscIndex + i] = value;
3884 					/* Send event to engine */
3885 					/* Decrement the value - only the first hit will remain 1 */
3886 					if ((value -=  1.0) < 0)
3887 						value = 0.0;
3888 				}
3889 			}
3890 		}
3891 	} else {
3892 		int osc = 4, parm;
3893 
3894 		if (b1debug(synth, 3))
3895 			printf("DCO\n");
3896 		if (c >= 35)
3897 		{
3898 			oscIndex = 35;
3899 			osc = 5;
3900 		}
3901 		parm = c - oscIndex;
3902 
3903 		/*
3904 		 * These are the harmonic selectors from the DCO. If the value is zero
3905 		 * just clear the harmonic, otherwise when going on we need to check
3906 		 * the boolean to ensure exclusion if configured.
3907 		 */
3908 		if (v == 0) {
3909 			/* Send value to engine unless its the last one */
3910 			if ((layer->mem.param[oscIndex] == 0)
3911 				&& (layer->mem.param[oscIndex + 1] == 0)
3912 				&& (layer->mem.param[oscIndex + 2] == 0)
3913 				&& (layer->mem.param[oscIndex + 3] == 0))
3914 				return;
3915 
3916 			bristolMidiSendMsg(fd, sid, osc, parm, v);
3917 
3918 			return;
3919 		}
3920 
3921 		/*
3922 		 * Now we can turn the harmonic on
3923 		 */
3924 		bristolMidiSendMsg(fd, sid, osc, parm, v);
3925 
3926 		/*
3927 		 * then we start exclusion.
3928 		 */
3929 		if (c >= 35) {
3930 			if (layer->mem.param[DCO_2_EXCLUSIVE] == 0.0)
3931 				return;
3932 			oscIndex =  35;
3933 		} else {
3934 			if (layer->mem.param[DCO_1_EXCLUSIVE] == 0.0)
3935 				return;
3936 			oscIndex =  24;
3937 		}
3938 
3939 		value = 0.0;
3940 
3941 		for (i = 0;i < 4; i++)
3942 		{
3943 			if ((oscIndex + i) == c)
3944 				continue;
3945 
3946 			if (layer->mem.param[oscIndex + i] != 0)
3947 			{
3948 				layer->mem.param[oscIndex + i] = 0.0;
3949 				/* send value off to osc */
3950 				bristolMidiSendMsg(fd, sid, osc, i, 0);
3951 			}
3952 		}
3953 	}
3954 }
3955 
3956 static void
bitoneMod(guiSynth * synth,int fd,int chan,int c,int o,int v)3957 bitoneMod(guiSynth *synth, int fd, int chan, int c, int o, int v)
3958 {
3959 	if (global.libtest)
3960 		return;
3961 
3962 	if (v == 0)
3963 		v = 1;
3964 
3965 	/*
3966 	 * If this is controller 0 it is the frequency control, otherwise a
3967 	 * generic controller 1.
3968 	 */
3969 	if (c == 1) {
3970 		bristolMidiSendMsg(global.controlfd, synth->midichannel,
3971 			BRISTOL_EVENT_PITCH, 0, (int) (v * C_RANGE_MIN_1));
3972 		if ((synth->mem.param[120] != 0) &&
3973 			(synth->midichannel != ((guiSynth *) synth->second)->midichannel))
3974 			bristolMidiSendMsg(global.controlfd,
3975 				((guiSynth *) synth->second)->midichannel,
3976 				BRISTOL_EVENT_PITCH, 0, (int) (v * C_RANGE_MIN_1));
3977 	} else {
3978 		bristolMidiControl(global.controlfd, synth->midichannel,
3979 			0, 1, ((int) (v * C_RANGE_MIN_1)) >> 7);
3980 		if ((synth->mem.param[120] != 0) &&
3981 			(synth->midichannel != ((guiSynth *) synth->second)->midichannel))
3982 			bristolMidiControl(global.controlfd,
3983 				((guiSynth *) synth->second)->midichannel,
3984 				0, 1, ((int) (v * C_RANGE_MIN_1)) >> 7);
3985 	}
3986 	return;
3987 }
3988 
3989 static void
bitoneGlide(guiSynth * synth,int fd,int chan,int c,int o,int v)3990 bitoneGlide(guiSynth *synth, int fd, int chan, int c, int o, int v)
3991 {
3992 	if (!global.libtest) {
3993 		bristolMidiSendNRP(global.controlfd, synth->sid, BRISTOL_NRP_GLIDE, v);
3994 		bristolMidiSendNRP(global.controlfd, synth->sid2, BRISTOL_NRP_GLIDE, v);
3995 	}
3996 }
3997 
3998 static void
bitoneMidiDebug(guiSynth * synth,int fd,int chan,int c,int o,int v)3999 bitoneMidiDebug(guiSynth *synth, int fd, int chan, int c, int o, int v)
4000 {
4001 	if (!global.libtest) {
4002 		bristolMidiSendNRP(global.controlfd, synth->sid, BRISTOL_NRP_DEBUG, v);
4003 		bristolMidiSendNRP(global.controlfd, synth->sid2, BRISTOL_NRP_DEBUG, v);
4004 	}
4005 }
4006 
4007 static void
bitoneVelocity(guiSynth * synth,int fd,int chan,int c,int o,int v)4008 bitoneVelocity(guiSynth *synth, int fd, int chan, int c, int o, int v)
4009 {
4010 	synth->velocity = v + 500;
4011 
4012 	if (global.libtest)
4013 		return;
4014 
4015 	if (mode == MODE_SINGLE) {
4016 		bristolMidiSendNRP(global.controlfd, synth->sid,
4017 			BRISTOL_NRP_VELOCITY, synth->velocity);
4018 		bristolMidiSendNRP(global.controlfd, synth->sid2,
4019 			BRISTOL_NRP_VELOCITY, synth->velocity);
4020 	} else {
4021 		if (entryPoint == ENTER_UPPER)
4022 			bristolMidiSendNRP(global.controlfd, synth->sid2,
4023 				BRISTOL_NRP_VELOCITY, synth->velocity);
4024 		else
4025 			bristolMidiSendNRP(global.controlfd, synth->sid,
4026 				BRISTOL_NRP_VELOCITY, synth->velocity);
4027 	}
4028 }
4029 
4030 static void
bitoneTranspose(guiSynth * synth,int fd,int chan,int c,int o,int v)4031 bitoneTranspose(guiSynth *synth, int fd, int chan, int c, int o, int v)
4032 {
4033 	int lt = -1, ut = -1;
4034 
4035 	if (b1debug(synth, 1))
4036 		printf("Transpose (%i, %f)\n", v, prePark[0].mem.param[65]);
4037 
4038 	if (v > 61)
4039 		/*
4040 		 * We have probably been given an integer from the pot range, convert
4041 		 * it to decimal.
4042 		 */
4043 		v = b1decimal(65, prePark[0].mem.param[65]);
4044 
4045 	/*
4046 	 * We are going to request transpose to the engine. At the moment this
4047 	 * would cause issues with memory loading or transpose changes. The former
4048 	 * is avoided due to allNotesOff() when the midi channel is changed when
4049 	 * memories are loaded however alterations to transpose when holding notes
4050 	 * will need to be addressed. Resolved.
4051 	 *
4052 	 * We need to look at separate split points, this pends on the DE 121 flag.
4053 	 *
4054 	 * We either transpose just the upper layer unless we have DE 121 and we
4055 	 * are setting the lower layer transpose.
4056 	 */
4057 	if (mode == MODE_SINGLE) {
4058 		lt = v;
4059 	} else {
4060 		if (synth->mem.param[122] != 0) {
4061 			if (entryPoint == ENTER_UPPER)
4062 				ut = v;
4063 			else
4064 				lt = v;
4065 		} else
4066 			ut = b1decimal(65, prePark[0].mem.param[65]);
4067 	}
4068 
4069 	if (b1debug(synth, 2))
4070 		printf("lt %i, ut %i\n", lt, ut);
4071 
4072 	if (!global.libtest) {
4073 		if (lt != -1)
4074 			bristolMidiSendMsg(global.controlfd, synth->sid, 127, 0,
4075 				BRISTOL_TRANSPOSE + lt - 12);
4076 		else
4077 			bristolMidiSendMsg(global.controlfd, synth->sid2, 127, 0,
4078 				BRISTOL_TRANSPOSE + ut - 12);
4079 	}
4080 }
4081 
4082 static void
bitoneOmni(guiSynth * synth,int fd,int chan,int c,int o,int v)4083 bitoneOmni(guiSynth *synth, int fd, int chan, int c, int o, int v)
4084 {
4085 	guiSynth *layer = b1getScratch(synth);
4086 	int channel = synth->midichannel;
4087 
4088 	if (v != 0) {
4089 		if (b1debug(synth, 1))
4090 			printf("OMNI On Requested\n");
4091 		channel = BRISTOL_CHAN_OMNI;
4092 	} else {
4093 		if (b1debug(synth, 1))
4094 			printf("OMNI Off Requested\n");
4095 	}
4096 
4097 	/*
4098 	 * See if we have separate MIDI channel by layer (not the default).
4099 	 */
4100 	if  (layer->mem.param[120] == 0)
4101 	{
4102 		/*
4103 		 * Send this to both channels.
4104 		 */
4105 		if (global.libtest == 0)
4106 		{
4107 			bristolMidiSendMsg(global.controlfd, synth->sid,
4108 				127, 0, BRISTOL_MIDICHANNEL|channel);
4109 			bristolMidiSendMsg(global.controlfd, synth->sid2,
4110 				127, 0, BRISTOL_MIDICHANNEL|channel);
4111 		}
4112 	} else {
4113 		/*
4114 		 * If we get here then we are only going to configure the channel for
4115 		 * the one layer and they can then be different.
4116 		 */
4117 		if (global.libtest == 0)
4118 		{
4119 			bristolMidiSendMsg(global.controlfd, layer->sid,
4120 				127, 0, BRISTOL_MIDICHANNEL|channel);
4121 		}
4122 	}
4123 }
4124 
4125 static void
bitoneEmulationGain(guiSynth * synth,int fd,int chan,int c,int o,int v)4126 bitoneEmulationGain(guiSynth *synth, int fd, int chan, int c, int o, int v)
4127 {
4128 	synth->gain = v / 16;
4129 	((guiSynth *) synth->second)->gain = v / 16;
4130 
4131 	if (!global.libtest) {
4132 		bristolMidiSendNRP(global.controlfd, synth->sid,
4133 			BRISTOL_NRP_GAIN, v / 16);
4134 		bristolMidiSendNRP(global.controlfd, synth->sid2,
4135 			BRISTOL_NRP_GAIN, v / 16);
4136 	}
4137 }
4138 
4139 static void
bitoneNRPEnable(guiSynth * synth,int fd,int chan,int c,int o,int v)4140 bitoneNRPEnable(guiSynth *synth, int fd, int chan, int c, int o, int v)
4141 {
4142 	if (!global.libtest) {
4143 		bristolMidiSendNRP(global.controlfd, synth->sid,
4144 			BRISTOL_NRP_ENABLE_NRP, v);
4145 		bristolMidiSendNRP(global.controlfd, synth->sid2,
4146 			BRISTOL_NRP_ENABLE_NRP, v);
4147 	}
4148 }
4149 
4150 static void
bitoneDetune(guiSynth * synth,int fd,int chan,int c,int o,int v)4151 bitoneDetune(guiSynth *synth, int fd, int chan, int c, int o, int v)
4152 {
4153 	int value = v / 50;
4154 
4155 	if (!global.libtest) {
4156 		bristolMidiSendNRP(global.controlfd, synth->sid,
4157 			BRISTOL_NRP_DETUNE, value);
4158 		bristolMidiSendNRP(global.controlfd, synth->sid2,
4159 			BRISTOL_NRP_DETUNE, value);
4160 	}
4161 }
4162 
4163 static int
bitoneGetMem(guiSynth * synth,int dir)4164 bitoneGetMem(guiSynth *synth, int dir)
4165 {
4166 	int i = synth->location;
4167 
4168 	if ((dir > 0) && (i >= 99))
4169 		i = -1;
4170 	if ((dir < 0) && (i <= 0))
4171 		i = 100;
4172 
4173 	while ((i += dir) != synth->location)
4174 	{
4175 		if (loadMemory(synth, SYNTH_NAME, 0, synth->bank * 100 + i,
4176 			synth->mem.active, 0, BRISTOL_STAT) >= 0)
4177 			return(i);
4178 
4179 		if ((dir > 0) && (i >= 99))
4180 			i = -1;
4181 		if ((dir < 0) && (i <= 0))
4182 			i = 100;
4183 	}
4184 
4185 	return(-1);
4186 }
4187 
4188 static int
bitoneGetFreeMem(guiSynth * synth,int dir)4189 bitoneGetFreeMem(guiSynth *synth, int dir)
4190 {
4191 	int i, start;
4192 
4193 	start = i = synth->mem.param[DISPLAY_DEV + 4] * 10 +
4194 		synth->mem.param[DISPLAY_DEV + 5];
4195 
4196 	if ((dir > 0) && (i >= 99))
4197 		i = -1;
4198 	if ((dir < 0) && (i <= 0))
4199 		i = 100;
4200 
4201 	while ((i += dir) != start)
4202 	{
4203 		if (loadMemory(synth, SYNTH_NAME, 0, synth->bank * 100 + i,
4204 			synth->mem.active, 0, BRISTOL_STAT) < 0)
4205 			return(i);
4206 
4207 		if ((dir > 0) && (i >= 99))
4208 			i = -1;
4209 		if ((dir < 0) && (i <= 0))
4210 			i = 100;
4211 	}
4212 
4213 	return(-1);
4214 }
4215 
4216 static int exclude = 0;
4217 
4218 static void
bitoneMemSearch(guiSynth * synth,int fd,int chan,int c,int o,int v)4219 bitoneMemSearch(guiSynth *synth, int fd, int chan, int c, int o, int v)
4220 {
4221 	int i;
4222 
4223 	if ((synth->flags & MEM_LOADING) != 0)
4224 		return;
4225 
4226 //	if ((v == 0) || (exclude != 0))
4227 	if (exclude != 0)
4228 		return;
4229 
4230 	/* This does not go in a memory */
4231 	synth->mem.param[c] = prePark[0].mem.param[c] = prePark[1].mem.param[c] = 0;
4232 
4233 	/*
4234 	 * Find the next mem
4235 	 */
4236 	if (c == 74) {
4237 		if ((i = bitoneGetMem(synth, 1)) < 0)
4238 			return;
4239 	} else {
4240 		if ((i = bitoneGetMem(synth, -1)) < 0)
4241 			return;
4242 	}
4243 
4244 	/*
4245 	 * Then stuff this into a display, exit extended and then load the memory.
4246 	 */
4247 	if (entryPoint == ENTER_UPPER)
4248 		bitoneUpdateDisplayDec(synth, synth->sid, synth->midichannel, 0, 6, i);
4249 	else
4250 		bitoneUpdateDisplayDec(synth, synth->sid, synth->midichannel, 0, 4, i);
4251 
4252 	synth->location = i;
4253 
4254 	exclude = 1;
4255 	bitoneMemory(synth, fd, chan, 1, o, 1);
4256 	exclude = 0;
4257 }
4258 
4259 static void
bitoneMemFreeSearch(guiSynth * synth,int fd,int chan,int c,int o,int v)4260 bitoneMemFreeSearch(guiSynth *synth, int fd, int chan, int c, int o, int v)
4261 {
4262 	int i;
4263 
4264 	if (synth->flags & MEM_LOADING)
4265 		return;
4266 
4267 //	if ((v == 0) || (exclude != 0))
4268 	if (exclude != 0)
4269 		return;
4270 
4271 	/* This does not go in a memory */
4272 	synth->mem.param[c] = prePark[0].mem.param[c] = prePark[1].mem.param[c] = 0;
4273 
4274 	/*
4275 	 * Find a free mem
4276 	 */
4277 	if (c == 130) {
4278 		if ((i = bitoneGetFreeMem(synth, 1)) < 0)
4279 			return;
4280 	} else {
4281 		if ((i = bitoneGetFreeMem(synth, -1)) < 0)
4282 			return;
4283 	}
4284 
4285 	/*
4286 	 * Then stuff this into a display
4287 	 */
4288 	if (entryPoint == ENTER_UPPER)
4289 		bitoneUpdateDisplayDec(synth, synth->sid, synth->midichannel, 0, 6, i);
4290 	else
4291 		bitoneUpdateDisplayDec(synth, synth->sid, synth->midichannel, 0, 4, i);
4292 }
4293 
4294 static void
bitoneSaveOther(guiSynth * synth,int fd,int chan,int c,int o,int v)4295 bitoneSaveOther(guiSynth *synth, int fd, int chan, int c, int o, int v)
4296 {
4297 	int i;
4298 	guiSynth *scratch = b1getScratch(synth);
4299 
4300 	/*
4301 	 * If we have extended entry and the value is zero then return.
4302 	 */
4303 	if ((synth->mem.param[DISPLAY_DEV + 5] * 10
4304 		+ synth->mem.param[DISPLAY_DEV + 6] == 110) && (v == 0))
4305 		return;
4306 
4307 	synth->mem.param[c] = 0;
4308 
4309 	if (c == 193) {
4310 		printf("bristol save bit-1\n");
4311 
4312 		prePark[5].location = synth->location;
4313 		prePark[5].bank = synth->bank;
4314 
4315 		prePark[5].win = synth->win;
4316 		prePark[5].mem.active = ACTIVE_DEVS;
4317 		prePark[5].resources = &bitoneApp;
4318 
4319 		/*
4320 		 * Copy over all the parameters.
4321 		 */
4322 		for (i = 0; i < ACTIVE_DEVS; i++)
4323 			prePark[5].mem.param[i] = scratch->mem.param[i];
4324 		for (; i < DEVICE_COUNT; i++)
4325 			prePark[5].mem.param[i] = synth->mem.param[i];
4326 
4327 		/*
4328 		 * Clean up the ones that do not apply to this synth
4329 		 *
4330 		 * FM/Glide, etc.
4331 		 */
4332 		prePark[5].mem.param[72] = 1.0; /* OMNI On */
4333 		prePark[5].mem.param[77] = 0;
4334 		prePark[5].mem.param[78] = 0;
4335 		prePark[5].mem.param[79] = 0;
4336 
4337 		prePark[5].mem.param[81] = 0;
4338 		prePark[5].mem.param[82] = 0;
4339 		prePark[5].mem.param[83] = 0;
4340 		prePark[5].mem.param[84] = 0;
4341 		prePark[5].mem.param[85] = 0;
4342 		prePark[5].mem.param[86] = 1.0; /* LFO UNI */
4343 
4344 		prePark[5].mem.param[87] = 0;
4345 		prePark[5].mem.param[88] = 0;
4346 		prePark[5].mem.param[89] = 0;
4347 		prePark[5].mem.param[90] = 0;
4348 		prePark[5].mem.param[91] = 0;
4349 		prePark[5].mem.param[92] = 1.0; /* LFO UNI */
4350 
4351 		prePark[5].mem.param[93] = 0.0; /* ENV PWM */
4352 		prePark[5].mem.param[94] = 0.0; /* ENV PWM */
4353 
4354 		prePark[5].mem.param[95] = 1.0; /* Restrict harmonics */
4355 		prePark[5].mem.param[96] = 1.0; /* Restrict harmonics */
4356 
4357 		prePark[5].mem.param[97] = 2.0; /* Filter */
4358 		prePark[5].mem.param[98] = 1.0; /* MIX DCO1 */
4359 		prePark[5].mem.param[99] = 1.0; /* Noise UNI */
4360 
4361 		prePark[5].mem.param[101] = 0.0;
4362 		prePark[5].mem.param[102] = 0.0;
4363 		prePark[5].mem.param[103] = 0.0;
4364 		prePark[5].mem.param[104] = 0.0;
4365 		prePark[5].mem.param[105] = 0.0;
4366 		prePark[5].mem.param[106] = 0.0;
4367 		prePark[5].mem.param[107] = 0.0;
4368 		prePark[5].mem.param[108] = 0.0;
4369 		prePark[5].mem.param[109] = 0.0;
4370 
4371 		prePark[5].mem.param[110] = 0.78;
4372 		prePark[5].mem.param[111] = 0.78;
4373 		prePark[5].mem.param[112] = 1.0;
4374 		prePark[5].mem.param[113] = 0.0;
4375 		prePark[5].mem.param[114] = 0.78;
4376 		prePark[5].mem.param[115] = 0.78;
4377 		prePark[5].mem.param[116] = 0.0;
4378 		prePark[5].mem.param[117] = 1.0;
4379 
4380 		prePark[5].mem.param[118] = 0.0;
4381 
4382 		for (i = 120; i < ACTIVE_DEVS; i++)
4383 			prePark[5].mem.param[i] = 0;
4384 
4385 		/* Carry over glide and noise settings */
4386 		prePark[5].mem.param[136] = 0.0;
4387 		prePark[5].mem.param[137] = 1.0;
4388 		prePark[5].mem.param[138] = synth->mem.param[138];
4389 		prePark[5].mem.param[139] = synth->mem.param[139];
4390 	} else if (c == 194) {
4391 		printf("bristol save bit-99\n");
4392 
4393 		prePark[5].location = synth->location;
4394 		prePark[5].bank = synth->bank;
4395 
4396 		prePark[5].win = synth->win;
4397 		prePark[5].resources = &bit99App;
4398 		prePark[5].mem.active = ACTIVE_DEVS;
4399 
4400 		/*
4401 		 * Copy over all the parameters.
4402 		 */
4403 		for (i = 0; i < ACTIVE_DEVS; i++)
4404 			prePark[5].mem.param[i] = scratch->mem.param[i];
4405 		for (; i < DEVICE_COUNT; i++)
4406 			prePark[5].mem.param[i] = synth->mem.param[i];
4407 
4408 		/*
4409 		 * Clean up the ones that do not apply to this synth
4410 		 */
4411 		prePark[5].mem.param[86] = 1.0; /* LFO UNI */
4412 		prePark[5].mem.param[92] = 1.0; /* LFO UNI */
4413 
4414 		prePark[5].mem.param[97] = 2.0; /* Filter */
4415 		prePark[5].mem.param[98] = 1.0; /* MIX DCO1 */
4416 		prePark[5].mem.param[99] = 1.0; /* Noise UNI */
4417 
4418 		prePark[5].mem.param[101] = 0.0;
4419 		prePark[5].mem.param[102] = 0.0;
4420 		prePark[5].mem.param[103] = 0.0;
4421 		prePark[5].mem.param[104] = 0.0;
4422 		prePark[5].mem.param[105] = 0.0;
4423 		prePark[5].mem.param[106] = 0.0;
4424 		prePark[5].mem.param[107] = 0.0;
4425 		prePark[5].mem.param[108] = 0.0;
4426 		prePark[5].mem.param[109] = 0.0;
4427 
4428 		prePark[5].mem.param[118] = 0.0;
4429 
4430 		for (i = 120; i < ACTIVE_DEVS; i++)
4431 			prePark[5].mem.param[i] = 0;
4432 
4433 		/* Carry over glide */
4434 		prePark[5].mem.param[136] = 0.0;
4435 		prePark[5].mem.param[137] = 1.0;
4436 		prePark[5].mem.param[138] = synth->mem.param[138];
4437 		prePark[5].mem.param[139] = synth->mem.param[139];
4438 	} else {
4439 		printf("bristol save bit-100\n");
4440 
4441 		prePark[5].location = synth->location;
4442 		prePark[5].bank = synth->bank;
4443 
4444 		for (i = 0; i < ACTIVE_DEVS; i++)
4445 			prePark[5].mem.param[i] = scratch->mem.param[i];
4446 		for (; i < DEVICE_COUNT; i++)
4447 			prePark[5].mem.param[i] = synth->mem.param[i];
4448 
4449 		prePark[5].resources = &bit100App;
4450 		prePark[5].win = synth->win;
4451 		prePark[5].mem.active = ACTIVE_DEVS;
4452 	}
4453 
4454 	/* Arpeggio relearn */
4455 	prePark[5].mem.param[155] = 0;
4456 	prePark[5].mem.param[157] = 0;
4457 
4458 	/*
4459 	 * Save our 200 parameters to scratchpad, restate some of them to reflect
4460 	 * the configurations of the -1 or -99, save the memory then return the
4461 	 * scratched data. We actually just need to copy over the 100 lowest params,
4462 	 * the rest are defaulted.
4463 	 */
4464 	bitoneSaveMemory(&prePark[5]);
4465 
4466 	synth->mem.param[c] = 0;
4467 }
4468 
4469 static void
bitoneSeqRelearn(guiSynth * synth,int fd,int chan,int c,int o,int v)4470 bitoneSeqRelearn(guiSynth *synth, int fd, int chan, int c, int o, int v)
4471 {
4472 	if (b1debug(synth, 1))
4473 		printf("bitoneSeqRelearn\n");
4474 
4475 	if (synth->seq1.param == NULL)
4476 		loadSequence(&synth->seq1, SYNTH_NAME, 0, 0);
4477 	if (synth->seq2.param == NULL)
4478 		loadSequence(&synth->seq2, SYNTH_NAME, 0, BRISTOL_SID2);
4479 
4480 	/*
4481 	 * We need to turn off the arpeggiator to do this and reset one index
4482 	 */
4483 	if (v != 0) {
4484 		if (entryPoint == ENTER_UPPER) {
4485 			bristolMidiSendMsg(fd, synth->sid2,
4486 				BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, 0);
4487 			bristolMidiSendMsg(fd, synth->sid2,
4488 				BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 1);
4489 			synth->seq1.param[0] = 0;
4490 		} else {
4491 			bristolMidiSendMsg(fd, synth->sid,
4492 				BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, 0);
4493 			bristolMidiSendMsg(fd, synth->sid,
4494 				BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 1);
4495 			synth->seq1.param[BRISTOL_AM_SMAX] = 0;
4496 		}
4497 		return;
4498 	}
4499 
4500 	if (entryPoint == ENTER_UPPER)
4501 		bristolMidiSendMsg(fd, synth->sid2,
4502 			BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 0);
4503 	else
4504 		bristolMidiSendMsg(fd, synth->sid,
4505 			BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 0);
4506 }
4507 
4508 static void
bitoneChordRelearn(guiSynth * synth,int fd,int chan,int c,int o,int v)4509 bitoneChordRelearn(guiSynth *synth, int fd, int chan, int c, int o, int v)
4510 {
4511 	if (b1debug(synth, 1))
4512 		printf("bitoneChordRelearn\n");
4513 
4514 	if (synth->seq1.param == NULL)
4515 		loadSequence(&synth->seq1, SYNTH_NAME, 0, 0);
4516 	if (synth->seq2.param == NULL)
4517 		loadSequence(&synth->seq2, SYNTH_NAME, 0, BRISTOL_SID2);
4518 
4519 	/*
4520 	 * We need to turn off chording to do this and reset one index
4521 	 */
4522 	if (v != 0) {
4523 		if (entryPoint == ENTER_UPPER) {
4524 			bristolMidiSendMsg(fd, synth->sid2,
4525 				BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_ENABLE, 0);
4526 			bristolMidiSendMsg(fd, synth->sid2,
4527 				BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 1);
4528 			synth->seq1.param[1] = 0;
4529 		} else {
4530 			bristolMidiSendMsg(fd, synth->sid,
4531 				BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_ENABLE, 0);
4532 			bristolMidiSendMsg(fd, synth->sid,
4533 				BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 1);
4534 			synth->seq1.param[BRISTOL_AM_CCOUNT] = 0;
4535 		}
4536 		return;
4537 	}
4538 
4539 	if (entryPoint == ENTER_UPPER)
4540 		bristolMidiSendMsg(fd, synth->sid2,
4541 			BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 0);
4542 	else
4543 		bristolMidiSendMsg(fd, synth->sid,
4544 			BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 0);
4545 }
4546 
4547 static void
bitoneFilter(guiSynth * synth,int fd,int chan,int c,int o,int v)4548 bitoneFilter(guiSynth *synth, int fd, int chan, int c, int o, int v)
4549 {
4550 	if (v == 2)
4551 		v = 4;
4552 
4553 	if (entryPoint == ENTER_UPPER)
4554 		bristolMidiSendMsg(fd, synth->sid2, 6, 4, v);
4555 	else
4556 		bristolMidiSendMsg(fd, synth->sid, 6, 4, v);
4557 }
4558 
4559 static void
bitoneRelease(guiSynth * synth,int fd,int chan,int c,int o,int v)4560 bitoneRelease(guiSynth *synth, int fd, int chan, int c, int o, int v)
4561 {
4562 	if (b1debug(synth, 1))
4563 		printf("Midi Panic (%i)\n", v);
4564 
4565 	if (v == 0)
4566 		return;
4567 
4568 	prePark[0].mem.param[76] = 0;
4569 
4570 	if (!global.libtest)
4571 		bristolMidiSendMsg(fd, synth->sid, 127, 0,
4572 			BRISTOL_ALL_NOTES_OFF);
4573 }
4574 
4575 /*
4576  * Any location initialisation required to run the callbacks. For bristol, this
4577  * will connect to the engine, and give it some base parameters.
4578  * May need to generate some application specific menus.
4579  * Will also then make specific requests to some of the devices to alter their
4580  * rendering.
4581  */
4582 static int
bitoneInit(brightonWindow * win)4583 bitoneInit(brightonWindow *win)
4584 {
4585 	guiSynth *synth = findSynth(global.synths, win);
4586 	dispatcher *dispatch;
4587 	int i;
4588 
4589 	if (synth == 0)
4590 	{
4591 		synth = findSynth(global.synths, 0);
4592 		if (synth == 0)
4593 		{
4594 			printf("cannot init\n");
4595 			return(0);
4596 		}
4597 	}
4598 
4599 	synth->win = win;
4600 
4601 	printf("Initialise the bitone link to bristol: %p\n", synth->win);
4602 
4603 	synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
4604 	synth->mem.count = DEVICE_COUNT;
4605 	synth->mem.active = ACTIVE_DEVS;
4606 	synth->dispatch = (dispatcher *)
4607 		brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
4608 	dispatch = synth->dispatch;
4609 
4610 	synth->second = brightonmalloc(sizeof(guiSynth));
4611 	bcopy(synth, ((guiSynth *) synth->second), sizeof(guiSynth));
4612 	((guiSynth *) synth->second)->mem.param =
4613 		(float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
4614 	((guiSynth *) synth->second)->mem.count = DEVICE_COUNT;
4615 	((guiSynth *) synth->second)->mem.active = ACTIVE_DEVS;
4616 	((guiSynth *) synth->second)->dispatch = synth->dispatch;
4617 	synth->synthtype = BRISTOL_BIT_ONE;
4618 	((guiSynth *) synth->second)->synthtype = BRISTOL_BIT_ONE;
4619 
4620 	prePark[0].mem.param = scratchpad0;
4621 	prePark[1].mem.param = scratchpad1;
4622 	prePark[2].mem.param = scratchpad2;
4623 	prePark[3].mem.param = scratchpad3;
4624 	prePark[4].mem.param = scratchpad4;
4625 	prePark[5].mem.param = scratchpad5;
4626 
4627 	/* If we have a default voice count then limit it */
4628 	if (synth->voices == BRISTOL_VOICECOUNT) {
4629 		synth->voices = 6; /* Uses twice the number for single mode only */
4630 		((guiSynth *) synth->second)->voices = 3;
4631 	} else
4632 		((guiSynth *) synth->second)->voices = synth->voices >> 1;
4633 
4634 	/*
4635 	 * We really want to have three connection mechanisms. These should be
4636 	 *	1. Unix named sockets.
4637 	 *	2. UDP sockets (actually implements TCP unfortunately).
4638 	 *	3. MIDI pipe.
4639 	 */
4640 	if (!global.libtest)
4641 	{
4642 		int vhold = synth->voices;
4643 
4644 		bcopy(&global, &manual, sizeof(guimain));
4645 
4646 		if ((synth->sid = initConnection(&global, synth)) < 0)
4647 			return(-1);
4648 
4649 		manual.flags |= BRISTOL_CONN_FORCE|BRIGHTON_NOENGINE;
4650 		manual.host = global.host;
4651 		manual.port = global.port;
4652 
4653 		synth->voices = synth->voices >> 1;
4654 		if ((synth->sid2 = initConnection(&manual, synth)) < 0)
4655 			return(-1);
4656 
4657 		global.manualfd = manual.controlfd;
4658 		global.manual = &manual;
4659 		manual.manual = &global;
4660 
4661 		((guiSynth *) synth->second)->sid = synth->sid2;
4662 
4663 		synth->voices = vhold;
4664 	}
4665 
4666 	for (i = 0; i < ACTIVE_DEVS; i++)
4667 	{
4668 		synth->dispatch[i].controller = i;
4669 		synth->dispatch[i].operator = i;
4670 	}
4671 
4672 	synth->dispatch[ACTIVE_DEVS - 1].controller = 12;
4673 
4674 	for (; i < DEVICE_COUNT; i++)
4675 		synth->dispatch[i].routine = (synthRoutine) bitoneMidiShim;
4676 
4677 	synth->dispatch[0].routine = (synthRoutine) bitoneMidiNull;
4678 	synth->dispatch[73].routine = (synthRoutine) bitoneMidi;
4679 
4680 	/* LFO Waveform */
4681 	synth->dispatch[1].operator = 0;
4682 	synth->dispatch[1].routine = (synthRoutine) bitoneLFO;
4683 	synth->dispatch[2].operator = 1;
4684 	synth->dispatch[2].routine = (synthRoutine) bitoneLFO;
4685 	synth->dispatch[3].operator = 2;
4686 	synth->dispatch[3].routine = (synthRoutine) bitoneLFO;
4687 
4688 	/* LFO Waveform */
4689 	synth->dispatch[53].operator = 0;
4690 	synth->dispatch[53].routine = (synthRoutine) bitoneLFO;
4691 	synth->dispatch[54].operator = 1;
4692 	synth->dispatch[54].routine = (synthRoutine) bitoneLFO;
4693 	synth->dispatch[55].operator = 2;
4694 	synth->dispatch[55].routine = (synthRoutine) bitoneLFO;
4695 
4696 	/* Harmonics */
4697 	synth->dispatch[24].controller = 24;
4698 	synth->dispatch[24].operator = 0;
4699 	synth->dispatch[24].routine = (synthRoutine) bitoneHarmonics;
4700 	synth->dispatch[25].controller = 25;
4701 	synth->dispatch[25].operator = 1;
4702 	synth->dispatch[25].routine = (synthRoutine) bitoneHarmonics;
4703 	synth->dispatch[26].controller = 26;
4704 	synth->dispatch[26].operator = 2;
4705 	synth->dispatch[26].routine = (synthRoutine) bitoneHarmonics;
4706 	synth->dispatch[27].controller = 27;
4707 	synth->dispatch[27].operator = 3;
4708 	synth->dispatch[27].routine = (synthRoutine) bitoneHarmonics;
4709 
4710 	/* Harmonics */
4711 	synth->dispatch[35].controller = 35;
4712 	synth->dispatch[35].operator = 0;
4713 	synth->dispatch[35].routine = (synthRoutine) bitoneHarmonics;
4714 	synth->dispatch[36].controller = 36;
4715 	synth->dispatch[36].operator = 1;
4716 	synth->dispatch[36].routine = (synthRoutine) bitoneHarmonics;
4717 	synth->dispatch[37].controller = 37;
4718 	synth->dispatch[37].operator = 2;
4719 	synth->dispatch[37].routine = (synthRoutine) bitoneHarmonics;
4720 	synth->dispatch[38].controller = 38;
4721 	synth->dispatch[38].operator = 3;
4722 	synth->dispatch[38].routine = (synthRoutine) bitoneHarmonics;
4723 
4724 	synth->dispatch[64].routine = (synthRoutine) b1SetSplit;
4725 
4726 	synth->dispatch[65].routine = (synthRoutine) bitoneTranspose;
4727 
4728 	synth->dispatch[66].operator = 2;
4729 	synth->dispatch[66].routine = (synthRoutine) bitoneStereo;
4730 	synth->dispatch[67].operator = 2;
4731 	synth->dispatch[67].routine = (synthRoutine) bitoneStereo;
4732 
4733 	synth->dispatch[69].routine = (synthRoutine) bitoneVelocity;
4734 	synth->dispatch[70].routine = (synthRoutine) bitoneMidiDebug;
4735 
4736 	synth->dispatch[72].routine = (synthRoutine) bitoneOmni;
4737 
4738 	synth->dispatch[74].routine = (synthRoutine) bitoneMemSearch;
4739 	synth->dispatch[75].routine = (synthRoutine) bitoneMemSearch;
4740 
4741 	synth->dispatch[76].routine = (synthRoutine) bitoneRelease;
4742 
4743 	/* LFO S/H */
4744 	synth->dispatch[81].operator = 3;
4745 	synth->dispatch[81].routine = (synthRoutine) bitoneLFO;
4746 	synth->dispatch[87].operator = 3;
4747 	synth->dispatch[87].routine = (synthRoutine) bitoneLFO;
4748 
4749 	/* Filter shim */
4750 	synth->dispatch[97].routine = (synthRoutine) bitoneFilter;
4751 
4752 	/* Harmonic control */
4753 	synth->dispatch[DCO_1_EXCLUSIVE].routine = (synthRoutine) bitoneHarmonics;
4754 	synth->dispatch[DCO_2_EXCLUSIVE].routine = (synthRoutine) bitoneHarmonics;
4755 
4756 	synth->dispatch[123].routine = (synthRoutine) bitoneNRPEnable;
4757 
4758 	/* Search */
4759 	synth->dispatch[130].routine = (synthRoutine) bitoneMemFreeSearch;
4760 	synth->dispatch[131].routine = (synthRoutine) bitoneMemFreeSearch;
4761 	synth->dispatch[139].routine = (synthRoutine) bitoneEmulationGain;
4762 
4763 	/* Split Double */
4764 	synth->dispatch[200].controller = 0;
4765 	synth->dispatch[200].routine = (synthRoutine) bitoneSplitDouble;
4766 	synth->dispatch[201].controller = 1;
4767 	synth->dispatch[201].routine = (synthRoutine) bitoneSplitDouble;
4768 
4769 	/* Stereo */
4770 	synth->dispatch[202].operator = 1;
4771 	synth->dispatch[202].routine = (synthRoutine) bitoneStereo;
4772 	synth->dispatch[110].operator = 1;
4773 	synth->dispatch[110].routine = (synthRoutine) bitoneStereo;
4774 	synth->dispatch[111].operator = 1;
4775 	synth->dispatch[111].routine = (synthRoutine) bitoneStereo;
4776 	synth->dispatch[112].operator = 1;
4777 	synth->dispatch[112].routine = (synthRoutine) bitoneStereo;
4778 	synth->dispatch[113].operator = 1;
4779 	synth->dispatch[113].routine = (synthRoutine) bitoneStereo;
4780 	synth->dispatch[114].operator = 1;
4781 	synth->dispatch[114].routine = (synthRoutine) bitoneStereo;
4782 	synth->dispatch[115].operator = 1;
4783 	synth->dispatch[115].routine = (synthRoutine) bitoneStereo;
4784 	synth->dispatch[116].operator = 1;
4785 	synth->dispatch[116].routine = (synthRoutine) bitoneStereo;
4786 	synth->dispatch[117].operator = 1;
4787 	synth->dispatch[117].routine = (synthRoutine) bitoneStereo;
4788 
4789 	synth->dispatch[119].routine = (synthRoutine) bitoneDetune;
4790 
4791 	synth->dispatch[138].routine = (synthRoutine) bitoneGlide;
4792 
4793 	synth->dispatch[158].routine = (synthRoutine) bitoneChordRelearn;
4794 	synth->dispatch[165].routine = (synthRoutine) bitoneSeqRelearn;
4795 
4796 	synth->dispatch[193].routine = (synthRoutine) bitoneSaveOther;
4797 	synth->dispatch[194].routine = (synthRoutine) bitoneSaveOther;
4798 	synth->dispatch[195].routine = (synthRoutine) bitoneSaveOther;
4799 
4800 	/* Tuning */
4801 	synth->dispatch[203].controller = 126;
4802 	synth->dispatch[203].operator = 1;
4803 
4804 	synth->dispatch[206].controller = 126;
4805 	synth->dispatch[206].operator = 3;
4806 	synth->dispatch[206].routine = (synthRoutine) bitoneDualSend;
4807 	synth->dispatch[207].controller = 126;
4808 	synth->dispatch[207].operator = 4;
4809 	synth->dispatch[207].routine = (synthRoutine) bitoneDualSend;
4810 
4811 	/* Entry */
4812 	synth->dispatch[ENTRY_POT].controller = 0;
4813 	synth->dispatch[ENTRY_POT].routine = (synthRoutine) bitoneEntryPot;
4814 
4815 	/* Data Entry buttons */
4816 	synth->dispatch[209].controller = 1;
4817 	synth->dispatch[209].operator = 0;
4818 	synth->dispatch[209].routine = (synthRoutine) bitoneEntry;
4819 	synth->dispatch[210].controller = 2;
4820 	synth->dispatch[210].operator = 1;
4821 	synth->dispatch[210].routine = (synthRoutine) bitoneEntry;
4822 	synth->dispatch[211].controller = 3;
4823 	synth->dispatch[211].operator = 2;
4824 	synth->dispatch[211].routine = (synthRoutine) bitoneEntry;
4825 	synth->dispatch[212].controller = 4;
4826 	synth->dispatch[212].operator = 3;
4827 	synth->dispatch[212].routine = (synthRoutine) bitoneEntry;
4828 	synth->dispatch[213].controller = 5;
4829 	synth->dispatch[213].operator = 4;
4830 	synth->dispatch[213].routine = (synthRoutine) bitoneEntry;
4831 	synth->dispatch[214].controller = 6;
4832 	synth->dispatch[214].operator = 5;
4833 	synth->dispatch[214].routine = (synthRoutine) bitoneEntry;
4834 	synth->dispatch[215].controller = 7;
4835 	synth->dispatch[215].operator = 6;
4836 	synth->dispatch[215].routine = (synthRoutine) bitoneEntry;
4837 	synth->dispatch[216].controller = 8;
4838 	synth->dispatch[216].operator = 7;
4839 	synth->dispatch[216].routine = (synthRoutine) bitoneEntry;
4840 	synth->dispatch[217].controller = 9;
4841 	synth->dispatch[217].operator = 8;
4842 	synth->dispatch[217].routine = (synthRoutine) bitoneEntry;
4843 	synth->dispatch[218].controller = 0;
4844 	synth->dispatch[218].operator = 9;
4845 	synth->dispatch[218].routine = (synthRoutine) bitoneEntry;
4846 
4847 	/* Second radio set for address, upper and lower manual selection */
4848 	synth->dispatch[219].operator = ENTER_ADDRESS;
4849 	synth->dispatch[219].controller = 6;
4850 	synth->dispatch[219].routine = (synthRoutine) bitoneALU;
4851 	synth->dispatch[220].operator = ENTER_LOWER;
4852 	synth->dispatch[220].controller = 4;
4853 	synth->dispatch[220].routine = (synthRoutine) bitoneALU;
4854 	synth->dispatch[221].operator = ENTER_UPPER;
4855 	synth->dispatch[221].controller = 2;
4856 	synth->dispatch[221].routine = (synthRoutine) bitoneALU;
4857 
4858 	synth->dispatch[222].routine = (synthRoutine) bitonePark;
4859 	synth->dispatch[223].routine = (synthRoutine) bitoneCompare;
4860 
4861 	synth->dispatch[224].operator = 1;
4862 	synth->dispatch[224].controller = 1;
4863 	synth->dispatch[224].routine = (synthRoutine) bitoneMemory;
4864 	synth->dispatch[225].controller = 0;
4865 	synth->dispatch[225].routine = (synthRoutine) bitoneMemory;
4866 
4867 	synth->dispatch[226].controller = 0;
4868 	synth->dispatch[226].routine = (synthRoutine) bitoneMod;
4869 	synth->dispatch[227].controller = 1;
4870 	synth->dispatch[227].routine = (synthRoutine) bitoneMod;
4871 
4872 	synth->dispatch[228].controller = 0;
4873 	synth->dispatch[228].routine = (synthRoutine) bitoneIncDec;
4874 	synth->dispatch[229].controller = 1;
4875 	synth->dispatch[229].routine = (synthRoutine) bitoneIncDec;
4876 
4877 	synth->dispatch[230].routine = NULL;
4878 	synth->dispatch[231].routine = NULL;
4879 	synth->dispatch[232].routine = NULL;
4880 	synth->dispatch[233].routine = NULL;
4881 	synth->dispatch[234].routine = NULL;
4882 	synth->dispatch[235].routine = NULL;
4883 	synth->dispatch[236].routine = NULL;
4884 	synth->dispatch[237].routine = NULL;
4885 	synth->dispatch[238].routine = NULL;
4886 	synth->dispatch[239].routine = NULL;
4887 
4888 	/* Unison */
4889 	synth->dispatch[238].controller = 126;
4890 	synth->dispatch[238].operator = 7;
4891 	synth->dispatch[238].routine = (synthRoutine) bitoneUnison;
4892 
4893 	/*
4894 	 * We need to default the LFO Envelope parameters and some other stuff.
4895 	 *
4896 	 * There are lots of defaults we need to set for the bit-1: stereo on, MIDI
4897 	 * channel, we need to build a method to enable disable OMNI and some of the
4898 	 * midi controllers such as wheel, etc.
4899 	 */
4900 	bitoneDualSend(synth, global.controlfd, 0, 7, 4, 16000);
4901 	/* Set noise gain - reasonably low as it is going to be used for S/H also */
4902 	bitoneDualSend(synth, global.controlfd, 0, 10, 0, 1024);
4903 	/* LFO Env parameters */
4904 	bitoneDualSend(synth, global.controlfd, 0, 2, 1, 12000);
4905 	bitoneDualSend(synth, global.controlfd, 0, 2, 2, 16000);
4906 	bitoneDualSend(synth, global.controlfd, 0, 2, 3, 1000);
4907 	bitoneDualSend(synth, global.controlfd, 0, 2, 5, 0);
4908 	bitoneDualSend(synth, global.controlfd, 0, 2, 8, 0);
4909 
4910 	bitoneDualSend(synth, global.controlfd, 0, 3, 1, 12000);
4911 	bitoneDualSend(synth, global.controlfd, 0, 3, 2, 16000);
4912 	bitoneDualSend(synth, global.controlfd, 0, 3, 3, 1000);
4913 	bitoneDualSend(synth, global.controlfd, 0, 3, 5, 0);
4914 	bitoneDualSend(synth, global.controlfd, 0, 3, 8, 0);
4915 
4916 	return(0);
4917 }
4918 
4919 /*
4920  * This will be called to make any routine specific parameters available.
4921  */
4922 static int
bitoneConfigure(brightonWindow * win)4923 bitoneConfigure(brightonWindow *win)
4924 {
4925 	guiSynth *synth = findSynth(global.synths, win);
4926 	brightonEvent event;
4927 
4928 	if (synth == 0)
4929 	{
4930 		printf("problems going operational\n");
4931 		return(-1);
4932 	}
4933 
4934 	synth->bank = synth->location / 100;
4935 	synth->location = synth->location % 100;
4936 
4937 	if (synth->flags & OPERATIONAL)
4938 		return(0);
4939 
4940 	printf("going operational\n");
4941 
4942 	synth->flags |= OPERATIONAL;
4943 	synth->keypanel = 1;
4944 	synth->keypanel2 = -1;
4945 	synth->transpose = 36;
4946 
4947 	B1display[0] = 76;
4948 	B1display[1] = synth->location;
4949 	B1display[2] = -10;
4950 	synth->mem.param[DISPLAY_DEV + 4] = synth->location / 10;
4951 	synth->mem.param[DISPLAY_DEV + 5] = synth->location % 10;
4952 	prePark[0].mem.param[DISPLAY_DEV + 4] = synth->location / 10;
4953 	prePark[0].mem.param[DISPLAY_DEV + 5] = synth->location % 10;
4954 
4955 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 2,
4956 		(B1display[0]) * CONTROLLER_RANGE / 99);
4957 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 4,
4958 		(B1display[1]) * CONTROLLER_RANGE / 99);
4959 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 6,
4960 		(B1display[2]) * CONTROLLER_RANGE / 99);
4961 
4962 	event.type = BRIGHTON_FLOAT;
4963 
4964 	/*
4965 	 * Ping the split button to reset the voice allocations
4966 	 */
4967 	event.value = 0.0;
4968 	brightonParamChange(synth->win, 0, RADIOSET_3, &event);
4969 
4970 	event.value = 1.0;
4971 	brightonParamChange(synth->win, 0, RADIOSET_2 + 1, &event);
4972 
4973 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 2,
4974 		(B1display[0]) * CONTROLLER_RANGE / 99);
4975 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 4,
4976 		(B1display[1]) * CONTROLLER_RANGE / 99);
4977 	bitoneUpdateDisplay(synth, synth->sid, synth->midichannel, 0, 6,
4978 		(B1display[2]) * CONTROLLER_RANGE / 99);
4979 
4980 	event.type = BRIGHTON_FLOAT;
4981 
4982 	/*
4983 	 * Ping the split button to reset the voice allocations
4984 	 */
4985 	event.value = 0.0;
4986 	brightonParamChange(synth->win, 0, RADIOSET_3, &event);
4987 
4988 	event.value = 1.0;
4989 	brightonParamChange(synth->win, 0, RADIOSET_2 + 1, &event);
4990 
4991 	/*
4992 	 * Set the synth to a known state from which to start
4993 	loadMemory(synth, SYNTH_NAME, 0, 0,
4994 		synth->mem.active, 0, BRISTOL_FORCE|BRISTOL_NOCALLS);
4995 	brightonParamChange(synth->win, 0, 224, &event);
4996 	event.type = 0.0;
4997 	brightonParamChange(synth->win, 0, 224, &event);
4998 	 */
4999 	loadMemory(synth, SYNTH_NAME, 0, synth->bank * 100 + synth->location,
5000 		synth->mem.active, 0, BRISTOL_FORCE|BRISTOL_NOCALLS);
5001 	bitoneMemoryShim(synth, ACTIVE_DEVS - 10);
5002 	loadMemory(synth, SYNTH_NAME, 0, synth->bank * 100 + synth->location,
5003 		synth->mem.active, 0, BRISTOL_FORCE|BRISTOL_NOCALLS);
5004 
5005 	/*
5006 	synth->mem.param[109] = 5;
5007 	*/
5008 	bitoneMemoryShim(synth, ACTIVE_DEVS - 10);
5009 	bitoneDAUpdate(synth);
5010 
5011 	/*
5012 	 * OK, this is a bit of a hack but it works. If the stereo pot has a
5013 	 * WITHDRAWN flag against it then we have a bit-1, otherwise we have been
5014 	 * given a bit-99
5015 	 */
5016 	if (bit99App.resources[0].devlocn[STEREO_BUTTON].flags & BRIGHTON_WITHDRAWN)
5017 		/* We have a bit-1 */
5018 		brightonPut(win, "bitmaps/blueprints/bitoneshade.xpm",
5019 			0, 0, win->width, win->height);
5020 	else {
5021 		if (strcmp("bit100", synth->resources->name) == 0)
5022 			/* bit99m2/bit100 */
5023 			brightonPut(win, "bitmaps/blueprints/bitoneshade.xpm",
5024 				0, 0, win->width, win->height);
5025 		else
5026 			brightonPut(win, "bitmaps/blueprints/bit99shade.xpm",
5027 				0, 0, win->width, win->height);
5028 	}
5029 
5030 	/*
5031 	 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
5032 	 * occurs on first paint, so we suppress the first paint, and then request
5033 	 * an expose here.
5034 	 */
5035 	event.type = BRIGHTON_EXPOSE;
5036 	event.intvalue = 1;
5037 	brightonParamChange(synth->win, KEY_PANEL, -1, &event);
5038 	configureGlobals(synth);
5039 
5040 	event.type = BRIGHTON_FLOAT;
5041 	event.value = 0.8;
5042 	brightonParamChange(synth->win, 0, 206, &event);
5043 	brightonParamChange(synth->win, 0, 207, &event);
5044 
5045 	event.value = 1.0;
5046 	brightonParamChange(synth->win, 0, 209, &event);
5047 	brightonParamChange(synth->win, 0, 219, &event);
5048 
5049 	event.value = 0.51;
5050 	brightonParamChange(synth->win, 0, ENTRY_POT, &event);
5051 	event.value = 0.5;
5052 	brightonParamChange(synth->win, 0, 203, &event);
5053 
5054 	dc = brightonGetDCTimer(win->dcTimeout);
5055 
5056 	synth->loadMemory = (loadRoutine) bitoneMemoryKey;
5057 	synth->saveMemory = (saveRoutine) bitoneSaveMemory;
5058 
5059 	return(0);
5060 }
5061 
5062