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 /* Synthi Sound alike */
23
24 #include <fcntl.h>
25 #include <stdlib.h>
26
27 #include "brighton.h"
28 #include "brightonMini.h"
29 #include "brightoninternals.h"
30
31 static int sAksInit();
32 static int sAksConfigure();
33 static int sAksCallback(brightonWindow *, int, int, float);
34
35 extern guimain global;
36
37 #include "brightonKeys.h"
38
39 #define DEVICE_COUNT (81 + 256)
40 #define ACTIVE_DEVS (59 + 256)
41 #define DISPLAY (DEVICE_COUNT - 1)
42
43 #define MEM_START (ACTIVE_DEVS + 5)
44 #define MIDI_START (MEM_START + 14)
45
46 /*
47 * This structure is for device definition. The structure is defined in
48 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
49 * include/brightoninternals.h
50 *
51 * typedef int (*brightonCallback)(int, float);
52 * typedef struct BrightonLocations {
53 * int device; 0=rotary, 1=scale, etc.
54 * float relx, rely; relative position with regards to 1000 by 1000 window
55 * float relw, relh; relative height.
56 * int from, to;
57 * brightonCallback callback; specific to this dev
58 * char *image; bitmap. If zero take a device default.
59 * int flags;
60 * } brightonLocations;
61 *
62 * This example is for a sAksBristol type synth interface.
63 */
64
65 #define CD1 88
66
67 #define CC1 83
68 #define CC2 (CC1 + CD1)
69 #define CC3 (CC2 + CD1)
70 #define CC4 (CC3 + CD1)
71 #define CC5 (CC4 + CD1)
72 #define CC6 (CC5 + CD1)
73 #define CC7 (CC6 + CD1)
74 #define CC8 (CC7 + CD1)
75 #define CC9 (CC8 + CD1)
76 #define CC10 (CC9 + CD1)
77
78 #define CC4b (CC3 + CD1 + 45)
79 #define CC5b (CC4 + CD1 + 45)
80 #define CC6b (CC5 + CD1 + 45)
81 #define CC7b (CC6 + CD1 + 45)
82
83 #define RD1 140
84 #define RD2 190
85 #define R0 129
86 #define R1 (R0 + RD1)
87 #define R2 (R1 + RD1)
88 #define R3 (R2 + RD1)
89 #define R4 (R3 + RD1)
90 #define R5 (R4 + RD1)
91
92 #define S1 75
93 #define S2 75
94 #define S3 95
95 #define S4 25
96
97 #define PSPX 508
98 #define PSPY 500
99
100 #define PS1 ((float) 250 / 16.1f)
101 #define PS2 ((float) 349 / 16.1f)
102
103 #define PATCHBUS(y) \
104 {"", 2, PSPX + PS1 * 0 - 1, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
105 "patchonSA", 0 , BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
106 {"", 2, PSPX + PS1 * 1, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
107 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
108 {"", 2, PSPX + PS1 * 2, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
109 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
110 {"", 2, PSPX + PS1 * 3, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
111 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
112 {"", 2, PSPX + PS1 * 4, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
113 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
114 {"", 2, PSPX + PS1 * 5, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
115 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
116 {"", 2, PSPX + PS1 * 6, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
117 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
118 {"", 2, PSPX + PS1 * 7, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
119 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
120 {"", 2, PSPX + PS1 * 8, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
121 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
122 {"", 2, PSPX + PS1 * 9, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
123 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
124 {"", 2, PSPX + PS1 * 10, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
125 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
126 {"", 2, PSPX + PS1 * 11, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
127 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
128 {"", 2, PSPX + PS1 * 12, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
129 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
130 {"", 2, PSPX + PS1 * 13, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
131 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
132 {"", 2, PSPX + PS1 * 14, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
133 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
134 {"", 2, PSPX + PS1 * 15, PSPY + PS2 * y, PS1, PS2, 0, 2, 0, \
135 "patchonSA", "patchonSA", BRIGHTON_NOSHADOW|BRIGHTON_FIVEWAY},\
136
137 static brightonLocations locations[DEVICE_COUNT] = {
138 /* 0 Filter Check controller 50 that adjusts filter/fine. */
139 {"", 0, CC4b, R0, S1 - 3, S2 - 3, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
140 "bitmaps/knobs/alpharotary.xpm", 0},
141 {"", 0, CC5b, R0, S1, S2, 0, 1, 0, "bitmaps/knobs/knobyellownew.xpm",
142 "bitmaps/knobs/alpharotary.xpm", 0},
143 {"", 0, CC6b, R0, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
144 "bitmaps/knobs/alpharotary.xpm", 0},
145 /* Ring Mod */
146 {"", 0, CC7b, R0, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
147 "bitmaps/knobs/alpharotary.xpm", 0},
148
149 /* 4 osc 1 Inner and outer tuners first. */
150 {"", 0, CC1 + 1, R1 + 0, S1 - 3, S2 - 3, 0, 1, 0,
151 "bitmaps/knobs/knobbluenew.xpm",
152 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOSHADOW},
153 {"", 0, CC1 - 7, R1 - 10, S3, S3, 0, 1, 0,
154 "bitmaps/knobs/knobhollownew.xpm", 0, 0},
155 {"", 0, CC2, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
156 "bitmaps/knobs/alpharotary.xpm", 0},
157 {"", 0, CC3, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
158 "bitmaps/knobs/alpharotary.xpm", 0},
159 {"", 0, CC4, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
160 "bitmaps/knobs/alpharotary.xpm", 0},
161
162 /* 9 Env */
163 {"", 0, CC5, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
164 "bitmaps/knobs/alpharotary.xpm", 0},
165 {"", 0, CC6, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
166 "bitmaps/knobs/alpharotary.xpm", 0},
167 {"", 0, CC7, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
168 "bitmaps/knobs/alpharotary.xpm", 0},
169 {"", 0, CC8, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobrednew.xpm",
170 "bitmaps/knobs/alpharotary.xpm", 0},
171 {"", 0, CC9, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
172 "bitmaps/knobs/alpharotary.xpm", 0},
173 {"", 0, CC10, R1, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
174 "bitmaps/knobs/alpharotary.xpm", 0},
175
176 /* 15 Osc 2 */
177 {"", 0, CC1 + 1, R2 + 0, S1 - 3, S2 - 3, 0, 1, 0,
178 "bitmaps/knobs/knobbluenew.xpm",
179 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOSHADOW},
180 {"", 0, CC1 - 7, R2 - 10, S3, S3, 0, 1, 0,
181 "bitmaps/knobs/knobhollownew.xpm", 0, 0},
182 {"", 0, CC2, R2, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
183 "bitmaps/knobs/alpharotary.xpm", 0},
184 {"", 0, CC3, R2, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
185 "bitmaps/knobs/alpharotary.xpm", 0},
186 {"", 0, CC4, R2, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
187 "bitmaps/knobs/alpharotary.xpm", 0},
188
189 {"", 0, CC9, R2, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
190 "bitmaps/knobs/alpharotary.xpm", 0},
191 {"", 0, CC10, R2, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
192 "bitmaps/knobs/alpharotary.xpm", 0},
193
194 /* 22 Osc 3 */
195 {"", 0, CC1 + 1, R3 + 0, S1 - 3, S2 - 3, 0, 1, 0,
196 "bitmaps/knobs/knobbluenew.xpm",
197 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOSHADOW},
198 {"", 0, CC1 - 7, R3 - 10, S3, S3, 0, 1, 0,
199 "bitmaps/knobs/knobhollownew.xpm", 0, 0},
200 {"", 0, CC2, R3, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
201 "bitmaps/knobs/alpharotary.xpm", 0},
202 {"", 0, CC3, R3, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
203 "bitmaps/knobs/alpharotary.xpm", 0},
204 {"", 0, CC4, R3, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
205 "bitmaps/knobs/alpharotary.xpm", 0},
206
207 {"", 0, CC9, R3, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
208 "bitmaps/knobs/alpharotary.xpm", 0},
209 {"", 0, CC10, R3, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
210 "bitmaps/knobs/alpharotary.xpm", 0},
211
212 /* Noise 29 */
213 {"", 0, CC1, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm",
214 "bitmaps/knobs/alpharotary.xpm", 0},
215 {"", 0, CC2, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
216 "bitmaps/knobs/alpharotary.xpm", 0},
217
218 {"", 0, CC3, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobyellownew.xpm",
219 "bitmaps/knobs/alpharotary.xpm", 0},
220 {"", 0, CC4, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobyellownew.xpm",
221 "bitmaps/knobs/alpharotary.xpm", 0},
222
223 {"", 0, CC9 - 15, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
224 "bitmaps/knobs/alpharotary.xpm", 0},
225 {"", 0, CC10, R4, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
226 "bitmaps/knobs/alpharotary.xpm", 0},
227
228 /* 35 */
229 {"", 0, CC1, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
230 "bitmaps/knobs/alpharotary.xpm", 0},
231 {"", 0, CC2, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
232 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOTCH},
233 {"", 0, CC3, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreennew.xpm",
234 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_NOTCH},
235 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
236 "bitmaps/knobs/alpharotary.xpm", 0},
237
238 /* 39 - Filter Fine. */
239 /*{"", 0, CC4b, R0, S1, S2, 0, 1, 0, "bitmaps/knobs/knobbluenew.xpm", */
240 {"", 0, CC4b - 7, R0 - 10, S3, S3, 0, 1, 0,
241 "bitmaps/knobs/knobhollownew.xpm", 0, 0},
242
243 /* 40 - 19 Dummies for later use. */
244 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
245 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
246 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
247 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
248 {"", 0, 923, 890, 40, 40, 0, 1.0, 0, "bitmaps/knobs/knob2.xpm",
249 0, BRIGHTON_WITHDRAWN},
250 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
251 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
252 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
253 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
254 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
255 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
256 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
257 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
258 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
259 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
260 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
261 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
262 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
263 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
264 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
265 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
266 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
267 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
268 {"", 0, 923, 890, 40, 40, 0, 1.0, 0, "bitmaps/knobs/knob2.xpm",
269 0, BRIGHTON_WITHDRAWN},
270 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
271 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
272 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
273 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
274 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
275 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
276 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
277 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
278 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
279 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
280 {"", 0, CC4, R5, S1, S2, 0, 1, 0, "bitmaps/knobs/knobgreynew.xpm",
281 "bitmaps/knobs/alpharotary.xpm", BRIGHTON_WITHDRAWN},
282
283 /* From 59 - the patch matrix */
284 PATCHBUS(0.0f)
285 PATCHBUS(1.0f)
286 PATCHBUS(2.0f)
287 PATCHBUS(3.0f)
288 PATCHBUS(4.0f)
289 PATCHBUS(5.0f)
290 PATCHBUS(6.0f)
291 PATCHBUS(7.0f)
292 PATCHBUS(8.0f)
293 PATCHBUS(9.0f)
294 PATCHBUS(10.0f)
295 PATCHBUS(11.0f)
296 PATCHBUS(12.0f)
297 PATCHBUS(13.0f)
298 PATCHBUS(14.0f)
299 PATCHBUS(15.0f)
300
301 /* 315 (59 + 256) Touch panel */
302 {"", 5, 810, 814, 79, 128, 0, 1, 0, "bitmaps/images/sphere.xpm",
303 0, BRIGHTON_WIDE},
304 {"", 5, 810, 814, 79, 128, 0, 1, 0, "bitmaps/images/sphere.xpm",
305 0, BRIGHTON_WITHDRAWN},
306
307 /* 317 Monitor switches */
308 {"", 2, 130, RD2, 37, 18, 0, 2, 0, "switch", 0,
309 BRIGHTON_VERTICAL|BRIGHTON_THREEWAY|BRIGHTON_NOSHADOW},
310 {"", 2, 850, RD2, 37, 18, 0, 2, 0, "switch", 0,
311 BRIGHTON_VERTICAL|BRIGHTON_THREEWAY|BRIGHTON_NOSHADOW},
312
313 /* 319 Trigger switch */
314 {"", 2, 928, 850, 20, 30, 0, 1.01, 0,
315 "bitmaps/buttons/touchnlw.xpm",
316 "bitmaps/buttons/touchnlo.xpm", BRIGHTON_NOSHADOW},
317
318 #define C18 230
319 #define C19 260
320
321 #define C20 306
322 #define C21 334
323 #define C22 362
324
325 #define R1_1 87
326 #define R21_0 120
327 #define R21_1 154
328 #define R22_1 186
329
330 #define S5 17
331 #define S6 20
332
333 /* Memory/Midi */
334 /* Load/Save */
335 {"", 2, C20, R22_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnl.xpm",
336 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
337 {"", 2, C22, R22_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlo.xpm",
338 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
339
340 /* 1 - 3 */
341 /* {"", 2, C20, R1_1, S5, S6, 0, 1, 0, "bitmaps/digits/1.xpm", */
342 {"", 2, C20, R1_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
343 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
344 {"", 2, C21, R1_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
345 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
346 {"", 2, C22, R1_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
347 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
348 /* 4 - 6 */
349 {"", 2, C20, R21_0, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
350 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
351 {"", 2, C21, R21_0, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
352 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
353 {"", 2, C22, R21_0, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
354 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
355 /* 7 - 9 */
356 {"", 2, C20, R21_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
357 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
358 {"", 2, C21, R21_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
359 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
360 {"", 2, C22, R21_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
361 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
362 /* 0 */
363 {"", 2, C21, R22_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
364 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
365
366 /* mem/midi Up/down */
367 {"", 2, C19, R21_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
368 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
369 {"", 2, C19, R22_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
370 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
371
372 {"", 2, C18, R22_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
373 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
374 {"", 2, C18, R21_1, S5, S6, 0, 1, 0, "bitmaps/buttons/touchnlw.xpm",
375 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
376
377 {"", 3, 199, R1_1 + 23, 106, 25, 0, 1, 0, 0,
378 "bitmaps/images/alphadisplay3.xpm", 0}
379 };
380
381 /*
382 */
383
384 /*
385 * This is a set of globals for the main window rendering. Again taken from
386 * include/brighton.h
387 */
388 brightonApp sAksApp = {
389 "aks",
390 0, /* no blueprint on wood background. */
391 "bitmaps/textures/metal6.xpm",
392 0,
393 sAksInit,
394 sAksConfigure, /* 3 callbacks, unused? */
395 0,
396 destroySynth,
397 {1, 0, 2, 2, 5, 520, 0, 0},
398 700, 500, 0, 0,
399 1, /* Panels */
400 {
401 {
402 "synthi",
403 "bitmaps/blueprints/sAks.xpm",
404 "bitmaps/textures/metal1.xpm",
405 BRIGHTON_STRETCH, /* flags */
406 0,
407 0,
408 sAksCallback,
409 0, 0, 1000, 1000,
410 DEVICE_COUNT,
411 locations
412 },
413 }
414 };
415
416 /*static dispatcher dispatch[DEVICE_COUNT]; */
417
418 static void
sAksReverb(guiSynth * synth,int fd,int chan,int c,int o,int v)419 sAksReverb(guiSynth *synth, int fd, int chan, int c, int o, int v)
420 {
421 v = v >> 1;
422
423 bristolMidiSendMsg(fd, chan, 8, 0, v);
424 bristolMidiSendMsg(fd, chan, 8, 1, v);
425 bristolMidiSendMsg(fd, chan, 8, 2, v >> 1);
426 }
427
428 static void
aksManualStart(guiSynth * synth,int fd,int chan,int c,int o,int v)429 aksManualStart(guiSynth *synth, int fd, int chan, int c, int o, int v)
430 {
431 printf("trigger %i\n", v);
432 if (v == 0)
433 bristolMidiSendMsg(global.controlfd, synth->midichannel,
434 BRISTOL_EVENT_KEYOFF, 0, 6);
435 else
436 bristolMidiSendMsg(global.controlfd, synth->midichannel,
437 BRISTOL_EVENT_KEYON, 0, 6);
438 }
439
440 static int
sAksMidiSendMsg(void * synth,int fd,int chan,int c,int o,int v)441 sAksMidiSendMsg(void *synth, int fd, int chan, int c, int o, int v)
442 {
443 /*printf("%i, %i, %i\n", c, o, v); */
444 bristolMidiSendMsg(fd, chan, c, o, v);
445 return(0);
446 }
447
448 static void
sAksMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)449 sAksMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
450 {
451 int cmem = synth->location;
452
453 /*printf("mem(%i, %i, %i)\n", c, o, v); */
454
455 if (synth->flags & MEM_LOADING)
456 return;
457
458 switch (c) {
459 default:
460 case 0:
461 synth->location = synth->location * 10 + o;
462
463 if (synth->location >= 1000)
464 synth->location = o;
465 if (loadMemory(synth, "aks", 0, synth->location,
466 synth->mem.active, 0, BRISTOL_STAT) < 0)
467 displayPanelText(synth, "FRE", synth->location, 0, DISPLAY);
468 else
469 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
470 break;
471 case 1:
472 loadMemory(synth, "aks", 0, synth->location,
473 synth->mem.active, 0, 0);
474 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
475 synth->location = 0;
476 break;
477 case 2:
478 saveMemory(synth, "aks", 0, synth->location, 0);
479 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
480 synth->location = 0;
481 break;
482 case 3:
483 while (loadMemory(synth, "aks", 0, --synth->location,
484 synth->mem.active, 0, 0) < 0)
485 {
486 if (synth->location < 0)
487 synth->location = 1000;
488 if (synth->location == cmem)
489 break;
490 }
491 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
492 break;
493 case 4:
494 while (loadMemory(synth, "aks", 0, ++synth->location,
495 synth->mem.active, 0, 0) < 0)
496 {
497 if (synth->location > 999)
498 synth->location = -1;
499 if (synth->location == cmem)
500 break;
501 }
502 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
503 break;
504 }
505 }
506
507 static void
sAksPatchPanel(guiSynth * synth,int fd,int chan,int c,int o,int v)508 sAksPatchPanel(guiSynth *synth, int fd, int chan, int c, int o, int v)
509 {
510 int value = C_RANGE_MIN_1;
511
512 /* if (v != 0) */
513 /* printf("requested %i, %i, %i\n", c, o, v); */
514
515 /*
516 * values:
517 *
518 * 4 = 5%
519 * 3 = -6dB
520 * 2 = 1%
521 * 1 = invert.
522 * 0 = 0
523 *
524 * These are sent such that the sent value of 0.5 is off. below that is
525 * negative, and above that tends to one.
526 */
527
528 switch (v) {
529 case 0:
530 /* Value zero, send zero to turn pin off */
531 bristolMidiSendMsg(fd, chan, c + 100, o, 0);
532 break;
533 case 1:
534 /* when the value is 1 send 1, which will invert the signal. */
535 /* Trust me, see the engine code for this synth. */
536 bristolMidiSendMsg(fd, chan, c + 100, o, C_RANGE_MIN_1);
537 break;
538 case 2:
539 /* Accurate mapping */
540 value = C_RANGE_MIN_1 * 98 / 100
541 + ((C_RANGE_MIN_1 / 50) * (rand() >> 17)) / C_RANGE_MIN_1;
542 bristolMidiSendMsg(fd, chan, c + 100, o, value * 19 / 20);
543 break;
544 case 3:
545 /* damped by about -6dB */
546 bristolMidiSendMsg(fd, chan, c + 100, o, (C_RANGE_MIN_1 >> 2));
547 break;
548 case 4:
549 /*
550 * Some half random value, perhaps with a 10% margin to emulate the
551 * resistor accuracy of the original synth.
552 */
553 value = C_RANGE_MIN_1 * 9 / 10
554 + ((C_RANGE_MIN_1 / 10) * (rand() >> 17)) / C_RANGE_MIN_1;
555 printf("requested %i, %i, %i\n", c, o, value);
556 bristolMidiSendMsg(fd, chan, c + 100, o, value);
557 break;
558 }
559 }
560
561 static int
sAksMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)562 sAksMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
563 {
564 int newchan;
565
566 if ((synth->flags & OPERATIONAL) == 0)
567 return(0);
568
569 if (c == 1) {
570 if ((newchan = synth->midichannel - 1) < 0)
571 {
572 synth->midichannel = 0;
573 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
574 return(0);
575 }
576 } else {
577 if ((newchan = synth->midichannel + 1) >= 15)
578 {
579 synth->midichannel = 15;
580 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
581 return(0);
582 }
583 }
584
585 if (global.libtest == 0)
586 {
587 bristolMidiSendMsg(global.controlfd, synth->sid,
588 127, 0, BRISTOL_MIDICHANNEL|newchan);
589 }
590
591 synth->midichannel = newchan;
592
593 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
594
595 return(0);
596 }
597
598 /*
599 * For the sake of ease of use, links have been placed here to be called
600 * by any of the devices created. They would be better in some other file,
601 * perhaps with this as a dispatch.
602 *
603 * Param refers to the device index in the locations table given below.
604 */
605 static int
sAksCallback(brightonWindow * win,int panel,int index,float value)606 sAksCallback(brightonWindow * win, int panel, int index, float value)
607 {
608 guiSynth *synth = findSynth(global.synths, win);
609 int sendvalue;
610
611 /*printf("sAksCallback(%i, %f): %x\n", index, value, synth); */
612
613 if (synth == 0)
614 return(0);
615
616 if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
617 return(0);
618
619 if (sAksApp.resources[panel].devlocn[index].to == 1)
620 sendvalue = value * C_RANGE_MIN_1;
621 else
622 sendvalue = value;
623
624 synth->mem.param[index] = value;
625
626 if ((!global.libtest) || (index >= ACTIVE_DEVS))
627 synth->dispatch[index].routine(synth,
628 global.controlfd, synth->sid,
629 synth->dispatch[index].controller,
630 synth->dispatch[index].operator,
631 sendvalue);
632 #ifdef DEBUG
633 else
634 printf("dispatch[%p,%i](%i, %i, %i, %i, %i)\n", synth, index,
635 global.controlfd, synth->sid,
636 synth->dispatch[index].controller,
637 synth->dispatch[index].operator,
638 sendvalue);
639 #endif
640
641 return(0);
642 }
643
644 /*
645 * Any location initialisation required to run the callbacks. For bristol, this
646 * will connect to the engine, and give it some base parameters.
647 * May need to generate some application specific menus.
648 * Will also then make specific requests to some of the devices to alter their
649 * rendering.
650 */
651 static int
sAksInit(brightonWindow * win)652 sAksInit(brightonWindow *win)
653 {
654 guiSynth *synth = findSynth(global.synths, win);
655 dispatcher *dispatch;
656 int i, in, out;
657
658 if (synth == 0)
659 {
660 synth = findSynth(global.synths, 0);
661 if (synth == 0)
662 {
663 printf("cannot init\n");
664 return(0);
665 }
666 }
667
668 synth->win = win;
669
670 printf("Initialise the sAks link to bristol: %p\n", synth->win);
671
672 synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
673 synth->mem.count = DEVICE_COUNT;
674 synth->mem.active = ACTIVE_DEVS;
675 synth->dispatch = (dispatcher *)
676 brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
677 dispatch = synth->dispatch;
678
679 /*
680 * We really want to have three connection mechanisms. These should be
681 * 1. Unix named sockets.
682 * 2. UDP sockets.
683 * 3. MIDI pipe.
684 */
685 synth->voices = 1;
686 if (!global.libtest)
687 if ((synth->sid = initConnection(&global, synth)) < 0)
688 return(-1);
689
690 for (i = 0; i < DEVICE_COUNT; i++)
691 synth->dispatch[i].routine = sAksMidiSendMsg;
692
693 /* Filter */
694 dispatch[0].controller = 3;
695 dispatch[0].operator = 0;
696 dispatch[1].controller = 3;
697 dispatch[1].operator = 1;
698 dispatch[2].controller = 3;
699 dispatch[2].operator = 5;
700
701 /* Ring mod gain */
702 dispatch[3].controller = 7;
703 dispatch[3].operator = 2;
704
705 /* Osc1 tuning */
706 dispatch[4].controller = 0;
707 dispatch[4].operator = 0;
708 dispatch[5].controller = 0;
709 dispatch[5].operator = 1;
710 dispatch[6].controller = 0;
711 dispatch[6].operator = 2;
712 dispatch[7].controller = 0;
713 dispatch[7].operator = 3;
714 dispatch[8].controller = 0;
715 dispatch[8].operator = 4;
716
717 /* ENV controllers */
718 dispatch[9].controller = 4;
719 dispatch[9].operator = 0;
720 dispatch[10].controller = 4;
721 dispatch[10].operator = 1;
722 dispatch[11].controller = 4;
723 dispatch[11].operator = 2;
724 dispatch[12].controller = 4;
725 dispatch[12].operator = 3;
726 dispatch[13].controller = 126;
727 dispatch[13].operator = 16;
728 dispatch[14].controller = 126;
729 dispatch[14].operator = 17;
730
731 /* Osc2 tuning */
732 dispatch[15].controller = 1;
733 dispatch[15].operator = 0;
734 dispatch[16].controller = 1;
735 dispatch[16].operator = 1;
736 dispatch[17].controller = 1;
737 dispatch[17].operator = 2;
738 dispatch[18].controller = 1;
739 dispatch[18].operator = 3;
740 dispatch[19].controller = 1;
741 dispatch[19].operator = 4;
742
743 /* Reverb */
744 dispatch[20].controller = 8;
745 dispatch[20].operator = 0;
746 /* This should be a compound controller for delay and feedback */
747 dispatch[20].routine = (synthRoutine) sAksReverb;
748 dispatch[21].controller = 8;
749 dispatch[21].operator = 4;
750
751 /* Osc3 tuning */
752 dispatch[22].controller = 2;
753 dispatch[22].operator = 0;
754 dispatch[23].controller = 2;
755 dispatch[23].operator = 1;
756 dispatch[24].controller = 2;
757 dispatch[24].operator = 2;
758 dispatch[25].controller = 2;
759 dispatch[25].operator = 3;
760 dispatch[26].controller = 2;
761 dispatch[26].operator = 4;
762
763 /* Input gain */
764 dispatch[27].controller = 126;
765 dispatch[27].operator = 2;
766 dispatch[28].controller = 126;
767 dispatch[28].operator = 3;
768
769 /* Noise */
770 dispatch[29].controller = 6;
771 dispatch[29].operator = 2;
772 dispatch[30].controller = 6;
773 dispatch[30].operator = 0;
774
775 /* Output */
776 dispatch[31].controller = 126;
777 dispatch[31].operator = 4;
778 dispatch[32].controller = 126;
779 dispatch[32].operator = 5;
780
781 /* Range */
782 dispatch[33].controller = 126;
783 dispatch[33].operator = 6;
784 dispatch[34].controller = 126;
785 dispatch[34].operator = 7;
786
787 /* Mix */
788 dispatch[35].controller = 126;
789 dispatch[35].operator = 8;
790 dispatch[36].controller = 126;
791 dispatch[36].operator = 9;
792 dispatch[37].controller = 126;
793 dispatch[37].operator = 10;
794 dispatch[38].controller = 126;
795 dispatch[38].operator = 11;
796 /* filter fine */
797 dispatch[39].controller = 3;
798 dispatch[39].operator = 2;
799
800 /* Patch panel */
801 i = 59;
802 for (out = 0; out < 16; out++)
803 {
804 for (in = 0; in < 16; in++)
805 {
806 dispatch[i].controller = in;
807 dispatch[i].operator = out;
808 dispatch[i].routine = (synthRoutine) sAksPatchPanel;
809 i++;
810 }
811 }
812
813 dispatch[ACTIVE_DEVS + 0].controller = 126;
814 dispatch[ACTIVE_DEVS + 0].operator = 12;
815 /* dispatch[ACTIVE_DEVS + 0].routine = (synthRoutine) sAksHShift; */
816 dispatch[ACTIVE_DEVS + 1].controller = 126;
817 dispatch[ACTIVE_DEVS + 1].operator = 13;
818 /* dispatch[ACTIVE_DEVS + 1].routine = (synthRoutine) sAksHShift; */
819
820 /* Switches */
821 dispatch[ACTIVE_DEVS + 2].controller = 126;
822 dispatch[ACTIVE_DEVS + 2].operator = 14;
823 dispatch[ACTIVE_DEVS + 3].controller = 126;
824 dispatch[ACTIVE_DEVS + 3].operator = 15;
825
826 dispatch[ACTIVE_DEVS + 4].routine = (synthRoutine) aksManualStart;
827
828 dispatch[MEM_START +0].routine = dispatch[MEM_START +1].routine =
829 dispatch[MEM_START +2].routine = dispatch[MEM_START +3].routine =
830 dispatch[MEM_START +4].routine = dispatch[MEM_START +5].routine =
831 dispatch[MEM_START +6].routine = dispatch[MEM_START +7].routine =
832 dispatch[MEM_START +8].routine = dispatch[MEM_START +9].routine =
833 dispatch[MEM_START +10].routine = dispatch[MEM_START +11].routine =
834 dispatch[MEM_START +12].routine = dispatch[MEM_START +13].routine
835 = (synthRoutine) sAksMemory;
836
837 dispatch[MEM_START + 0].controller = 1;
838 dispatch[MEM_START + 1].controller = 2;
839 dispatch[MEM_START + 2].operator = 1;
840 dispatch[MEM_START + 3].operator = 2;
841 dispatch[MEM_START + 4].operator = 3;
842 dispatch[MEM_START + 5].operator = 4;
843 dispatch[MEM_START + 6].operator = 5;
844 dispatch[MEM_START + 7].operator = 6;
845 dispatch[MEM_START + 8].operator = 7;
846 dispatch[MEM_START + 9].operator = 8;
847 dispatch[MEM_START + 10].operator = 9;
848 dispatch[MEM_START + 11].operator = 0;
849
850 dispatch[MEM_START + 12].controller = 4;
851 dispatch[MEM_START + 13].controller = 3;
852
853 dispatch[MIDI_START].controller = 1;
854 dispatch[MIDI_START + 1].controller = 2;
855 dispatch[MIDI_START].routine = dispatch[MIDI_START + 1].routine =
856 (synthRoutine) sAksMidi;
857
858 /* Set the oscillator indeces */
859 bristolMidiSendMsg(global.controlfd, synth->sid, 1, 5, 1);
860 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 5, 2);
861 /* Pink noise source (is variable with filter) */
862 bristolMidiSendMsg(global.controlfd, synth->sid, 6, 1, 1);
863 /* bristolMidiSendMsg(global.controlfd, synth->sid, 1, 6, C_RANGE_MIN_1); */
864 /* LFO Env parameters. */
865 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 1, 12000); */
866 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 2, 16383); */
867 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 3, 0); */
868 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 4, 16383); */
869 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 5, 0); */
870
871 return(0);
872 }
873
874 /*
875 * This will be called to make any routine specific parameters available.
876 */
877 static int
sAksConfigure(brightonWindow * win)878 sAksConfigure(brightonWindow *win)
879 {
880 guiSynth *synth = findSynth(global.synths, win);
881 brightonEvent event;
882
883 if (synth == 0)
884 {
885 printf("problems going operational\n");
886 return(-1);
887 }
888
889 if (synth->flags & OPERATIONAL)
890 return(0);
891
892 printf("going operational\n");
893
894 synth->flags |= OPERATIONAL;
895 synth->keypanel = synth->keypanel2 = -1;
896 synth->transpose = 48;
897
898 synth->bank = 0;
899 event.value = 1;
900 /* Poly */
901 loadMemory(synth, "aks", 0, synth->location, synth->mem.active, 0, 0);
902
903 /* event.type = BRIGHTON_PARAMCHANGE; */
904 /* event.value = 1.0; */
905 /* brightonParamChange(synth->win, 0, ACTIVE_DEVS, &event); */
906 configureGlobals(synth);
907
908 return(0);
909 }
910
911