source: buchla-68k/orig/RAM/LOCALKB.C@ 0170798

Last change on this file since 0170798 was 3ae31e9, checked in by Thomas Lopatic <thomas@…>, 7 years ago

Imported original source code.

  • Property mode set to 100755
File size: 11.5 KB
Line 
1/*
2 =============================================================================
3 localkb.c -- local keyboard processing
4 Version 39 -- 1988-11-28 -- D.N. Lynx Crowe
5
6 List with the pr -e4 option to expand tabs to 4 spaces instead of 8.
7 =============================================================================
8*/
9
10#include "stddefs.h"
11#include "graphdef.h"
12#include "glcdefs.h"
13#include "glcfns.h"
14#include "hwdefs.h"
15#include "lcdline.h"
16#include "vsdd.h"
17#include "panel.h"
18#include "smdefs.h"
19#include "slice.h"
20#include "macros.h"
21
22#include "midas.h"
23#include "score.h"
24#include "scdsp.h"
25#include "scfns.h"
26
27#define LCL_PRT 3 /* 1-origin local keyboard port number */
28
29/*
30
31*/
32
33extern short (*point)();
34
35extern short ancmsw;
36extern short angroup;
37extern short asmode;
38extern short astat;
39extern short aval;
40extern short ctrsw;
41extern short curasg;
42extern short curtun;
43extern short curvce;
44extern short editsw;
45extern short gomode;
46extern short gtmsel;
47extern short insmode;
48extern short ismode;
49extern short ldpass;
50extern short lksel;
51extern short lstbgnc;
52extern short lstendc;
53extern short lstflag;
54extern short oldpk;
55extern short pkctrl;
56extern short recsw;
57extern short stepenb;
58extern short stepint;
59extern short stepwgt;
60
61extern char keystat[];
62extern char trgtab[];
63
64extern short grpmode[];
65extern short grpstat[];
66extern short grptmap[];
67extern short ldmap[];
68extern short prstab[];
69extern short tuntab[];
70extern short veltab[];
71extern short vce2grp[];
72extern short vce2trg[];
73
74extern short grp2prt[][2];
75extern short ldbox[][8];
76extern short varmode[][16];
77
78extern struct gdsel *gdstbc[];
79
80extern struct n_entry *lstbgns[NLSTENTS];
81extern struct n_entry *lstends[NLSTENTS];
82
83/*
84
85*/
86
87short lclkmap[24] = { /* local key to MIDI key number map table */
88
89 0, 1, 2, 3, 4, 5, 6, /* 1..7 */
90 7, 8, 9, 10, 11, 12, 13, /* 8..14 */
91 114, 115, 116, 117, 118, 119, 120, /* 15..21 */
92 121, 122, 123 /* 22..24 */
93};
94
95short panlkey[24] = { /* default tunings, in cents, for local keys */
96
97 560, 960, 1360, 1760, 2160, 2560, 2960, 3360,
98 3760, 4160, 4560, 4960, 5360, 5760, 6160, 6560, 6960,
99 7360, 7760, 8160, 8560, 8960, 9360, 9760
100};
101
102/*
103
104*/
105
106short stepfrm[4][17] = { /* step mode frame counts */
107
108 /* 1 1 1 1 1 1 */
109 /* -- -- -- - - - */
110 /* 64 32 16 8 4 2 1 */
111
112 { 3, 4, 10, 22, 46, 94, 190, /* legato - normal */
113 7, 16, 34, 70, 142, 286, /* legato - dotted */
114 3, 6, 14, 30}, /* legato - triplets */
115
116 { 2, 4, 8, 16, 32, 64, 128, /* normal - normal */
117 6, 12, 24, 48, 96, 192, /* normal - dotted */
118 3, 5, 10, 20}, /* normal - triplets */
119
120 { 2, 3, 4, 6, 10, 16, 24, /* stacato - normal */
121 4, 5, 8, 12, 20, 30, /* stacato - dotted */
122 3, 4, 5, 8}, /* stacato - triplets */
123
124 { 3, 6, 12, 24, 48, 96, 192, /* interval - normal */
125 9, 18, 36, 72, 144, 288, /* interval - dotted */
126 4, 8, 16, 32} /* interval - triplets */
127};
128
129/*
130
131*/
132
133/*
134 =============================================================================
135 setleds() -- set LEDs according to pkctrl, etc.
136 =============================================================================
137*/
138
139setleds()
140{
141 register short i;
142
143 for (i = 0; i < 24; i++) /* turn off all LEDs */
144 io_leds = 0x0080 | i;
145
146 switch (pkctrl) {
147
148 default:
149 case PK_PFRM: /* performance */
150 case PK_INST: /* instrument */
151 case PK_LOAD: /* load */
152
153 return;
154
155 case PK_NOTE: /* note entry */
156
157 if (stepenb)
158 io_leds = 0x01;
159
160 io_leds = 6 - stepwgt;
161 io_leds = 7 + stepint;
162 return;
163
164 case PK_ASGN: /* assignment table */
165
166 if (curasg EQ 0)
167 return;
168
169 io_leds = (curasg - 1) % 20; /* indicate current assignment */
170 return;
171/*
172
173*/
174 case PK_GOTO: /* go to */
175
176 if (gomode EQ GO_SECT) { /* indicate active sections */
177
178 for (i = 0; i < 20; i++)
179 if (E_NULL NE seclist[curscor][i])
180 io_leds = i;
181
182 } else { /* indicate active scores */
183
184 for (i = 0; i < 20; i++)
185 if (E_NULL NE scores[i])
186 io_leds = i;
187 }
188
189 return;
190
191 case PK_LIBR:
192
193 for (i = 0; i < 20; i++)
194 if (E_NULL NE scores[i])
195 io_leds = i;
196
197 return;
198 }
199}
200
201/*
202
203*/
204
205/*
206 =============================================================================
207 localkb() -- local keyboard processing
208 =============================================================================
209*/
210
211localkb(sig)
212short sig;
213{
214 register short i, trg, lclkey, key, vel;
215 register struct s_entry *ep;
216 short val, disptag;
217
218 key = sig - 1;
219
220 switch (pkctrl) {
221
222 case PK_PFRM: /* performance */
223
224 lclkey = lclkmap[key];
225 trg = ((LCL_PRT - 1) << 11) + lclkey;
226
227 if (astat) { /* key down */
228
229 prstab[trg] = SM_SCALE(aval);
230
231 if (keystat[key] EQ 0) { /* initial key closure */
232
233 trgtab[trg] |= M_KSTATE;
234 veltab[trg] = vel = SM_SCALE(64);
235 keystat[key] = 1;
236
237 stmproc(trg); /* process as a patch stimulus */
238
239 if (editsw) { /* edit mode */
240
241 execkey(trg, tuntab[lclkey], curvce, 0);
242
243 } else { /* normal mode */
244
245 for (i = 0; i < 12; i++)
246 if ((grp2prt[i][0] EQ LCL_PRT) AND
247 (grp2prt[i][1] EQ 1)) {
248
249 asgvce(i, LCL_PRT - 1, 0, lclkey, vel);
250 ne_bgn(i, lclkey, vel);
251 }
252 }
253/*
254
255*/
256 } else { /* pressure change */
257
258 val = SM_SCALE(aval);
259
260 for (i = 0; i < 12; i++) {
261
262 if ((grp2prt[i][0] EQ LCL_PRT) AND
263 (grp2prt[i][1] EQ 1)) {
264
265 if (newsv(i, SM_KPRS, val)) {
266
267 if (recsw AND grpstat[i] AND
268 (2 EQ (ancmsw ? varmode[5][i] : grpmode[i]))) {
269
270 if (E_NULL NE (ep = e_alc(E_SIZE2))) {
271
272 ep->e_time = t_cur;
273 ep->e_type = EV_ANVL;
274 ep->e_data1 = 0x0050 | i;
275 ep->e_dn = (struct s_entry *)((long)val << 16);
276 p_cur = e_ins(ep, ep_adj(p_cur, 0, t_cur))->e_fwd;
277 ctrsw = TRUE;
278 se_disp(ep, D_FWD, gdstbc, 1);
279 ctrsw = FALSE;
280 }
281
282 } else if ((angroup - 1) EQ i) {
283
284 dsanval(5);
285 }
286 }
287 }
288 }
289 }
290/*
291
292*/
293 } else { /* key release */
294
295 keystat[key] = 0;
296 trgtab[trg] &= ~M_KSTATE;
297 prstab[trg] = 0;
298
299 if (NOT trgtab[trg]) {
300
301 for (i = 0; i < 12; i++) {
302
303 if (vce2trg[i] EQ trg) {
304
305 vce2trg[i] = -1;
306 procpfl(trg);
307 }
308
309 if ((grp2prt[i][0] EQ LCL_PRT) AND
310 (grp2prt[i][1] EQ 1))
311 ne_end(trg, i);
312 }
313
314 stmproc(0x8000 | trg); /* process as a patch stimulus */
315 }
316 }
317
318 return;
319
320/*
321
322*/
323 case PK_NOTE: /* note entry - interval and weight selection */
324
325 if (astat) { /* key down */
326
327 if (keystat[key] EQ 0) { /* closure */
328
329 keystat[key] = 1;
330
331 if (key EQ 0) { /* delete last entry */
332
333 disptag = FALSE;
334
335 while (lstendc-- > 0) { /* note ends */
336
337 ep = lstends[lstendc];
338 lstends[lstendc] = (struct n_entry *)NULL;
339
340 if ((struct n_entry *)NULL EQ ep)
341 continue;
342
343 if (ep EQ p_bak)
344 p_bak = p_bak->e_bak;
345
346 if (ep EQ p_ctr)
347 p_ctr = p_ctr->e_bak;
348
349 if (ep EQ p_cur)
350 p_cur = p_cur->e_bak;
351
352 if (ep EQ p_fwd)
353 p_fwd = p_fwd->e_bak;
354
355 e_del(e_rmv(ep));
356 disptag = TRUE;
357 }
358
359 lstendc = 0;
360/*
361
362*/
363 while (lstbgnc-- > 0) { /* note begins */
364
365 ep = lstbgns[lstbgnc];
366 lstbgns[lstbgnc] = (struct n_entry *)NULL;
367
368 if ((struct n_entry *)NULL EQ ep)
369 continue;
370
371 if (ep EQ p_bak)
372 p_bak = p_bak->e_bak;
373
374 if (ep EQ p_ctr)
375 p_ctr = p_ctr->e_bak;
376
377 if (ep EQ p_cur)
378 p_cur = p_cur->e_bak;
379
380 if (ep EQ p_fwd)
381 p_fwd = p_fwd->e_bak;
382
383 e_del(e_rmv(ep));
384 disptag = TRUE;
385 }
386
387 lstbgnc = 0;
388 lstflag = FALSE;
389
390 if (disptag) {
391
392 if ((fc_val - stepfrm[3][stepint]) GE 0L)
393 fc_val -= stepfrm[3][stepint];
394
395 sc_refr(fc_val);
396 }
397
398 } else if (key EQ 1) { /* enable step */
399
400 stepenb = NOT stepenb;
401 setleds();
402
403/*
404
405*/
406 } else if (key EQ 2) { /* insert bar */
407
408 if (recsw) {
409
410 if (E_NULL NE (ep = e_alc(E_SIZE1))) {
411
412 ep->e_type = EV_BAR;
413 ep->e_time = t_cur;
414 p_cur = e_ins(ep, ep_adj(p_cur, 1, t_cur)->e_bak)->e_fwd;
415 sc_refr(fc_val);
416 }
417 }
418
419 } else if (key EQ 3) { /* insert a rest */
420
421 if ((fc_val + stepfrm[3][stepint]) < 0x00FFFFFEL)
422 fc_val += stepfrm[3][stepint];
423
424 } else if ((key GE 4) AND (key LE 6)) {
425
426 stepwgt = 6 - key; /* select weight */
427 setleds();
428
429 } else if ((key GE 7) AND (key LE 23)) {
430
431 stepint = key - 7; /* select interval */
432 setleds();
433 }
434 }
435
436 } else { /* key up */
437
438 keystat[key] = 0;
439 }
440
441 return;
442/*
443
444*/
445
446 case PK_INST: /* instrument selection */
447
448 if (astat) {
449
450 if (keystat[key] EQ 0) {
451
452 keystat[key] = 1;
453
454 if (key GE 20)
455 return;
456
457 if (ismode EQ IS_LORC)
458 selins(key + 1);
459 else
460 selins(key + 21);
461 }
462
463 } else {
464
465 keystat[key] = 0;
466 }
467
468 return;
469
470 case PK_ASGN: /* assignment table selection */
471
472 if (astat) {
473
474 if (keystat[key] EQ 0) {
475
476 keystat[key] = 1;
477
478 if ((asmode EQ 5) AND (key GE 19))
479 return;
480 else if (key GE 20)
481 return;
482
483 selasg(key + 1 + ((asmode - 1) * 20));
484 }
485
486 } else {
487
488 keystat[key] = 0;
489 }
490
491 return;
492/*
493
494*/
495 case PK_GOTO: /* go to */
496
497 if (astat) {
498
499 if (keystat[key] EQ 0) {
500
501 keystat[key] = 1;
502
503 if (key GE 20) /* limit key range */
504 return;
505
506 if (gomode EQ GO_SECT) { /* section */
507
508 if (E_NULL NE (ep = seclist[curscor][key])) {
509
510 if (insmode) {
511
512 icancel();
513 dsimode();
514 }
515
516 sc_goto(fc_val = ep->e_time);
517 pkctrl = oldpk;
518 gomode = GO_NULL;
519 GLCcurs(G_ON);
520 GLCtext(0, 31, "Go To");
521 point = GLCplot;
522 lseg(GOTO_XL, GOTO_Y, GOTO_XR, GOTO_Y, 0);
523 GLCcurs(G_OFF);
524 setleds();
525 return;
526 }
527/*
528
529*/
530 } else { /* score */
531
532 if (E_NULL NE scores[key]) {
533
534 if (insmode) {
535
536 icancel();
537 dsimode();
538 }
539
540 selscor(key);
541 pkctrl = oldpk;
542 gomode = GO_NULL;
543 GLCcurs(G_ON);
544 GLCtext(0, 31, "Go To");
545 point = GLCplot;
546 lseg(GOTO_XL, GOTO_Y, GOTO_XR, GOTO_Y, 0);
547 GLCcurs(G_OFF);
548 setleds();
549 return;
550 }
551 }
552 }
553
554 } else {
555
556 keystat[key] = 0;
557 }
558
559 return;
560/*
561
562*/
563 case PK_LIBR:
564
565 if (astat) {
566
567 if (keystat[key] EQ 0) {
568
569 keystat[key] = 1;
570
571 if ((-1 NE lksel) AND (key < 20)) {
572
573 ldpass = 2;
574
575 for (i = 0; i < N_SCORES; i++)
576 if (ldmap[i] EQ key) {
577
578 ldmap[i] = -1;
579 dpy_scr(ldbox[1][4], i);
580 }
581
582 ldmap[lksel] = key;
583 dpy_scr(ldbox[1][4], lksel);
584 lksel = -1;
585 }
586 }
587
588 } else {
589
590 keystat[key] = 0;
591 }
592
593 return;
594/*
595
596*/
597 case PK_NGRP:
598
599 if (astat) {
600
601 if (keystat[key] EQ 0) {
602
603 keystat[key] = 1;
604
605 if ((-1 NE gtmsel) AND (key < 12)) {
606
607 for (i = 0; i < 12; i++)
608 if (grptmap[i] EQ key) {
609
610 grptmap[i] = -1;
611 dsgtme(i);
612 }
613
614 grptmap[gtmsel] = key;
615 dsgtmn(gtmsel, FALSE);
616 dsgtme(gtmsel);
617 gtmsel = -1;
618 }
619 }
620
621 } else {
622
623 keystat[key] = 0;
624 }
625
626 return;
627
628 case PK_LOAD:
629
630 if (astat)
631 keystat[key] = 1;
632 else
633 keystat[key] = 0;
634
635 return;
636 }
637}
Note: See TracBrowser for help on using the repository browser.