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 /* Korg MemoryMoog UI */
23
24 #include <fcntl.h>
25
26 #include "brighton.h"
27 #include "brightonMini.h"
28 #include "brightoninternals.h"
29
30 static int memMoogInit();
31 static int memMoogConfigure();
32 static int memMoogCallback(brightonWindow *, int, int, float);
33 static int memMoogModCallback(brightonWindow *, int, int, float);
34 static int MMmidiCallback(brightonWindow *, int, int, float);
35
36 extern guimain global;
37
38 #include "brightonKeys.h"
39
40 #define DEVICE_COUNT 113
41 #define ACTIVE_DEVS 91
42 #define DISPLAY (DEVICE_COUNT - 1)
43
44 #define MEM_START (ACTIVE_DEVS + 4)
45 #define MIDI_START (MEM_START + 14)
46
47 #define KEY_PANEL 1
48
49 #define OSC_1_RADIO 0
50 #define OSC_2_RADIO 1
51 #define OSC_3_RADIO 2
52
53 /*
54 * This structure is for device definition. The structure is defined in
55 * include/brighton.h, further definitions in brighton/brightonDevtable.h and
56 * include/brightoninternals.h
57 *
58 * typedef int (*brightonCallback)(int, float);
59 * typedef struct BrightonLocations {
60 * int device; 0=rotary, 1=scale, etc.
61 * float relx, rely; relative position with regards to 1000 by 1000 window
62 * float relw, relh; relative height.
63 * int from, to;
64 * brightonCallback callback; specific to this dev
65 * char *image; bitmap. If zero take a device default.
66 * int flags;
67 * } brightonLocations;
68 *
69 * This example is for a memMoogBristol type synth interface.
70 */
71
72 #define RD1 210
73 #define C4D0 30
74 #define C4D1 27
75 #define C4D2 44
76 #define C4D3 25
77
78 #define R0 140
79 #define R1 (R0 + RD1)
80 #define R2 (R1 + RD1)
81 #define R3 (R2 + RD1)
82
83 #define R1_1 (R0 + (R3 - R0) / 2)
84 #define R1_0 (R0 + (R1_1 - R0) / 2)
85 #define R1_2 (R3 - (R1_1 - R0) / 2)
86
87 #define C10 35
88 #define C11 (C10 + C4D0)
89
90 #define C20 (C11 + C4D1 + 10)
91 #define C21 (C20 + C4D1)
92 #define C22 (C21 + C4D1)
93 #define C23 (C22 + C4D1)
94
95 #define R21_0 (R1_1 + (R3 - R1_1) / 3)
96 #define R21_1 (R1_1 + (R3 - R1_1) * 2 / 3)
97
98 #define C30 (C23 + C4D1 + 10)
99
100 #define C40 (C30 + C4D1 + 30)
101 #define C41 (C40 + C4D3)
102 #define C42 (C41 + C4D3)
103 #define C43 (C42 + C4D3)
104 #define C44 (C43 + C4D3)
105 #define C45 (C44 + C4D3)
106 #define C46 (C45 + C4D3)
107
108 #define C50 (C46 + C4D3 + 10)
109 #define C51 (C50 + C4D3)
110 #define C52 (C51 + C4D3)
111 #define C53 (C52 + C4D3)
112 #define C54 (C53 + C4D3 + 10)
113 #define C55 (C54 + C4D3 - 10)
114 #define C56 (C55 + C4D3 - 10)
115 #define C57 (C56 + C4D3 + 15)
116 #define C58 (C57 + C4D3)
117 #define C59 (C58 + C4D3)
118
119 #define C60 (C59 + C4D1 + 5)
120
121 #define C70 (C60 + C4D2 + 15)
122 #define C71 (C70 + C4D2)
123 #define C72 (C71 + C4D2)
124 #define C73 (C72 + C4D2)
125
126 #define C80 (C73 + C4D2)
127
128 #define S1 90
129 #define S2 14
130 #define S3 40
131 #define S4 100
132
133 static brightonLocations locations[DEVICE_COUNT] = {
134 /* Oscillators - 0 */
135 {"Osc1-16", 2, C50, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
136 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
137 {"Osc1-8", 2, C51, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
138 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
139 {"Osc1-4", 2, C52, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
140 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
141 {"Osc1-2", 2, C53, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
142 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
143 {"Osc1-Sync", 2, C54, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
144 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
145 {"Osc1-PW", 0, C56, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
146 {"Osc1-Square", 2, C57, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
147 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
148 {"Osc1-Ramp", 2, C58, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
149 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
150 {"Osc1-Tri", 2, C59, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
151 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
152
153 /* Osc-2 9 */
154 {"Osc2-16", 2, C50, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
155 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
156 {"Osc2-8", 2, C51, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
157 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
158 {"Osc2-4", 2, C52, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
159 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
160 {"Osc2-2", 2, C53, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
161 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
162 {"Osc2-Tuning", 0, C54 - 5, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, BRIGHTON_NOTCH},
163 {"Osc2-PW", 0, C56, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
164 {"Osc2-Square", 2, C57, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
165 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
166 {"Osc2-Ramp", 2, C58, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
167 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
168 {"Osc2-Tri", 2, C59, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
169 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
170
171 /* Osc-3 - 18 */
172 {"Osc3-16", 2, C50, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
173 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
174 {"Osc3-8", 2, C51, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
175 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
176 {"Osc3-4", 2, C52, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
177 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
178 {"Osc3-2", 2, C53, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
179 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
180 {"Osc3-Tuning", 0, C54 - 5, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, BRIGHTON_NOTCH},
181 {"Osc3-PW", 0, C56, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
182 {"Osc3-Square", 2, C57, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
183 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
184 {"Osc3-Ramp", 2, C58, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
185 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
186 {"Osc3-Tri", 2, C59, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
187 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
188
189 /* Osc-3 options - 27 */
190 {"Osc3-LFO", 2, C51, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
191 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
192 {"Osc3-KBD", 2, C53, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
193 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
194
195 /* Mixer - 29 */
196 {"Mix-Osc1", 0, C60, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
197 {"Mix-Osc2", 0, C60, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
198 {"Mix-Osc3", 0, C60, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
199 {"Mix-Noise", 0, C60, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
200
201 /* Filter/Env - 33 */
202 {"VCF-Cutoff", 0, C71, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
203 {"VCF-Resonance", 0, C72, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
204 {"VCF-Env", 0, C73, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
205 {"VCF-Attack", 0, C70, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
206 {"VCF-Decay", 0, C71, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
207 {"VCF-Sustain", 0, C72, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
208 {"VCF-Release", 0, C73, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
209 {"VCF-KBD-1/3", 2, C70 - 5, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
210 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
211 {"VCF-KBD-2/3", 2, C70 + 15, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
212 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
213
214 /* Env - 42 */
215 {"VCA-Attack", 0, C70, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
216 {"VCA-Decay", 0, C71, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
217 {"VCA-Sustain", 0, C72, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
218 {"VCA-Release", 0, C73, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
219 {"Env-ReZero", 2, C70, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
220 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
221 {"Env-Conditional", 2, C71, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
222 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
223 {"Env-KBD", 2, C72, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
224 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
225 {"Env-Release", 2, C73, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
226 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
227
228 /* Outputs - 50 */
229 {"ProgVolume", 0, C80, R1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
230 {"Chorus-Depth", 0, C80, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
231
232 /* Mods - 52 */
233 {"LFO-Freq", 0, C40 + 10, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
234 {"LFO-Tri", 2, C42, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
235 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
236 {"LFO-Saw", 2, C43, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
237 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
238 {"LFO-Ramp", 2, C44, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
239 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
240 {"LFO-Square", 2, C45, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
241 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
242 {"LFO-S/H", 2, C46, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
243 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
244
245 {"Mod-FM1", 2, C40, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
246 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
247 {"Mod-FM2", 2, C41, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
248 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
249 {"Mod-FM3", 2, C42, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
250 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
251 {"Mod-PW1", 2, C43, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
252 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
253 {"Mod-PW2", 2, C44, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
254 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
255 {"Mod-PW3", 2, C45, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
256 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
257 {"Mod-Filter", 2, C46, R1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchog.xpm",
258 "bitmaps/buttons/touchg.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
259
260 {"PolyMod-Osc3", 0, C40 + 10, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
261 {"PolyMod-Env", 0, C41 + 30, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
262 {"PolyMod-Cont", 2, C44, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
263 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
264 {"PolyMod-Inv", 2, C46, R2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
265 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
266
267 {"PolyMod-FM1", 2, C41, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
268 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
269 {"PolyMod-FM2", 2, C42, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
270 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
271 {"PolyMod-PM1", 2, C43, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
272 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
273 {"PolyMod-PM2", 2, C44, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
274 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
275 {"PolyMod-Filt", 2, C45, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
276 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
277
278 /* Pedals - 74 */
279 {"Pedal1-AMT", 0, C30, R0 + 45, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
280 {"Pedal1-Pitch", 2, C30 - 7, R1_0 - 20, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
281 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
282 {"Pedal1-Filt", 2, C30 + 13, R1_0 - 20, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
283 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
284 {"Pedal1-Vol", 2, C30 + 3, R1_1 - 30, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
285 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
286 {"Pedal2-AMT", 0, C30, R1_2 + 60, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
287 {"Pedal2-Mod", 2, C30 - 7, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
288 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
289 {"Pedal2-Osc2", 2, C30 + 13, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
290 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
291
292 /* Main - 81 */
293 {"G-Mono", 2, C10 - 10, R1_0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
294 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
295 {"G-Hold", 2, C10 + 10, R1_0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
296 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
297 {"G-Multi", 2, C11, R1_0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
298 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
299 {"Glide", 0, C10 - 10, R1_1, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
300 {"Glide-On", 2, C11, R1_1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
301 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
302 {"Transpose1", 2, C10 - 10, R1_2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
303 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
304 {"Transpose2", 2, C10 + 10, R1_2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
305 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
306 {"Transpose3", 2, C11, R1_2, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
307 "bitmaps/buttons/touch.xpm", BRIGHTON_RADIOBUTTON|BRIGHTON_NOSHADOW},
308 {"Tuning", 0, C10 - 10, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
309 {"ModDepth", 0, C11 - 5, R3, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
310
311 /* Effect option */
312 {"", 0, C80, R2, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
313
314 /* Master vol - 92 */
315 {"", 0, C80, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, 0},
316 /* Tuning */
317 {"", 2, C10 - 10, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchoff.xpm",
318 "bitmaps/buttons/touch.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
319 {"", 0, C11 - 5, R0, S3, S4, 0, 1, 0, "bitmaps/knobs/knob6.xpm", 0, BRIGHTON_NOTCH},
320
321 /* Memory/Midi - 94 */
322 /* Load/Save */
323 {"", 2, C20 - 4, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
324 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
325 {"", 2, C23 + 3, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
326 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
327 /* 1 - 3 */
328 {"", 2, C20 - 4, R1_1 - 70, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
329 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
330 {"", 2, C21 + S2, R1_1 - 70, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
331 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
332 {"", 2, C23 + 3, R1_1 - 70, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
333 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
334 /* 4 - 6 */
335 {"", 2, C20 - 4, R21_0 - 46, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
336 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
337 {"", 2, C21 + S2, R21_0 - 46, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
338 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
339 {"", 2, C23 + 3, R21_0 - 46, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
340 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
341 /* 7 - 9 */
342 {"", 2, C20 - 4, R21_1 - 23, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
343 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
344 {"", 2, C21 + S2, R21_1 - 23, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
345 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
346 {"", 2, C23 + 3, R21_1 - 23, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
347 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
348 /* 0 */
349 {"", 2, C21 + S2, R3, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
350 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
351
352 /* {"", 2, C23, R1_1, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm", */
353 /* "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW}, */
354 /* {"", 2, C23, R21_0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm", */
355 /* "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW}, */
356 {"", 2, C23 + 3, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
357 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
358 {"", 2, C20 - 4, R0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
359 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_NOSHADOW},
360
361 {"", 2, 0, 0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
362 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_WITHDRAWN},
363 {"", 2, 0, 0, S2, S1, 0, 1, 0, "bitmaps/buttons/touchogb.xpm",
364 "bitmaps/buttons/touchgb.xpm", BRIGHTON_CHECKBUTTON|BRIGHTON_WITHDRAWN},
365
366 {"", 4, 790, 1020, 180, 140, 0, 1, 0, "bitmaps/images/memorymoog.xpm",0, 0},
367
368 {"", 3, C20 - 6, R1_0, 106, S1 - 10, 0, 1, 0, 0,
369 "bitmaps/images/alphadisplay3.xpm", 0},
370 };
371
372 /*
373 */
374
375 /*
376 * This is a set of globals for the main window rendering. Again taken from
377 * include/brighton.h
378 */
379 brightonApp memMoogApp = {
380 "memoryMoog",
381 0, /* no blueprint on wood background. */
382 "bitmaps/textures/metal6.xpm",
383 0,
384 memMoogInit,
385 memMoogConfigure, /* 3 callbacks, unused? */
386 MMmidiCallback,
387 destroySynth,
388 {6, 100, 4, 2, 5, 520, 0, 0},
389 817, 310, 0, 0,
390 8, /* Panels */
391 {
392 {
393 "MemoryMoog",
394 "bitmaps/blueprints/memMoog.xpm",
395 "bitmaps/textures/metal4.xpm",
396 BRIGHTON_STRETCH, /* flags */
397 0,
398 0,
399 memMoogCallback,
400 12, 0, 980, 550,
401 DEVICE_COUNT,
402 locations
403 },
404 {
405 "Keyboard",
406 0,
407 "bitmaps/newkeys/nkbg.xpm", /* flags */
408 0x020|BRIGHTON_STRETCH,
409 0,
410 0,
411 keyCallback,
412 100, 650, 913, 340,
413 KEY_COUNT_5OCTAVE,
414 keysprofile2
415 },
416 {
417 "Mods",
418 "bitmaps/blueprints/mmmods.xpm",
419 "bitmaps/textures/metal6.xpm", /* flags */
420 BRIGHTON_STRETCH,
421 0,
422 0,
423 memMoogModCallback,
424 14, 656, 86, 334,
425 2,
426 mods
427 },
428 {
429 "Edge",
430 0,
431 "bitmaps/textures/wood4.xpm",
432 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
433 0,
434 0,
435 0,
436 988, 0, 13, 1000,
437 0,
438 0
439 },
440 {
441 "Bar",
442 0,
443 "bitmaps/textures/wood6.xpm",
444 BRIGHTON_VERTICAL, /* flags */
445 0,
446 0,
447 0,
448 13, 550, 975, 100,
449 0,
450 0
451 },
452 {
453 "Edge",
454 0,
455 "bitmaps/textures/wood4.xpm",
456 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
457 0,
458 0,
459 0,
460 0, 0, 12, 1000,
461 0,
462 0
463 },
464 {
465 "Edge",
466 0,
467 "bitmaps/textures/wood.xpm",
468 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
469 0,
470 0,
471 0,
472 2, 4, 9, 988,
473 0,
474 0
475 },
476 {
477 "Edge",
478 0,
479 "bitmaps/textures/wood.xpm",
480 BRIGHTON_STRETCH|BRIGHTON_VERTICAL, /* flags */
481 0,
482 0,
483 0,
484 990, 4, 10, 988,
485 0,
486 0
487 },
488 }
489 };
490
491 /*static dispatcher dispatch[DEVICE_COUNT]; */
492
493 static void
postMemory(guiSynth * synth)494 postMemory(guiSynth *synth)
495 {
496 brightonEvent event;
497 int i;
498
499 /*
500 * We have a couple of settings to force into their targetted values,
501 * namely the radio buttons.
502 * Each Osc transpose
503 * Synth transpose
504 * LFO waveform
505 */
506 event.value = 1;
507
508 if (synth->mem.param[0])
509 i = 0;
510 else if (synth->mem.param[1])
511 i = 1;
512 else if (synth->mem.param[2])
513 i = 2;
514 else
515 i = 3;
516 brightonParamChange(synth->win, 0, i, &event);
517
518 if (synth->mem.param[9])
519 i = 9;
520 else if (synth->mem.param[10])
521 i = 10;
522 else if (synth->mem.param[11])
523 i = 11;
524 else
525 i = 12;
526 brightonParamChange(synth->win, 0, i, &event);
527
528 if (synth->mem.param[18])
529 i = 18;
530 else if (synth->mem.param[19])
531 i = 19;
532 else if (synth->mem.param[20])
533 i = 20;
534 else
535 i = 21;
536 brightonParamChange(synth->win, 0, i, &event);
537
538 if (synth->mem.param[53])
539 i = 53;
540 else if (synth->mem.param[54])
541 i = 54;
542 else if (synth->mem.param[55])
543 i = 55;
544 else if (synth->mem.param[56])
545 i = 56;
546 else
547 i = 57;
548 brightonParamChange(synth->win, 0, i, &event);
549
550 if (synth->mem.param[86])
551 i = 86;
552 else if (synth->mem.param[87])
553 i = 87;
554 else
555 i = 88;
556 brightonParamChange(synth->win, 0, i, &event);
557 }
558
559 int
memoogloadMemory(guiSynth * synth,char * algo,char * name,int location,int active,int skip,int flags)560 memoogloadMemory(guiSynth *synth, char *algo, char *name, int location,
561 int active, int skip, int flags)
562 {
563 loadMemory(synth, "memoryMoog", 0, location, synth->mem.active, 0, 0);
564 postMemory(synth);
565
566 return(0);
567 }
568
569 static int
MMmidiCallback(brightonWindow * win,int controller,int value,float n)570 MMmidiCallback(brightonWindow *win, int controller, int value, float n)
571 {
572 guiSynth *synth = findSynth(global.synths, win);
573
574 printf("midi callback: %x, %i\n", controller, value);
575
576 switch(controller)
577 {
578 case MIDI_PROGRAM:
579 printf("midi program: %x, %i\n", controller, value);
580 synth->location = value + synth->bank;
581 loadMemory(synth, "memoryMoog", 0, synth->location,
582 synth->mem.active, 0, 0);
583 break;
584 case MIDI_BANK_SELECT:
585 printf("midi banksel: %x, %i\n", controller, value);
586 synth->bank = value + 10;
587 synth->location = (synth->location % 10) + synth->bank;
588 loadMemory(synth, "memoryMoog", 0, synth->location,
589 synth->mem.active, 0, 0);
590 break;
591 }
592 postMemory(synth);
593
594 return(0);
595 }
596
597 static int
memMoogModCallback(brightonWindow * win,int panel,int index,float value)598 memMoogModCallback(brightonWindow *win, int panel, int index, float value)
599 {
600 guiSynth *synth = findSynth(global.synths, win);
601
602 /*printf("memMoogModCallback(%x, %i, %i, %f)\n", synth, panel, index, value); */
603
604 /*
605 * If this is controller 0 it is the frequency control, otherwise a
606 * generic controller 1. The depth of the bend wheel is a parameter, so
607 * we need to scale the value here.
608 */
609 if (index == 0)
610 {
611 float bend = synth->mem.param[89];
612 /*
613 * Value is between 0 and 1 latching at 0.5. Have to scale the value
614 * and subtrace if from the mid point
615 */
616 bristolMidiSendMsg(global.controlfd, synth->midichannel,
617 BRISTOL_EVENT_PITCH, 0,
618 (int) (((0.5 - bend / 2) + (value * bend)) * C_RANGE_MIN_1));
619 } else {
620 bristolMidiControl(global.controlfd, synth->midichannel,
621 0, 1, ((int) (value * C_RANGE_MIN_1)) >> 7);
622 }
623 return(0);
624 }
625
626 static int
memMoogMidiSendMsg(void * synth,int fd,int chan,int c,int o,int v)627 memMoogMidiSendMsg(void *synth, int fd, int chan, int c, int o, int v)
628 {
629 /*printf("%i, %i, %i\n", c, o, v); */
630 bristolMidiSendMsg(fd, chan, c, o, v);
631 return(0);
632 }
633
634 static void
memMoogMemory(guiSynth * synth,int fd,int chan,int c,int o,int v)635 memMoogMemory(guiSynth *synth, int fd, int chan, int c, int o, int v)
636 {
637 int cmem = synth->location;
638
639 if (synth->flags & MEM_LOADING)
640 return;
641
642 switch (c) {
643 default:
644 case 0:
645 synth->location = synth->location * 10 + o;
646
647 if (synth->location >= 1000)
648 synth->location = o;
649 if (loadMemory(synth, "memoryMoog", 0, synth->location,
650 synth->mem.active, 0, BRISTOL_STAT) < 0)
651 displayPanelText(synth, "FRE", synth->location, 0, DISPLAY);
652 else
653 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
654 break;
655 case 1:
656 loadMemory(synth, "memoryMoog", 0, synth->location,
657 synth->mem.active, 0, 0);
658 postMemory(synth);
659 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
660 synth->location = 0;
661 break;
662 case 2:
663 saveMemory(synth, "memoryMoog", 0, synth->location, 0);
664 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
665 synth->location = 0;
666 break;
667 case 3:
668 while (loadMemory(synth, "memoryMoog", 0, --synth->location,
669 synth->mem.active, 0, 0) < 0)
670 {
671 if (synth->location < 0)
672 synth->location = 1000;
673 if (synth->location == cmem)
674 break;
675 }
676 postMemory(synth);
677 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
678 break;
679 case 4:
680 while (loadMemory(synth, "memoryMoog", 0, ++synth->location,
681 synth->mem.active, 0, 0) < 0)
682 {
683 if (synth->location > 999)
684 synth->location = -1;
685 if (synth->location == cmem)
686 break;
687 }
688 postMemory(synth);
689 displayPanelText(synth, "PRG", synth->location, 0, DISPLAY);
690 break;
691 }
692 }
693
694 static void
memMoogMidi(guiSynth * synth,int fd,int chan,int c,int o,int v)695 memMoogMidi(guiSynth *synth, int fd, int chan, int c, int o, int v)
696 {
697 int newchan;
698
699 if ((synth->flags & OPERATIONAL) == 0)
700 return;
701
702 if (c == 1) {
703 if ((newchan = synth->midichannel - 1) < 0)
704 {
705 synth->midichannel = 0;
706 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
707 return;
708 }
709 } else {
710 if ((newchan = synth->midichannel + 1) >= 15)
711 {
712 synth->midichannel = 15;
713 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
714 return;
715 }
716 }
717
718 if (global.libtest == 0)
719 {
720 bristolMidiSendMsg(global.controlfd, synth->sid,
721 127, 0, BRISTOL_MIDICHANNEL|newchan);
722 }
723
724 synth->midichannel = newchan;
725
726 displayPanelText(synth, "MIDI", synth->midichannel + 1, 0, DISPLAY);
727 }
728
729 /*
730 * For the sake of ease of use, links have been placed here to be called
731 * by any of the devices created. They would be better in some other file,
732 * perhaps with this as a dispatch.
733 *
734 * Param refers to the device index in the locations table given below.
735 */
736 static int
memMoogCallback(brightonWindow * win,int panel,int index,float value)737 memMoogCallback(brightonWindow * win, int panel, int index, float value)
738 {
739 guiSynth *synth = findSynth(global.synths, win);
740 int sendvalue;
741
742 /*printf("memMoogCallback(%i, %f): %x\n", index, value, synth); */
743
744 if (synth == 0)
745 return(0);
746
747 if ((index >= DEVICE_COUNT) || ((synth->flags & OPERATIONAL) == 0))
748 return(0);
749
750 if (memMoogApp.resources[panel].devlocn[index].to == 1)
751 sendvalue = value * C_RANGE_MIN_1;
752 else
753 sendvalue = value;
754
755 synth->mem.param[index] = value;
756
757 if ((!global.libtest) || (index >= ACTIVE_DEVS))
758 synth->dispatch[index].routine(synth,
759 global.controlfd, synth->sid,
760 synth->dispatch[index].controller,
761 synth->dispatch[index].operator,
762 sendvalue);
763 #ifdef DEBUG
764 else
765 printf("dispatch[%x,%i](%i, %i, %i, %i, %i)\n", synth, index,
766 global.controlfd, synth->sid,
767 synth->dispatch[index].controller,
768 synth->dispatch[index].operator,
769 sendvalue);
770 #endif
771
772 return(0);
773 }
774
775 static void
memMoogOsc3LFO(guiSynth * synth,int fd,int chan,int c,int o,int v)776 memMoogOsc3LFO(guiSynth *synth, int fd, int chan, int c, int o, int v)
777 {
778 int value = 0;
779
780 if (v == 0)
781 {
782 /*
783 * LFO off, find the desired transpose
784 */
785 if (synth->mem.param[18])
786 value = 0;
787 else if (synth->mem.param[19])
788 value = 1;
789 else if (synth->mem.param[20])
790 value = 2;
791 else if (synth->mem.param[21])
792 value = 3;
793 } else {
794 /*
795 * LFO on
796 */
797 bristolMidiSendMsg(fd, chan, 2, 1, 10);
798 return;
799 }
800 bristolMidiSendMsg(fd, chan, 2, 1, value);
801 }
802
803 static void
memMoogOscTranspose(guiSynth * synth,int fd,int chan,int c,int o,int v)804 memMoogOscTranspose(guiSynth *synth, int fd, int chan, int c, int o, int v)
805 {
806 brightonEvent event;
807 int value;
808
809 if (synth->flags & MEM_LOADING)
810 return;
811
812 /*
813 * We need to configure the radio set and then request the tranpose value.
814 */
815 if (synth->dispatch[c].other2)
816 {
817 synth->dispatch[c].other2 = 0;
818 return;
819 }
820
821 if (synth->dispatch[c].other1 != -1)
822 {
823 event.type = BRIGHTON_FLOAT;
824
825 synth->dispatch[c].other2 = 1;
826
827 if (synth->dispatch[c].other1 != o)
828 event.value = 0;
829 else
830 event.value = 1;
831
832 brightonParamChange(synth->win, synth->panel,
833 synth->dispatch[c].other1, &event);
834 }
835 synth->dispatch[c].other1 = o;
836
837 if (o > 17) {
838 /*
839 * Osc 3 - tranpose depends on mem[27]
840 */
841 if (synth->mem.param[27])
842 return;
843 else
844 value = o - 18;
845 } else if (o > 4)
846 value = o - 9;
847 else
848 value = o;
849
850 bristolMidiSendMsg(fd, chan, c, 1, value);
851 }
852
853 static void
memMoogLFOWave(guiSynth * synth,int fd,int chan,int c,int o,int v)854 memMoogLFOWave(guiSynth *synth, int fd, int chan, int c, int o, int v)
855 {
856 brightonEvent event;
857
858 if (synth->flags & MEM_LOADING)
859 return;
860
861 /*
862 * We need to configure the radio set and then request the tranpose value.
863 */
864 if (synth->dispatch[c].other2)
865 {
866 synth->dispatch[c].other2 = 0;
867 return;
868 }
869
870 if (synth->dispatch[c].other1 != -1)
871 {
872 event.type = BRIGHTON_FLOAT;
873
874 synth->dispatch[c].other2 = 1;
875
876 if (synth->dispatch[c].other1 != o)
877 event.value = 0;
878 else
879 event.value = 1;
880
881 brightonParamChange(synth->win, synth->panel,
882 synth->dispatch[c].other1, &event);
883 }
884 synth->dispatch[c].other1 = o;
885
886 bristolMidiSendMsg(fd, chan, 126, 4, o - 53);
887 }
888
889 static void
memMoogTranspose(guiSynth * synth,int fd,int chan,int c,int o,int v)890 memMoogTranspose(guiSynth *synth, int fd, int chan, int c, int o, int v)
891 {
892 brightonEvent event;
893
894 if (synth->flags & MEM_LOADING)
895 return;
896
897 /*
898 * We need to configure the radio set and then request the tranpose value.
899 */
900 if (synth->dispatch[c].other2)
901 {
902 synth->dispatch[c].other2 = 0;
903 return;
904 }
905
906 if (synth->dispatch[c].other1 != -1)
907 {
908 event.type = BRIGHTON_FLOAT;
909
910 synth->dispatch[c].other2 = 1;
911
912 if (synth->dispatch[c].other1 != o)
913 event.value = 0;
914 else
915 event.value = 1;
916
917 brightonParamChange(synth->win, synth->panel,
918 synth->dispatch[c].other1, &event);
919 }
920 synth->dispatch[c].other1 = o;
921
922 synth->transpose = 24 + (o - 86) * 12;
923 }
924
925 static void
multiTune(guiSynth * synth,int fd,int chan,int c,int o,int v)926 multiTune(guiSynth *synth, int fd, int chan, int c, int o, int v)
927 {
928 brightonEvent event;
929
930 /*
931 * Configures all the tune settings to zero (ie, 0.5). Do the Osc-A first,
932 * since it is not visible, and then request the GUI to configure Osc-B.
933 */
934 /* bristolMidiSendMsg(fd, synth->sid, 0, 2, 8192); */
935 event.type = BRIGHTON_FLOAT;
936 event.value = 0.5;
937 brightonParamChange(synth->win, synth->panel, 13, &event);
938 brightonParamChange(synth->win, synth->panel, 22, &event);
939 brightonParamChange(synth->win, synth->panel, 94, &event);
940 }
941
942 static void
keyHold(guiSynth * synth)943 keyHold(guiSynth *synth)
944 {
945 if ((synth->flags & OPERATIONAL) == 0)
946 return;
947
948 if (synth->mem.param[82])
949 bristolMidiSendMsg(global.controlfd, synth->sid,
950 127, 0, BRISTOL_HOLD|1);
951 else
952 bristolMidiSendMsg(global.controlfd, synth->sid,
953 127, 0, BRISTOL_HOLD|0);
954 }
955
956 static void
memoryGlide(guiSynth * synth,int fd,int chan,int c,int o,int v)957 memoryGlide(guiSynth *synth, int fd, int chan, int c, int o, int v)
958 {
959 if ((synth->flags & OPERATIONAL) == 0)
960 return;
961
962 if (c == 126)
963 {
964 if (synth->mem.param[85] != 0)
965 bristolMidiSendMsg(fd, chan, 126, 0, v);
966 return;
967 }
968 if (v != 0)
969 bristolMidiSendMsg(fd, chan, 126, 0,
970 (int) (synth->mem.param[84] * C_RANGE_MIN_1));
971 else
972 bristolMidiSendMsg(fd, chan, 126, 0, 0);
973 }
974
975 static void
filterTrack(guiSynth * synth,int fd,int chan,int c,int o,int v)976 filterTrack(guiSynth *synth, int fd, int chan, int c, int o, int v)
977 {
978 float value;
979
980 value = (synth->mem.param[40] + synth->mem.param[41] * 2)
981 * C_RANGE_MIN_1 / 3;
982
983 bristolMidiSendMsg(fd, chan, 3, 3, (int) value);
984 }
985
986 static void
jointRelease(guiSynth * synth,int fd,int chan,int c,int o,int v)987 jointRelease(guiSynth *synth, int fd, int chan, int c, int o, int v)
988 {
989 if (c == 45)
990 {
991 if (synth->mem.param[49] == 0)
992 bristolMidiSendMsg(fd, chan, 6, 3, v);
993 return;
994 }
995 if (v == 0)
996 bristolMidiSendMsg(fd, chan, 6, 3,
997 (int) (synth->mem.param[45] * C_RANGE_MIN_1));
998 else
999 bristolMidiSendMsg(fd, chan, 6, 3, 10);
1000 }
1001
1002 /*
1003 * Any location initialisation required to run the callbacks. For bristol, this
1004 * will connect to the engine, and give it some base parameters.
1005 * May need to generate some application specific menus.
1006 * Will also then make specific requests to some of the devices to alter their
1007 * rendering.
1008 */
1009 static int
memMoogInit(brightonWindow * win)1010 memMoogInit(brightonWindow *win)
1011 {
1012 guiSynth *synth = findSynth(global.synths, win);
1013 dispatcher *dispatch;
1014 int i;
1015
1016 if (synth == 0)
1017 {
1018 synth = findSynth(global.synths, 0);
1019 if (synth == 0)
1020 {
1021 printf("cannot init\n");
1022 return(0);
1023 }
1024 }
1025
1026 synth->win = win;
1027
1028 printf("Initialise the memMoog link to bristol: %p\n", synth->win);
1029
1030 synth->mem.param = (float *) brightonmalloc(DEVICE_COUNT * sizeof(float));
1031 synth->mem.count = DEVICE_COUNT;
1032 synth->mem.active = ACTIVE_DEVS;
1033 synth->dispatch = (dispatcher *)
1034 brightonmalloc(DEVICE_COUNT * sizeof(dispatcher));
1035 dispatch = synth->dispatch;
1036
1037 /*
1038 * We really want to have three connection mechanisms. These should be
1039 * 1. Unix named sockets.
1040 * 2. UDP sockets.
1041 * 3. MIDI pipe.
1042 */
1043 synth->voices = 6;
1044 if (!global.libtest)
1045 if ((synth->sid = initConnection(&global, synth)) < 0)
1046 return(-1);
1047
1048 for (i = 0; i < DEVICE_COUNT; i++)
1049 synth->dispatch[i].routine = memMoogMidiSendMsg;
1050
1051 /* Osc - first transpose options */
1052 dispatch[0].controller = 0;
1053 dispatch[0].operator = 0;
1054 dispatch[1].controller = 0;
1055 dispatch[1].operator = 1;
1056 dispatch[2].controller = 0;
1057 dispatch[2].operator = 2;
1058 dispatch[3].controller = 0;
1059 dispatch[3].operator = 3;
1060 dispatch[9].controller = 1;
1061 dispatch[9].operator = 9;
1062 dispatch[10].controller = 1;
1063 dispatch[10].operator = 10;
1064 dispatch[11].controller = 1;
1065 dispatch[11].operator = 11;
1066 dispatch[12].controller = 1;
1067 dispatch[12].operator = 12;
1068 dispatch[18].controller = 2;
1069 dispatch[18].operator = 18;
1070 dispatch[19].controller = 2;
1071 dispatch[19].operator = 19;
1072 dispatch[20].controller = 2;
1073 dispatch[20].operator = 20;
1074 dispatch[21].controller = 2;
1075 dispatch[21].operator = 21;
1076 dispatch[0].routine = dispatch[1].routine =
1077 dispatch[2].routine = dispatch[3].routine =
1078 dispatch[9].routine = dispatch[10].routine =
1079 dispatch[11].routine = dispatch[12].routine =
1080 dispatch[18].routine = dispatch[19].routine =
1081 dispatch[20].routine = dispatch[21].routine =
1082 (synthRoutine) memMoogOscTranspose;
1083 /* Osc Options. */
1084 dispatch[4].controller = 1;
1085 dispatch[4].operator = 7;
1086 dispatch[5].controller = 0;
1087 dispatch[5].operator = 0;
1088 dispatch[6].controller = 0;
1089 dispatch[6].operator = 6;
1090 dispatch[7].controller = 0;
1091 dispatch[7].operator = 4;
1092 dispatch[8].controller = 0;
1093 dispatch[8].operator = 5;
1094 /* Osc 2 */
1095 dispatch[13].controller = 1;
1096 dispatch[13].operator = 2;
1097 dispatch[14].controller = 1;
1098 dispatch[14].operator = 0;
1099 dispatch[15].controller = 1;
1100 dispatch[15].operator = 6;
1101 dispatch[16].controller = 1;
1102 dispatch[16].operator = 4;
1103 dispatch[17].controller = 1;
1104 dispatch[17].operator = 5;
1105 /* Osc 3 */
1106 dispatch[22].controller = 2;
1107 dispatch[22].operator = 2;
1108 dispatch[23].controller = 2;
1109 dispatch[23].operator = 0;
1110 dispatch[24].controller = 2;
1111 dispatch[24].operator = 6;
1112 dispatch[25].controller = 2;
1113 dispatch[25].operator = 4;
1114 dispatch[26].controller = 2;
1115 dispatch[26].operator = 5;
1116 /* LFO/KBD */
1117 dispatch[27].controller = 126;
1118 dispatch[27].operator = 1;
1119 dispatch[27].routine = (synthRoutine) memMoogOsc3LFO;
1120 dispatch[28].controller = 126;
1121 dispatch[28].operator = 7;
1122
1123 /* Mixer */
1124 dispatch[29].controller = 126;
1125 dispatch[29].operator = 30;
1126 dispatch[30].controller = 126;
1127 dispatch[30].operator = 31;
1128 dispatch[31].controller = 126;
1129 dispatch[31].operator = 32;
1130 dispatch[32].controller = 126;
1131 dispatch[32].operator = 33;
1132
1133 /* Filter */
1134 dispatch[33].controller = 3;
1135 dispatch[33].operator = 0;
1136 dispatch[34].controller = 3;
1137 dispatch[34].operator = 1;
1138 dispatch[35].controller = 126;
1139 dispatch[35].operator = 17;
1140 /* Filter Env */
1141 dispatch[36].controller = 4;
1142 dispatch[36].operator = 0;
1143 dispatch[37].controller = 4;
1144 dispatch[37].operator = 1;
1145 dispatch[38].controller = 4;
1146 dispatch[38].operator = 2;
1147 dispatch[39].controller = 4;
1148 dispatch[39].operator = 3;
1149 /* Filter Key tracking */
1150 dispatch[40].controller = 126;
1151 dispatch[40].operator = 1;
1152 dispatch[41].controller = 126;
1153 dispatch[41].operator = 2;
1154 dispatch[40].routine = dispatch[41].routine = (synthRoutine) filterTrack;
1155
1156 /* AMP ENV */
1157 dispatch[42].controller = 6;
1158 dispatch[42].operator = 0;
1159 dispatch[43].controller = 6;
1160 dispatch[43].operator = 1;
1161 dispatch[44].controller = 6;
1162 dispatch[44].operator = 2;
1163 dispatch[45].controller = 45;
1164 dispatch[45].operator = 3;
1165 dispatch[45].routine = (synthRoutine) jointRelease;
1166 /* AMP ENV Options */
1167 dispatch[46].controller = 6;
1168 dispatch[46].operator = 6;
1169 dispatch[47].controller = 6;
1170 dispatch[47].operator = 7;
1171 dispatch[48].controller = 6;
1172 dispatch[48].operator = 8;
1173 dispatch[49].controller = 126;
1174 dispatch[49].operator = 101;
1175 dispatch[49].routine = (synthRoutine) jointRelease;
1176 /* Prog volume */
1177 dispatch[50].controller = 6;
1178 dispatch[50].operator = 4;
1179 /* Aux? We don't have aux out or headphones, so use this for panning. */
1180 dispatch[51].controller = 100;
1181 dispatch[51].operator = 0;
1182
1183 /* Mods - LFO freq first */
1184 dispatch[52].controller = 8;
1185 dispatch[52].operator = 0;
1186 dispatch[53].controller = 3;
1187 dispatch[53].operator = 53;
1188 dispatch[54].controller = 3;
1189 dispatch[54].operator = 54;
1190 dispatch[55].controller = 3;
1191 dispatch[55].operator = 55;
1192 dispatch[56].controller = 3;
1193 dispatch[56].operator = 56;
1194 dispatch[57].controller = 3;
1195 dispatch[57].operator = 57;
1196 dispatch[53].routine = dispatch[54].routine =
1197 dispatch[55].routine = dispatch[56].routine =
1198 dispatch[57].routine = (synthRoutine) memMoogLFOWave;
1199 /* LFO Routing: */
1200 dispatch[58].controller = 126;
1201 dispatch[58].operator = 8;
1202 dispatch[59].controller = 126;
1203 dispatch[59].operator = 9;
1204 dispatch[60].controller = 126;
1205 dispatch[60].operator = 10;
1206 dispatch[61].controller = 126;
1207 dispatch[61].operator = 11;
1208 dispatch[62].controller = 126;
1209 dispatch[62].operator = 12;
1210 dispatch[63].controller = 126;
1211 dispatch[63].operator = 13;
1212 dispatch[64].controller = 126;
1213 dispatch[64].operator = 14;
1214
1215 /* Poly mods */
1216 dispatch[65].controller = 126;
1217 dispatch[65].operator = 20;
1218 dispatch[66].controller = 126;
1219 dispatch[66].operator = 21;
1220 dispatch[67].controller = 126;
1221 dispatch[67].operator = 27;
1222 dispatch[68].controller = 126;
1223 dispatch[68].operator = 28;
1224 /* Poly Routing */
1225 dispatch[69].controller = 126;
1226 dispatch[69].operator = 22;
1227 dispatch[70].controller = 126;
1228 dispatch[70].operator = 23;
1229 dispatch[71].controller = 126;
1230 dispatch[71].operator = 24;
1231 dispatch[72].controller = 126;
1232 dispatch[72].operator = 25;
1233 dispatch[73].controller = 126;
1234 dispatch[73].operator = 26;
1235
1236 /* Pedals */
1237 dispatch[74].controller = 126;
1238 dispatch[74].operator = 40;
1239 dispatch[75].controller = 126;
1240 dispatch[75].operator = 41;
1241 dispatch[76].controller = 126;
1242 dispatch[76].operator = 42;
1243 dispatch[77].controller = 126;
1244 dispatch[77].operator = 43;
1245 dispatch[78].controller = 126;
1246 dispatch[78].operator = 44;
1247 dispatch[79].controller = 126;
1248 dispatch[79].operator = 45;
1249 dispatch[80].controller = 126;
1250 dispatch[80].operator = 46;
1251
1252 /* Main - Mono/Hold/Multi */
1253 dispatch[81].controller = 126;
1254 dispatch[81].operator = 2;
1255 dispatch[82].routine = (synthRoutine) keyHold;
1256 dispatch[83].controller = 126;
1257 dispatch[83].operator = 6;
1258 /* Glide */
1259 dispatch[84].controller = 126;
1260 dispatch[84].operator = 0;
1261 dispatch[85].controller = 127;
1262 dispatch[85].operator = 0;
1263 dispatch[84].routine = dispatch[85].routine = (synthRoutine) memoryGlide;
1264
1265 /* Transpose */
1266 dispatch[86].controller = 4;
1267 dispatch[86].operator = 86;
1268 dispatch[87].controller = 4;
1269 dispatch[87].operator = 87;
1270 dispatch[88].controller = 4;
1271 dispatch[88].operator = 88;
1272 dispatch[86].routine = dispatch[87].routine = dispatch[88].routine
1273 = (synthRoutine) memMoogTranspose;
1274
1275 /* Depth controls */
1276 dispatch[89].controller = 126;
1277 dispatch[89].operator = 47;
1278 dispatch[90].controller = 126;
1279 dispatch[90].operator = 3;
1280
1281 /* Effects depth */
1282 dispatch[91].controller = 100;
1283 dispatch[91].operator = 1;
1284
1285 /* Master, Autotune and tune */
1286 dispatch[92].controller = 126;
1287 dispatch[92].operator = 16;
1288 dispatch[93].routine = (synthRoutine) multiTune;
1289 dispatch[94].controller = 126;
1290 dispatch[94].operator = 1;
1291
1292 dispatch[MEM_START +0].routine = dispatch[MEM_START +1].routine =
1293 dispatch[MEM_START +2].routine = dispatch[MEM_START +3].routine =
1294 dispatch[MEM_START +4].routine = dispatch[MEM_START +5].routine =
1295 dispatch[MEM_START +6].routine = dispatch[MEM_START +7].routine =
1296 dispatch[MEM_START +8].routine = dispatch[MEM_START +9].routine =
1297 dispatch[MEM_START +10].routine = dispatch[MEM_START +11].routine =
1298 dispatch[MEM_START +12].routine = dispatch[MEM_START +13].routine
1299 = (synthRoutine) memMoogMemory;
1300
1301 dispatch[MEM_START + 0].controller = 1;
1302 dispatch[MEM_START + 1].controller = 2;
1303 dispatch[MEM_START + 2].operator = 1;
1304 dispatch[MEM_START + 3].operator = 2;
1305 dispatch[MEM_START + 4].operator = 3;
1306 dispatch[MEM_START + 5].operator = 4;
1307 dispatch[MEM_START + 6].operator = 5;
1308 dispatch[MEM_START + 7].operator = 6;
1309 dispatch[MEM_START + 8].operator = 7;
1310 dispatch[MEM_START + 9].operator = 8;
1311 dispatch[MEM_START + 10].operator = 9;
1312 dispatch[MEM_START + 11].operator = 0;
1313
1314 dispatch[MEM_START + 12].controller = 4;
1315 dispatch[MEM_START + 13].controller = 3;
1316
1317 dispatch[MIDI_START].controller = 1;
1318 dispatch[MIDI_START + 1].controller = 2;
1319 dispatch[MIDI_START].routine = dispatch[MIDI_START + 1].routine =
1320 (synthRoutine) memMoogMidi;
1321
1322 dispatch[OSC_1_RADIO].other1 = -1;
1323 dispatch[OSC_2_RADIO].other1 = -1;
1324 dispatch[OSC_3_RADIO].other1 = -1;
1325
1326 /* Put in diverse defaults settings */
1327 bristolMidiSendMsg(global.controlfd, synth->sid, 7, 0, 16383);
1328 /* Tune osc-1 */
1329 bristolMidiSendMsg(global.controlfd, synth->sid, 0, 2, 8192);
1330 /* Gain on filter env - changed to fixed MOD on filter, variable Env. Then */
1331 /* changed to fixed env with in-algo filter gain... */
1332 bristolMidiSendMsg(global.controlfd, synth->sid, 3, 4, 4);
1333 bristolMidiSendMsg(global.controlfd, synth->sid, 3, 2, C_RANGE_MIN_1);
1334 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 4, C_RANGE_MIN_1);
1335 /* Filter env does not track velocity */
1336 bristolMidiSendMsg(global.controlfd, synth->sid, 4, 5, 0);
1337 /* Waveform subosc */
1338 /* bristolMidiSendMsg(global.controlfd, synth->sid, 1, 0, C_RANGE_MIN_1); */
1339 /* bristolMidiSendMsg(global.controlfd, synth->sid, 1, 6, C_RANGE_MIN_1); */
1340 /* LFO Env parameters. */
1341 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 1, 12000); */
1342 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 2, 16383); */
1343 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 3, 0); */
1344 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 4, 16383); */
1345 /* bristolMidiSendMsg(global.controlfd, synth->sid, 8, 5, 0); */
1346
1347 return(0);
1348 }
1349
1350 /*
1351 * This will be called to make any routine specific parameters available.
1352 */
1353 static int
memMoogConfigure(brightonWindow * win)1354 memMoogConfigure(brightonWindow *win)
1355 {
1356 guiSynth *synth = findSynth(global.synths, win);
1357 brightonEvent event;
1358
1359 if (synth == 0)
1360 {
1361 printf("problems going operational\n");
1362 return(-1);
1363 }
1364
1365 if (synth->flags & OPERATIONAL)
1366 return(0);
1367
1368 printf("going operational\n");
1369
1370 synth->flags |= OPERATIONAL;
1371 synth->keypanel = 1;
1372 synth->keypanel2 = -1;
1373 synth->transpose = 48;
1374
1375 synth->bank = 0;
1376 event.value = 1;
1377 /* Poly */
1378 loadMemory(synth, "memoryMoog", 0,
1379 synth->location, synth->mem.active, 0, 0);
1380 postMemory(synth);
1381
1382 brightonPut(win,
1383 "bitmaps/blueprints/memMoogshade.xpm", 0, 0, win->width, win->height);
1384
1385 /*
1386 * Hm. This is a hack for a few bits of bad rendering of a keyboard. Only
1387 * occurs on first paint, so we suppress the first paint, and then request
1388 * an expose here.
1389 */
1390 event.type = BRIGHTON_EXPOSE;
1391 event.intvalue = 1;
1392 brightonParamChange(synth->win, KEY_PANEL, -1, &event);
1393 event.type = BRIGHTON_FLOAT;
1394 event.value = 0.5;
1395 brightonParamChange(synth->win, 0, 93, &event);
1396 event.value = 1.0;
1397 brightonParamChange(synth->win, 0, 92, &event); /* Volume */
1398 brightonParamChange(synth->win, 0, 74, &event); /* pedalamt1 */
1399 brightonParamChange(synth->win, 0, 78, &event); /* pedalamt2 */
1400 configureGlobals(synth);
1401
1402 synth->loadMemory = (loadRoutine) memoogloadMemory;
1403
1404 return(0);
1405 }
1406
1407