1
2 /*
3 * Diverse Bristol audio routines.
4 * Copyright (c) by Nick Copeland <nickycopeland@hotmail.com> 1996,2012
5 *
6 *
7 * This program is free software; you can redistribute it and/or modify
8 * it under the terms of the GNU General Public License as published by
9 * the Free Software Foundation; either version 3 of the License, or
10 * (at your option) any later version.
11 *
12 * This program is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 * GNU General Public License for more details.
16 *
17 * You should have received a copy of the GNU General Public License
18 * along with this program; if not, see <http://www.gnu.org/licenses/>.
19 *
20 */
21
22 /*
23 * This is the emulator stub for the Moog Voyager Ice Blue. It has a separate
24 * layout but then uses all the same code from the Explorer interface. It could
25 * have been buried in the same file.
26 */
27 #include "brighton.h"
28 #include "brightonMini.h"
29 #include "brightoninternals.h"
30
31 /*
32 static int voyagerInit();
33 static int voyagerCallback(brightonWindow *, int, int, float);
34 */
35 static int voyagerConfigure();
36
37 extern int explorerInit();
38 extern int explorerConfigure();
39 extern int explorerCallback(brightonWindow *, int, int, float);
40
41 static int midiCallback(brightonWindow *, int, int, float);
42
43 extern guimain global;
44
45 extern int empty;
46
47 #include "brightonKeys.h"
48
49 #define KEY_PANEL 1
50
51 #define FIRST_DEV 0
52 #define DEVICE_COUNT 77
53 #define ACTIVE_DEVS 56
54 #define MEM_START (ACTIVE_DEVS + 1)
55
56 #define DISPLAY1 (DEVICE_COUNT - 2)
57 #define DISPLAY2 (DEVICE_COUNT - 1)
58
59 #define S1 85
60
61 #define B1 15
62 #define B2 110
63 #define B3 37
64 #define B4 42
65
66 #define R14 200
67 #define R24 400
68 #define R34 600
69 #define R44 800
70
71 #define R15 200
72 #define R25 350
73 #define R35 500
74 #define R45 650
75 #define R55 800
76
77 #define C1 25
78 #define C2 90
79 #define C3 155
80 #define C4 220
81 #define C5 285
82 #define C6 350
83 #define C6I 395
84
85 #define C7 615
86 #define C8 665
87 #define C9 742
88 #define C10 810
89 #define C11 875
90 #define C12 945
91
92 /*
93 * This structure is for device definition. The structure is defined in
94 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
95 * include/brightoninternals.h
96 *
97 * typedef int (*brightonCallback)(int, float);
98 * typedef struct BrightonLocations {
99 * int device; 0=rotary, 1=scale, etc.
100 * float relx, rely; relative position with regards to 1000 by 1000 window
101 * float relw, relh; relative height.
102 * int from, to;
103 * brightonCallback callback; specific to this dev
104 * char *image; bitmap. If zero take a device default.
105 * int flags;
106 * } brightonLocations;
107 *
108 * This example is for a voyagerBristol type synth interface.
109 */
110 static brightonLocations locations[DEVICE_COUNT] = {
111
112 /* LFO and control */
113 {"LFO-Freq", 0, C1 - 7, R14 - 20, S1 + 40, S1 + 40, 0, 1, 0, 0, 0, 0},
114 {"LFO-Sync", 2, C1 - 5, R24 + 25, B3, B4, 0, 3, 0,
115 "bitmaps/buttons/rockerblue.xpm", 0, 0},
116 {"GLOBAL TUNE", 0, C1, R34, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_NOTCH},
117 {"Glide", 0, C1, R44, S1, S1, 0, 1, 0, 0, 0, 0},
118 /* Routing */
119 {"Mod1-Source", 0, C2, R14, S1, S1, 0, 4, 0, 0, 0, 0},
120 {"Mod1-Shape", 0, C2, R24, S1, S1, 0, 3, 0, 0, 0, 0},
121 {"Mod1-Dest", 0, C2, R34, S1, S1, 0, 5, 0, 0, 0, 0},
122 {"Mod1-Gain", 0, C2, R44, S1, S1, 0, 1, 0, 0, 0, 0},
123 {"Mod2-Source", 0, C3, R14, S1, S1, 0, 4, 0, 0, 0, 0},
124 {"Mod2-Shape", 0, C3, R24, S1, S1, 0, 3, 0, 0, 0, 0},
125 {"Mod2-Dest", 0, C3, R34, S1, S1, 0, 5, 0, 0, 0, 0},
126 {"Mod2-Gain", 0, C3, R44, S1, S1, 0, 1, 0, 0, 0, 0},
127 /* Oscillators */
128 {"Osc1-Transpose", 0, C4, R24, S1, S1, 0, 5, 0, 0, 0, 0},
129 {"Osc1-Waveform", 0, C4, R34, S1, S1, 0, 1, 0, 0, 0, 0},
130 {"Osc2-Tuning", 0, C5 - 7, R14 - 20, S1 + 40, S1 + 40, 0, 1, 0, 0, 0, BRIGHTON_NOTCH},
131 {"Osc2-Transpose", 0, C5, R24, S1, S1, 0, 5, 0, 0, 0, 0},
132 {"Osc2-Waveform", 0, C5, R34, S1, S1, 0, 1, 0, 0, 0, 0},
133 {"Osc3-Tuning", 0, C6 - 7, R14 - 20, S1 + 40, S1 + 40, 0, 1, 0, 0, 0, BRIGHTON_NOTCH},
134 {"Osc3-Transpose", 0, C6, R24, S1, S1, 0, 5, 0, 0, 0, 0},
135 {"Osc3-Waveform", 0, C6, R34, S1, S1, 0, 1, 0, 0, 0, 0},
136 /* Osc mod switches */
137 {"Sync-1/2", 2, C4, R44 + 10, B1, B2, 0, 1, 0, 0, 0, BRIGHTON_VERTICAL},
138 {"FM-1/3", 2, C4 + 40, R44 + 10, B1, B2, 0, 1, 0, 0, 0, BRIGHTON_VERTICAL},
139 {"KBD-3", 2, C4 + 95, R44 + 10, B1, B2, 0, 1, 0, 0, 0, BRIGHTON_VERTICAL},
140 {"Freq-3", 2, C4 + 135, R44 + 10, B1, B2, 0, 1, 0, 0, 0, BRIGHTON_VERTICAL},
141 /* Mixer */
142 {"Mix-EXT", 0, C7, R15, S1, S1, 0, 1, 0, 0, 0, 0},
143 {"Mix-O1", 0, C7, R25, S1, S1, 0, 1, 0, 0, 0, 0},
144 {"Mix-O2", 0, C7, R35, S1, S1, 0, 1, 0, 0, 0, 0},
145 {"Mix-O3", 0, C7, R45, S1, S1, 0, 1, 0, 0, 0, 0},
146 {"Mix-NSE", 0, C7, R55, S1, S1, 0, 1, 0, 0, 0, 0},
147 {"Mix-Ext-off", 2, C8, R15 + 25, B3, B4, 0, 1, 0,
148 "bitmaps/buttons/rockerblue.xpm", 0, 0},
149 {"Mix-O1-off", 2, C8, R25 + 25, B3, B4, 0, 1, 0,
150 "bitmaps/buttons/rockerblue.xpm", 0, 0},
151 {"Mix-O2-off", 2, C8, R35 + 25, B3, B4, 0, 1, 0,
152 "bitmaps/buttons/rockerblue.xpm", 0, 0},
153 {"Mix-O3-off", 2, C8, R45 + 25, B3, B4, 0, 1, 0,
154 "bitmaps/buttons/rockerblue.xpm", 0, 0},
155 {"Mix-Nse-off", 2, C8, R55 + 25, B3, B4, 0, 1, 0,
156 "bitmaps/buttons/rockerblue.xpm", 0, 0},
157 /* Filter */
158 {"VCF-Cutoff", 0, C9 - 7, R15 - 25, S1 + 40, S1 + 40, 0, 1, 0, 0, 0, 0},
159 {"VCF-Space", 0, C9, R25, S1, S1, 0, 1, 0, 0, 0, 0},
160 {"VCF-Res", 0, C9, R35, S1, S1, 0, 1, 0, 0, 0, 0},
161 {"VCF-KBD", 0, C9, R45, S1, S1, 0, 1, 0, 0, 0, 0},
162 {"VCF-Mode", 2, C9, R55 + 25, B3, B4, 0, 1, 0, 0, 0, 0},
163 /* Filter envelope */
164 {"VCF-Attack", 0, C10, R15, S1, S1, 0, 1, 0, 0, 0, 0},
165 {"VCF-Decay", 0, C10, R25, S1, S1, 0, 1, 0, 0, 0, 0},
166 {"VCF-Sustain", 0, C10, R35, S1, S1, 0, 1, 0, 0, 0, 0},
167 {"VCF-Release", 0, C10, R45, S1, S1, 0, 1, 0, 0, 0, 0},
168 {"VCF-EnvLevel", 0, C10, R55, S1, S1, 0, 1, 0, 0, 0, 0},
169 /* Amp Envelope */
170 {"VCA-Attack", 0, C11, R15, S1, S1, 0, 1, 0, 0, 0, 0},
171 {"VCA-Decay", 0, C11, R25, S1, S1, 0, 1, 0, 0, 0, 0},
172 {"VCA-Sustain", 0, C11, R35, S1, S1, 0, 1, 0, 0, 0, 0},
173 {"VCA-Release", 0, C11, R45, S1, S1, 0, 1, 0, 0, 0, 0},
174 {"VCA-Veloc", 2, C11, R55 + 25, B3, B4, 0, 1, 0, 0, 0, 0},
175 /* Vol, on/off, glide and release */
176 {"Volume", 0, C12 - 7, R15 - 25 , S1 + 40, S1 + 40, 0, 1, 0, 0, 0, 0},
177 {"On/Off", 2, C12 - 4, R25 + 25, B3, B4, 0, 1, 0, 0, 0, 0},
178 {"LFO-Multi", 2, C12 - 4, R35 + 25, B3, B4, 0, 1, 0,
179 "bitmaps/buttons/rockerwhite.xpm", 0, 0},
180 {"Glide-On", 2, C12 - 4, R45 + 25, B3, B4, 0, 1, 0,
181 "bitmaps/buttons/rockerwhite.xpm", 0, 0},
182 {"Release-On", 2, C12 - 4, R55 + 25, B3, B4, 0, 1, 0,
183 "bitmaps/buttons/rockerwhite.xpm", 0, 0},
184 {"Reserved", 5, 405, 410, 180, 518, 0, 1, 0, "bitmaps/buttons/pointer.xpm", 0, 0},
185 {"Reserved", 5, 405, 410, 180, 518, 0, 1, 0, "bitmaps/buttons/pointer.xpm", 0,
186 BRIGHTON_WITHDRAWN},
187 /* logo */
188 {"", 4, 762, 1037, 240, 140, 0, 1, 0, "bitmaps/images/explorer.xpm", 0, 0},
189
190 /* memories */
191 {"", 2, 418, 225, 17, 78, 0, 1.01, 0,
192 "bitmaps/buttons/pressoff.xpm",
193 "bitmaps/buttons/presson.xpm", 0},
194 {"", 2, 436, 225, 17, 78, 0, 1.01, 0,
195 "bitmaps/buttons/pressoff.xpm",
196 "bitmaps/buttons/presson.xpm", 0},
197 {"", 2, 454, 225, 17, 78, 0, 1.01, 0,
198 "bitmaps/buttons/pressoff.xpm",
199 "bitmaps/buttons/presson.xpm", 0},
200 {"", 2, 472, 225, 17, 78, 0, 1.01, 0,
201 "bitmaps/buttons/pressoff.xpm",
202 "bitmaps/buttons/presson.xpm", 0},
203 {"", 2, 490, 225, 17, 78, 0, 1.01, 0,
204 "bitmaps/buttons/pressoff.xpm",
205 "bitmaps/buttons/presson.xpm", 0},
206 {"", 2, 418, 308, 17, 78, 0, 1.01, 0,
207 "bitmaps/buttons/pressoff.xpm",
208 "bitmaps/buttons/presson.xpm", 0},
209 {"", 2, 436, 308, 17, 78, 0, 1.01, 0,
210 "bitmaps/buttons/pressoff.xpm",
211 "bitmaps/buttons/presson.xpm", 0},
212 {"", 2, 454, 308, 17, 78, 0, 1.01, 0,
213 "bitmaps/buttons/pressoff.xpm",
214 "bitmaps/buttons/presson.xpm", 0},
215 {"", 2, 472, 308, 17, 78, 0, 1.01, 0,
216 "bitmaps/buttons/pressoff.xpm",
217 "bitmaps/buttons/presson.xpm", 0},
218 {"", 2, 490, 308, 17, 78, 0, 1.01, 0,
219 "bitmaps/buttons/pressoff.xpm",
220 "bitmaps/buttons/presson.xpm", 0},
221 {"", 2, 510, 228, 15, 70, 0, 1.01, 0,
222 "bitmaps/buttons/pressoffg.xpm",
223 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
224 {"", 2, 510, 309, 15, 70, 0, 1.01, 0,
225 "bitmaps/buttons/pressoffo.xpm",
226 "bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
227 {"", 2, 540, 70, 16, 78, 0, 1.01, 0,
228 "bitmaps/buttons/pressoff.xpm",
229 "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
230 {"", 2, 540, 145, 16, 78, 0, 1.01, 0,
231 "bitmaps/buttons/pressoff.xpm",
232 "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
233 {"", 2, 540, 227, 16, 78, 0, 1.01, 0,
234 "bitmaps/buttons/pressoff.xpm",
235 "bitmaps/buttons/presson.xpm", 0},
236 {"", 2, 540, 308, 16, 78, 0, 1.01, 0,
237 "bitmaps/buttons/pressoff.xpm",
238 "bitmaps/buttons/presson.xpm", 0},
239 /* mem up down */
240 {"", 2, 402, 228, 15, 70, 0, 1.01, 0,
241 "bitmaps/buttons/pressoffg.xpm",
242 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
243 {"", 2, 402, 311, 15, 70, 0, 1.01, 0,
244 "bitmaps/buttons/pressoffg.xpm",
245 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
246 /* displays */
247 {"", 3, 403, 90, 128, 63, 0, 1, 0, 0,
248 "bitmaps/images/alphadisplay3.xpm", 0},
249 {"", 3, 403, 150, 128, 63, 0, 1, 0, 0, 0, 0}
250 };
251
252 /*
253 * These are new mod controls for the Pro-1. Used here for the Explorer.
254 */
255 static brightonLocations newmods[2] = {
256 {"", BRIGHTON_MODWHEEL, 260, 200, 190, 565, 0, 1, 0,
257 "bitmaps/knobs/modwheelblue.xpm", 0,
258 BRIGHTON_HSCALE|BRIGHTON_NOSHADOW|BRIGHTON_CENTER|BRIGHTON_NOTCH},
259 {"", BRIGHTON_MODWHEEL, 610, 200, 190, 565, 0, 1, 0,
260 "bitmaps/knobs/modwheelblue.xpm", 0,
261 BRIGHTON_HSCALE|BRIGHTON_NOSHADOW},
262 };
263
264 /*
265 * This is a set of globals for the main window rendering. Again taken from
266 * include/brighton.h
267 */
268 brightonApp voyagerApp = {
269 "voyager",
270 0, /* no blueprint on wood background. */
271 "bitmaps/textures/voyagerpaint.xpm",
272 0, /* or BRIGHTON_STRETCH, default is tesselate */
273 explorerInit,
274 voyagerConfigure, /* 3 callbacks, unused? */
275 midiCallback,
276 destroySynth,
277 {1, 100, 2, 2, 5, 520, 0, 0},
278 817, 472, 0, 0,
279 7, /* one panel only */
280 {
281 {
282 "Voyager",
283 "bitmaps/blueprints/voyager.xpm",
284 "bitmaps/textures/black.xpm",
285 0, /* flags */
286 0,
287 explorerConfigure,
288 explorerCallback,
289 25, 25, 950, 532,
290 DEVICE_COUNT,
291 locations
292 },
293 {
294 "Keyboard",
295 0,
296 "bitmaps/newkeys/ekbg.xpm", /* flags */
297 0x020|BRIGHTON_STRETCH,
298 0,
299 0,
300 keyCallback,
301 140, 675, 840, 300,
302 KEY_COUNT_3OCTAVE,
303 keys3octave
304 },
305 {
306 "Mods",
307 0,
308 "bitmaps/textures/voyagerpaint.xpm", /* flags */
309 BRIGHTON_STRETCH,
310 0,
311 0,
312 modCallback,
313 15, 675, 125, 300,
314 2,
315 newmods
316 },
317 {
318 "SP0",
319 0,
320 "bitmaps/textures/voyagerpaint.xpm",
321 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
322 0,
323 0,
324 0,
325 930, 675, 60, 300,
326 0,
327 0
328 },
329 {
330 "SP1",
331 0,
332 "bitmaps/textures/voyagerpaint.xpm",
333 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
334 0,
335 0,
336 0,
337 0, 0, 15, 1000,
338 0,
339 0
340 },
341 {
342 "SP2",
343 0,
344 "bitmaps/textures/voyagerpaint.xpm",
345 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
346 0,
347 0,
348 0,
349 985, 0, 15, 1000,
350 0,
351 0
352 },
353 }
354 };
355
356 /*static dispatcher dispatch[DEVICE_COUNT]; */
357
358 static int
midiCallback(brightonWindow * win,int controller,int value,float n)359 midiCallback(brightonWindow *win, int controller, int value, float n)
360 {
361 guiSynth *synth = findSynth(global.synths, win);
362
363 printf("midi callback: %x, %i\n", controller, value);
364
365 switch(controller)
366 {
367 case MIDI_PROGRAM:
368 printf("midi program: %x, %i\n", controller, value);
369 synth->location = value;
370 loadMemory(synth, "explorer", 0, synth->bank + synth->location,
371 synth->mem.active, FIRST_DEV, 0);
372 break;
373 case MIDI_BANK_SELECT:
374 printf("midi banksel: %x, %i\n", controller, value);
375 synth->bank = value;
376 break;
377 }
378 return(0);
379 }
380
381 /*
382 * This will be called to make any routine specific parameters available.
383 */
384 static int
voyagerConfigure(brightonWindow * win)385 voyagerConfigure(brightonWindow *win)
386 {
387 guiSynth *synth = findSynth(global.synths, win);
388 brightonEvent event;
389
390 memset(&event, 0, sizeof(brightonEvent));
391
392 if (synth == 0)
393 {
394 printf("problems going operational\n");
395 return(-1);
396 }
397
398 if (synth->flags & OPERATIONAL)
399 return(0);
400
401 printf("going operational\n");
402
403 synth->flags |= OPERATIONAL;
404 synth->keypanel = 1;
405 synth->keypanel2 = -1;
406 synth->transpose = 36;
407
408 displayText(synth, "CHAN", synth->midichannel + 1, DISPLAY1);
409
410 loadMemory(synth, "explorer", 0, synth->location, synth->mem.active,
411 FIRST_DEV, 0);
412 displayText(synth, "PRG", synth->location, DISPLAY2);
413
414 brightonPut(win,
415 "bitmaps/blueprints/voyagershade.xpm", 0, 0, win->width, win->height);
416
417 /*
418 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
419 * occurs on first paint, so we suppress the first paint, and then request
420 * an expose here.
421 */
422 event.type = BRIGHTON_EXPOSE;
423 event.intvalue = 1;
424 brightonParamChange(synth->win, KEY_PANEL, -1, &event);
425 configureGlobals(synth);
426
427 return(0);
428 }
429
430