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 /* ARP Axxe */
23 
24 #include <fcntl.h>
25 
26 #include "brighton.h"
27 #include "brightonMini.h"
28 #include "brightoninternals.h"
29 
30 static int initmem;
31 
32 static int axxeInit();
33 static int axxeConfigure();
34 static int axxeCallback(brightonWindow *, int, int, float);
35 /*static int keyCallback(void *, int, int, float); */
36 static int midiCallback(brightonWindow *, int, int, float);
37 
38 extern guimain global;
39 
40 #include "brightonKeys.h"
41 
42 #define DEVICE_COUNT 50
43 #define ACTIVE_DEVS 30
44 #define MEM_START (ACTIVE_DEVS)
45 #define MIDI_START (MEM_START + 18)
46 #define RADIOSET_1 MEM_START
47 #define RADIOSET_2 (MEM_START + 1)
48 
49 #define KEY_PANEL 1
50 
51 #define CDIFF 32
52 #define CDIFF2 12
53 
54 #define PC0 118
55 #define PC1 (PC0 + CDIFF)
56 #define PC2 (PC1 + CDIFF)
57 #define PC3 (PC2 + CDIFF)
58 #define PC4 (PC3 + CDIFF)
59 #define PC5 (PC4 + CDIFF)
60 #define PC6 (PC5 + CDIFF + CDIFF2)
61 #define PC7 (PC6 + CDIFF)
62 #define PC8 (PC7 + CDIFF)
63 #define PC9 (PC8 + CDIFF + CDIFF2)
64 #define PC10 (PC9 + CDIFF + CDIFF2)
65 #define PC11 (PC10 + CDIFF)
66 #define PC12 (PC11 + CDIFF)
67 #define PC13 (PC12 + CDIFF + CDIFF2)
68 #define PC14 (PC13 + CDIFF)
69 #define PC15 (PC14 + CDIFF + CDIFF2)
70 #define PC16 (PC15 + CDIFF)
71 #define PC17 (PC16 + CDIFF)
72 #define PC18 (PC17 + CDIFF + CDIFF2)
73 #define PC19 (PC18 + CDIFF)
74 #define PC20 (PC19 + CDIFF + CDIFF2)
75 #define PC21 (PC20 + CDIFF)
76 #define PC22 (PC21 + CDIFF)
77 #define PC23 (PC22 + CDIFF)
78 
79 #define C0 126
80 #define C1 (C0 + CDIFF)
81 #define C2 (C1 + CDIFF)
82 #define C3 (C2 + CDIFF)
83 #define C4 (C3 + CDIFF)
84 #define C5 (C4 + CDIFF)
85 #define C6 (C5 + CDIFF + CDIFF2)
86 #define C7 (C6 + CDIFF)
87 #define C8 (C7 + CDIFF)
88 #define C9 (C8 + CDIFF + CDIFF2)
89 #define C10 (C9 + CDIFF + CDIFF2)
90 #define C11 (C10 + CDIFF)
91 #define C12 (C11 + CDIFF)
92 #define C13 (C12 + CDIFF + CDIFF2)
93 #define C14 (C13 + CDIFF)
94 #define C15 (C14 + CDIFF + CDIFF2)
95 #define C16 (C15 + CDIFF)
96 #define C17 (C16 + CDIFF)
97 #define C18 (C17 + CDIFF + CDIFF2)
98 #define C19 (C18 + CDIFF)
99 #define C20 (C19 + CDIFF + CDIFF2)
100 #define C21 (C20 + CDIFF)
101 #define C22 (C21 + CDIFF)
102 #define C23 (C22 + CDIFF)
103 
104 #define RP0 414
105 #define RP1 (RP0 + 205)
106 #define RP2 (RP0 + 100)
107 #define RP3 880
108 
109 #define R0 500
110 #define R1 (R0 + 205)
111 #define R2 (R0 + 75)
112 #define R3 900
113 
114 #define W1 12
115 #define PW1 26
116 #define L1 300
117 #define LP1 363
118 
119 #define BDIFF (CDIFF + 2)
120 #define BDIFF2 (CDIFF2 + 2)
121 
122 #define B0 170
123 #define B1 (B0 + BDIFF + BDIFF2)
124 #define B2 (B1 + BDIFF)
125 #define B3 (B2 + BDIFF)
126 #define B4 (B3 + BDIFF)
127 #define B5 (B4 + BDIFF)
128 #define B6 (B5 + BDIFF)
129 #define B7 (B6 + BDIFF)
130 #define B8 (B7 + BDIFF)
131 #define B9 (B8 + BDIFF + BDIFF2)
132 #define B10 (B9 + BDIFF)
133 #define B11 (B10 + BDIFF)
134 #define B12 (B11 + BDIFF)
135 #define B13 (B12 + BDIFF)
136 #define B14 (B13 + BDIFF)
137 #define B15 (B14 + BDIFF)
138 #define B16 (B15 + BDIFF)
139 #define B17 (B16 + BDIFF + BDIFF2)
140 
141 #define B18 (BDIFF)
142 #define B19 (B18 + BDIFF + BDIFF)
143 
144 /*
145  * This structure is for device definition. The structure is defined in
146  * include/brighton.h, further definitions in brighton/brightonDevtable.h and
147  * include/brightoninternals.h
148  *
149  *	typedef int (*brightonCallback)(int, float);
150  *	typedef struct BrightonLocations {
151  *		int device; 0=rotary, 1=scale, etc.
152  *		float relx, rely; relative position with regards to 1000 by 1000 window
153  *		float relw, relh; relative height.
154  *		int from, to;
155  *		brightonCallback callback; specific to this dev
156  *		char *image; bitmap. If zero take a device default.
157  *		int flags;
158  *	} brightonLocations;
159  *
160  * This example is for a axxeBristol type synth interface.
161  */
162 static brightonLocations phatlocations[DEVICE_COUNT] = {
163 	/* Glide/Tranpose - 0 */
164 	{"Glide", 1, PC0, RP0, PW1, LP1, 0, 1, 0,
165 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
166 	{"Transpose", 2, C1, R2 - 30, 15, LP1/2 - 60, 0, 2, 0, 0, 0,
167 		BRIGHTON_THREEWAY|BRIGHTON_NOSHADOW},
168 
169 	/* VCO - 2 */
170 	{"VCO LFO Sine Mod", 1, PC2, RP0, PW1, LP1, 0, 1, 0,
171 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
172 	{"VCO LFO Square Mod", 1, PC3, RP0, PW1, LP1, 0, 1, 0,
173 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
174 	{"VCO S/H Mod", 1, PC4, RP0, PW1, LP1, 0, 1, 0,
175 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
176 	{"VCO ADSR Mod", 1, PC5, RP0, PW1, LP1, 0, 1, 0,
177 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
178 	{"VCO PW", 1, PC6, RP0, PW1, LP1, 0, 1, 0,
179 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
180 	{"VCO PWM LFO", 1, PC7, RP0, PW1, LP1, 0, 1, 0,
181 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
182 	{"VCO PWM ADSR", 1, PC8, RP0, PW1, LP1, 0, 1, 0,
183 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
184 
185 	/* LFO - 9 */
186 	{"LFO Freq", 1, PC9, RP0, PW1, LP1, 0, 1, 0,
187 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
188 
189 	/* Mixer - 10 */
190 	{"Mix Noise", 1, PC10, RP0, PW1, LP1, 0, 1, 0,
191 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
192 	{"Mix VCO Ramp", 1, PC11, RP0, PW1, LP1, 0, 1, 0,
193 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
194 	{"Mix VCO Pulse", 1, PC12, RP0, PW1, LP1, 0, 1, 0,
195 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
196 
197 	/* VCF - 13 */
198 	{"VCF Cutoff", 1, PC13, RP0, PW1, LP1, 0, 1, 0,
199 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
200 	{"VCO Resonance", 1, PC14, RP0, PW1, LP1, 0, 1, 0,
201 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
202 	{"VCO KBD", 1, PC15, RP0, PW1, LP1, 0, 1, 0,
203 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
204 	{"VCF LFO Sine", 1, PC16, RP0, PW1, LP1, 0, 1, 0,
205 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
206 	{"VCF ADSR", 1, PC17, RP0, PW1, LP1, 0, 1, 0,
207 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
208 
209 	/* VCA - 18 */
210 	{"VCA Gain", 1, PC18, RP0, PW1, LP1, 0, 1, 0,
211 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
212 	{"VCA ADSR", 1, PC19, RP0, PW1, LP1, 0, 1, 0,
213 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
214 
215 	/* ADSR - 20 */
216 	{"Attack", 1, PC20, RP0, PW1, LP1, 0, 1, 0,
217 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
218 	{"Decay", 1, PC21, RP0, PW1, LP1, 0, 1, 0,
219 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
220 	{"Sustain", 1, PC22, RP0, PW1, LP1, 0, 1, 0,
221 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
222 	{"Release", 1, PC23, RP0, PW1, LP1, 0, 1, 0,
223 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
224 
225 	/* Pink/White noise - 24 */
226 	{"Pink/White", 2, C1, 110, 14, 100, 0, 1, 0,
227 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
228 
229 	/* LFO mode - 25 */
230 	{"LFO S/M", 2, C22, 110, 14, 100, 0, 1, 0,
231 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
232 
233 	/* LFO trigger - gate/auto - 26 */
234 	{"LFO Trig", 2, C20, 110, 14, 100, 0, 1, 0,
235 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
236 
237 	/* Pitch Control - 27 */
238 	{"Pitch Flat", 2, 25, RP2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
239 		"bitmaps/buttons/touchnlw.xpm", 0},
240 	{"Pitch Trill", 2, 53, RP2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
241 		"bitmaps/buttons/touchnlw.xpm", 0},
242 	{"Pitch Sharp", 2, 80, RP2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
243 		"bitmaps/buttons/touchnlw.xpm", 0},
244 
245 	/* Memory Load, mem, Save - 30 */
246 	{"", 2, B0, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
247 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
248 
249 	{"", 2, B1, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
250 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
251 	{"", 2, B2, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
252 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
253 	{"", 2, B3, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
254 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
255 	{"", 2, B4, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
256 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
257 	{"", 2, B5, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
258 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
259 	{"", 2, B6, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
260 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
261 	{"", 2, B7, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
262 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
263 	{"", 2, B8, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
264 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
265 
266 	{"", 2, B9, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
267 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
268 	{"", 2, B10, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
269 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
270 	{"", 2, B11, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
271 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
272 	{"", 2, B12, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
273 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
274 	{"", 2, B13, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
275 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
276 	{"", 2, B14, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
277 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
278 	{"", 2, B15, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
279 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
280 	{"", 2, B16, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
281 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
282 
283 	{"", 2, B17, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm",
284 		"bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
285 
286 	/* MIDI - or android up/down memories */
287 	{"", 2, B18, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
288 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
289 	{"", 2, B19, RP3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
290 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
291 };
292 static brightonLocations locations[DEVICE_COUNT] = {
293 	/* Glide/Tranpose - 0 */
294 	{"Glide", 1, C0, R0, W1, L1, 0, 1, 0,
295 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
296 	{"Transpose", 2, C1, R2 + 30, 15, L1/2 - 60, 0, 2, 0, 0, 0,
297 		BRIGHTON_THREEWAY|BRIGHTON_NOSHADOW},
298 
299 	/* VCO - 2 */
300 	{"VCO LFO Sine Mod", 1, C2, R0, W1, L1, 0, 1, 0,
301 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
302 	{"VCO LFO Square Mod", 1, C3, R0, W1, L1, 0, 1, 0,
303 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
304 	{"VCO S/H Mod", 1, C4, R0, W1, L1, 0, 1, 0,
305 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
306 	{"VCO ADSR Mod", 1, C5, R0, W1, L1, 0, 1, 0,
307 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
308 	{"VCO PW", 1, C6, R0, W1, L1, 0, 1, 0,
309 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
310 	{"VCO PWM LFO", 1, C7, R0, W1, L1, 0, 1, 0,
311 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
312 	{"VCO PWM ADSR", 1, C8, R0, W1, L1, 0, 1, 0,
313 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
314 
315 	/* LFO - 9 */
316 	{"LFO Freq", 1, C9, R0, W1, L1, 0, 1, 0,
317 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
318 
319 	/* Mixer - 10 */
320 	{"Mix Noise", 1, C10, R0, W1, L1, 0, 1, 0,
321 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
322 	{"Mix VCO Ramp", 1, C11, R0, W1, L1, 0, 1, 0,
323 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
324 	{"Mix VCO Pulse", 1, C12, R0, W1, L1, 0, 1, 0,
325 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
326 
327 	/* VCF - 13 */
328 	{"VCF Cutoff", 1, C13, R0, W1, L1, 0, 1, 0,
329 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
330 	{"VCO Resonance", 1, C14, R0, W1, L1, 0, 1, 0,
331 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
332 	{"VCO KBD", 1, C15, R0, W1, L1, 0, 1, 0,
333 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
334 	{"VCF LFO Sine", 1, C16, R0, W1, L1, 0, 1, 0,
335 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
336 	{"VCF ADSR", 1, C17, R0, W1, L1, 0, 1, 0,
337 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
338 
339 	/* VCA - 18 */
340 	{"VCA Gain", 1, C18, R0, W1, L1, 0, 1, 0,
341 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
342 	{"VCA ADSR", 1, C19, R0, W1, L1, 0, 1, 0,
343 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
344 
345 	/* ADSR - 20 */
346 	{"Attack", 1, C20, R0, W1, L1, 0, 1, 0,
347 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
348 	{"Decay", 1, C21, R0, W1, L1, 0, 1, 0,
349 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
350 	{"Sustain", 1, C22, R0, W1, L1, 0, 1, 0,
351 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
352 	{"Release", 1, C23, R0, W1, L1, 0, 1, 0,
353 		"bitmaps/knobs/sliderblack.xpm", 0, 0},
354 
355 	/* Pink/White noise - 24 */
356 	{"Pink/White", 2, C1, 220, 14, 100, 0, 1, 0,
357 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
358 
359 	/* LFO mode - 25 */
360 	{"LFO S/M", 2, C22, 220, 14, 100, 0, 1, 0,
361 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
362 
363 	/* LFO trigger - gate/auto - 26 */
364 	{"LFO Trig", 2, C20, 220, 14, 100, 0, 1, 0,
365 		"bitmaps/buttons/klunk.xpm", 0, BRIGHTON_VERTICAL},
366 
367 	/* Pitch Control - 27 */
368 	{"Pitch Flat", 2, 25, R2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
369 		"bitmaps/buttons/touchnlw.xpm", 0},
370 	{"Pitch Trill", 2, 53, R2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
371 		"bitmaps/buttons/touchnlw.xpm", 0},
372 	{"Pitch Sharp", 2, 80, R2, 30, 80, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
373 		"bitmaps/buttons/touchnlw.xpm", 0},
374 
375 	/* Memory Load, mem, Save - 30 */
376 	{"", 2, B0, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
377 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
378 
379 	{"", 2, B1, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
380 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
381 	{"", 2, B2, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
382 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
383 	{"", 2, B3, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
384 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
385 	{"", 2, B4, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
386 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
387 	{"", 2, B5, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
388 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
389 	{"", 2, B6, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
390 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
391 	{"", 2, B7, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
392 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
393 	{"", 2, B8, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
394 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
395 
396 	{"", 2, B9, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
397 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
398 	{"", 2, B10, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
399 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
400 	{"", 2, B11, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
401 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
402 	{"", 2, B12, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
403 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
404 	{"", 2, B13, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
405 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
406 	{"", 2, B14, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
407 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
408 	{"", 2, B15, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
409 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
410 	{"", 2, B16, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
411 		"bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
412 
413 	{"", 2, B17, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm",
414 		"bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
415 
416 	/* MIDI */
417 	{"", 2, B18, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
418 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
419 	{"", 2, B19, R3, 20, 60, 0, 1, 0, "bitmaps/buttons/pressoffw.xpm",
420 		"bitmaps/buttons/pressonw.xpm", BRIGHTON_CHECKBUTTON},
421 };
422 
423 /*
424  */
425 
426 /*
427  * This is a set of globals for the main window rendering. Again taken from
428  * include/brighton.h
429  */
430 brightonApp axxePhatApp = {
431 	"axxe",
432 	0, /* no blueprint on wood background. */
433 	"bitmaps/textures/metal4.xpm",
434 	0, /* BRIGHTON_STRETCH, //flags */
435 	axxeInit,
436 	axxeConfigure, /* 3 callbacks, unused? */
437 	midiCallback,
438 	destroySynth,
439 	{1, 100, 2, 2, 5, 520, 0, 0},
440 	600, 350, 0, 0,
441 	4, /* Panels */
442 	{
443 		{
444 			"Axxe",
445 			"bitmaps/blueprints/axxephat.xpm",
446 			"bitmaps/textures/metal6.xpm",
447 			BRIGHTON_STRETCH, /* flags */
448 			0,
449 			0,
450 			axxeCallback,
451 			15, 0, 970, 620,
452 			DEVICE_COUNT,
453 			phatlocations
454 		},
455 #ifdef RIBBON_KEYBOARD
456 		{
457 			"RibbonKeyboard",
458 			0,
459 			"bitmaps/newkeys/ribbonKeys.xpm",
460 			BRIGHTON_STRETCH,
461 			0,
462 			ribbonCallBack,
463 			ribbonCallBack,
464 			80, 625, 840, 360,
465 			1,
466 			ribbonkeyboard,
467 		},
468 #else
469 		{
470 			"Keyboard",
471 			0,
472 			"bitmaps/newkeys/fkbg.xpm", /* flags */
473 			BRIGHTON_STRETCH|BRIGHTON_KEY_PANEL,
474 			0,
475 			0,
476 			keyCallback,
477 			80, 625, 840, 360,
478 			KEY_COUNT_2OCTAVE2,
479 			keys2octave2
480 		},
481 #endif
482 		{
483 			"Axxe",
484 			0,
485 			"bitmaps/textures/metal4.xpm",
486 			BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
487 			0,
488 			0,
489 			0,
490 			0, 0, 15, 1000,
491 			0,
492 			0
493 		},
494 		{
495 			"Axxe",
496 			0,
497 			"bitmaps/textures/metal4.xpm",
498 			BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
499 			0,
500 			0,
501 			0,
502 			985, 0, 15, 1000,
503 			0,
504 			0
505 		}
506 	}
507 };
508 
509 /*
510  * This is a set of globals for the main window rendering. Again taken from
511  * include/brighton.h
512  */
513 brightonApp axxeApp = {
514 	"axxe",
515 	0, /* no blueprint on wood background. */
516 	"bitmaps/textures/metal4.xpm",
517 	0, /* BRIGHTON_STRETCH, //flags */
518 	axxeInit,
519 	axxeConfigure, /* 3 callbacks, unused? */
520 	midiCallback,
521 	destroySynth,
522 	{1, 100, 2, 2, 5, 520, 0, 0},
523 	600, 350, 0, 0,
524 	4, /* Panels */
525 	{
526 		{
527 			"Axxe",
528 			"bitmaps/blueprints/axxe.xpm",
529 			"bitmaps/textures/metal6.xpm",
530 			BRIGHTON_STRETCH, /* flags */
531 			0,
532 			0,
533 			axxeCallback,
534 			15, 0, 970, 700,
535 			DEVICE_COUNT,
536 			locations
537 		},
538 		{
539 			"Keyboard",
540 			0,
541 			"bitmaps/newkeys/ekbg.xpm", /* flags */
542 			0x020|BRIGHTON_STRETCH,
543 			0,
544 			0,
545 			keyCallback,
546 			120, 700, 800, 300,
547 			KEY_COUNT_3OCTAVE,
548 			keys3octave
549 		},
550 		{
551 			"Axxe",
552 			0,
553 			"bitmaps/textures/metal4.xpm",
554 			BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
555 			0,
556 			0,
557 			0,
558 			0, 0, 15, 1000,
559 			0,
560 			0
561 		},
562 		{
563 			"Axxe",
564 			0,
565 			"bitmaps/textures/metal4.xpm",
566 			BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
567 			0,
568 			0,
569 			0,
570 			985, 0, 15, 1000,
571 			0,
572 			0
573 		}
574 	}
575 };
576 
577 static int
midiCallback(brightonWindow * win,int controller,int value,float n)578 midiCallback(brightonWindow *win, int controller, int value, float n)
579 {
580 	guiSynth *synth = findSynth(global.synths, win);
581 
582 	printf("midi callback: %x, %i\n", controller, value);
583 
584 	switch(controller)
585 	{
586 		case MIDI_PROGRAM:
587 			printf("midi program: %x, %i\n", controller, value);
588 			synth->location = value;
589 			loadMemory(synth, synth->resources->name, 0,
590 				synth->location, synth->mem.active, 0, 0);
591 			break;
592 		case MIDI_BANK_SELECT:
593 			printf("midi banksel: %x, %i\n", controller, value);
594 			synth->bank = value * 10;
595 
596 			synth->location = (synth->location % 10) + value * 10;
597 			loadMemory(synth, synth->resources->name, 0,
598 				synth->location, synth->mem.active, 0, 0);
599 			break;
600 	}
601 	return(0);
602 }
603 
604 static int
axxeMidiSendMsg(void * synth,int fd,int chan,int c,int o,int v)605 axxeMidiSendMsg(void *synth, int fd, int chan, int c, int o, int v)
606 {
607 	bristolMidiSendMsg(fd, chan, c, o, v);
608 	return(0);
609 }
610 
611 static int
axxeMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)612 axxeMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
613 {
614 	brightonEvent event;
615 
616 	if ((synth->flags | OPERATIONAL) == 0)
617 		return(0);
618 
619 /*	printf("	axxeMemory(B: %i L %i: %i, %i)\n", */
620 /*		synth->bank, synth->location, c, o); */
621 
622 	switch(c) {
623 		case 0:
624 			saveMemory(synth, "axxe", 0, synth->bank + synth->location, 0);
625 			return(0);
626 			break;
627 		case 17:
628 			loadMemory(synth, "axxe", 0, synth->bank + synth->location,
629 				synth->mem.active, 0, 0);
630 			return(0);
631 			break;
632 		case 1:
633 		case 2:
634 		case 3:
635 		case 4:
636 		case 5:
637 		case 6:
638 		case 7:
639 		case 8:
640 			if (synth->dispatch[RADIOSET_1].other2)
641 			{
642 				synth->dispatch[RADIOSET_1].other2 = 0;
643 				return(0);
644 			}
645 			if (synth->dispatch[RADIOSET_1].other1 != -1)
646 			{
647 				synth->dispatch[RADIOSET_1].other2 = 1;
648 
649 				if (synth->dispatch[RADIOSET_1].other1 != c)
650 					event.value = 0;
651 				else
652 					event.value = 1;
653 
654 				brightonParamChange(synth->win, synth->panel,
655 					synth->dispatch[RADIOSET_1].other1 + MEM_START, &event);
656 			}
657 			synth->dispatch[RADIOSET_1].other1 = c;
658 			synth->bank = c * 10;
659 			break;
660 		case 9:
661 		case 10:
662 		case 11:
663 		case 12:
664 		case 13:
665 		case 14:
666 		case 15:
667 		case 16:
668 			if (synth->dispatch[RADIOSET_2].other2)
669 			{
670 				synth->dispatch[RADIOSET_2].other2 = 0;
671 				return(0);
672 			}
673 			if (synth->dispatch[RADIOSET_2].other1 != -1)
674 			{
675 				synth->dispatch[RADIOSET_2].other2 = 1;
676 
677 				if (synth->dispatch[RADIOSET_2].other1 != c)
678 					event.value = 0;
679 				else
680 					event.value = 1;
681 
682 				brightonParamChange(synth->win, synth->panel,
683 					synth->dispatch[RADIOSET_2].other1 + MEM_START, &event);
684 			}
685 			synth->dispatch[RADIOSET_2].other1 = c;
686 			/* Do radio buttons */
687 			synth->location = c - 8;
688 			break;
689 	}
690 	return(0);
691 }
692 
693 static int
axxeMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)694 axxeMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
695 {
696 	int newchan;
697 
698 	if ((synth->flags & OPERATIONAL) == 0)
699 		return(0);
700 
701 	if (c == 1) {
702 		if ((newchan = synth->midichannel - 1) < 0)
703 		{
704 			synth->midichannel = 0;
705 			return(0);
706 		}
707 	} else {
708 		if ((newchan = synth->midichannel + 1) >= 16)
709 		{
710 			synth->midichannel = 15;
711 			return(0);
712 		}
713 	}
714 
715 	if (global.libtest == 0)
716 	{
717 		/*
718 #warning if we do not check for ack then socket might hang on exit
719 		 * To overcome that we should consider checking a sequence number in
720 		 * the message library? That is non trivial since it requires that
721 		 * our midi messges have a 'ack' flag included - we cannot check for
722 		 * ack here (actually, we could, and in the app is probably the right
723 		 * place to do it rather than the lib however both would have to be
724 		 * changed to suppor this - nc).
725 		 */
726 		bristolMidiSendMsg(global.controlfd, synth->sid,
727 			127, 0, BRISTOL_MIDICHANNEL|newchan);
728 	}
729 
730 	synth->midichannel = newchan;
731 	return(0);
732 }
733 
734 /*
735  * For the sake of ease of use, links have been placed here to be called
736  * by any of the devices created. They would be better in some other file,
737  * perhaps with this as a dispatch.
738  *
739  * Param refers to the device index in the locations table given below.
740  */
741 static int
axxeCallback(brightonWindow * win,int panel,int index,float value)742 axxeCallback(brightonWindow * win, int panel, int index, float value)
743 {
744 	guiSynth *synth = findSynth(global.synths, win);
745 	int sendvalue;
746 
747 /*printf("axxeCallback(%i, %f): %x\n", index, value, synth); */
748 
749 	if (synth == 0)
750 		return(0);
751 
752 	if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
753 		return(0);
754 
755 	if (axxeApp.resources[0].devlocn[index].to == 1.0)
756 		sendvalue = value * (CONTROLLER_RANGE - 1);
757 	else
758 		sendvalue = value;
759 
760 	synth->mem.param[index] = value;
761 
762 	if ((!global.libtest) || (index >= ACTIVE_DEVS))
763 		synth->dispatch[index].routine(synth,
764 			global.controlfd, synth->sid,
765 			synth->dispatch[index].controller,
766 			synth->dispatch[index].operator,
767 			sendvalue);
768 
769 #ifdef DEBUG
770 	else
771 		printf("dispatch[%x,%i](%i, %i, %i, %i, %i)\n", synth, index,
772 			global.controlfd, synth->sid,
773 			synth->dispatch[index].controller,
774 			synth->dispatch[index].operator,
775 			sendvalue);
776 #endif
777 
778 	return(0);
779 }
780 
781 static int
axxeAutoTrig(guiSynth * synth,int fd,int chan,int c,int o,int v)782 axxeAutoTrig(guiSynth *synth, int fd, int chan, int c, int o, int v)
783 {
784 	/*
785 	 * This takes the LFO value and sends it to the LFO, and if we have auto
786 	 * trig configured will also send a value to 126/19 for trigger repeat rate.
787 	 */
788 	if (synth->mem.param[26] == 0)
789 	{
790 		/*
791 		 * This is measured in buffer sizes, so it not exactly accurate.
792 		 *
793 		 * Fastest rate is going to be 10Hz (1.0), slowest rate 0.1Hz (0.0).
794 		 */
795 		bristolMidiSendMsg(fd, chan, 126, 19,
796 			(int) (synth->mem.param[9] * C_RANGE_MIN_1));
797 	} else {
798 		bristolMidiSendMsg(fd, chan, 126, 19, 0);
799 	}
800 
801 	bristolMidiSendMsg(fd, chan, 2, 0,
802 		(int) (synth->mem.param[9] * C_RANGE_MIN_1));
803 	return(0);
804 }
805 
806 static int
axxeTranspose(guiSynth * synth,int fd,int chan,int c,int o,int v)807 axxeTranspose(guiSynth *synth, int fd, int chan, int c, int o, int v)
808 {
809 	switch (v)
810 	{
811 		case 0:
812 			synth->transpose = 36;
813 			break;
814 		case 1:
815 			synth->transpose = 48;
816 			break;
817 		case 2:
818 			synth->transpose = 60;
819 			break;
820 	}
821 	return(0);
822 }
823 
824 /*
825  * Any location initialisation required to run the callbacks. For bristol, this
826  * will connect to the engine, and give it some base parameters.
827  * May need to generate some application specific menus.
828  * Will also then make specific requests to some of the devices to alter their
829  * rendering.
830  */
831 static int
axxeInit(brightonWindow * win)832 axxeInit(brightonWindow *win)
833 {
834 	guiSynth *synth = findSynth(global.synths, win);
835 	dispatcher *dispatch;
836 	int i;
837 
838 	if (synth == 0)
839 	{
840 		synth = findSynth(global.synths, (int) 0);
841 		if (synth == 0)
842 		{
843 			printf("cannot init\n");
844 			return(0);
845 		}
846 	}
847 
848 	/*
849 	 * We need to take a copy here since the value may change as the synth
850 	 * is drawn
851 	 */
852 	if ((initmem = synth->location) == 0)
853 		initmem = 11;
854 
855 	synth->win = win;
856 
857 	printf("Initialise the axxe link to bristol: %p\n", synth->win);
858 
859 	synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
860 	synth->mem.count = DEVICE_COUNT;
861 	synth->mem.active = ACTIVE_DEVS;
862 	synth->dispatch = (dispatcher *)
863 		brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
864 	dispatch = synth->dispatch;
865 
866 	/*
867 	 * We really want to have three connection mechanisms. These should be
868 	 *	1. Unix named sockets.
869 	 *	2. UDP sockets.
870 	 *	3. MIDI pipe.
871 	 */
872 	if (!global.libtest)
873 	{
874 		if ((synth->sid = initConnection(&global, synth)) < 0)
875 			return(-1);
876 	}
877 
878 	for (i = 0; i < DEVICE_COUNT; i++)
879 	{
880 		synth->dispatch[i].routine = axxeMidiSendMsg;
881 	}
882 
883 	dispatch[0].controller = 126;
884 	dispatch[0].operator = 0;
885 
886 	dispatch[1].controller = 126;
887 	dispatch[1].operator = 0;
888 	dispatch[1].routine = (synthRoutine) axxeTranspose;
889 
890 	dispatch[2].controller = 126;
891 	dispatch[2].operator = 2;
892 	dispatch[3].controller = 126;
893 	dispatch[3].operator = 3;
894 	dispatch[4].controller = 126;
895 	dispatch[4].operator = 4;
896 	dispatch[5].controller = 126;
897 	dispatch[5].operator = 5;
898 
899 	dispatch[6].controller = 1;
900 	dispatch[6].operator = 0;
901 
902 	dispatch[7].controller = 126;
903 	dispatch[7].operator = 6;
904 	dispatch[8].controller = 126;
905 	dispatch[8].operator = 7;
906 
907 	dispatch[9].controller = 2;
908 	dispatch[9].operator = 0;
909 	dispatch[9].routine = (synthRoutine) axxeAutoTrig;
910 
911 	dispatch[10].controller = 126;
912 	dispatch[10].operator = 8;
913 	dispatch[11].controller = 126;
914 	dispatch[11].operator = 9;
915 	dispatch[12].controller = 126;
916 	dispatch[12].operator = 10;
917 
918 	dispatch[13].controller = 3;
919 	dispatch[13].operator = 0;
920 	dispatch[14].controller = 3;
921 	dispatch[14].operator = 1;
922 	dispatch[15].controller = 3;
923 	dispatch[15].operator = 3;
924 
925 	dispatch[16].controller = 126;
926 	dispatch[16].operator = 11;
927 	dispatch[17].controller = 126;
928 	dispatch[17].operator = 12;
929 
930 	dispatch[18].controller = 126;
931 	dispatch[18].operator = 13;
932 	dispatch[19].controller = 126;
933 	dispatch[19].operator = 14;
934 
935 	dispatch[20].controller = 4;
936 	dispatch[20].operator = 0;
937 	dispatch[21].controller = 4;
938 	dispatch[21].operator = 1;
939 	dispatch[22].controller = 4;
940 	dispatch[22].operator = 2;
941 	dispatch[23].controller = 4;
942 	dispatch[23].operator = 3;
943 
944 	dispatch[24].controller = 6;
945 	dispatch[24].operator = 1;
946 
947 	dispatch[25].controller = 126;
948 	dispatch[25].operator = 15;
949 	dispatch[26].controller = 126;
950 	dispatch[26].operator = 19;
951 	dispatch[26].routine = (synthRoutine) axxeAutoTrig;
952 
953 	dispatch[27].controller = 126;
954 	dispatch[27].operator = 16;
955 	dispatch[28].controller = 126;
956 	dispatch[28].operator = 17;
957 	dispatch[29].controller = 126;
958 	dispatch[29].operator = 18;
959 
960 	dispatch[MEM_START + 0].controller = 17;
961 	dispatch[MEM_START + 1].controller = 1;
962 	dispatch[MEM_START + 2].controller = 2;
963 	dispatch[MEM_START + 3].controller = 3;
964 	dispatch[MEM_START + 4].controller = 4;
965 	dispatch[MEM_START + 5].controller = 5;
966 	dispatch[MEM_START + 6].controller = 6;
967 	dispatch[MEM_START + 7].controller = 7;
968 	dispatch[MEM_START + 8].controller = 8;
969 	dispatch[MEM_START + 9].controller = 9;
970 	dispatch[MEM_START + 10].controller = 10;
971 	dispatch[MEM_START + 11].controller = 11;
972 	dispatch[MEM_START + 12].controller = 12;
973 	dispatch[MEM_START + 13].controller = 13;
974 	dispatch[MEM_START + 14].controller = 14;
975 	dispatch[MEM_START + 15].controller = 15;
976 	dispatch[MEM_START + 16].controller = 16;
977 	dispatch[MEM_START + 17].controller = 0;
978 
979 	dispatch[MEM_START + 0].routine =
980 		dispatch[MEM_START + 1].routine =
981 		dispatch[MEM_START + 2].routine =
982 		dispatch[MEM_START + 3].routine =
983 		dispatch[MEM_START + 4].routine =
984 		dispatch[MEM_START + 5].routine =
985 		dispatch[MEM_START + 6].routine =
986 		dispatch[MEM_START + 7].routine =
987 		dispatch[MEM_START + 8].routine =
988 		dispatch[MEM_START + 9].routine =
989 		dispatch[MEM_START + 10].routine =
990 		dispatch[MEM_START + 11].routine =
991 		dispatch[MEM_START + 12].routine =
992 		dispatch[MEM_START + 13].routine =
993 		dispatch[MEM_START + 14].routine =
994 		dispatch[MEM_START + 15].routine =
995 		dispatch[MEM_START + 16].routine =
996 		dispatch[MEM_START + 17].routine
997 			= (synthRoutine) axxeMemory;
998 
999 	dispatch[MIDI_START].controller = 1;
1000 	dispatch[MIDI_START + 1].controller = 2;
1001 	dispatch[MIDI_START].routine = dispatch[MIDI_START + 1].routine =
1002 		(synthRoutine) axxeMidi;
1003 
1004 	dispatch[RADIOSET_1].other1 = -1;
1005 	dispatch[RADIOSET_2].other1 = -1;
1006 
1007 	/*
1008 	 * Grooming env for 'gain' to amp. Short but not choppy attack, slightly
1009 	 * larger decay since the main env can shorten that if really desired.
1010 	 */
1011 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 0, 20);
1012 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 1, 1000);
1013 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 2, 16383);
1014 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 3, 50);
1015 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 4, 16383);
1016 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 5, 0); /* no velocity */
1017 	bristolMidiSendMsg(global.controlfd, synth->sid, 7, 6, 0); /* no rezero */
1018 
1019 	/*
1020 	 * Need to specify env gain fixed, filter mod on, osc waveform.
1021 	 */
1022 	bristolMidiSendMsg(global.controlfd, synth->sid, 4, 4, 16383);
1023 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 2, 16383);
1024 	bristolMidiSendMsg(global.controlfd, synth->sid, 3, 4, 4);
1025 	bristolMidiSendMsg(global.controlfd, synth->sid, 0, 4, 16383);
1026 	bristolMidiSendMsg(global.controlfd, synth->sid, 1, 6, 16383);
1027 
1028 	/* sync LFO to keyon */
1029 	bristolMidiSendMsg(global.controlfd, synth->sid, 2, 1, 16383);
1030 	return(0);
1031 }
1032 
1033 /*
1034  * This will be called to make any routine specific parameters available.
1035  */
1036 static int
axxeConfigure(brightonWindow * win)1037 axxeConfigure(brightonWindow* win)
1038 {
1039 	guiSynth *synth = findSynth(global.synths, win);
1040 	brightonEvent event;
1041 
1042 	if (synth == 0)
1043 	{
1044 		printf("problems going operational\n");
1045 		return(-1);
1046 	}
1047 
1048 	if (synth->flags & OPERATIONAL)
1049 		return(0);
1050 
1051 	printf("going operational\n");
1052 
1053 	synth->bank = 10;
1054 	if (synth->location == 0)
1055 		synth->location = 11;
1056 
1057 	synth->flags |= OPERATIONAL;
1058 	synth->keypanel = 1;
1059 	synth->keypanel2 = -1;
1060 	synth->transpose = 36;
1061 
1062 	loadMemory(synth, "axxe", 0, initmem, synth->mem.active, 0, 0);
1063 
1064 	brightonPut(win,
1065 		"bitmaps/blueprints/axxeshade.xpm", 0, 0, win->width, win->height);
1066 
1067 	event.value = 1;
1068 	brightonParamChange(synth->win, synth->panel, MEM_START + 1, &event);
1069 	brightonParamChange(synth->win, synth->panel, MEM_START + 9, &event);
1070 
1071 	/*
1072 	 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
1073 	 * occurs on first paint, so we suppress the first paint, and then request
1074 	 * an expose here.
1075 	 */
1076 	event.type = BRIGHTON_EXPOSE;
1077 	event.intvalue = 1;
1078 	brightonParamChange(synth->win, KEY_PANEL, -1, &event);
1079 
1080 	/*
1081 	 * Touch a key on/off
1082 	 */
1083 /*	bristolMidiSendMsg(global.controlfd, synth->midichannel, */
1084 /*		BRISTOL_EVENT_KEYON, 0, 10 + synth->transpose); */
1085 /*	bristolMidiSendMsg(global.controlfd, synth->midichannel, */
1086 /*		BRISTOL_EVENT_KEYOFF, 0, 10 + synth->transpose); */
1087 	configureGlobals(synth);
1088 	return(0);
1089 }
1090 
1091