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 * Master controls need to be implemented - vol/balance/tune. Done
24 * Layer balance should be pan. Done
25 * Master balance should be layer. Done
26 *
27 * Seq/Arp/Chord CHORDED
28 * Mode selections Done.
29 *
30 * Confirm all the keyboard modes esp WRT layers.
31 */
32
33
34 #include <fcntl.h>
35
36 #include "brighton.h"
37 #include "brightonMini.h"
38 #include "brightoninternals.h"
39
40 static int initmem;
41 static int exclude = 0;
42
43 extern void *brightonmalloc();
44
45 static int pro10Init();
46 static int pro10Configure();
47 static int pro10Callback(brightonWindow * , int, int, float);
48 static int lmCallback(brightonWindow * , int, int, float);
49 static int ummodCallback(brightonWindow * , int, int, float);
50 static int lmmodCallback(brightonWindow * , int, int, float);
51 static int midiCallback(brightonWindow *, int, int, float);
52
53 #define MODE_DUAL 0
54 #define MODE_LAYER 1
55 #define MODE_POLY 2
56 #define MODE_ALT 3 /* One voice then the other - not supported */
57
58 static int keymode = MODE_DUAL;
59 static int seqLearn = 0, chordLearn = 0;
60
61 extern guimain global;
62 /*
63 * These have to be integrated into the synth private structures, since we may
64 * have multiple invocations of any given synth.
65 */
66 static guimain manual;
67
68 #include "brightonKeys.h"
69
70 #define DEVICE_COUNT 100
71 #define ACTIVE_DEVS 48
72 #define DISPLAY_DEV (DEVICE_COUNT - 2)
73 #define DISPLAY_DEV_2 (DEVICE_COUNT - 1)
74 #define RADIOSET_1 70
75 #define RADIOSET_2 81
76 #define RADIOSET_3 51
77 #define RADIOSET_4 (DEVICE_COUNT + 2)
78 #define RADIOSET_5 (DEVICE_COUNT + 5)
79 #define PANEL_SWITCH 95
80
81 #define KEY_PANEL 1
82 #define KEY_PANEL2 3
83
84 #define R1 75
85 #define RB1 95
86 #define R2 305
87 #define RB2 330
88 #define R3 535
89 #define RB3 560
90 #define RB4 785
91 #define RB5 880
92
93 #define C1 26
94 #define C2 76
95 #define CB1 66
96 #define CB2 95
97 #define C3 125
98 #define C4 155
99 #define C5 184
100
101 #define C6 235
102 #define CB6 275
103 #define CB7 305
104 #define C7 340
105 #define CB8 390
106
107 #define C9 280
108 #define CB9 330
109 #define CB10 360
110 #define CB11 390
111 #define C10 430
112 #define CB12 480
113 #define CB13 510
114
115 #define C11 442
116 #define C12 490
117 #define C13 538
118
119 #define C14 595
120 #define C15 642
121 #define C16 688
122 #define C17 735
123
124 #define C18 800
125 #define C19 850
126 #define C20 900
127 #define C21 950
128
129 #define C22 265
130 #define C23 470
131
132 #define S1 95
133
134 #define B1 14
135 #define B2 80
136 #define B3 65
137
138 /*
139 * This structure is for device definition. The structure is defined in
140 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
141 * include/brightoninternals.h
142 *
143 * typedef int (*brightonCallback)(int, float);
144 * typedef struct BrightonLocations {
145 * int device; 0=rotary, 1=scale, etc.
146 * float relx, rely; relative position with regards to 1000 by 1000 window
147 * float relw, relh; relative height.
148 * int from, to;
149 * brightonCallback callback; specific to this dev
150 * char *image; bitmap. If zero take a device default.
151 * int flags;
152 * } brightonLocations;
153 *
154 * This example is for a pro10Bristol type synth interface.
155 */
156 static brightonLocations locations[DEVICE_COUNT] = {
157 /* poly mod */
158 {"PolyMod-Filt", 0, C1, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
159 {"PolyMod-OscB", 0, C2, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
160 {"PolyMod-FreqA", 2, C3, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
161 {"PolyMod-PW-S", 2, C4, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
162 {"PolyMod-Filt", 2, C5, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
163 /* lfo */
164 {"LFO-Freq", 0, C2, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
165 {"LFO-Ramp", 2, C3, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
166 {"LFO-Tri", 2, C4, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
167 {"LFO-Square", 2, C5, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
168 /* wheel mod */
169 {"Wheel-Mix", 0, C1, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
170 {"Wheel-FreqA", 2, CB1, RB3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
171 {"Wheel-FreqB", 2, CB2, RB3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
172 {"Wheel-PW-A", 2, C3, RB3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
173 {"Wheel-PW-B", 2, C4, RB3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
174 {"Wheel-Filt", 2, C5, RB3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
175 /* osc a */
176 {"OscA-Transpose", 0, C6, R1, S1, S1, 0, 5, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
177 {"OscA-Ramp", 2, CB6, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
178 {"OscA-Pule", 2, CB7, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
179 {"OscA-PW", 0, C7, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
180 {"OscA-Sync", 2, CB8, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
181 /* osc b */
182 {"OscB-Transpose", 0, C6, R2, S1, S1, 0, 5, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
183 {"OscB-Tune", 0, C9, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, BRIGHTON_NOTCH},
184 {"OscB-Ramp", 2, CB9, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
185 {"OscB-Tri", 2, CB10, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
186 {"OscB-Pulse", 2, CB11, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
187 {"OscB-PW", 0, C10, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
188 {"OscB-LFO", 2, CB12, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
189 {"OscB-KBD", 2, CB13, RB2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
190 /* glide, etc */
191 {"Glide", 0, C6, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
192 {"Unison", 2, CB7, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
193 "bitmaps/buttons/presson.xpm", 0},
194 /* mixer */
195 {"Mix-OscA", 0, C11, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
196 {"Mix-OscB", 0, C12, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
197 {"Mix-Noise", 0, C13, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
198 /* filter + env */
199 {"VCF-Cutoff", 0, C14, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
200 {"VCF-Resonance", 0, C15, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
201 {"VCF-Envelope", 0, C16, R1, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
202 {"VCF-KBD", 2, C17 + 6, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", 0},
203 {"VCF-Attack", 0, C14, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
204 {"VCF-Decay", 0, C15, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
205 {"VCF-Sustain", 0, C16, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
206 {"VCF-Release", 0, C17, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
207 /* main env */
208 {"VCA-Attack", 0, C14, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
209 {"VCA-Decay", 0, C15, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
210 {"VCA-Sustain", 0, C16, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
211 {"VCA-Release", 0, C17, R3, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
212
213 /* tune + vol + pan */
214 {"LayerTuning", 0, C20, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, BRIGHTON_NOTCH},
215 {"LayerVolume", 0, C18, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, 0},
216 {"LayerPanning", 0, C19, R2, S1, S1, 0, 1, 0, "bitmaps/knobs/knob2.xpm", 0, BRIGHTON_NOTCH},
217
218 {"Release", 2, C19 + 10, RB4, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
219 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
220 /* A440 */
221 {"A-440", 2, C21 + 5, R2, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
222 "bitmaps/buttons/presson.xpm", 0},
223 {"Retune", 2, C21 + 7, RB4, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
224 "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
225 /* Dual/Layer/Poly */
226 {"Mode-Dual", 2, CB12 - 20, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
227 "bitmaps/buttons/presson.xpm", 0},
228 {"Mode-Layer", 2, CB12 + 15, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
229 "bitmaps/buttons/presson.xpm", 0},
230 {"Mode-Split", 2, CB12 + 50, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
231 "bitmaps/buttons/presson.xpm", 0},
232 /* Master Globals */
233 {"MasterVolume", 0, C17, RB4, S1, S1, 0, 1, 0, "bitmaps/knobs/knob3.xpm", 0, 0},
234 {"MasterPan", 0, C18, RB4, S1, S1, 0, 1, 0, "bitmaps/knobs/knob3.xpm", 0,
235 BRIGHTON_NOTCH},
236 {"MasterTune", 0, C20, RB4, S1, S1, 0, 1, 0, "bitmaps/knobs/knob3.xpm", 0,
237 BRIGHTON_NOTCH},
238 /* Chording */
239 {"", 2, C19 + 5, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
240 "bitmaps/buttons/presson.xpm", 0},
241 {"", 2, C20 + 5, R3, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm",
242 "bitmaps/buttons/presson.xpm", 0},
243 /* dummies */
244 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
245 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
246 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
247 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
248 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
249 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
250 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
251 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
252 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
253 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
254 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
255 {"", 0, C17, R3, S1, S1, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN},
256 /* memories */
257 {"", 2, C23 + 10, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
258 {"", 2, C23 + 31, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
259 {"", 2, C23 + 52, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
260 {"", 2, C23 + 73, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
261 {"", 2, C23 + 94, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
262 {"", 2, C23 + 115, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
263 {"", 2, C23 + 136, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
264 {"", 2, C23 + 157, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
265 {"", 2, C22, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
266 {"", 2, C22 + 30, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm", "bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
267 {"", 2, C22 + 60, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
268
269 {"", 2, C23 + 10, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
270 {"", 2, C23 + 31, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
271 {"", 2, C23 + 52, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
272 {"", 2, C23 + 73, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
273 {"", 2, C23 + 94, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
274 {"", 2, C23 + 115, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
275 {"", 2, C23 + 136, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
276 {"", 2, C23 + 157, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_RADIOBUTTON},
277 {"", 2, C22, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
278 {"", 2, C22 + 30, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm", "bitmaps/buttons/pressono.xpm", BRIGHTON_CHECKBUTTON},
279 {"", 2, C22 + 60, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", BRIGHTON_CHECKBUTTON},
280
281 /* Midi, perhaps eventually file import/export buttons */
282 {"", 2, C20 + 10, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
283 {"", 2, C21 + 10, RB1, B1, B2, 0, 1, 0, "bitmaps/buttons/pressoff.xpm", "bitmaps/buttons/presson.xpm", BRIGHTON_CHECKBUTTON},
284 /* Synth select */
285 {"Upper", 2, CB6 - 62, RB4, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", 0},
286 {"Lower", 2, CB6 - 62, RB5, B1, B3, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm", "bitmaps/buttons/pressong.xpm", 0},
287 /* LOGO */
288 {"", 4, 30, RB4, 143, 150, 0, 1, 0, "bitmaps/images/pro10.xpm", 0, 0},
289 /* Display */
290 {"", 3, C22 + 80, RB4, 130, B3, 0, 1, 0, 0,
291 "bitmaps/images/alphadisplay3.xpm", 0},
292 {"", 3, C22 + 80, RB5, 130, B3, 0, 1, 0, 0,
293 "bitmaps/images/alphadisplay3.xpm", 0}
294 };
295
296 /*
297 * This is for the lower mod panel. It will control the MIDI operational mode
298 * for poly/split/layer stuff and mod routing. It is not totally according to
299 * the original that used the panel for argeggio. This may also control some
300 * of the mod routing for each layer. It will not be saved in the memories.
301 */
302 #define P10_MOD_COUNT 15
303 static brightonLocations p10Mods[P10_MOD_COUNT] = {
304 /* lmod umod lpitch upitch */
305 {"", 2, 60, 122, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
306 "bitmaps/buttons/pressong.xpm", 0},
307 {"", 2, 260, 122, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
308 "bitmaps/buttons/pressong.xpm", 0},
309 {"", 2, 460, 122, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
310 "bitmaps/buttons/pressong.xpm", 0},
311 {"", 2, 660, 122, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
312 "bitmaps/buttons/pressong.xpm", 0},
313 {"", 2, 860, 122, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
314 "bitmaps/buttons/pressong.xpm", 0},
315
316 {"", 2, 60, 420, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
317 "bitmaps/buttons/pressong.xpm", 0},
318 {"", 2, 60, 625, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
319 "bitmaps/buttons/pressong.xpm", 0},
320 {"", 2, 60, 830, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
321 "bitmaps/buttons/pressong.xpm", 0},
322
323 {"", 2, 660, 420, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
324 "bitmaps/buttons/pressong.xpm", 0},
325 {"", 2, 860, 420, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
326 "bitmaps/buttons/pressong.xpm", 0},
327
328 {"", 2, 660, 625, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm",
329 "bitmaps/buttons/pressono.xpm", 0},
330 {"", 2, 860, 625, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
331 "bitmaps/buttons/pressong.xpm", 0},
332 {"", 2, 660, 830, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffo.xpm",
333 "bitmaps/buttons/pressono.xpm", 0},
334 {"", 2, 860, 830, 90, 140, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
335 "bitmaps/buttons/pressong.xpm", 0},
336
337 /* Rate */
338 {"", 0, 300, 520, 220, 220, 0, 1, 0, "bitmaps/knobs/knob3.xpm", 0, 0},
339 };
340
341 #define PMOD_COUNT 6
342 brightonLocations pmods[PMOD_COUNT] = {
343 {"", 1, 150, 170, 70, 620, 0, 1, 0, 0, 0,BRIGHTON_CENTER|BRIGHTON_NOSHADOW},
344 {"", 1, 350, 170, 70, 620, 0, 1, 0, 0, 0, BRIGHTON_NOSHADOW},
345
346 {"", 2, 580, 320, 90, 135, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
347 "bitmaps/buttons/pressong.xpm", 0},
348 {"", 2, 760, 320, 90, 135, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
349 "bitmaps/buttons/pressong.xpm", 0},
350 {"", 2, 580, 560, 90, 135, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
351 "bitmaps/buttons/pressong.xpm", 0},
352 {"", 2, 760, 560, 90, 135, 0, 1, 0, "bitmaps/buttons/pressoffg.xpm",
353 "bitmaps/buttons/pressong.xpm", 0},
354 };
355
356 #define LM_MOD_INDEX DEVICE_COUNT
357 #define UM_MOD_INDEX (LM_MOD_INDEX + P10_MOD_COUNT)
358
359 static int
pro10destroy(brightonWindow * win)360 pro10destroy(brightonWindow *win)
361 {
362 guiSynth *synth = findSynth(global.synths, win);
363
364 /*printf("pro10destroy(%i): %i\n", win, synth->midichannel); */
365 /*
366 * Since we registered two synths, we now need to remove the upper
367 * manual.
368 */
369 bristolMidiSendMsg(manual.controlfd, synth->sid2, 127, 0,
370 BRISTOL_EXIT_ALGO);
371 bristolMidiSendMsg(global.controlfd, synth->sid, 127, 0,
372 BRISTOL_EXIT_ALGO);
373 return(0);
374 }
375
376 /*
377 * This is a set of globals for the main window rendering. Again taken from
378 * include/brighton.h
379 */
380 brightonApp pro10App = {
381 "prophet10",
382 0, /* no blueprint on wood background. */
383 "bitmaps/textures/metal5.xpm",
384 0, /* BRIGHTON_STRETCH, //flags */
385 pro10Init,
386 pro10Configure, /* 3 callbacks, unused? */
387 midiCallback,
388 pro10destroy,
389 {10, 100, 2, 2, 5, 520, 0, 0},
390 745, 410, 0, 0,
391 7,
392 {
393 {
394 "Pro10",
395 "bitmaps/blueprints/prophet10.xpm",
396 "bitmaps/textures/metal5.xpm",
397 0, /*BRIGHTON_STRETCH, // flags */
398 0,
399 0,
400 pro10Callback,
401 15, 5, 970, 500,
402 DEVICE_COUNT,
403 locations
404 },
405 {
406 "Keyboard",
407 0,
408 "bitmaps/newkeys/kbg.xpm", /* flags */
409 0x020|BRIGHTON_STRETCH,
410 0,
411 0,
412 lmCallback,
413 148, 505, 860, 240,
414 KEY_COUNT,
415 keysprofile
416 },
417 {
418 "Mods",
419 "bitmaps/blueprints/prophet10mod.xpm",
420 "bitmaps/textures/metal5.xpm", /* flags */
421 0,
422 0,
423 0,
424 ummodCallback,
425 15, 505, 135, 240,
426 PMOD_COUNT,
427 pmods
428 },
429 {
430 "Keyboard",
431 0,
432 "bitmaps/newkeys/kbg.xpm", /* flags */
433 0x020|BRIGHTON_STRETCH,
434 0,
435 0,
436 lmCallback,
437 153, 745, 850, 240,
438 KEY_COUNT,
439 keysprofile
440 },
441 {
442 "Mods",
443 "bitmaps/blueprints/prophetmod2.xpm",
444 "bitmaps/textures/metal5.xpm", /* flags */
445 0,
446 0,
447 0,
448 lmmodCallback,
449 18, 745, 136, 240,
450 P10_MOD_COUNT,
451 p10Mods
452 },
453 {
454 "Pro10",
455 0,
456 "bitmaps/textures/wood2.xpm",
457 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
458 0,
459 0,
460 0,
461 0, 0, 15, 1000,
462 0,
463 0
464 },
465 {
466 "Pro10",
467 0,
468 "bitmaps/textures/wood2.xpm",
469 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /*flags */
470 0,
471 0,
472 0,
473 985, 0, 15, 1000,
474 0,
475 0
476 }
477 }
478 };
479
480 static int
midiCallback(brightonWindow * win,int controller,int value,float n)481 midiCallback(brightonWindow *win, int controller, int value, float n)
482 {
483 guiSynth *synth = findSynth(global.synths, win);
484
485 printf("midi callback: %i, %i\n", controller, value);
486
487 switch(controller)
488 {
489 case MIDI_PROGRAM:
490 printf("midi program: %x, %i\n", controller, value);
491 synth->location = value;
492 loadMemory(synth, "prophet", 0, synth->bank + synth->location,
493 synth->mem.active, 0, 0);
494 break;
495 case MIDI_BANK_SELECT:
496 printf("midi banksel: %x, %i\n", controller, value);
497 synth->bank = value;
498 break;
499 }
500 return(0);
501 }
502
503 /*
504 * Default dispatcher
505 */
506 static int
pro10MidiSendMsg(void * synth,int fd,int chan,int c,int o,int v)507 pro10MidiSendMsg(void *synth, int fd, int chan, int c, int o, int v)
508 {
509 bristolMidiSendMsg(fd, chan, c, o, v);
510 return(0);
511 }
512
513 static void
pro10DLP(guiSynth * synth,int fd,int chan,int c,int o,int v)514 pro10DLP(guiSynth *synth, int fd, int chan, int c, int o, int v)
515 {
516 brightonEvent event;
517
518 event.type = BRIGHTON_FLOAT;
519
520 if (synth->dispatch[RADIOSET_3].other2)
521 {
522 synth->dispatch[RADIOSET_3].other2 = 0;
523 return;
524 }
525
526 if (synth->dispatch[RADIOSET_3].other1 != -1)
527 {
528 synth->dispatch[RADIOSET_3].other2 = 1;
529
530 if (synth->dispatch[RADIOSET_3].other1 != c)
531 event.value = 0;
532 else
533 event.value = 1;
534
535 brightonParamChange(synth->win, synth->panel,
536 synth->dispatch[RADIOSET_3].other1 + RADIOSET_3, &event);
537 }
538 synth->dispatch[RADIOSET_3].other1 = c;
539
540 /* printf("pro10DLP(%i, %i)\n", c, v); */
541
542 /* We may have to consider Seq/Arpeg/Chord issues here */
543 switch (c) {
544 case 0:
545 /*
546 * Dual keyboard:
547 *
548 * Separate the midi channels
549 * Half the key count for primary layer
550 * Max out the split for second layer
551 */
552 keymode = MODE_DUAL;
553
554 /* Separate the midi channels */
555 if (synth->midichannel == 15) {
556 synth->midichannel--;
557 bristolMidiSendMsg(global.controlfd, synth->sid,
558 127, 0, BRISTOL_MIDICHANNEL|synth->midichannel);
559 bristolMidiSendMsg(global.controlfd, synth->sid2,
560 127, 0, (BRISTOL_MIDICHANNEL|synth->midichannel) + 1);
561 } else
562 bristolMidiSendMsg(global.controlfd, synth->sid2,
563 127, 0, (BRISTOL_MIDICHANNEL|synth->midichannel) + 1);
564
565 ((guiSynth *) synth->second)->midichannel = synth->midichannel + 1;
566
567 /* Halve the voicecount */
568 bristolMidiSendMsg(fd, chan, 126, 35, 1);
569
570 /* Configure a whole keyboard */
571 bristolMidiSendMsg(global.controlfd, synth->sid2,
572 127, 0, BRISTOL_LOWKEY|0);
573
574 break;
575 case 1:
576 /*
577 * Layered keyboards
578 *
579 * Join up the midi channels
580 * Half the key count for primary layer
581 * Max out the split for second layer
582 */
583 keymode = MODE_LAYER;
584
585 /* Join the midi channel */
586 bristolMidiSendMsg(global.controlfd, synth->sid2,
587 127, 0, (BRISTOL_MIDICHANNEL|synth->midichannel));
588 /* Halve the voicecount */
589 bristolMidiSendMsg(fd, chan, 126, 35, 1);
590 /* Configure a whole keyboard */
591 bristolMidiSendMsg(global.controlfd, synth->sid2,
592 127, 0, BRISTOL_LOWKEY|0);
593
594 ((guiSynth *) synth->second)->midichannel = synth->midichannel;
595
596 break;
597 case 2:
598 /*
599 * 10 Note Poly keyboards
600 *
601 * Join up the midi channels
602 * Double the key count for primary layer
603 * Zero out the split for second layer
604 */
605 keymode = MODE_POLY;
606
607 /* Join the midi channel although this is superfluous */
608 bristolMidiSendMsg(global.controlfd, synth->sid2,
609 127, 0, (BRISTOL_MIDICHANNEL|synth->midichannel));
610 /* Whole the voicecount */
611 bristolMidiSendMsg(fd, chan, 126, 35, 0);
612 /* Configure no keyboard */
613 bristolMidiSendMsg(global.controlfd, synth->sid2,
614 127, 0, BRISTOL_LOWKEY|127);
615
616 ((guiSynth *) synth->second)->midichannel = synth->midichannel;
617 break;
618 };
619 }
620
621 static void
multiA440(guiSynth * synth,int fd,int chan,int c,int o,int v)622 multiA440(guiSynth *synth, int fd, int chan, int c, int o, int v)
623 {
624 if (v != 0) {
625 bristolMidiSendMsg(fd, synth->sid, 126, 3, 1);
626 bristolMidiSendMsg(fd, synth->sid2, 126, 3, 1);
627 } else {
628 bristolMidiSendMsg(fd, synth->sid, 126, 3, 0);
629 bristolMidiSendMsg(fd, synth->sid2, 126, 3, 0);
630 }
631 }
632
633 static void
pro10Tune(guiSynth * synth,int fd,int chan,int c,int o,int v)634 pro10Tune(guiSynth *synth, int fd, int chan, int c, int o, int v)
635 {
636 float t1, t2, tg;
637 int value;
638
639 /*
640 * We have three different tuning parameters, these are one per layer plus
641 * the global tuning. Here we are going to send the respective tuning values
642 * to both the target synths.
643 */
644 t1 = synth->mem.param[45];
645 t2 = ((guiSynth *) synth->second)->mem.param[45];
646 tg = synth->mem.param[56] - 0.5;
647
648 if ((value = (t1 + tg) * C_RANGE_MIN_1) < 0)
649 value = 0;
650 if (value > C_RANGE_MIN_1)
651 value = C_RANGE_MIN_1;
652 bristolMidiSendMsg(fd, synth->sid, 126, 2, value);
653
654 if ((value = (t2 + tg) * C_RANGE_MIN_1) < 0)
655 value = 0;
656 if (value > C_RANGE_MIN_1)
657 value = C_RANGE_MIN_1;
658 bristolMidiSendMsg(fd, synth->sid2, 126, 2, value);
659 }
660
661 static void
multiTune(guiSynth * synth,int fd,int chan,int c,int o,int v)662 multiTune(guiSynth *synth, int fd, int chan, int c, int o, int v)
663 {
664 brightonEvent event;
665 int hold = synth->mem.param[PANEL_SWITCH];
666
667 /*printf("multiTune()\n"); */
668 /*
669 * Configures all the tune settings to zero (ie, 0.5). Do the Osc-A first,
670 * since it is not visible, and then request the GUI to configure Osc-B.
671 */
672 synth->mem.param[PANEL_SWITCH] = 1;
673 bristolMidiSendMsg(global.controlfd, synth->sid, 0, 2, 8191);
674 event.type = BRIGHTON_FLOAT;
675 event.value = 0.49;
676 brightonParamChange(synth->win, 0, 45, &event);
677 brightonParamChange(synth->win, 0, 21, &event);
678 event.value = 0.50;
679 brightonParamChange(synth->win, 0, 45, &event);
680 brightonParamChange(synth->win, 0, 21, &event);
681 /*
682 * This is global tuning outside of memories and should perhaps be left
683 * alone?
684 brightonParamChange(synth->win, 0, 56, &event);
685 */
686
687 synth->mem.param[PANEL_SWITCH] = 0;
688 bristolMidiSendMsg(global.controlfd, synth->sid2, 0, 2, 8191);
689 event.value = 0.49;
690 brightonParamChange(synth->win, 0, 45, &event);
691 brightonParamChange(synth->win, 0, 21, &event);
692 event.value = 0.50;
693 brightonParamChange(synth->win, 0, 45, &event);
694 brightonParamChange(synth->win, 0, 21, &event);
695
696 synth->mem.param[PANEL_SWITCH] = hold;
697
698 ((guiSynth *) synth->second)->mem.param[49] = 0.5;
699 synth->mem.param[49] = 0.5;
700 }
701
702 static void
midiRelease(guiSynth * synth,int fd,int chan,int c,int o,int v)703 midiRelease(guiSynth *synth, int fd, int chan, int c, int o, int v)
704 {
705 if (!global.libtest)
706 {
707 /*
708 * Midi release is ALL notes, ALL synths. If this behaviour (in the
709 * engine) changes we may need to put in an all_notes_off on the
710 * second manual as well.
711 */
712 bristolMidiSendMsg(fd, synth->sid, 127, 0,
713 BRISTOL_ALL_NOTES_OFF);
714 }
715 }
716
717 static int
ummodCallback(brightonWindow * win,int panel,int index,float value)718 ummodCallback(brightonWindow *win, int panel, int index, float value)
719 {
720 guiSynth *synth = findSynth(global.synths, win);
721
722 synth->mem.param[UM_MOD_INDEX + index] = value;
723
724 /*
725 * Selector buttonn debugs.
726 printf("ummodCallback(%i, %i, %f) [%f %f %f %f]\n", panel, index, value,
727 synth->mem.param[UM_MOD_INDEX + 2],
728 synth->mem.param[UM_MOD_INDEX + 3],
729 synth->mem.param[UM_MOD_INDEX + 4],
730 synth->mem.param[UM_MOD_INDEX + 5]
731 );
732 */
733
734 /*
735 * If this is controller 0 it is the frequency control, otherwise a
736 * generic controller 1.
737 */
738 if (index == 0)
739 {
740 if (synth->mem.param[UM_MOD_INDEX + 4] != 0)
741 bristolMidiSendMsg(global.controlfd, synth->midichannel + 1,
742 BRISTOL_EVENT_PITCH, 0, (int) (value * C_RANGE_MIN_1));
743 if (synth->mem.param[UM_MOD_INDEX + 2] != 0)
744 bristolMidiSendMsg(global.controlfd, synth->midichannel,
745 BRISTOL_EVENT_PITCH, 0, (int) (value * C_RANGE_MIN_1));
746 } else if (index == 1) {
747 if (synth->mem.param[UM_MOD_INDEX + 5] != 0)
748 bristolMidiControl(global.controlfd, synth->midichannel + 1,
749 0, 1, ((int) (value * C_RANGE_MIN_1)) >> 7);
750 if (synth->mem.param[UM_MOD_INDEX + 3] != 0)
751 bristolMidiControl(global.controlfd, synth->midichannel,
752 0, 1, ((int) (value * C_RANGE_MIN_1)) >> 7);
753 }
754
755 return(0);
756 }
757
758 static int
lmmodCallback(brightonWindow * win,int panel,int index,float value)759 lmmodCallback(brightonWindow * win, int panel, int index, float value)
760 {
761 guiSynth *synth = findSynth(global.synths, win);
762 brightonEvent event;
763 int ivalue = (int) (value * C_RANGE_MIN_1);
764
765 if (synth->dispatch[RADIOSET_4].other2)
766 {
767 synth->dispatch[RADIOSET_4].other2 = 0;
768 return(0);
769 }
770
771 if (synth->dispatch[RADIOSET_5].other2)
772 {
773 synth->dispatch[RADIOSET_5].other2 = 0;
774 return(0);
775 }
776
777 if (exclude)
778 return(0);
779
780 event.type = BRIGHTON_FLOAT;
781
782 /*
783 printf("lmmodCallback(%i, %i, %f)\n", panel, index, value);
784 */
785
786 synth->mem.param[DEVICE_COUNT + index] = value;
787
788 switch (index) {
789 case 0:
790 /* Lower Arpeg */
791 bristolMidiSendMsg(global.controlfd, synth->sid2,
792 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_ENABLE, ivalue);
793 break;
794 case 1:
795 /* Upper Arpeg */
796 bristolMidiSendMsg(global.controlfd, synth->sid,
797 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_ENABLE, ivalue);
798 break;
799 case 2:
800 case 3:
801 case 4:
802 /* Arpeg direction Up/UpDown/Down */
803 if (synth->dispatch[RADIOSET_4].other1 != -1)
804 {
805 synth->dispatch[RADIOSET_4].other2 = 1;
806
807 if (synth->dispatch[RADIOSET_4].other1 != index)
808 event.value = 0;
809 else
810 event.value = 1;
811
812 brightonParamChange(synth->win, 4,
813 synth->dispatch[RADIOSET_4].other1, &event);
814 }
815 synth->dispatch[RADIOSET_4].other1 = index;
816
817 bristolMidiSendMsg(global.controlfd, synth->sid,
818 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_DIR, index - 2);
819 bristolMidiSendMsg(global.controlfd, synth->sid,
820 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_DIR, index - 2);
821 bristolMidiSendMsg(global.controlfd, synth->sid2,
822 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_DIR, index - 2);
823 bristolMidiSendMsg(global.controlfd, synth->sid2,
824 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_DIR, index - 2);
825 break;
826 case 5:
827 case 6:
828 case 7:
829 /* Range 3 octaves */
830 /* Range 2 octaves */
831 /* Range 1 octaves */
832 /*
833 * We first need to ensure exclusion, then send the octave value.
834 */
835 if (synth->dispatch[RADIOSET_5].other1 != -1)
836 {
837 synth->dispatch[RADIOSET_5].other2 = 1;
838
839 if (synth->dispatch[RADIOSET_5].other1 != index)
840 event.value = 0;
841 else
842 event.value = 1;
843
844 brightonParamChange(synth->win, 4,
845 synth->dispatch[RADIOSET_5].other1, &event);
846 }
847 synth->dispatch[RADIOSET_5].other1 = index;
848
849 bristolMidiSendMsg(global.controlfd, synth->sid,
850 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RANGE, 7 - index);
851 bristolMidiSendMsg(global.controlfd, synth->sid,
852 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_RANGE, 7 - index);
853 bristolMidiSendMsg(global.controlfd, synth->sid2,
854 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RANGE, 7 - index);
855 bristolMidiSendMsg(global.controlfd, synth->sid2,
856 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_RANGE, 7 - index);
857 break;
858 case 8:
859 /* Lower Env Trigger */
860 bristolMidiSendMsg(global.controlfd, synth->sid2,
861 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_TRIGGER, ivalue);
862 break;
863 case 9:
864 /* Upper Env Trigger */
865 bristolMidiSendMsg(global.controlfd, synth->sid,
866 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_TRIGGER, ivalue);
867 break;
868 case 10:
869 /* Upper manual Seq Rec */
870 event.value = 0;
871 exclude = 1;
872 brightonParamChange(synth->win, 4, 11, &event);
873 exclude = 0;
874 bristolMidiSendMsg(global.controlfd, synth->sid,
875 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, 0);
876 bristolMidiSendMsg(global.controlfd, synth->sid,
877 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, ivalue);
878 seqLearn = ivalue;
879 break;
880 case 11:
881 /* Upper manual Seq Play */
882 event.value = 0;
883 exclude = 1;
884 brightonParamChange(synth->win, 4, 10, &event);
885 exclude = 0;
886 bristolMidiSendMsg(global.controlfd, synth->sid,
887 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 0);
888 bristolMidiSendMsg(global.controlfd, synth->sid,
889 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, ivalue);
890 seqLearn = 0;
891 break;
892 case 12:
893 /* Lower manual Seq Rec */
894 event.value = 0;
895 exclude = 1;
896 brightonParamChange(synth->win, 4, 13, &event);
897 exclude = 0;
898 bristolMidiSendMsg(global.controlfd, synth->sid2,
899 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, 0);
900 bristolMidiSendMsg(global.controlfd, synth->sid2,
901 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, ivalue);
902 seqLearn = ivalue;
903 break;
904 case 13:
905 /* Lower manual Seq Play */
906 event.value = 0;
907 exclude = 1;
908 brightonParamChange(synth->win, 4, 12, &event);
909 exclude = 0;
910 bristolMidiSendMsg(global.controlfd, synth->sid2,
911 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RESEQ, 0);
912 bristolMidiSendMsg(global.controlfd, synth->sid2,
913 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_ENABLE, ivalue);
914 seqLearn = 0;
915 break;
916 case 14:
917 /* Seq/Arp rate */
918 bristolMidiSendMsg(global.controlfd, synth->sid,
919 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RATE, ivalue);
920 bristolMidiSendMsg(global.controlfd, synth->sid,
921 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_RATE, ivalue);
922
923 bristolMidiSendMsg(global.controlfd, synth->sid2,
924 BRISTOL_ARPEGGIATOR, BRISTOL_SEQ_RATE, ivalue);
925 bristolMidiSendMsg(global.controlfd, synth->sid2,
926 BRISTOL_ARPEGGIATOR, BRISTOL_ARPEG_RATE, ivalue);
927 break;
928 }
929 return(0);
930 }
931
932 static void
pro10ChordInsert(guiSynth * synth,int note,int layer)933 pro10ChordInsert(guiSynth *synth, int note, int layer)
934 {
935 arpeggiatorMemory *seq = (arpeggiatorMemory *) synth->seq1.param;
936
937 if (layer != KEY_PANEL)
938 seq = (arpeggiatorMemory *) synth->seq2.param;
939
940 if (seq->c_count == 0)
941 seq->c_dif = note + synth->transpose;
942
943 seq->chord[(int) (seq->c_count)]
944 = (float) (note + synth->transpose - seq->c_dif);
945
946 // if (jupiterDebug(synth, 0))
947 printf("Chord put %i into %i\n", (int) seq->chord[(int) (seq->c_count)],
948 (int) (seq->c_count));
949
950 if ((seq->c_count += 1) >= BRISTOL_CHORD_MAX)
951 seq->c_count = BRISTOL_CHORD_MAX;
952 }
953
954 static void
pro10SeqInsert(guiSynth * synth,int note,int layer)955 pro10SeqInsert(guiSynth *synth, int note, int layer)
956 {
957 arpeggiatorMemory *seq = (arpeggiatorMemory *) synth->seq1.param;
958
959 if (layer != KEY_PANEL) {
960 printf(" Learning on second layer\n");
961 seq = (arpeggiatorMemory *) synth->seq2.param;
962 }
963
964 if (seq->s_max == 0)
965 seq->s_dif = note + synth->transpose;
966
967 seq->sequence[(int) (seq->s_max)] =
968 // (float) (note + synth->transpose - seq->s_dif);
969 (float) (note + synth->transpose);
970
971 // if (pro10Debug(synth, 0))
972 printf("Seq put %i into %i\n", (int) seq->sequence[(int) (seq->s_max)],
973 (int) (seq->s_max));
974
975 if ((seq->s_max += 1) >= BRISTOL_SEQ_MAX)
976 seq->s_max = BRISTOL_SEQ_MAX;
977 }
978
979 /*
980 * This used to send key events on one or two channels depending on the config.
981 * Nothing really wrong with that however it would be better to actually tell
982 * the emmulator what midi channels to use so that other master keyboards work
983 * as expected.
984 *
985 * For 10 vs 5 layered voices (layer versus poly) we also need to add some
986 * tweaks to the voicecounts.
987 *
988 * The code for all this is in the Jupiter, Bit* and OBXa.
989 */
990 static int
lmCallback(brightonWindow * win,int panel,int index,float value)991 lmCallback(brightonWindow * win, int panel, int index, float value)
992 {
993 guiSynth *synth = findSynth(global.synths, win);
994 int mchan;
995
996 /* printf("lmCallback(%i, %i, %f)\n", panel, index, value); */
997
998 if (global.libtest)
999 return(0);
1000
1001 if (panel == KEY_PANEL)
1002 mchan = synth->midichannel;
1003 else
1004 mchan = ((guiSynth *) synth->second)->midichannel;
1005
1006 if ((chordLearn) && (value != 0))
1007 pro10ChordInsert(synth, index, panel);
1008
1009 if ((seqLearn) && (value != 0))
1010 pro10SeqInsert(synth, index, panel);
1011
1012 /*
1013 * Want to send a note event, on or off, for this index + transpose.
1014 */
1015 if (value)
1016 bristolMidiSendMsg(global.controlfd, mchan,
1017 BRISTOL_EVENT_KEYON, 0, index + synth->transpose);
1018 else
1019 bristolMidiSendMsg(global.controlfd, mchan,
1020 BRISTOL_EVENT_KEYOFF, 0, index + synth->transpose);
1021
1022 return(0);
1023 }
1024
1025 static void
pro10PanelSwitch2(guiSynth * synth,int fd,int chan,int c,int o,int v)1026 pro10PanelSwitch2(guiSynth *synth, int fd, int chan, int c, int o, int v)
1027 {
1028 if (synth->flags & SUPPRESS)
1029 return;
1030
1031 if (v != 0) {
1032 brightonEvent event;
1033
1034 event.type = BRIGHTON_FLOAT;
1035 event.value = 0.0;
1036 brightonParamChange(synth->win, 0, PANEL_SWITCH, &event);
1037 }
1038 }
1039
1040 static void
pro10PanelSwitch(guiSynth * synth,int fd,int chan,int c,int o,int v)1041 pro10PanelSwitch(guiSynth *synth, int fd, int chan, int c, int o, int v)
1042 {
1043 brightonEvent event;
1044 int i;
1045
1046 /* printf("pro10PanelSwitch(%x, %i, %i, %i, %i, %1.0f)\n", */
1047 /* synth, fd, chan, c, o, global.synths->mem.param[PANEL_SWITCH]); */
1048
1049 /*
1050 * Prevent param changes when we are switching panels.
1051 */
1052 synth->flags |= SUPPRESS;
1053
1054 /*
1055 * Go through all the active devices, and force the GUI to represent
1056 * the new value.
1057 */
1058 if (synth->mem.param[PANEL_SWITCH] == 0)
1059 {
1060 /*
1061 * Go through all the params, and request an update to the GUI
1062 */
1063 for (i = 0; i < ACTIVE_DEVS; i++)
1064 {
1065 event.type = BRIGHTON_FLOAT;
1066 event.value = ((guiSynth *) synth->second)->mem.param[i] + 1;
1067 brightonParamChange(synth->win, 0, i, &event);
1068 event.value = ((guiSynth *) synth->second)->mem.param[i];
1069 brightonParamChange(synth->win, 0, i, &event);
1070 }
1071 } else {
1072 for (i = 0; i < ACTIVE_DEVS; i++)
1073 {
1074 event.type = BRIGHTON_FLOAT;
1075 event.value = synth->mem.param[i] + 1;
1076 brightonParamChange(synth->win, 0, i, &event);
1077 event.value = synth->mem.param[i];
1078 brightonParamChange(synth->win, 0, i, &event);
1079 }
1080 }
1081
1082 event.type = BRIGHTON_FLOAT;
1083 event.value = 1.0 - synth->mem.param[PANEL_SWITCH];
1084 brightonParamChange(synth->win, 0, PANEL_SWITCH + 1, &event);
1085
1086 synth->flags &= ~SUPPRESS;
1087 }
1088
1089 /*
1090 pro10MemoryShim(synth, "prophet", 0, synth->bank + synth->location,
1091 synth->mem.active, 0, 0) < 0)
1092 */
1093 static int
pro10MemoryShim(guiSynth * synth,char * algo,char * name,int location,int active,int skip,int flags)1094 pro10MemoryShim(guiSynth *synth, char *algo, char *name, int location,
1095 int active, int skip, int flags)
1096 {
1097 if ((synth->flags & REQ_DEBUG_MASK) >= REQ_MIDI_DEBUG2)
1098 printf("Shim %i\n", location);
1099
1100 /*
1101 * Decide which manual is operational, load it
1102 */
1103 if (synth->mem.param[PANEL_SWITCH] == 0)
1104 synth = ((guiSynth *) synth->second);
1105
1106 loadMemory(synth, "prophet", 0, location, synth->mem.active, 0, 0);
1107 loadSequence(&synth->seq1, "prophet", location, 0);
1108 fillSequencer(synth, (arpeggiatorMemory *) synth->seq1.param, 0);
1109
1110 return(0);
1111 }
1112
1113 static void
pro10MemoryLower(guiSynth * synth,int fd,int chan,int c,int o,int v)1114 pro10MemoryLower(guiSynth *synth, int fd, int chan, int c, int o, int v)
1115 {
1116 brightonEvent event;
1117
1118 event.type = BRIGHTON_FLOAT;
1119 event.value = 1.0;
1120
1121 /* printf("pro10MemoryLower(%i, %i)\n", c, o); */
1122
1123 if (synth->flags & MEM_LOADING)
1124 return;
1125 if ((synth->flags & OPERATIONAL) == 0)
1126 return;
1127
1128 if (synth->flags & SUPPRESS)
1129 return;
1130
1131 if (synth->dispatch[RADIOSET_2].other2)
1132 {
1133 synth->dispatch[RADIOSET_2].other2 = 0;
1134 return;
1135 }
1136
1137 if (synth->mem.param[PANEL_SWITCH] != 0)
1138 brightonParamChange(synth->win, 0, PANEL_SWITCH + 1, &event);
1139
1140 synth = ((guiSynth *) synth->second);
1141
1142 switch (c) {
1143 default:
1144 case 0:
1145 /*
1146 * We want to make these into memory buttons. To do so we need to
1147 * know what the last active button was, and deactivate its
1148 * display, then send any message which represents the most
1149 * recently configured value. Since this is a memory button we do
1150 * not have much issue with the message, but we are concerned with
1151 * the display.
1152 */
1153 if (synth->dispatch[RADIOSET_2].other1 != -1)
1154 {
1155 synth->dispatch[RADIOSET_2].other2 = 1;
1156
1157 if (synth->dispatch[RADIOSET_2].other1 != o)
1158 event.value = 0;
1159 else
1160 event.value = 1;
1161
1162 brightonParamChange(synth->win, synth->panel,
1163 synth->dispatch[RADIOSET_2].other1 + RADIOSET_2, &event);
1164 }
1165 synth->dispatch[RADIOSET_2].other1 = o;
1166
1167 if (synth->flags & BANK_SELECT) {
1168 if ((synth->bank * 10 + o * 10) >= 1000)
1169 {
1170 synth->location = o;
1171 synth->flags &= ~BANK_SELECT;
1172 if (loadMemory(synth, "prophet", 0,
1173 synth->bank + synth->location, synth->mem.active,
1174 0, BRISTOL_STAT) < 0)
1175 displayText(synth, "FRE", synth->bank + synth->location,
1176 DISPLAY_DEV_2);
1177 else
1178 displayText(synth, "PRG", synth->bank + synth->location,
1179 DISPLAY_DEV_2);
1180 } else {
1181 synth->bank = synth->bank * 10 + o * 10;
1182 if (loadMemory(synth, "prophet", 0,
1183 synth->bank + synth->location, synth->mem.active,
1184 0, BRISTOL_STAT) < 0)
1185 displayText(synth, "FRE", synth->bank + synth->location,
1186 DISPLAY_DEV_2);
1187 else
1188 displayText(synth, "BANK",
1189 synth->bank + synth->location, DISPLAY_DEV_2);
1190 }
1191 } else {
1192 if (synth->bank < 10)
1193 synth->bank = 10;
1194 synth->location = o;
1195 if (loadMemory(synth, "prophet", 0,
1196 synth->bank + synth->location, synth->mem.active,
1197 0, BRISTOL_STAT) < 0)
1198 displayText(synth, "FRE", synth->bank + synth->location,
1199 DISPLAY_DEV_2);
1200 else
1201 displayText(synth, "PRG", synth->bank + synth->location,
1202 DISPLAY_DEV_2);
1203 }
1204 break;
1205 case 1:
1206 if (synth->bank < 10)
1207 synth->bank = 10;
1208 if (synth->location == 0)
1209 synth->location = 1;
1210 if (loadMemory(synth, "prophet", 0, synth->bank + synth->location,
1211 synth->mem.active, 0, 0) < 0)
1212 displayText(synth, "FRE", synth->bank + synth->location,
1213 DISPLAY_DEV_2);
1214 else {
1215 displayText(synth, "PRG", synth->bank + synth->location,
1216 DISPLAY_DEV_2);
1217 loadSequence(&synth->seq1,
1218 "prophet", synth->bank + synth->location, 0);
1219 fillSequencer(synth, (arpeggiatorMemory *) synth->seq1.param, 0);
1220 }
1221 synth->flags &= ~BANK_SELECT;
1222 break;
1223 case 2:
1224 if (synth->bank < 10)
1225 synth->bank = 10;
1226 if (synth->location == 0)
1227 synth->location = 1;
1228 saveMemory(synth, "prophet", 0, synth->bank + synth->location,
1229 0);
1230 saveSequence(synth, "prophet", synth->bank + synth->location, 0);
1231 displayText(synth, "PRG", synth->bank + synth->location,
1232 DISPLAY_DEV_2);
1233 synth->flags &= ~BANK_SELECT;
1234 break;
1235 case 3:
1236 if (synth->flags & BANK_SELECT) {
1237 synth->flags &= ~BANK_SELECT;
1238 if (loadMemory(synth, "prophet", 0,
1239 synth->bank + synth->location, synth->mem.active,
1240 0, BRISTOL_STAT) < 0)
1241 displayText(synth, "FRE", synth->bank + synth->location,
1242 DISPLAY_DEV_2);
1243 else
1244 displayText(synth, "PRG", synth->bank + synth->location,
1245 DISPLAY_DEV_2);
1246 } else {
1247 synth->bank = 0;
1248 displayText(synth, "BANK", synth->bank, DISPLAY_DEV_2);
1249 synth->flags |= BANK_SELECT;
1250 }
1251 break;
1252 }
1253 /* printf(" pro10Memory(B: %i L %i: %i)\n", */
1254 /* synth->bank, synth->location, o); */
1255 }
1256
1257 static void
pro10Memory(guiSynth * synth,int fd,int chan,int c,int o,int v)1258 pro10Memory(guiSynth *synth, int fd, int chan, int c, int o, int v)
1259 {
1260 brightonEvent event;
1261
1262 event.type = BRIGHTON_FLOAT;
1263 event.value = 1.0;
1264
1265 /* printf("pro10Memory(%i, %i)\n", c, o); */
1266
1267 if (synth->flags & MEM_LOADING)
1268 return;
1269 if ((synth->flags & OPERATIONAL) == 0)
1270 return;
1271
1272 if (synth->flags & SUPPRESS)
1273 return;
1274
1275 if (synth->dispatch[RADIOSET_1].other2)
1276 {
1277 synth->dispatch[RADIOSET_1].other2 = 0;
1278 return;
1279 }
1280
1281 if (synth->mem.param[PANEL_SWITCH] == 0)
1282 brightonParamChange(synth->win, 0, PANEL_SWITCH, &event);
1283
1284 switch (c) {
1285 default:
1286 case 0:
1287 /*
1288 * We want to make these into memory buttons. To do so we need to
1289 * know what the last active button was, and deactivate its
1290 * display, then send any message which represents the most
1291 * recently configured value. Since this is a memory button we do
1292 * not have much issue with the message, but we are concerned with
1293 * the display.
1294 */
1295 if (synth->dispatch[RADIOSET_1].other1 != -1)
1296 {
1297 synth->dispatch[RADIOSET_1].other2 = 1;
1298
1299 if (synth->dispatch[RADIOSET_1].other1 != o)
1300 event.value = 0;
1301 else
1302 event.value = 1;
1303
1304 brightonParamChange(synth->win, synth->panel,
1305 synth->dispatch[RADIOSET_1].other1 + RADIOSET_1, &event);
1306 }
1307 synth->dispatch[RADIOSET_1].other1 = o;
1308
1309 if (synth->flags & BANK_SELECT) {
1310 if ((synth->bank * 10 + o * 10) >= 1000)
1311 {
1312 synth->location = o;
1313 synth->flags &= ~BANK_SELECT;
1314 if (loadMemory(synth, "prophet", 0,
1315 synth->bank + synth->location, synth->mem.active,
1316 0, BRISTOL_STAT) < 0)
1317 displayText(synth, "FRE", synth->bank + synth->location,
1318 DISPLAY_DEV);
1319 else
1320 displayText(synth, "PRG", synth->bank + synth->location,
1321 DISPLAY_DEV);
1322 } else {
1323 synth->bank = synth->bank * 10 + o * 10;
1324 if (loadMemory(synth, "prophet", 0,
1325 synth->bank + synth->location, synth->mem.active,
1326 0, BRISTOL_STAT) < 0)
1327 displayText(synth, "FRE", synth->bank + synth->location,
1328 DISPLAY_DEV);
1329 else
1330 displayText(synth, "BANK",
1331 synth->bank + synth->location, DISPLAY_DEV);
1332 }
1333 } else {
1334 if (synth->bank < 10)
1335 synth->bank = 10;
1336 synth->location = o;
1337 if (loadMemory(synth, "prophet", 0,
1338 synth->bank + synth->location, synth->mem.active,
1339 0, BRISTOL_STAT) < 0)
1340 displayText(synth, "FRE", synth->bank + synth->location,
1341 DISPLAY_DEV);
1342 else
1343 displayText(synth, "PRG", synth->bank + synth->location,
1344 DISPLAY_DEV);
1345 }
1346 break;
1347 case 1:
1348 if (synth->bank < 10)
1349 synth->bank = 10;
1350 if (synth->location == 0)
1351 synth->location = 1;
1352 if (loadMemory(synth, "prophet", 0, synth->bank + synth->location,
1353 synth->mem.active, 0, 0) < 0)
1354 displayText(synth, "FRE", synth->bank + synth->location,
1355 DISPLAY_DEV);
1356 else {
1357 displayText(synth, "PRG", synth->bank + synth->location,
1358 DISPLAY_DEV);
1359 loadSequence(&synth->seq1, "prophet",
1360 synth->bank + synth->location, 0);
1361 fillSequencer(synth,
1362 (arpeggiatorMemory *) synth->seq1.param, 0);
1363 }
1364 synth->flags &= ~BANK_SELECT;
1365 break;
1366 case 2:
1367 if (synth->bank < 10)
1368 synth->bank = 10;
1369 if (synth->location == 0)
1370 synth->location = 1;
1371 saveMemory(synth, "prophet", 0, synth->bank + synth->location,
1372 0);
1373 saveSequence(synth, "prophet", synth->bank + synth->location, 0);
1374 displayText(synth, "PRG", synth->bank + synth->location,
1375 DISPLAY_DEV);
1376 synth->flags &= ~BANK_SELECT;
1377 break;
1378 case 3:
1379 if (synth->flags & BANK_SELECT) {
1380 synth->flags &= ~BANK_SELECT;
1381 if (loadMemory(synth, "prophet", 0,
1382 synth->bank + synth->location, synth->mem.active,
1383 0, BRISTOL_STAT) < 0)
1384 displayText(synth, "FRE", synth->bank + synth->location,
1385 DISPLAY_DEV);
1386 else
1387 displayText(synth, "PRG", synth->bank + synth->location,
1388 DISPLAY_DEV);
1389 } else {
1390 synth->bank = 0;
1391 displayText(synth, "BANK", synth->bank, DISPLAY_DEV);
1392 synth->flags |= BANK_SELECT;
1393 }
1394 break;
1395 }
1396 /* printf(" pro10Memory(B: %i L %i: %i)\n", */
1397 /* synth->bank, synth->location, o); */
1398 }
1399
1400 static void
pro10Midi(guiSynth * synth,int fd,int chan,int c,int o,int v)1401 pro10Midi(guiSynth *synth, int fd, int chan, int c, int o, int v)
1402 {
1403 int newchan;
1404
1405 if ((synth->flags & OPERATIONAL) == 0)
1406 return;
1407
1408 if (c == 1) {
1409 if ((newchan = synth->midichannel - 1) < 0)
1410 {
1411 synth->midichannel = 0;
1412 return;
1413 }
1414 } else {
1415 if ((newchan = synth->midichannel + 1) > 14)
1416 {
1417 synth->midichannel = 14;
1418 return;
1419 }
1420 }
1421
1422 if (global.libtest == 0)
1423 {
1424 /*
1425 * Do second manual, then upper.
1426 */
1427 bristolMidiSendMsg(global.controlfd, synth->sid2,
1428 127, 0, (BRISTOL_MIDICHANNEL|newchan) + 1);
1429 bristolMidiSendMsg(global.controlfd, synth->sid,
1430 127, 0, BRISTOL_MIDICHANNEL|newchan);
1431 }
1432
1433 synth->midichannel = newchan;
1434
1435 /*printf("P: going to display: %x, %x\n", synth, synth->win); */
1436 displayText(synth, "MIDI", synth->midichannel + 1, DISPLAY_DEV);
1437 }
1438
1439 /*
1440 * For the sake of ease of use, links have been placed here to be called
1441 * by any of the devices created. They would be better in some other file,
1442 * perhaps with this as a dispatch.
1443 *
1444 * Param refers to the device index in the locations table given below.
1445 */
1446 static int
pro10Callback(brightonWindow * win,int panel,int index,float value)1447 pro10Callback(brightonWindow * win, int panel, int index, float value)
1448 {
1449 guiSynth *synth = findSynth(global.synths, win);
1450 int sendvalue, sid;
1451
1452 /*
1453 printf("pro10Callback(%i, %f): %1.0f\n", index, value,
1454 global.synths->mem.param[PANEL_SWITCH]);
1455 */
1456
1457 if (synth->flags & SUPPRESS)
1458 return(0);
1459
1460 if (synth == 0)
1461 return(0);
1462
1463 if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
1464 return(0);
1465
1466 if (pro10App.resources[0].devlocn[index].to == 1.0)
1467 sendvalue = value * (CONTROLLER_RANGE - 1);
1468 else
1469 sendvalue = value;
1470
1471 if (synth->mem.param[PANEL_SWITCH] != 0)
1472 {
1473 synth->mem.param[index] = value;
1474 sid = synth->sid;
1475 } else {
1476 ((guiSynth *) synth->second)->mem.param[index] = value;
1477 if (index >= ACTIVE_DEVS)
1478 synth->mem.param[index] = value;
1479 sid = synth->sid2;
1480 }
1481
1482
1483 if ((!global.libtest) || (index >= ACTIVE_DEVS))
1484 synth->dispatch[index].routine(synth,
1485 global.controlfd,
1486 sid,
1487 synth->dispatch[index].controller,
1488 synth->dispatch[index].operator,
1489 sendvalue);
1490
1491 #ifdef DEBUG
1492 else
1493 printf("dispatch[%p,%i](%i, %i, %i, %i, %i)\n", synth, index,
1494 global.controlfd, synth->sid,
1495 synth->dispatch[index].controller,
1496 synth->dispatch[index].operator,
1497 sendvalue);
1498 #endif
1499
1500 return(0);
1501 }
1502
1503 static void
pro10Balance(guiSynth * synth,int fd,int chan,int c,int o,int v)1504 pro10Balance(guiSynth *synth, int fd, int chan, int c, int o, int v)
1505 {
1506 float vol, bal;
1507
1508 vol = synth->mem.param[54];
1509 bal = synth->mem.param[55];
1510
1511 bristolMidiSendMsg(global.controlfd, synth->sid2, 126, 36,
1512 (int) (vol * (1.0 - bal) * C_RANGE_MIN_1));
1513
1514 bristolMidiSendMsg(global.controlfd, synth->sid, 126, 36,
1515 (int) (vol * bal * C_RANGE_MIN_1));
1516 }
1517
1518 static void
pro10Chord(guiSynth * synth,int fd,int chan,int c,int o,int v)1519 pro10Chord(guiSynth *synth, int fd, int chan, int c, int o, int v)
1520 {
1521 brightonEvent event;
1522 int sid = synth->sid;
1523
1524 if ((synth->flags & OPERATIONAL) == 0)
1525 return;
1526 if (synth->flags & MEM_LOADING)
1527 return;
1528
1529
1530 if (exclude)
1531 return;
1532
1533 event.type = BRIGHTON_FLOAT;
1534
1535 // if (jupiterDebug(synth, 1))
1536 printf("Chord request: %i %i %i (p=%f)\n", c, o, v, synth->mem.param[PANEL_SWITCH]);
1537
1538 if (synth->mem.param[PANEL_SWITCH] == 0)
1539 sid = synth->sid2;
1540
1541 /*
1542 * We can be called from Record or Play with values of on or off. The first
1543 * step is always to stop any peer processing such as stopping recording if
1544 * Play is selected, etc.
1545 *
1546 * After that we decide what to do, it may be start/stop recording or
1547 * start/stop playing a chord.
1548 */
1549 if (c == 0)
1550 {
1551 /* Record */
1552 if (v != 0)
1553 {
1554 if (synth->seq1.param == NULL)
1555 loadSequence(&synth->seq1, "prophet", 0, 0);
1556 if (synth->seq2.param == NULL)
1557 loadSequence(&synth->seq2, "prophet", 0, BRISTOL_SID2);
1558
1559 chordLearn = 1;
1560
1561 // if (jupiterDebug(synth, 0))
1562 printf("Chord learn requested %x\n", synth->flags);
1563
1564 if (synth->mem.param[PANEL_SWITCH] == 0)
1565 synth->seq2.param[1] = 0;
1566 else
1567 synth->seq1.param[1] = 0;
1568
1569 /*
1570 * This is to start a re-seq of the chord. Disable play if it was
1571 * selected then request resequence.
1572 */
1573 bristolMidiSendMsg(global.controlfd, sid,
1574 BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_ENABLE, 0);
1575
1576 event.value = 0;
1577 exclude = 1;
1578 brightonParamChange(synth->win, 0, 58, &event);
1579 exclude = 0;
1580
1581 bristolMidiSendMsg(global.controlfd, sid,
1582 BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 1);
1583 } else {
1584 chordLearn = 0;
1585 bristolMidiSendMsg(global.controlfd, sid,
1586 BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 0);
1587 }
1588
1589 return;
1590 }
1591
1592 if (chordLearn == 1) {
1593 /*
1594 * This is a button press during the learning sequence, in which case
1595 * it needs to be terminated.
1596 */
1597 chordLearn = 0;
1598 bristolMidiSendMsg(global.controlfd, sid,
1599 BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_RESEQ, 0);
1600
1601 event.value = 0;
1602 exclude = 1;
1603 brightonParamChange(synth->win, 0, 57, &event);
1604 exclude = 0;
1605 }
1606
1607 bristolMidiSendMsg(global.controlfd, sid,
1608 BRISTOL_ARPEGGIATOR, BRISTOL_CHORD_ENABLE, v);
1609
1610 return;
1611 }
1612
1613 static void
keyTracking(guiSynth * synth,int fd,int chan,int c,int o,int v)1614 keyTracking(guiSynth *synth, int fd, int chan, int c, int o, int v)
1615 {
1616 if (synth->mem.param[PANEL_SWITCH] -= 0)
1617 bristolMidiSendMsg(fd, synth->sid, 4, 3, v / 2);
1618 else
1619 bristolMidiSendMsg(fd, synth->sid2, 4, 3, v / 2);
1620 }
1621
1622 /*
1623 * Any location initialisation required to run the callbacks. For bristol, this
1624 * will connect to the engine, and give it some base parameters.
1625 * May need to generate some application specific menus.
1626 * Will also then make specific requests to some of the devices to alter their
1627 * rendering.
1628 */
1629 static int
pro10Init(brightonWindow * win)1630 pro10Init(brightonWindow *win)
1631 {
1632 guiSynth *synth = findSynth(global.synths, win);
1633 dispatcher *dispatch;
1634 int i;
1635
1636 if (synth == 0)
1637 {
1638 synth = findSynth(global.synths, 0);
1639 if (synth == 0)
1640 {
1641 printf("cannot init\n");
1642 return(0);
1643 }
1644 }
1645
1646 if ((initmem = synth->location) == 0)
1647 initmem = 11;
1648
1649 synth->win = win;
1650
1651 printf("Initialise the pro10 link to bristol: %p %p\n",
1652 synth, synth->win);
1653
1654 synth->mem.param = (float *) brightonmalloc(
1655 (DEVICE_COUNT + P10_MOD_COUNT + PMOD_COUNT) * sizeof(float));
1656 synth->mem.count = DEVICE_COUNT;
1657 synth->mem.active = ACTIVE_DEVS;
1658 synth->dispatch = (dispatcher *)
1659 brightonmalloc(
1660 (DEVICE_COUNT + P10_MOD_COUNT + PMOD_COUNT) * sizeof(dispatcher));
1661 dispatch = synth->dispatch;
1662
1663 synth->second = brightonmalloc(sizeof(guiSynth));
1664 bcopy(synth, ((guiSynth *) synth->second), sizeof(guiSynth));
1665 ((guiSynth *) synth->second)->mem.param =
1666 (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
1667 ((guiSynth *) synth->second)->mem.count = DEVICE_COUNT;
1668 ((guiSynth *) synth->second)->mem.active = ACTIVE_DEVS;
1669 ((guiSynth *) synth->second)->dispatch = synth->dispatch;
1670 /* If we have a default voice count then limit it */
1671 if (synth->voices == BRISTOL_VOICECOUNT) {
1672 ((guiSynth *) synth->second)->voices = 5;
1673 synth->voices = 10;
1674 } else
1675 ((guiSynth *) synth->second)->voices = synth->voices >> 1;
1676
1677 /*
1678 * We really want to have three connection mechanisms. These should be
1679 * 1. Unix named sockets.
1680 * 2. UDP sockets.
1681 * 3. MIDI pipe.
1682 */
1683 if (!global.libtest)
1684 {
1685 int v = synth->voices;
1686
1687 synth->synthtype = BRISTOL_PROPHET;
1688
1689 bcopy(&global, &manual, sizeof(guimain));
1690 if ((synth->sid = initConnection(&global, synth)) < 0)
1691 return(-1);
1692
1693 manual.flags |= BRISTOL_CONN_FORCE|BRIGHTON_NOENGINE;
1694 manual.host = global.host;
1695 manual.port = global.port;
1696
1697 synth->voices = ((guiSynth *) synth->second)->voices;
1698 /*
1699 * This looks a bit evil now but whatever happens it gets fixed later
1700 * when the dual/split/layer is configured - that will 'retweak' the
1701 * midi channels.
1702 */
1703 if (++synth->midichannel > 15)
1704 synth->midichannel = 15;
1705
1706 if ((synth->sid2 = initConnection(&manual, synth)) < 0)
1707 return(-1);
1708
1709 global.manualfd = manual.controlfd;
1710 global.manual = &manual;
1711 manual.manual = &global;
1712
1713 synth->midichannel--;
1714 synth->voices = v;
1715 } else {
1716 synth->sid = 5;
1717 synth->sid2 = 10;
1718 }
1719
1720 for (i = 0; i < DEVICE_COUNT; i++)
1721 synth->dispatch[i].routine = pro10MidiSendMsg;
1722
1723 dispatch[0].controller = 126;
1724 dispatch[0].operator = 6;
1725 dispatch[1].controller = 126;
1726 dispatch[1].operator = 7;
1727 dispatch[2].controller = 126;
1728 dispatch[2].operator = 8;
1729 dispatch[3].controller = 126;
1730 dispatch[3].operator = 9;
1731 dispatch[4].controller = 126;
1732 dispatch[4].operator = 10;
1733
1734 dispatch[5].controller = 2;
1735 dispatch[5].operator = 0;
1736 dispatch[6].controller = 126;
1737 dispatch[6].operator = 24;
1738 dispatch[7].controller = 126;
1739 dispatch[7].operator = 25;
1740 dispatch[8].controller = 126;
1741 dispatch[8].operator = 26;
1742
1743 dispatch[9].controller = 126;
1744 dispatch[9].operator = 11;
1745 dispatch[10].controller = 126;
1746 dispatch[10].operator = 12;
1747 dispatch[11].controller = 126;
1748 dispatch[11].operator = 13;
1749 dispatch[12].controller = 126;
1750 dispatch[12].operator = 14;
1751 dispatch[13].controller = 126;
1752 dispatch[13].operator = 15;
1753 dispatch[14].controller = 126;
1754 dispatch[14].operator = 16;
1755
1756 dispatch[15].controller = 0;
1757 dispatch[15].operator = 1;
1758 dispatch[16].controller = 0;
1759 dispatch[16].operator = 4;
1760 dispatch[17].controller = 0;
1761 dispatch[17].operator = 6;
1762 dispatch[18].controller = 0;
1763 dispatch[18].operator = 0;
1764 dispatch[19].controller = 0;
1765 dispatch[19].operator = 7;
1766
1767 dispatch[20].controller = 1;
1768 dispatch[20].operator = 1;
1769 dispatch[21].controller = 1;
1770 dispatch[21].operator = 2;
1771 dispatch[22].controller = 1;
1772 dispatch[22].operator = 4;
1773 dispatch[23].controller = 1;
1774 dispatch[23].operator = 5;
1775 dispatch[24].controller = 1;
1776 dispatch[24].operator = 6;
1777 dispatch[25].controller = 1;
1778 dispatch[25].operator = 0;
1779 dispatch[26].controller = 126;
1780 dispatch[26].operator = 18;
1781 dispatch[27].controller = 126;
1782 dispatch[27].operator = 19;
1783
1784 dispatch[28].controller = 126;
1785 dispatch[28].operator = 0;
1786 dispatch[29].controller = 126;
1787 dispatch[29].operator = 1;
1788
1789 dispatch[30].controller = 126;
1790 dispatch[30].operator = 20;
1791 dispatch[31].controller = 126;
1792 dispatch[31].operator = 21;
1793 dispatch[32].controller = 126;
1794 dispatch[32].operator = 22;
1795
1796 dispatch[33].controller = 4;
1797 dispatch[33].operator = 0;
1798 dispatch[34].controller = 4;
1799 dispatch[34].operator = 1;
1800 dispatch[35].controller = 126;
1801 dispatch[35].operator = 23;
1802 dispatch[36].controller = 4;
1803 dispatch[36].routine = (synthRoutine) keyTracking;
1804 dispatch[36].operator = 3;
1805 dispatch[37].controller = 3;
1806 dispatch[37].operator = 0;
1807 dispatch[38].controller = 3;
1808 dispatch[38].operator = 1;
1809 dispatch[39].controller = 3;
1810 dispatch[39].operator = 2;
1811 dispatch[40].controller = 3;
1812 dispatch[40].operator = 3;
1813
1814 dispatch[41].controller = 5;
1815 dispatch[41].operator = 0;
1816 dispatch[42].controller = 5;
1817 dispatch[42].operator = 1;
1818 dispatch[43].controller = 5;
1819 dispatch[43].operator = 2;
1820 dispatch[44].controller = 5;
1821 dispatch[44].operator = 3;
1822
1823 dispatch[45].controller = 126;
1824 dispatch[45].operator = 2;
1825 dispatch[45].routine = (synthRoutine) pro10Tune;
1826 /* Volume */
1827 dispatch[46].controller = 5;
1828 dispatch[46].operator = 4;
1829
1830 dispatch[47].controller = 126;
1831 dispatch[47].operator = 34;
1832
1833 dispatch[48].controller = 1;
1834 dispatch[48].operator = 1;
1835 dispatch[48].routine = (synthRoutine) midiRelease;
1836 dispatch[49].controller = 126;
1837 dispatch[49].operator = 3;
1838 dispatch[49].routine = (synthRoutine) multiA440;
1839 dispatch[50].controller = 1;
1840 dispatch[50].operator = 1;
1841 dispatch[50].routine = (synthRoutine) multiTune;
1842
1843 /* D/L/P */
1844 dispatch[51].controller = 0;
1845 dispatch[51].routine = (synthRoutine) pro10DLP;
1846 dispatch[52].controller = 1;
1847 dispatch[52].routine = (synthRoutine) pro10DLP;
1848 dispatch[53].controller = 2;
1849 dispatch[53].routine = (synthRoutine) pro10DLP;
1850
1851 /* Master gain */
1852 dispatch[54].controller = 126;
1853 dispatch[54].operator = 36;
1854 dispatch[54].routine = (synthRoutine) pro10Balance;
1855 /* Master balance */
1856 dispatch[55].controller = 126;
1857 dispatch[55].operator = 35;
1858 dispatch[55].routine = (synthRoutine) pro10Balance;
1859 dispatch[56].routine = (synthRoutine) pro10Tune;
1860
1861 /* Hold/Chord */
1862 dispatch[57].controller = 0;
1863 dispatch[57].operator = BRISTOL_CHORD_ENABLE;
1864 dispatch[57].routine = (synthRoutine) pro10Chord;
1865 dispatch[58].controller = 1;
1866 dispatch[58].operator = BRISTOL_CHORD_ENABLE;
1867 dispatch[58].routine = (synthRoutine) pro10Chord;
1868
1869 dispatch[71].operator = 1;
1870 dispatch[72].operator = 2;
1871 dispatch[73].operator = 3;
1872 dispatch[74].operator = 4;
1873 dispatch[75].operator = 5;
1874 dispatch[76].operator = 6;
1875 dispatch[77].operator = 7;
1876 dispatch[78].operator = 8;
1877
1878 dispatch[79].controller = 1;
1879 dispatch[80].controller = 2;
1880 dispatch[81].controller = 3;
1881
1882 dispatch[71].routine =
1883 dispatch[72].routine =
1884 dispatch[73].routine =
1885 dispatch[74].routine =
1886 dispatch[75].routine =
1887 dispatch[76].routine =
1888 dispatch[77].routine =
1889 dispatch[78].routine =
1890 dispatch[79].routine =
1891 dispatch[80].routine =
1892 dispatch[81].routine
1893 = (synthRoutine) pro10Memory;
1894
1895 dispatch[82].operator = 1;
1896 dispatch[83].operator = 2;
1897 dispatch[84].operator = 3;
1898 dispatch[85].operator = 4;
1899 dispatch[86].operator = 5;
1900 dispatch[87].operator = 6;
1901 dispatch[88].operator = 7;
1902 dispatch[89].operator = 8;
1903
1904 dispatch[90].controller = 1;
1905 dispatch[91].controller = 2;
1906 dispatch[92].controller = 3;
1907
1908 dispatch[82].routine =
1909 dispatch[83].routine =
1910 dispatch[84].routine =
1911 dispatch[85].routine =
1912 dispatch[86].routine =
1913 dispatch[87].routine =
1914 dispatch[88].routine =
1915 dispatch[89].routine =
1916 dispatch[90].routine =
1917 dispatch[91].routine =
1918 dispatch[92].routine
1919 = (synthRoutine) pro10MemoryLower;
1920
1921 dispatch[93].routine = dispatch[94].routine =
1922 (synthRoutine) pro10Midi;
1923 dispatch[93].controller = 1;
1924 dispatch[94].controller = 2;
1925
1926 dispatch[95].routine = (synthRoutine) pro10PanelSwitch;
1927 dispatch[96].routine = (synthRoutine) pro10PanelSwitch2;
1928
1929 dispatch[RADIOSET_1].other1 = -1;
1930 dispatch[RADIOSET_2].other1 = -1;
1931 dispatch[RADIOSET_3].other1 = -1;
1932 dispatch[RADIOSET_4].other1 = -1;
1933 dispatch[RADIOSET_5].other1 = -1;
1934 dispatch[DEVICE_COUNT].other1 = -1;
1935
1936 /* Tune osc-1 */
1937 bristolMidiSendMsg(global.controlfd, synth->sid, 0, 2, 8192);
1938 bristolMidiSendMsg(global.controlfd, synth->sid2, 0, 2, 8192);
1939 /* Gain on filter contour */
1940 bristolMidiSendMsg(global.controlfd, synth->sid, 3, 4,
1941 CONTROLLER_RANGE - 1);
1942 bristolMidiSendMsg(global.controlfd, synth->sid2, 3, 4,
1943 CONTROLLER_RANGE - 1);
1944 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 4, 4);
1945 bristolMidiSendMsg(global.controlfd, synth->sid2, 4, 4, 4);
1946
1947 return(0);
1948 }
1949
1950 static void
memForce(guiSynth * synth)1951 memForce(guiSynth *synth)
1952 {
1953 brightonEvent event;
1954 int i;
1955
1956 synth->flags |= SUPPRESS;
1957
1958 event.type = BRIGHTON_FLOAT;
1959 event.value = 1;
1960
1961 for (i = 0; i < ACTIVE_DEVS; i++)
1962 {
1963 brightonParamChange(synth->win, 0, i, &event);
1964 }
1965 event.value = 0;
1966 for (i = 0; i < ACTIVE_DEVS; i++)
1967 {
1968 brightonParamChange(synth->win, 0, i, &event);
1969 }
1970
1971 synth->flags &= ~SUPPRESS;
1972 }
1973
1974 /*
1975 * This will be called to make any routine specific parameters available.
1976 */
1977 static int
pro10Configure(brightonWindow * win)1978 pro10Configure(brightonWindow *win)
1979 {
1980 guiSynth *synth = findSynth(global.synths, win);
1981 brightonEvent event;
1982
1983 if (synth == 0)
1984 {
1985 printf("problems going operational\n");
1986 return(-1);
1987 }
1988
1989 if (synth->flags & OPERATIONAL)
1990 return(0);
1991
1992 printf("going operational: %p, %p\n", synth, win);
1993
1994 synth->flags |= OPERATIONAL;
1995 synth->keypanel = 1;
1996 synth->keypanel2 = 3;
1997 synth->transpose = 12;
1998
1999 synth->mem.param[PANEL_SWITCH] = 1;
2000
2001 synth->bank = 10;
2002 synth->location = 1;
2003 memForce(synth);
2004 loadMemory(synth, "prophet", 0, initmem, synth->mem.active, 0, 0);
2005 loadSequence(&synth->seq1, "prophet", initmem, 0);
2006 fillSequencer(synth, (arpeggiatorMemory *) synth->seq1.param, 0);
2007
2008 synth->mem.param[PANEL_SWITCH] = 0;
2009
2010 ((guiSynth *) synth->second)->resources = synth->resources;
2011 ((guiSynth *) synth->second)->win = synth->win;
2012 ((guiSynth *) synth->second)->bank = 10;
2013 ((guiSynth *) synth->second)->location = 2;
2014 ((guiSynth *) synth->second)->panel = 0;
2015 ((guiSynth *) synth->second)->mem.active = ACTIVE_DEVS;
2016 ((guiSynth *) synth->second)->transpose = 12;
2017
2018 memForce(((guiSynth *) synth->second));
2019 loadMemory(((guiSynth *) synth->second), "prophet", 0, initmem + 1,
2020 synth->mem.active, 0, 0);
2021
2022 synth->mem.param[PANEL_SWITCH] = 0;
2023
2024 /*
2025 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
2026 * occurs on first paint, so we suppress the first paint, and then request
2027 * an expose here.
2028 */
2029 brightonPut(win,
2030 "bitmaps/blueprints/prophet10shade.xpm", 0, 0, win->width, win->height);
2031 event.type = BRIGHTON_EXPOSE;
2032 event.intvalue = 1;
2033 brightonParamChange(synth->win, KEY_PANEL, -1, &event);
2034 event.type = BRIGHTON_EXPOSE;
2035 event.intvalue = 1;
2036 brightonParamChange(synth->win, KEY_PANEL + 2, -1, &event);
2037
2038 event.type = BRIGHTON_FLOAT;
2039 event.value = 1.0f;
2040 brightonParamChange(synth->win, 2, 2, &event);
2041 brightonParamChange(synth->win, 2, 3, &event);
2042 brightonParamChange(synth->win, 2, 4, &event);
2043 brightonParamChange(synth->win, 2, 5, &event);
2044 brightonParamChange(synth->win, 4, 2, &event);
2045 brightonParamChange(synth->win, 4, 6, &event);
2046 brightonParamChange(synth->win, 4, 8, &event);
2047 brightonParamChange(synth->win, 4, 9, &event);
2048 brightonParamChange(synth->win, 0, RADIOSET_1 + 1, &event);
2049 brightonParamChange(synth->win, 0, RADIOSET_2 + 2, &event);
2050 configureGlobals(synth);
2051
2052 brightonParamChange(synth->win, 0, 51, &event);
2053
2054 /* Master controls */
2055 event.value = 0.8f;
2056 brightonParamChange(synth->win, 0, 54, &event);
2057 event.value = 0.5f;
2058 brightonParamChange(synth->win, 0, 55, &event);
2059 event.value = 0.5f;
2060 brightonParamChange(synth->win, 0, 56, &event);
2061 event.value = 1.0;
2062 brightonParamChange(synth->win, 0, PANEL_SWITCH, &event);
2063
2064 synth->loadMemory = (loadRoutine) pro10MemoryShim;
2065
2066 return(0);
2067 }
2068
2069