source: buchla-68k/orig/RAM/SQSCAN.C@ ca867c1

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

Imported original source code.

  • Property mode set to 100755
File size: 18.9 KB
Line 
1/*
2 =============================================================================
3 sqscan.c -- scan a string and turn it into score events
4 Version 24 -- 1988-06-20 -- D.N. Lynx Crowe
5 =============================================================================
6*/
7
8#define CHEKSTOP 1 /* non-zero to trap to ROMP on error */
9
10#include "stddefs.h"
11#include "cmeta.h"
12#include "score.h"
13#include "scfns.h"
14#include "biosdefs.h"
15
16#if CHEKSTOP
17short chkstop = TRUE;
18#endif
19
20extern short notenum, notepit, curgrp, thescore, verbose;
21extern short testing;
22extern short sharp, endflg;
23
24extern long curtime, noteon, noteoff, noteval, noteper, nrest;
25extern long dvwork;
26
27char *nlist[] = { "a", "b", "c", "d", "e", "f", "g", NULL };
28
29int notetab[] = { 0, 2, 3, 5, 7, 8, 10 };
30int octab[] = { 21, 33, 45, 57, 69, 81, 93, 105 };
31
32/*
33
34*/
35
36/*
37 =============================================================================
38 nospace(et) -- print error message for no space condition
39 =============================================================================
40*/
41
42nospace(et)
43char *et;
44{
45
46#if CHEKSTOP
47 if (chkstop) {
48
49 printf("\n** sqscan: ERROR - no space for %s **\n\n", et);
50 xtrap15(); /* ERROR: trap to ROMP */
51
52 SEsnap();
53 waitcr();
54 }
55#endif
56}
57
58/*
59
60*/
61
62/*
63 =============================================================================
64 Pcheck(ptr, msg) -- check 'ptr' for validity -- output msg if bad.
65 A pointer is invalid if it points outside the score or is null.
66 Returns SUCCESS for a good pointer, FAILURE for a bad one.
67 =============================================================================
68*/
69
70int
71Pcheck(ptr, msg)
72struct s_entry *ptr;
73char *msg;
74{
75 register struct s_entry *cval;
76
77 if (ptr EQ E_NULL) {
78
79 printf("** Pcheck($%08.8lx): ZERO - %s **\n", ptr, msg);
80
81#if CHEKSTOP
82 if (chkstop)
83 xtrap15(); /* ERROR: trap to ROMP */
84#endif
85 return(FAILURE);
86 }
87
88 cval = spool;
89
90 if (ptr LT cval) {
91
92 printf("** Pcheck($%08.8lx): LOW - %s **\n", ptr, msg);
93#if CHEKSTOP
94 if (chkstop)
95 xtrap15(); /* ERROR: trap to ROMP */
96#endif
97 return(FAILURE);
98 }
99
100 cval = &spool[(long)MAX_SE-1];
101
102 if (ptr GT cval) {
103
104 printf("** Pcheck($%08.8lx): HIGH - %s **\n", ptr, msg);
105#if CHEKSTOP
106 if (chkstop)
107 xtrap15(); /* ERROR: trap to ROMP */
108#endif
109 return(FAILURE);
110 }
111
112 return(SUCCESS);
113}
114
115/*
116
117*/
118
119/*
120 =============================================================================
121 insnevt() -- insert a note event at t_cur/p_cur
122 =============================================================================
123*/
124
125struct n_entry *
126insnevt(nsp, nt, grp, note, vel)
127register struct n_entry *nsp;
128short nt, grp, note, vel;
129{
130 nsp->e_time = t_cur;
131 nsp->e_type = nt;
132 nsp->e_note = note;
133 nsp->e_group = grp;
134 nsp->e_vel = vel;
135
136 return(e_ins((struct s_entry *)nsp, ep_adj(p_cur, 0, t_cur))->e_fwd);
137}
138
139/*
140
141*/
142
143/*
144 =============================================================================
145 Qevent() -- 'event' syntax equation
146 =============================================================================
147*/
148
149int
150Qevent()
151{
152 register int aux1, aux2, aux3, aux4, aux5;
153 register char *chptr;
154 register struct s_entry *tsp1, *tsp2;
155 struct s_entry *tsp3;
156
157 if (!CM_CHR('!')) /* all commands start with ! */
158 CM_NOGO;
159
160 if (CM_USTR("group")) { /* !group = n */
161
162 if (!CM_CHR('='))
163 CM_NOGO;
164
165 if (!CM_NUM)
166 CM_NOGO;
167
168 curgrp = QQnum;
169
170 if (verbose)
171 printf("<Current group = %d>\n", curgrp);
172
173 CM_OK;
174 }
175
176/*
177
178*/
179 if (CM_USTR("status")) { /* !status = {on|off} */
180
181 if (!CM_CHR('='))
182 CM_NOGO;
183
184 if (CM_USTR("on")) {
185
186 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
187
188 nospace("!status=on");
189 CM_NOGO;
190 }
191
192 tsp1->e_time = t_cur;
193 tsp1->e_type = EV_GRP;
194 tsp1->e_data1 = curgrp;
195 tsp1->e_data2 = GS_ENBL;
196
197 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
198 eh_ins(tsp1, EH_GRP);
199
200 if (verbose)
201 printf("%8ld: Group %d enabled\n",
202 t_cur, curgrp);
203 CM_OK;
204
205 } else if (CM_USTR("off")) {
206
207 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
208
209 nospace("!status=off");
210 CM_NOGO;
211 }
212
213 tsp1->e_time = t_cur;
214 tsp1->e_type = EV_GRP;
215 tsp1->e_data1 = curgrp;
216 tsp1->e_data2 = GS_DSBL;
217
218 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
219 eh_ins(tsp1, EH_GRP);
220
221 if (verbose)
222 printf("%8ld: Group %d disabled\n",
223 t_cur, curgrp);
224 CM_OK;
225
226 } else
227 CM_NOGO;
228 }
229
230/*
231
232*/
233 if (CM_USTR("tempo")) { /* !tempo = n */
234
235 if (!CM_CHR('='))
236 CM_NOGO;
237
238 if (!CM_NUM)
239 CM_NOGO;
240
241 aux1 = QQnum;
242
243 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
244
245 nospace("!tempo");
246 CM_NOGO;
247 }
248
249 tsp1->e_time = t_cur;
250 tsp1->e_type = EV_TMPO;
251 tsp1->e_data1 = aux1;
252
253 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
254 eh_ins(tsp1, EH_TMPO);
255
256 if (verbose)
257 printf("%8ld: Tempo = %d\n", t_cur, aux1);
258 CM_OK;
259 }
260/*
261
262*/
263 if (CM_USTR("inst")) { /* !inst = n */
264
265 if (!CM_CHR('='))
266 CM_NOGO;
267
268 if (!CM_NUM)
269 CM_NOGO;
270
271 aux1 = QQnum;
272
273 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
274
275 nospace("!inst");
276 CM_NOGO;
277 }
278
279 tsp1->e_time = t_cur;
280 tsp1->e_type = EV_INST;
281 tsp1->e_data1 = curgrp;
282 tsp1->e_data2 = aux1;
283
284 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
285 eh_ins(tsp1, EH_INST);
286
287 if (verbose)
288 printf("%8ld: group %d set to inst %d\n",
289 t_cur, curgrp, aux1);
290 CM_OK;
291 }
292/*
293
294*/
295 if (CM_USTR("tuning")) { /* !tuning = n */
296
297 if (!CM_CHR('='))
298 CM_NOGO;
299
300 if (!CM_NUM)
301 CM_NOGO;
302
303 aux1 = QQnum;
304
305 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
306
307 nospace("!tuning");
308 CM_NOGO;
309 }
310
311 tsp1->e_time = t_cur;
312 tsp1->e_type = EV_TUNE;
313 tsp1->e_data1 = aux1;
314
315 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
316 eh_ins(tsp1, EH_TUNE);
317
318 if (verbose)
319 printf("%8ld: Tuning %d selected\n", t_cur, aux1);
320 CM_OK;
321 }
322/*
323
324*/
325 if (CM_USTR("trans")) { /* !trans = {+|-} n */
326
327 if (!CM_CHR('='))
328 CM_NOGO;
329
330 if (CM_CHR('+')) {
331
332 } else if (CM_CHR('-')) {
333
334 } else
335 CM_NOGO;
336
337 if (!CM_NUM)
338 CM_NOGO;
339
340 aux1 = QQnum;
341
342 if (QQchr EQ '-')
343 aux1 = -aux1;
344
345 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
346
347 nospace("!trans");
348 CM_NOGO;
349 }
350
351 tsp1->e_time = t_cur;
352 tsp1->e_type = EV_TRNS;
353 tsp1->e_data1 = curgrp;
354 (long)(tsp1->e_lft) = aux1;
355
356 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
357 eh_ins(tsp1, EH_TRNS);
358
359 if (verbose)
360 printf("%8ld: Transposition set to %d\n",
361 t_cur, aux1);
362 CM_OK;
363 }
364/*
365
366*/
367 if (CM_USTR("dyn")) { /* !dyn = n */
368
369 if (!CM_CHR('='))
370 CM_NOGO;
371
372 if (!CM_NUM)
373 CM_NOGO;
374
375 aux1 = QQnum;
376
377 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
378
379 nospace("!dyn");
380 CM_NOGO;
381 }
382
383 tsp1->e_time = t_cur;
384 tsp1->e_type = EV_DYN;
385 tsp1->e_data1 = curgrp;
386 tsp1->e_data2 = aux1;
387
388 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
389 eh_ins(tsp1, EH_DYN);
390
391 if (verbose)
392 printf("%8ld: Dynamics set to %d\n", t_cur, aux1);
393 CM_OK;
394 }
395/*
396
397*/
398 if (CM_USTR("loc")) { /* !loc = n */
399
400 if (!CM_CHR('='))
401 CM_NOGO;
402
403 if (!CM_NUM)
404 CM_NOGO;
405
406 aux1 = QQnum;
407
408 if (E_NULL EQ (tsp1 = e_alc(E_SIZE2))) {
409
410 nospace("!loc");
411 CM_NOGO;
412 }
413
414 tsp1->e_time = t_cur;
415 tsp1->e_type = EV_LOCN;
416 tsp1->e_data1 = curgrp;
417 tsp1->e_data2 = aux1;
418
419 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
420 eh_ins(tsp1, EH_LOCN);
421
422 if (verbose)
423 printf("%8ld: Location set to %d\n", t_cur, aux1);
424 CM_OK;
425 }
426/*
427
428*/
429 if (CM_USTR("goto")) { /* !goto n @ n */
430
431 if (!CM_NUM)
432 CM_NOGO;
433
434 curtime = QQnum * 48;
435
436 if (!CM_CHR('@'))
437 CM_NOGO;
438
439 if (!CM_NUM)
440 CM_NOGO;
441
442 sc_goto(curtime += QQnum);
443
444 if (verbose)
445 printf("\n<Score time set to %ld>\n", t_cur);
446
447 CM_OK;
448 }
449
450/*
451
452*/
453
454 if (CM_USTR("pos")) { /* !pos = n @ n */
455
456 if (!CM_CHR('='))
457 CM_NOGO;
458
459 if (!CM_NUM)
460 CM_NOGO;
461
462 curtime = QQnum * 48;
463
464 if (!CM_CHR('@'))
465 CM_NOGO;
466
467 if (!CM_NUM)
468 CM_NOGO;
469
470 t_cur = (curtime += QQnum);
471 p_cur = frfind(t_cur, 0);
472
473 if (verbose)
474 printf("\n<Score time set to %ld>\n", t_cur);
475
476 CM_OK;
477 }
478/*
479
480*/
481 if (CM_USTR("beat")) { /* !beat = n */
482
483 if (!CM_CHR('='))
484 CM_NOGO;
485
486 if (!CM_NUM)
487 CM_NOGO;
488
489 t_cur = QQnum * 48;
490 p_cur = frfind(t_cur, 0);
491
492 if (verbose)
493 printf("\n<Score time set to %ld>\n", t_cur);
494
495 CM_OK;
496 }
497/*
498
499*/
500 if (CM_USTR("frame")) { /* !frame = n */
501
502 if (!CM_CHR('='))
503 CM_NOGO;
504
505 if (!CM_NUM)
506 CM_NOGO;
507
508 t_cur = QQnum;
509 p_cur = frfind(t_cur, 0);
510
511 if (verbose)
512 printf("\n<Score time set to %ld>\n", t_cur);
513
514 CM_OK;
515 }
516/*
517
518*/
519 if (CM_USTR("score")) { /* !score = n */
520
521 if (!CM_CHR('='))
522 CM_NOGO;
523
524 if (!CM_NUM)
525 CM_NOGO;
526
527 if (QQnum > 127)
528 CM_NOGO;
529
530 thescore = QQnum;
531
532 selscor(thescore);
533
534 if (verbose)
535 printf("\n<Score %d selected>\n", thescore);
536 CM_OK;
537 }
538/*
539
540*/
541 if (CM_USTR("weight")) { /* !weight = n */
542
543 if (!CM_CHR('='))
544 CM_NOGO;
545
546 if (!CM_NUM)
547 CM_NOGO;
548
549 if (QQnum > 100L)
550 CM_NOGO;
551
552 noteper = QQnum;
553
554 if (verbose)
555 printf("<Note weight = %ld percent>\n", noteper);
556
557 CM_OK;
558 }
559
560 if (CM_USTR("snap")) { /* !snap */
561
562 SEsnap();
563 CM_OK;
564 }
565
566 if (CM_USTR("wait")) { /* !wait */
567
568 waitcr();
569 CM_OK;
570 }
571
572 if (CM_USTR("stop")) { /* !stop */
573
574 if (E_NULL EQ (tsp1 = e_alc(E_SIZE1))) {
575
576 nospace("!stop");
577 CM_NOGO;
578 }
579
580 tsp1->e_time = t_cur;
581 tsp1->e_type = EV_STOP;
582
583 p_cur = e_ins(tsp1, ep_adj(p_cur, 0, t_cur))->e_fwd;
584
585 if (verbose)
586 printf("%8ld: Stop entered\n", t_cur);
587 CM_OK;
588 }
589/*
590
591*/
592 if (CM_USTR("clear")) { /* !clear {n | * | $} */
593
594 if (CM_NUM) {
595
596 aux1 = QQnum;
597 sc_clr(aux1);
598
599 if (verbose)
600 printf("\n<Score %d cleared>\n", aux1);
601
602 CM_OK;
603 }
604
605 if (CM_CHR('*')) {
606
607 scinit();
608
609 if (verbose)
610 printf("\n<All scores cleared>\n");
611
612 CM_OK;
613 }
614
615 if (CM_CHR('$')) {
616
617 sc_clr(curscor);
618
619 if (verbose)
620 printf("\n<Current score (%d) cleared>\n", curscor);
621
622 CM_OK;
623 }
624
625 CM_NOGO;
626 }
627/*
628
629*/
630 if (CM_USTR("show")) { /* !show {active | names | sections} */
631
632 if (CM_USTR("active")) {
633
634 printf("<Active scores:\n");
635 aux1 = aux2 = 0;
636
637 for (aux3 = 0; aux3 < 4; aux3++) {
638
639 printf("<");
640
641 for (aux4 = 0; aux4 < 16; aux4++) {
642
643 if (scores[aux1]) {
644
645 printf("%3d ", aux1);
646 ++aux2;
647
648 } else {
649
650 printf("... ");
651 }
652
653 ++aux1;
654 }
655
656 printf(">\n");
657 }
658
659 printf("<%d active scores, score %d is current>\n\n",
660 aux2, curscor);
661 CM_OK;
662 }
663/*
664
665*/
666 if (CM_USTR("names")) {
667
668 printf("<Active score names:>\n");
669 aux2 = 0;
670
671 for (aux1 = 0; aux1 < 128; aux1++) {
672
673 if (scores[aux1] NE E_NULL) {
674
675 printf("<%3d: ", aux1);
676 chptr = scname[aux1];
677 printf("[$%08.8lx, $%08.8lx] ",
678 scores[aux1], chptr);
679
680 for (aux3 = 0; aux3 < 16; aux3++)
681 printf("%c", (*chptr++ & 0xFF));
682
683 printf(">\n");
684 ++aux2;
685 }
686 }
687
688 printf("<%d active scores, %d is current>\n\n",
689 aux2, curscor);
690
691 CM_OK;
692 }
693/*
694
695*/
696 if (CM_USTR("sections")) {
697
698 printf("<Active sections:>\n");
699 aux1 = aux2 = 0;
700
701 for (aux3 = 0; aux3 < 5; aux3++) {
702
703 printf("<");
704
705 for (aux4 = 0; aux4 < 10; aux4++) {
706
707 if (seclist[curscor][aux1]) {
708
709 printf("%3d ", aux1);
710 ++aux2;
711
712 } else {
713
714 printf("... ");
715 }
716
717 ++aux1;
718 }
719
720 printf(">\n");
721 }
722
723 printf("<%d active sections, %d is current>\n\n",
724 aux2, cursect);
725 CM_OK;
726 }
727
728 CM_NOGO;
729 }
730/*
731
732*/
733 if (CM_USTR("find")) { /* !find {l | r} n */
734
735 if (CM_UCHR('l'))
736 aux1 = 1;
737 else if (CM_UCHR('r'))
738 aux1 = 0;
739 else
740 CM_NOGO;
741
742 if (!CM_NUM)
743 CM_NOGO;
744
745 tsp1 = frfind(QQnum, aux1);
746
747 if (tsp1 NE E_NULL) {
748
749 if (verbose)
750 printf("\n<FIND: Found %ld at $%08.8lx>\n\n",
751 QQnum, tsp1);
752
753 p_cur = tsp1;
754 t_cur = QQnum;
755
756 } else {
757
758 if (verbose)
759 printf("<FIND: Found the current score empty>\n\n");
760
761 CM_NOGO;
762 }
763
764 CM_OK;
765 }
766/*
767
768*/
769 if (CM_USTR("chase")) { /* !chase */
770
771 if (E_NULL EQ (tsp1 = p_cur)) {
772
773 printf("<CHASE: Current score not active>\n\n");
774 CM_NOGO;
775 }
776
777 tsp2 = tsp1;
778
779 while (tsp2) {
780
781 tsp3 = &spool[0];
782
783 if (tsp2 LT tsp3) {
784
785 printf("\nCHASE: Error\n");
786 printf("** Bad pointer: $%08.8lx\n", tsp2);
787 printf("** spool: $%08.8lx, pspool: $%08.8lx\n",
788 &spool[0], pspool);
789 CM_NOGO;
790 }
791
792 tsp3 = &spool[MAX_SE-1];
793
794 if (tsp2 GT tsp3) {
795
796 printf("\nCHASE: Error\n");
797 printf("** Bad pointer: $%08.8lx\n", tsp2);
798 printf("** spool: $%08.8lx, pspool: $%08.8lx\n",
799 &spool[0], pspool);
800 CM_NOGO;
801 }
802
803 SEdump(tsp2);
804 tsp2 = tsp2->e_fwd;
805
806 if ((tsp1 EQ tsp2) OR
807 (tsp2->e_type EQ EV_SCORE)) {
808
809 printf("-- End of chain --\n\n");
810 break;
811 }
812 }
813
814 CM_OK;
815 }
816/*
817
818*/
819 if (CM_USTR("verbose")) { /* !verbose */
820
821 verbose = TRUE;
822 CM_OK;
823 }
824
825 if (CM_USTR("quiet")) { /* !quiet */
826
827 verbose = FALSE;
828 CM_OK;
829 }
830
831 if (CM_USTR("test")) { /* !test */
832
833 testing = TRUE;
834 CM_OK;
835 }
836
837 if (CM_USTR("normal")) { /* !normal */
838
839 testing = FALSE;
840 CM_OK;
841 }
842
843 if (CM_USTR("end")) { /* !end */
844
845 if (verbose)
846 printf("\n<End command encountered>\n");
847
848 endflg = TRUE;
849 CM_OK;
850 }
851
852 CM_NOGO;
853}
854
855/*
856
857*/
858
859/*
860 =============================================================================
861 Qnote() -- 'note' and rest syntax equation
862
863 "val [#] oct [+|-|/n]" | "r n / m"
864 e.g.: a#0+ .. a#0- .. c3/4 , r2/1 d3 , e3
865 =============================================================================
866*/
867
868int
869Qnote()
870{
871 struct n_entry *nsp1;
872
873 if (CM_UCHR('r')) { /* try for a rest */
874
875 if (!CM_NUM)
876 CM_NOGO;
877
878 nrest = QQnum;
879
880 if (!CM_CHR('/'))
881 CM_NOGO;
882
883 if (!CM_NUM)
884 CM_NOGO;
885
886 dvwork = 192L;
887 noteval = dvwork / QQnum;
888 t_cur += (noteval * nrest);
889 p_cur = ep_adj(p_cur, 0, t_cur);
890
891 if (verbose)
892 printf("%8ld: <rest>\n", t_cur);
893
894 CM_OK;
895 }
896/*
897
898*/
899 if (!CM_ULIST(nlist)) /* try for a note */
900 CM_NOGO;
901
902 notepit = QQlnum;
903
904 if (CM_CHR('#'))
905 sharp = 1;
906 else
907 sharp = 0;
908
909 if (!CM_DIG)
910 CM_NOGO;
911
912 if (QQdig > '7')
913 CM_NOGO;
914
915 notenum = octab[QQdig - '0'] + notetab[notepit] + sharp;
916
917 if (CM_CHR('+')) { /* output note begin */
918
919 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
920
921 nospace("note event");
922 CM_NOGO;
923 }
924
925 noteon = t_cur;
926 p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
927
928 if (verbose)
929 printf("%8ld: Note %3d ON\n", noteon, notenum);
930
931 CM_OK;
932 }
933/*
934
935*/
936 if (CM_CHR('-')) { /* output note end */
937
938 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
939
940 nospace("note event");
941 CM_NOGO;
942 }
943
944 noteoff = t_cur;
945 p_cur = insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
946
947 if (verbose)
948 printf("%8ld: Note %3d OFF\n", noteoff, notenum);
949
950 CM_OK;
951 }
952/*
953
954*/
955 if (CM_CHR('/')) { /* output note begin and end, given value */
956
957 if (!CM_NUM)
958 CM_NOGO;
959
960 dvwork = 192L;
961 noteval = dvwork / QQnum;
962 noteon = t_cur;
963 dvwork = 100L;
964 noteoff = t_cur + ((noteper * noteval) / dvwork);
965
966 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
967
968 nospace("note event");
969 CM_NOGO;
970 }
971
972 p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
973
974 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
975
976 nospace("note event");
977 CM_NOGO;
978 }
979
980 p_cur = ep_adj(p_cur, 0, (t_cur = noteoff));
981
982 insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
983
984 p_cur = ep_adj(p_cur, 0, (t_cur = noteon));
985
986 if (verbose)
987 printf("%8ld: Note %3d ON at %8ld, OFF at %8ld\n",
988 t_cur, notenum, noteon, noteoff);
989
990 CM_OK;
991 }
992/*
993
994*/
995 /* output note begin and end, use previous value */
996
997 noteon = t_cur;
998 dvwork = 100L;
999 noteoff = t_cur + ((noteval * noteper) / dvwork);
1000
1001 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
1002
1003 nospace("note event");
1004 CM_NOGO;
1005 }
1006
1007 p_cur = insnevt(nsp1, EV_NBEG, curgrp, notenum, 64);
1008
1009 if (E_NULL EQ (nsp1 = (struct n_entry *)e_alc(E_SIZE1))) {
1010
1011 nospace("note event");
1012 CM_NOGO;
1013 }
1014
1015 p_cur = ep_adj(p_cur, 0, (t_cur = noteoff));
1016
1017 insnevt(nsp1, EV_NEND, curgrp, notenum, 64);
1018
1019 p_cur = ep_adj(p_cur, 0, (t_cur = noteon));
1020
1021 if (verbose)
1022 printf("%8ld: Note %3d ON at %8ld, OFF at %8ld\n",
1023 t_cur, notenum, noteon, noteoff);
1024 CM_OK;
1025}
1026
1027/*
1028
1029*/
1030
1031/*
1032 =============================================================================
1033 Qadv() -- 'adv' syntax equation
1034 =============================================================================
1035*/
1036
1037int
1038Qadv()
1039{
1040 if (CM_CHR('.')) { /* advance by 1 frame */
1041
1042 ++t_cur;
1043 p_cur = ep_adj(p_cur, 0, t_cur);
1044 CM_OK;
1045 }
1046
1047 if (CM_CHR(',')) { /* advance by current note value */
1048
1049 t_cur += noteval;
1050 p_cur = ep_adj(p_cur, 0, t_cur);
1051 CM_OK;
1052 }
1053
1054 if (CM_CHR(';')) { /* avance to next beat */
1055
1056 dvwork = 48L;
1057 t_cur = ((t_cur / dvwork) + 1L) * 48L;
1058 p_cur = ep_adj(p_cur, 0, t_cur);
1059 CM_OK;
1060 }
1061
1062 if (CM_CHR(':')) { /* advance by one beat interval */
1063
1064 t_cur += 48L;
1065 p_cur = ep_adj(p_cur, 0, t_cur);
1066 CM_OK;
1067 }
1068
1069 CM_NOGO;
1070}
1071
1072/*
1073
1074*/
1075
1076/*
1077 =============================================================================
1078 Qseq() -- 'seq' syntax equation
1079 =============================================================================
1080*/
1081
1082int
1083Qseq()
1084{
1085 CM_DBLK;
1086
1087 if (!*QQip)
1088 CM_OK;
1089
1090 if (Qnote() OR Qadv() OR (Qevent() AND !endflg)) {
1091
1092 CM_DBLK;
1093
1094 if (!*QQip)
1095 return(QQsw);
1096
1097 while (QQsw AND !endflg) {
1098
1099 if (!Qadv())
1100 if (!Qnote())
1101 Qevent();
1102
1103 CM_DBLK;
1104
1105 if (!*QQip)
1106 return(QQsw);
1107 }
1108 }
1109
1110 return(QQsw);
1111}
1112
1113/*
1114
1115*/
1116
1117/*
1118 =============================================================================
1119 sqinit() -- setup score interpreter variables
1120 =============================================================================
1121*/
1122
1123sqinit()
1124{
1125 verbose = FALSE;
1126 testing = FALSE;
1127 endflg = FALSE;
1128
1129 noteval = 48L; /* default value = 1/4 note (192/48) */
1130 noteper = 80L; /* default weight = 80 percent */
1131
1132 curtime = t_cur = t_ctr = 0L;
1133 t_bak = t_cur - TO_BAK;
1134 t_fwd = t_cur + TO_FWD;
1135
1136 p_bak = p_cur = p_ctr = p_fwd = E_NULL;
1137
1138 curgrp = 0;
1139 thescore = 0;
1140}
1141
1142/*
1143
1144*/
1145
1146/*
1147 =============================================================================
1148 sqscan(ip) -- scans the string at 'ip' and converts the event
1149 descriptions therein to events in the current score. Returns
1150 the value of the parser switch.
1151 =============================================================================
1152*/
1153
1154int
1155sqscan(ip)
1156char *ip;
1157{
1158 endflg = FALSE;
1159 CMinit(ip);
1160
1161 if (!Qseq())
1162 CMstat("Syntax error");
1163
1164 return(QQsw);
1165}
Note: See TracBrowser for help on using the repository browser.