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 * Mods:
24 *
25 * LFO sync, Multi each 4 - 4 switches
26 * Osc detune and ramp 2, multithread option - 2 knob 1 switch
27 * Noise pink/multi - switch knob
28 * Envelope velocity, retrig, gain both 6 - 4 switches 2 knob
29 * Resonance res and mix high/low 4 (algo select for each?) 4 knob
30 * Filter mix, kbd tracking? 2 knob
31 *
32 * More signal into the filters, less out DONE
33 * Multiplying mods
34 * LFO/Env gain gives droning, mono mode
35 * Oscillator is dull SOME - multiple strands
36 * Load opts only once, or when double click load button DONE
37 *
38 * Remixed oscillators are also pretty dull, the only net effect appears to be
39 * a volume gain. Rework the code for add/subtract of different poles and/or
40 * add/sub different remix poles also.
41 */
42
43 #include <fcntl.h>
44
45 #include "brighton.h"
46 #include "brightonMini.h"
47 #include "brightoninternals.h"
48
49 static int BME700Init();
50 static int BME700Configure();
51 static int BME700Callback(brightonWindow *, int, int, float);
52 static int BME700ModCallback(brightonWindow *, int, int, float);
53 static int midiCallback(brightonWindow *, int, int, float);
54 static int BME700KeyCallback(brightonWindow *, int, int, float);
55
56 extern guimain global;
57
58 #include "brightonKeys.h"
59
60 #define SYNTH_NAME synth->resources->name
61
62 #define OPTS_START 43
63 #define OPTS_COUNT 32
64 #define ACTIVE_DEVS (OPTS_START + OPTS_COUNT)
65 #define MEM_MGT ACTIVE_DEVS
66 #define MIDI_MGT (MEM_MGT + 12)
67
68 #define MODS_COUNT 12
69
70 #define DEVICE_COUNT (ACTIVE_DEVS + 2)
71
72 #define KEY_PANEL 1
73 #define MODS_PANEL 2
74 #define DISPLAY_DEV (OPTS_COUNT - 6)
75
76 static int dc;
77 static int shade_id;
78
79 /*
80 * This structure is for device definition. The structure is defined in
81 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
82 * include/brightoninternals.h
83 *
84 * typedef int (*brightonCallback)(int, float);
85 * typedef struct BrightonLocations {
86 * int device; 0=rotary, 1=scale, etc.
87 * float relx, rely; relative position with regards to 1000 by 1000 window
88 * float relw, relh; relative height.
89 * int from, to;
90 * brightonCallback callback; specific to this dev
91 * char *image; bitmap. If zero take a device default.
92 * int flags;
93 * } brightonLocations;
94 *
95 * This example is for a BME700Bristol type synth interface.
96 */
97
98 #define SPW 50
99 #define SPH 110
100
101 #define R1 110
102 #define R1b (R1 + SPH / 4)
103 #define R2 330
104 #define R2b (R2 + SPH / 4)
105 #define R3 575
106 #define R3b (R3 + SPH / 4)
107 #define R4 795
108 #define R4b (R4 + SPH / 4)
109
110 #define D1 65
111
112 #define C1 36
113 #define C1b (C1 + SPW/3)
114 #define C2 (C1 + D1)
115 #define C2b (C2 + D1 / 2)
116 #define C3 (C2 + D1)
117 #define C3b (C3 + SPW/3)
118 #define C4 (C3 + D1)
119 #define C4b (C4 + SPW/3)
120
121 #define C10 401
122 #define C10b (C10 + SPW/3)
123
124 #define C20 570
125 #define C20b (C20 + SPW/3)
126 #define C21 (C20 + D1)
127 #define C21b (C21 + SPW/3)
128 #define C22 (C21 + D1)
129
130 #define C30 810
131 #define C30b (C30 + SPW/3)
132 #define C31 (C30 + D1)
133 #define C32 (C31 + D1)
134
135 static
136 brightonLocations locations[DEVICE_COUNT] = {
137 /* 0 */
138 {"Mod1 Tri/Square", 2, C1b, R1b, 10, 60, 0, 1.01, 0,
139 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
140 {"Mod1 Rate", 0, C2, R1, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
141 {"Mod2 Rate", 0, C3, R1, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
142 {"Mod2 Tri/Square", 2, C4b, R1b, 10, 60, 0, 1.01, 0,
143 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
144
145 /* 4 */
146 {"Mod1/Env", 2, C1b + 35, R2b, 10, 60, 0, 1.01, 0,
147 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
148 {"ModMix", 0, C2b, R2, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
149 {"Single/Double", 2, C4, R2b, 10, 60, 0, 1.01, 0,
150 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
151 {"Tri/Square", 2, C4b + 12, R2b, 10, 60, 0, 1.01, 0,
152 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
153
154 /* 8 */
155 {"VCO Glide", 0, C1, R3, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
156 {"VCO PW", 0, C2, R3, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
157 {"VCO Vibrato", 0, C3, R3, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
158 {"VCO Shape", 0, C3, R4, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
159 {"Glide On/Off", 2, C1b, R4b, 10, 60, 0, 1.01, 0,
160 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
161 {"PW Man/Auto", 2, C2 - 1, R4b, 10, 60, 0, 1.01, 0,
162 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
163 {"PW Env/Mod", 2, C2b, R4b, 10, 60, 0, 1.01, 0,
164 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
165 {"VCO 8'", 2, C4, R4b, 10, 60, 0, 1.01, 0,
166 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
167 {"VCO 16'/4'", 2, C4b + 12, R4b, 10, 60, 0, 1.01, 0,
168 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
169
170 /* 17 */
171 {"Mix Noise/VCO", 0, C10, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
172
173 {"Res #/b", 2, C10b, R3b, 10, 60, 0, 1.01, 0,
174 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
175
176 /* 19 */
177 {"Res 1", 2, C10b - 60, R4b, 10, 60, 0, 1.01, 0,
178 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
179 {"Res 2", 2, C10b - 30, R4b, 10, 60, 0, 1.01, 0,
180 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
181 {"Res 4", 2, C10b, R4b, 10, 60, 0, 1.01, 0,
182 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
183 {"Res 8", 2, C10b + 30, R4b, 10, 60, 0, 1.01, 0,
184 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
185 {"Res 16", 2, C10b + 60, R4b, 10, 60, 0, 1.01, 0,
186 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
187
188 /* 24 */
189 {"Env1 ASR/AR", 2, C20b, R1b, 10, 60, 0, 1.01, 0,
190 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
191 {"Attack", 0, C21, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
192 {"Decay", 0, C22, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
193 {"Env2 ASR/AR", 2, C30b, R1b, 10, 60, 0, 1.01, 0,
194 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
195 {"Attack", 0, C31, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
196 {"Decay", 0, C32, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
197
198 /* 30 */
199 {"VCF Env Mix", 0, C21, R2, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
200 {"VCA Env Mix", 0, C31, R2, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
201
202 /* 32 */
203 {"Filt Resonace", 0, C20, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
204 {"Filt Cutoff", 0, C21, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
205 {"Filt Env", 0, C22, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
206 {"Filt ModMix", 0, C22, R4, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
207 {"F-Mod Tri/Sqr", 2, C20b, R4b, 10, 60, 0, 1.01, 0,
208 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
209 {"F-Mod1/Mod2", 2, C21 - 7, R4b, 10, 60, 0, 1.01, 0,
210 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
211 {"F-KBD/Mod", 2, C21b + 12, R4b, 10, 60, 0, 1.01, 0,
212 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
213
214 /* 39 */
215 {"Mix VCF/Res", 0, C30, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
216 {"VCA ModMix", 0, C32, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
217 {"VCA Mod Mod1/Mod2", 2, C30b + 36, R4b, 10, 60, 0, 1.01, 0,
218 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
219 {"VCA Mod Tri/Sqr", 2, C30b + 101, R4b, 10, 60, 0, 1.01, 0,
220 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
221
222 /* 43 - 32 dummies masking opts */
223 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
224 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
225 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
226 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
227 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
228 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
229 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
230 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
231 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
232 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
233 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
234 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
235 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
236 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
237 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
238 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
239 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
240 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
241 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
242 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
243 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
244 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
245 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
246 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
247 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
248 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
249 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
250 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
251 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
252 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
253 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
254 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
255
256 /* 59 Tuning, moved out of active devs */
257 {"Tuning", 0, C4, R3, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0,
258 BRIGHTON_NOTCH},
259 /* 60 Global volume, moved out of active devs */
260 {"Volume", 0, C31, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
261 /* Done */
262 };
263
264 /*
265 * Memory panel, keep it simple - 8 memories, load save, up, down. Uses cs80 backlit buttons
266 */
267 static
268 brightonLocations bme700mods[MODS_COUNT] = {
269 /* LOAD */
270 {"", 2, 190, 700, 100, 100, 0, 1, 0, "bitmaps/buttons/touchnlo.xpm",
271 "bitmaps/buttons/touchnlO.xpm", BRIGHTON_CHECKBUTTON},
272
273 /* MEMORY SELECT */
274 {"", 2, 190, 200, 100, 100, 0, 1, 0,
275 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
276 {"", 2, 390, 200, 100, 100, 0, 1, 0,
277 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
278 {"", 2, 590, 200, 100, 100, 0, 1, 0,
279 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
280 {"", 2, 790, 200, 100, 100, 0, 1, 0,
281 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
282
283 {"", 2, 190, 450, 100, 100, 0, 1, 0,
284 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
285 {"", 2, 390, 450, 100, 100, 0, 1, 0,
286 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
287 {"", 2, 590, 450, 100, 100, 0, 1, 0,
288 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
289 {"", 2, 790, 450, 100, 100, 0, 1, 0,
290 "bitmaps/buttons/touchnlw.xpm", "bitmaps/buttons/touchnlW.xpm", 0},
291
292 /* SAVE */
293 {"", 2, 390, 700, 100, 100, 0, 1, 0, "bitmaps/buttons/touchnlr.xpm",
294 "bitmaps/buttons/touchnlR.xpm", BRIGHTON_CHECKBUTTON},
295
296 /*
297 * UP/DOWN was memory but could be midi channel. Withdrawn for now since I want to keep
298 * this panel uncluttered
299 */
300 {"", 2, 590, 700, 100, 100, 0, 1, 0, "bitmaps/buttons/touchnlg.xpm",
301 "bitmaps/buttons/touchnlG.xpm", BRIGHTON_CHECKBUTTON},
302 {"", 2, 790, 700, 100, 100, 0, 1, 0, "bitmaps/buttons/touchnlo.xpm",
303 "bitmaps/buttons/touchnlO.xpm", 0},
304 };
305
306 static
307 brightonLocations bme700opts[OPTS_COUNT] = {
308 {"", 2, C1b, R1b, 10, 60, 0, 1.00, 0,
309 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
310 {"", 2, C1b + 50, R1b, 10, 60, 0, 1.0, 0,
311 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
312
313 {"", 2, C4b - 50, R1b, 10, 60, 0, 1.0, 0,
314 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
315 {"", 2, C4b, R1b, 10, 60, 0, 1.00, 0,
316 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
317
318 {"", 0, 0, 0, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0,
319 BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
320 {"", 0, C2, R3, SPW, SPH, 0, 1, 0, "bitmaps/knobs/yellowknob.xpm", 0, 0},
321 {"", 2, C1b, R3b, 10, 60, 0, 1.00, 0,
322 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
323
324 /* Noise Pink + filter */
325 {"", 2, C10-5, R1b, 10, 60, 0, 1.00, 0,
326 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
327 {"", 0, C10+40, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
328
329 {"", 0, C10-40, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
330 {"", 0, C10+40, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
331 {"", 0, C10-40, R4, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
332 {"", 0, C10+40, R4, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
333
334 {"", 2, C20b, R1b, 10, 60, 0, 1.00, 0,
335 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
336 {"", 2, C21+12, R1b, 10, 60, 0, 1.00, 0,
337 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
338 {"", 0, C22, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
339
340 {"", 2, C30b, R1b, 10, 60, 0, 1.00, 0,
341 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
342 {"", 2, C31+12, R1b, 10, 60, 0, 1.00, 0,
343 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
344 {"", 0, C32, R1, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
345
346 {"", 0, C20, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
347 {"", 0, C21, R3, SPW, SPH, 0, 1, 0,"bitmaps/knobs/yellowknob.xpm", 0, 0},
348
349 /* Noise Multi */
350 {"", 2, C10-45, R1b, 10, 60, 0, 1.00, 0,
351 "bitmaps/buttons/klunk4.xpm", 0, BRIGHTON_VERTICAL},
352
353 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
354 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
355 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
356 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
357 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
358 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
359 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
360 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
361 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
362 {"", 0, 0, 0, 10, 10, 0, 1, 0, 0, 0, BRIGHTON_WITHDRAWN|BRIGHTON_NOSHADOW},
363 };
364
365 /*
366 * This is a set of globals for the main window rendering. Again taken from
367 * include/brighton.h
368 */
369 brightonApp bme700App = {
370 "BME700",
371 0, /* no blueprint on wood background. */
372 "bitmaps/textures/metal6.xpm",
373 BRIGHTON_STRETCH,
374 BME700Init,
375 BME700Configure, /* 3 callbacks, unused? */
376 midiCallback,
377 destroySynth,
378 {1, 100, 2, 2, 5, 520, 0, 0},
379 800, 417, 0, 0,
380 7,
381 {
382 {
383 "Bme700",
384 "bitmaps/blueprints/BME700.xpm",
385 "bitmaps/textures/metal5.xpm",
386 0, /* flags */
387 0,
388 0,
389 BME700Callback,
390 22, 0, 956, 600,
391 DEVICE_COUNT,
392 locations
393 },
394 {
395 "Keyboard",
396 0,
397 "bitmaps/newkeys/tkbg.xpm",
398 0x020|BRIGHTON_STRETCH,
399 0,
400 0,
401 BME700KeyCallback,
402 172, 600, 800, 350,
403 KEY_COUNT_3_OCTAVE,
404 keys3_octave
405 },
406 {
407 "Bme700Mods",
408 "bitmaps/blueprints/BME700mods.xpm",
409 "bitmaps/textures/bme700bg.xpm",
410 BRIGHTON_STRETCH, /* flags */
411 0,
412 0,
413 BME700ModCallback,
414 22, 600, 150, 350,
415 MODS_COUNT,
416 bme700mods
417 },
418 {
419 "Bme700Opts",
420 "bitmaps/blueprints/BME700opts.xpm",
421 "bitmaps/textures/metal5.xpm",
422 BRIGHTON_WITHDRAWN, /* flags */
423 0,
424 0,
425 BME700Callback,
426 22, 0, 956, 600,
427 OPTS_COUNT,
428 bme700opts
429 },
430 {
431 "SP2",
432 0,
433 "bitmaps/textures/wood.xpm",
434 BRIGHTON_STRETCH, /* flags */
435 0,
436 0,
437 0,
438 23, 955, 954, 44,
439 0,
440 0
441 },
442 {
443 "SP2",
444 0,
445 "bitmaps/textures/wood.xpm",
446 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
447 0,
448 0,
449 0,
450 0, 0, 22, 1000,
451 0,
452 0
453 },
454 {
455 "SP2",
456 0,
457 "bitmaps/textures/wood.xpm",
458 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
459 0,
460 0,
461 0,
462 978, 0, 22, 1000,
463 0,
464 0
465 },
466 }
467 };
468
469 /*
470 * We really want to just use one midi channel and let the midi library decide
471 * that we have multiple synths on the channel with their own split points.
472 * The lower layer should define the midi channel, split point and transpose
473 * of upper layer.
474 */
475 static int
BME700KeyCallback(brightonWindow * win,int panel,int index,float value)476 BME700KeyCallback(brightonWindow *win, int panel, int index, float value)
477 {
478 guiSynth *synth = findSynth(global.synths, win);
479
480 if (global.libtest)
481 return(0);
482
483 /*
484 * So we have a single key event and two MIDI channels. Just send the
485 * event on both channels, no need to be difficult about it since if this
486 * was a split configuration the library filters out the events.
487 */
488 if (value) {
489 bristolMidiSendMsg(global.controlfd, synth->midichannel,
490 BRISTOL_EVENT_KEYON, 0, index + synth->transpose);
491 } else {
492 bristolMidiSendMsg(global.controlfd, synth->midichannel,
493 BRISTOL_EVENT_KEYOFF, 0, index + synth->transpose);
494 }
495
496 return(0);
497 }
498
499 static void
optsShim(guiSynth * synth)500 optsShim(guiSynth *synth)
501 {
502 int i;
503 brightonEvent event;
504
505 event.type = BRISTOL_FLOAT;
506
507 for (i = 0; i < OPTS_COUNT; i++)
508 {
509 event.value = synth->mem.param[i + OPTS_START];
510 brightonParamChange(synth->win, 3, i, &event);
511 }
512 }
513
514 static void
panelSwitch(brightonWindow * win,guiSynth * synth,float value)515 panelSwitch(brightonWindow *win, guiSynth *synth, float value)
516 {
517 brightonEvent event;
518
519 /*
520 * If the sendvalue is zero, then withdraw the opts window, draw the
521 * slider window, and vice versa.
522 */
523 if (value == 0)
524 {
525 event.type = BRIGHTON_EXPOSE;
526 event.intvalue = 0;
527 brightonParamChange(synth->win, 3, -1, &event);
528 event.intvalue = 1;
529 brightonParamChange(synth->win, 0, -1, &event);
530
531 shade_id = brightonPut(synth->win, "bitmaps/blueprints/BME700shade.xpm",
532 0, 0, synth->win->width, synth->win->height);
533 } else {
534 event.type = BRIGHTON_EXPOSE;
535 event.intvalue = 0;
536 brightonParamChange(synth->win, 0, -1, &event);
537 event.intvalue = 1;
538 brightonParamChange(synth->win, 3, -1, &event);
539
540 brightonRemove(synth->win, shade_id);
541 }
542 }
543
544 static int
midiCallback(brightonWindow * win,int controller,int value,float n)545 midiCallback(brightonWindow *win, int controller, int value, float n)
546 {
547 guiSynth *synth = findSynth(global.synths, win);
548
549 switch(controller)
550 {
551 case MIDI_PROGRAM:
552 if (synth->mem.param[87] == 0)
553 return(0);
554 /*
555 * We should accept 0..74 as lower layer and above that as dual
556 * loading requests.
557 */
558 printf("midi program: %x, %i\n", controller, value);
559 synth->location = value;
560 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
561 OPTS_START, 0, BRISTOL_FORCE);
562 optsShim(synth);
563 break;
564 case MIDI_BANK_SELECT:
565 printf("midi banksel: %x, %i\n", controller, value);
566 synth->bank = value;
567 synth->location = value;
568 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
569 OPTS_START, 0, BRISTOL_FORCE);
570 break;
571 }
572 return(0);
573 }
574
575 static void
BME700MidiShim(guiSynth * synth,int fd,int chan,int c,int o,int v)576 BME700MidiShim(guiSynth *synth, int fd, int chan, int c, int o, int v)
577 {
578 bristolMidiSendMsg(fd, synth->sid, c, o, v);
579 }
580
581 static int
BME700ModCallback(brightonWindow * win,int panel,int index,float value)582 BME700ModCallback(brightonWindow *win, int panel, int index, float value)
583 {
584 guiSynth *synth = findSynth(global.synths, win);
585 brightonEvent event;
586 int start = synth->location;
587
588 if (global.libtest)
589 printf("BME700ModCallback(%i, %f)\n", index, value);
590
591 if (synth->dispatch[ACTIVE_DEVS].other2)
592 {
593 synth->dispatch[ACTIVE_DEVS].other2 = 0;
594 return(0);
595 }
596
597 switch (index) {
598 case 0:
599 /* Load */
600 if (brightonDoubleClick(dc) != 0) {
601 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
602 synth->mem.active, 0, BRISTOL_FORCE);
603 optsShim(synth);
604 } else
605 printf("%i %i\n", synth->bank, synth->location);
606 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
607 OPTS_START, 0, BRISTOL_FORCE);
608 break;
609 case 1:
610 case 2:
611 case 3:
612 case 4:
613 case 5:
614 case 6:
615 case 7:
616 case 8:
617 /*
618 * Radiobutton memory selectors, doubleclick should load
619 */
620 if (synth->dispatch[ACTIVE_DEVS].other1 != -1)
621 {
622 synth->dispatch[ACTIVE_DEVS].other2 = 1;
623
624 if (synth->dispatch[ACTIVE_DEVS].other1 != index)
625 event.value = 0;
626 else
627 event.value = 1;
628
629 brightonParamChange(synth->win, panel,
630 synth->dispatch[ACTIVE_DEVS].other1, &event);
631 }
632 synth->dispatch[ACTIVE_DEVS].other1 = index;
633
634 synth->location = index;
635
636 if (brightonDoubleClick(dc) != 0) {
637 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
638 OPTS_START, 0, BRISTOL_FORCE);
639 /* optsShim(synth); */
640 }
641 break;
642 case 9:
643 /*
644 * Save on doubleclick
645 */
646 if (brightonDoubleClick(dc) != 0)
647 saveMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location, 0);
648 break;
649 case 10:
650 /*
651 * Up
652 */
653 while (++synth->location != start)
654 {
655 if (synth->location > 8)
656 synth->location = 1;
657
658 if (loadMemory(synth, synth->resources->name, 0,
659 synth->bank + synth->location, synth->mem.active,
660 0, BRISTOL_STAT) >= 0)
661 break;
662 }
663
664 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
665 synth->mem.active, 0, BRISTOL_FORCE);
666 /* optsShim(synth); */
667 event.type = BRISTOL_FLOAT;
668 event.value = 1;
669 brightonParamChange(synth->win, MODS_PANEL, synth->location,
670 &event);
671 break;
672 case 12:
673 /*
674 * Down
675 */
676 while (--synth->location != start)
677 {
678 if (synth->location < 1)
679 synth->location = 8;
680
681 if (loadMemory(synth, synth->resources->name, 0,
682 synth->bank + synth->location, synth->mem.active,
683 0, BRISTOL_STAT) >= 0)
684 break;
685 }
686
687 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
688 OPTS_START, 0, BRISTOL_FORCE);
689 /* optsShim(synth); */
690 event.type = BRISTOL_FLOAT;
691 event.value = 1;
692 brightonParamChange(synth->win, MODS_PANEL, synth->location,
693 &event);
694 break;
695 case 11:
696 /*
697 * Show Opts panel
698 */
699 panelSwitch(win, synth, value);
700 break;
701 }
702
703 return(0);
704 }
705
706 /*
707 * For the sake of ease of use, links have been placed here to be called
708 * by any of the devices created. They would be better in some other file,
709 * perhaps with this as a dispatch.
710 *
711 * Param refers to the device index in the locations table given below.
712 */
713 static int
BME700Callback(brightonWindow * win,int panel,int index,float value)714 BME700Callback(brightonWindow *win, int panel, int index, float value)
715 {
716 guiSynth *synth = findSynth(global.synths, win);
717 int sendvalue;
718
719 if (global.libtest)
720 printf("BME700Callback(%i, %f)\n", index, value);
721
722 if (synth == 0)
723 return(0);
724
725 if ((index >= OPTS_START) && (index < ACTIVE_DEVS))
726 return(0);
727
728 if (panel == 3)
729 index += OPTS_START;
730
731 // if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
732 if (index >= DEVICE_COUNT)
733 return(0);
734
735 if (bme700App.resources[0].devlocn[index].to == 1)
736 sendvalue = value * C_RANGE_MIN_1;
737 else
738 sendvalue = value;
739
740 synth->mem.param[index] = value;
741
742 // if ((!global.libtest) || (index >= ACTIVE_DEVS))
743 synth->dispatch[index].routine(synth,
744 global.controlfd, synth->sid,
745 synth->dispatch[index].operator,
746 synth->dispatch[index].controller,
747 sendvalue);
748
749 return(0);
750 }
751
752 static void
envelope(guiSynth * synth,int fd,int chan,int c,int o,int v)753 envelope(guiSynth *synth, int fd, int chan, int c, int o, int v)
754 {
755 switch (o) {
756 case 0:
757 /* Mode selector - sustain level */
758 bristolMidiSendMsg(fd, synth->sid, c, 2, v == 0? 0:C_RANGE_MIN_1);
759 break;
760 case 1:
761 /* Attack */
762 bristolMidiSendMsg(fd, synth->sid, c, 0, v);
763 break;
764 case 2:
765 /* Decay/release */
766 bristolMidiSendMsg(fd, synth->sid, c, 1, v);
767 bristolMidiSendMsg(fd, synth->sid, c, 3, v);
768 break;
769 }
770 }
771
772 static void
pwm(guiSynth * synth,int fd,int chan,int c,int o,int v)773 pwm(guiSynth *synth, int fd, int chan, int c, int o, int v)
774 {
775 float pw = 0.5;
776 int source = 0;
777 int man = 0;
778
779 /*
780 * Params are
781 * 9 = PW rotary
782 * 13 = auto/man
783 * 14 = env/mod
784 */
785 if (synth->mem.param[13] != 0)
786 {
787 pw = synth->mem.param[9] * 0.5;
788 man = 1;
789 }
790
791 if (synth->mem.param[14] != 0)
792 source = 1;
793
794 bristolMidiSendMsg(fd, synth->sid, 2, 13, (int) (pw * C_RANGE_MIN_1));
795 bristolMidiSendMsg(fd, synth->sid, 126, 29,
796 (int) (synth->mem.param[9] * 0.9 * C_RANGE_MIN_1));
797 bristolMidiSendMsg(fd, synth->sid, 126, 16, man);
798 bristolMidiSendMsg(fd, synth->sid, 126, 17, source);
799 }
800
801 static void
lfofreq(guiSynth * synth,int fd,int chan,int c,int o,int v)802 lfofreq(guiSynth *synth, int fd, int chan, int c, int o, int v)
803 {
804 bristolMidiSendMsg(fd, synth->sid, c, o, C_RANGE_MIN_1 - v);
805 }
806
807 static void
filterTracking(guiSynth * synth,int fd,int chan,int c,int o,int v)808 filterTracking(guiSynth *synth, int fd, int chan, int c, int o, int v)
809 {
810 bristolMidiSendMsg(fd, synth->sid, 4, 3,
811 v == 0? 0: (int) (synth->mem.param[62] * C_RANGE_MIN_1));
812 bristolMidiSendMsg(fd, synth->sid, 126, 22, v);
813 }
814
815 static void
footage(guiSynth * synth,int fd,int chan,int c,int o,int v)816 footage(guiSynth *synth, int fd, int chan, int c, int o, int v)
817 {
818 if (synth->mem.param[49] != 0)
819 {
820 int f16 = 0, f8 = C_RANGE_MIN_1, f4 = 0, detune = 0;
821
822 if (synth->mem.param[15] == 0) {
823 detune =
824 (synth->mem.param[48] * synth->mem.param[48] * C_RANGE_MIN_1);
825 if (synth->mem.param[16] == 0)
826 /* 4' */
827 f4 = f8;
828 else
829 /* 16' */
830 f16 = f8;
831 }
832
833 /* Mix in separate strands */
834 bristolMidiSendMsg(fd, synth->sid, 2, 2, 12);
835 bristolMidiSendMsg(fd, synth->sid, 2, 3, detune);
836 bristolMidiSendMsg(fd, synth->sid, 2, 4, f16);
837 bristolMidiSendMsg(fd, synth->sid, 2, 5, f8);
838 bristolMidiSendMsg(fd, synth->sid, 2, 6, f4);
839 } else {
840 /* Transpose the oscillator */
841 int transp = 12;
842
843 if (synth->mem.param[15] == 0) {
844 if (synth->mem.param[16] == 0)
845 /* 4' */
846 transp = 24;
847 else
848 /* 16' */
849 transp = 0;
850 }
851
852 /* 8' only */
853 bristolMidiSendMsg(fd, synth->sid, 2, 2, transp);
854 bristolMidiSendMsg(fd, synth->sid, 2, 3, 0);
855 bristolMidiSendMsg(fd, synth->sid, 2, 4, 0);
856 bristolMidiSendMsg(fd, synth->sid, 2, 5, C_RANGE_MIN_1);
857 bristolMidiSendMsg(fd, synth->sid, 2, 6, 0);
858 }
859 }
860
861 static void
resFilter(guiSynth * synth,int fd,int chan,int c,int o,int v)862 resFilter(guiSynth *synth, int fd, int chan, int c, int o, int v)
863 {
864 float cutoff, lower = 0.10, upper = 0.90;
865 int algorithm = 4; /* This was 1, 12db/oct, now just 24dB with remix */
866 float res, mix;
867
868 if (synth->mem.param[18] != 0)
869 {
870 algorithm = 4;
871 res = synth->mem.param[52];
872 mix = synth->mem.param[53];
873 } else {
874 res = synth->mem.param[54];
875 mix = synth->mem.param[55];
876 }
877
878 bristolMidiSendMsg(fd, synth->sid, 3, 4, algorithm);
879
880 /*
881 * Otherwise we have 5 switches covering frequence. I will assume we are
882 * going to go full range. This is perhaps a bad idea, we should have a
883 * lower cutoff, a higher cutoff, and then the switches give 32 steps
884 * between the two.
885 if ((cutoff = 0.0312500
886 + (synth->mem.param[19] == 0? 0: 0.0312500)
887 + (synth->mem.param[20] == 0? 0: 0.062500)
888 + (synth->mem.param[21] == 0? 0: 0.12500)
889 + (synth->mem.param[22] == 0? 0: 0.2500)
890 + (synth->mem.param[23] == 0? 0: 0.500)) > 1.0)
891 cutoff = 1.0;
892 */
893 cutoff = (synth->mem.param[19] == 0? 0: 0.0312500)
894 + (synth->mem.param[20] == 0? 0: 0.062500)
895 + (synth->mem.param[21] == 0? 0: 0.12500)
896 + (synth->mem.param[22] == 0? 0: 0.2500)
897 + (synth->mem.param[23] == 0? 0: 0.500);
898
899 cutoff = lower + (upper - lower) * cutoff;
900
901 bristolMidiSendMsg(fd, synth->sid, 3, 0, (int) (cutoff * C_RANGE_MIN_1));
902 bristolMidiSendMsg(fd, synth->sid, 3, 1, (int) (res * C_RANGE_MIN_1));
903 bristolMidiSendMsg(fd, synth->sid, 3, 7, (int) (mix * C_RANGE_MIN_1));
904 }
905
906 /*
907 * Any location initialisation required to run the callbacks. For bristol, this
908 * will connect to the engine, and give it some base parameters.
909 * May need to generate some application specific menus.
910 * Will also then make specific requests to some of the devices to alter their
911 * rendering.
912 */
913 static int
BME700Init(brightonWindow * win)914 BME700Init(brightonWindow *win)
915 {
916 guiSynth *synth = findSynth(global.synths, win);
917 dispatcher *dispatch;
918 int i;
919
920 if (synth == 0)
921 {
922 synth = findSynth(global.synths, 0);
923 if (synth == 0)
924 {
925 printf("cannot init\n");
926 return(0);
927 }
928 }
929
930 synth->win = win;
931
932 printf("Initialise the BME700 link to bristol: %p\n", synth->win);
933
934 synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
935 synth->mem.count = DEVICE_COUNT;
936 synth->mem.active = ACTIVE_DEVS;
937 synth->dispatch = (dispatcher *)
938 brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
939 dispatch = synth->dispatch;
940
941 /*
942 * We really want to have three connection mechanisms. These should be
943 * 1. Unix named sockets.
944 * 2. UDP sockets (actually implements TCP unfortunately).
945 * 3. MIDI pipe.
946 */
947 if (!global.libtest)
948 {
949 if ((synth->sid = initConnection(&global, synth)) < 0)
950 return(-1);
951 }
952
953 for (i = 0; i < DEVICE_COUNT; i++)
954 {
955 synth->dispatch[i].operator = 126;
956 synth->dispatch[i].controller = 101;
957 synth->dispatch[i].routine = (synthRoutine) BME700MidiShim;
958 }
959
960 /* LFO */
961 synth->dispatch[0].operator = 126;
962 synth->dispatch[0].controller = 11;
963 synth->dispatch[1].operator = 0;
964 synth->dispatch[1].controller = 0;
965 synth->dispatch[2].operator = 1;
966 synth->dispatch[2].controller = 0;
967 synth->dispatch[1].routine = synth->dispatch[2].routine
968 = (synthRoutine) lfofreq;
969 synth->dispatch[3].operator = 126;
970 synth->dispatch[3].controller = 12;
971
972 /* Vib Env */
973 synth->dispatch[4].operator = 126;
974 synth->dispatch[4].controller = 10;
975 synth->dispatch[5].operator = 126;
976 synth->dispatch[5].controller = 27;
977
978 /* PWM double, wave */
979 synth->dispatch[6].operator = 126;
980 synth->dispatch[6].controller = 14;
981 synth->dispatch[7].operator = 126;
982 synth->dispatch[7].controller = 13;
983
984 /* Glide */
985 synth->dispatch[8].operator = 126;
986 synth->dispatch[8].controller = 0;
987 synth->dispatch[12].operator = 126;
988 synth->dispatch[12].controller = 15;
989
990 /* Signal */
991 synth->dispatch[11].operator = 2;
992 synth->dispatch[11].controller = 14;
993
994 /* Vibrato */
995 synth->dispatch[10].operator = 126;
996 synth->dispatch[10].controller = 28;
997
998 /* PWM Source */
999 synth->dispatch[9].operator = 126;
1000 synth->dispatch[9].controller = 101;
1001 synth->dispatch[13].operator = 126;
1002 synth->dispatch[13].controller = 102;
1003 synth->dispatch[14].operator = 126;
1004 synth->dispatch[14].controller = 103;
1005 synth->dispatch[9].routine = synth->dispatch[13].routine
1006 = synth->dispatch[14].routine = (synthRoutine) pwm;
1007
1008 /* Footage */
1009 synth->dispatch[15].operator = 126;
1010 synth->dispatch[15].controller = 18;
1011 synth->dispatch[16].operator = 126;
1012 synth->dispatch[16].controller = 19;
1013 synth->dispatch[15].routine = synth->dispatch[16].routine
1014 = (synthRoutine) footage;
1015
1016 /* Noise/VCO mix */
1017 synth->dispatch[17].operator = 126;
1018 synth->dispatch[17].controller = 3;
1019
1020 /* ResFilter - type, then frequency */
1021 synth->dispatch[18].operator = 3;
1022 synth->dispatch[18].controller = 0;
1023 synth->dispatch[19].operator = 3;
1024 synth->dispatch[19].controller = 1;
1025 synth->dispatch[20].operator = 3;
1026 synth->dispatch[20].controller = 2;
1027 synth->dispatch[21].operator = 3;
1028 synth->dispatch[21].controller = 3;
1029 synth->dispatch[22].operator = 3;
1030 synth->dispatch[22].controller = 4;
1031 synth->dispatch[23].operator = 3;
1032 synth->dispatch[23].controller = 5;
1033 synth->dispatch[18].routine = synth->dispatch[19].routine
1034 = synth->dispatch[20].routine = synth->dispatch[21].routine
1035 = synth->dispatch[22].routine = synth->dispatch[23].routine
1036 = (synthRoutine) resFilter;
1037
1038 /* Env-1 */
1039 synth->dispatch[24].operator = 6;
1040 synth->dispatch[24].controller = 0;
1041 synth->dispatch[25].operator = 6;
1042 synth->dispatch[25].controller = 1;
1043 synth->dispatch[26].operator = 6;
1044 synth->dispatch[26].controller = 2;
1045 /* Env-2 */
1046 synth->dispatch[27].operator = 7;
1047 synth->dispatch[27].controller = 0;
1048 synth->dispatch[28].operator = 7;
1049 synth->dispatch[28].controller = 1;
1050 synth->dispatch[29].operator = 7;
1051 synth->dispatch[29].controller = 2;
1052 synth->dispatch[24].routine = synth->dispatch[25].routine
1053 = synth->dispatch[26].routine = synth->dispatch[27].routine
1054 = synth->dispatch[28].routine = synth->dispatch[29].routine
1055 = (synthRoutine) envelope;
1056
1057 /* Env Mix */
1058 synth->dispatch[30].operator = 126;
1059 synth->dispatch[30].controller = 5;
1060 synth->dispatch[31].operator = 126;
1061 synth->dispatch[31].controller = 6;
1062
1063 /* VCF */
1064 synth->dispatch[32].operator = 4;
1065 synth->dispatch[32].controller = 1;
1066 synth->dispatch[33].operator = 4;
1067 synth->dispatch[33].controller = 0;
1068 synth->dispatch[34].operator = 4;
1069 synth->dispatch[34].controller = 2;
1070 synth->dispatch[35].operator = 126;
1071 synth->dispatch[35].controller = 25;
1072
1073 /* Filter mod */
1074 synth->dispatch[36].operator = 126;
1075 synth->dispatch[36].controller = 20;
1076 synth->dispatch[37].operator = 126;
1077 synth->dispatch[37].controller = 21;
1078 synth->dispatch[38].operator = 126;
1079 synth->dispatch[38].controller = 22;
1080 synth->dispatch[38].routine = (synthRoutine) filterTracking;
1081
1082 /* filter mix */
1083 synth->dispatch[39].operator = 126;
1084 synth->dispatch[39].controller = 4;
1085
1086 /* Amp mod */
1087 synth->dispatch[40].operator = 126;
1088 synth->dispatch[40].controller = 26;
1089 synth->dispatch[41].operator = 126;
1090 synth->dispatch[41].controller = 23;
1091 synth->dispatch[42].operator = 126;
1092 synth->dispatch[42].controller = 24;
1093
1094 /* Options LFO */
1095 synth->dispatch[43].operator = 126;
1096 synth->dispatch[43].controller = 7;
1097 synth->dispatch[44].operator = 0;
1098 synth->dispatch[44].controller = 1;
1099 synth->dispatch[45].operator = 126;
1100 synth->dispatch[45].controller = 8;
1101 synth->dispatch[46].operator = 1;
1102 synth->dispatch[46].controller = 1;
1103
1104 /* Test the LFO limits */
1105 synth->dispatch[47].operator = 0;
1106 synth->dispatch[47].controller = 4;
1107 synth->dispatch[48].operator = 0;
1108 synth->dispatch[48].controller = 5;
1109
1110 /* Footage */
1111 synth->dispatch[49].operator = 126;
1112 synth->dispatch[49].controller = 101;
1113 synth->dispatch[49].routine = synth->dispatch[48].routine
1114 = (synthRoutine) footage;
1115
1116 /* Noise */
1117 synth->dispatch[50].operator = 5;
1118 synth->dispatch[50].controller = 1;
1119 synth->dispatch[51].operator = 5;
1120 synth->dispatch[51].controller = 2;
1121 synth->dispatch[64].operator = 126;
1122 synth->dispatch[64].controller = 9;
1123
1124 /* Resonator */
1125 synth->dispatch[52].operator = 3;
1126 synth->dispatch[52].controller = 1;
1127 synth->dispatch[53].operator = 3;
1128 synth->dispatch[53].controller = 7;
1129 synth->dispatch[54].operator = 3;
1130 synth->dispatch[54].controller = 1;
1131 synth->dispatch[55].operator = 3;
1132 synth->dispatch[55].controller = 7;
1133 synth->dispatch[52].routine = synth->dispatch[53].routine
1134 = synth->dispatch[54].routine = synth->dispatch[55].routine
1135 = (synthRoutine) resFilter;
1136
1137 /* Env */
1138 synth->dispatch[56].operator = 6;
1139 synth->dispatch[56].controller = 5;
1140 synth->dispatch[57].operator = 6;
1141 synth->dispatch[57].controller = 6;
1142 synth->dispatch[58].operator = 6;
1143 synth->dispatch[58].controller = 4;
1144 synth->dispatch[59].operator = 7;
1145 synth->dispatch[59].controller = 5;
1146 synth->dispatch[60].operator = 7;
1147 synth->dispatch[60].controller = 6;
1148 synth->dispatch[61].operator = 7;
1149 synth->dispatch[61].controller = 4;
1150
1151 /* VCF */
1152 synth->dispatch[62].operator = 4;
1153 synth->dispatch[62].controller = 3;
1154 synth->dispatch[62].routine = (synthRoutine) filterTracking;
1155 synth->dispatch[63].operator = 4;
1156 synth->dispatch[63].controller = 7;
1157
1158 /* Global tuning, volume */
1159 synth->dispatch[75].operator = 126;
1160 synth->dispatch[75].controller = 1;
1161 synth->dispatch[76].operator = 126;
1162 synth->dispatch[76].controller = 2;
1163
1164 /* Both LFO upper and lower limits */
1165 bristolMidiSendMsg(global.controlfd, synth->sid, 0, 4, C_RANGE_MIN_1 / 20);
1166 bristolMidiSendMsg(global.controlfd, synth->sid, 0, 5, C_RANGE_MIN_1 / 2);
1167 bristolMidiSendMsg(global.controlfd, synth->sid, 1, 4, C_RANGE_MIN_1 / 20);
1168 bristolMidiSendMsg(global.controlfd, synth->sid, 1, 5, C_RANGE_MIN_1 / 2);
1169
1170 /* Osc settings */
1171 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 0, 8192);
1172 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 1, 8192);
1173 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 15, 1);
1174 /* Mix square 8' levels only */
1175 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 3, 0);
1176 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 4, 0);
1177 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 5, C_RANGE_MIN_1);
1178 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 6, 0);
1179 bristolMidiSendMsg(global.controlfd, synth->sid, 2, 9, C_RANGE_MIN_1);
1180
1181 /* Env settings: Gain */
1182 bristolMidiSendMsg(global.controlfd, synth->sid, 6, 4, C_RANGE_MIN_1);
1183 bristolMidiSendMsg(global.controlfd, synth->sid, 7, 4, C_RANGE_MIN_1);
1184
1185 /* Filter settings */
1186 bristolMidiSendMsg(global.controlfd, synth->sid, 3, 7, 12000);
1187 bristolMidiSendMsg(global.controlfd, synth->sid, 3, 5, 16383);
1188 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 7, 12000);
1189 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 4, 3);
1190 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 5, 16383);
1191
1192 dispatch[ACTIVE_DEVS].other1 = -1;
1193
1194 return(0);
1195 }
1196
1197 /*
1198 * This will be called to make any routine specific parameters available.
1199 */
1200 static int
BME700Configure(brightonWindow * win)1201 BME700Configure(brightonWindow *win)
1202 {
1203 guiSynth *synth = findSynth(global.synths, win);
1204 brightonEvent event;
1205
1206 if (synth == 0)
1207 {
1208 printf("problems going operational\n");
1209 return(-1);
1210 }
1211
1212 else if (synth->location == 0) {
1213 synth->bank = 0;
1214 synth->location = 1;
1215 } else if (synth->location > 0) {
1216 synth->bank = ((synth->location / 10) * 10) % 100;
1217 if (((synth->location = synth->location % 10) == 0)
1218 || (synth->location > 8))
1219 synth->location = 1;
1220 }
1221
1222 if (synth->flags & OPERATIONAL)
1223 return(0);
1224
1225 printf("going operational\n");
1226
1227 synth->flags |= OPERATIONAL;
1228 synth->keypanel = 1;
1229 synth->keypanel2 = -1;
1230 synth->transpose = 36;
1231
1232 shade_id = brightonPut(win,
1233 "bitmaps/blueprints/BME700shade.xpm", 0, 0, win->width, win->height);
1234
1235 /*
1236 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
1237 * occurs on first paint, so we suppress the first paint, and then request
1238 * an expose here.
1239 */
1240 event.type = BRIGHTON_EXPOSE;
1241 event.intvalue = 1;
1242 brightonParamChange(synth->win, KEY_PANEL, -1, &event);
1243 configureGlobals(synth);
1244
1245 brightonParamChange(synth->win, MODS_PANEL, synth->location, &event);
1246
1247 loadMemory(synth, SYNTH_NAME, 0, synth->bank + synth->location,
1248 synth->mem.active, 0, BRISTOL_FORCE);
1249 optsShim(synth);
1250
1251 /*
1252 * Volume, tuning, bend
1253 event.value = 0.822646;
1254 brightonParamChange(synth->win, MODS_PANEL, 10, &event);
1255 */
1256 event.type = BRIGHTON_FLOAT;
1257 event.value = 0.5;
1258 brightonParamChange(synth->win, 0, 75, &event);
1259 event.value = 0.7;
1260 brightonParamChange(synth->win, 0, 76, &event);
1261
1262 dc = brightonGetDCTimer(synth->win->dcTimeout);
1263
1264 return(0);
1265 }
1266
1267