1
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */
2
/* From input file "status.pas" */
37
#define lowest_pitch (-9)
38
#define highest_pitch 61
41
typedef struct line_status {
42
short pitch, chord_pitch, octave_adjust, beam_level, slur_level, after_slur;
43
Char octave, lastnote, chord_lastnote, duration, slurID, tieID;
44
boolean beamnext, beamed, slurnext, slurred, no_beam_melisma;
45
boolean no_slur_melisma[12];
47
Char chord_tie_label[6];
51
Static Char init_oct[256] = "";
52
Static line_status current[maxvoices];
53
Static Char lastdur[maxvoices];
56
Void chordTie(voice, lab)
63
WITH = ¤t[voice-1];
64
n = strlen(WITH->chord_tie_label);
66
error3(voice, "Only five slur ties allowed per voice");
70
*lab = WITH->chord_tie_label[n-1];
72
sprintf(WITH->chord_tie_label + strlen(WITH->chord_tie_label), "%c", *lab);
73
/* p2c: status.pas, line 66:
74
* Note: Possible string truncation in assignment [145] */
76
WITH->chord_tie_pitch[n-1] = WITH->chord_pitch;
80
Void getChordTies(voice, pitches, labels)
87
WITH = ¤t[voice-1];
88
memcpy(pitches, WITH->chord_tie_pitch, sizeof(int5));
89
strcpy(labels, WITH->chord_tie_label);
90
*WITH->chord_tie_label = '\0';
94
Void rememberDurations()
96
voice_index v, FORLIM;
99
for (v = 1; v <= FORLIM; v++)
100
lastdur[v-1] = duration(v);
104
Void restoreDurations()
106
voice_index v, FORLIM;
109
for (v = 1; v <= FORLIM; v++)
110
resetDuration(v, lastdur[v-1]);
117
return (current[voice-1].duration);
121
Void resetDuration(voice, dur)
125
if (pos1(dur, durations) == 0) {
126
printf("Trying to set duration to %c; ", dur);
127
error3(voice, "M-Tx system error: resetDuration");
129
current[voice-1].duration = dur;
133
Void activateBeamsAndSlurs(voice)
138
WITH = ¤t[voice-1];
139
if (WITH->beamnext) {
141
WITH->beamnext = false;
143
if (WITH->slurnext) {
144
WITH->slurred = true;
145
WITH->slurnext = false;
152
Void saveStatus(voice)
157
WITH = ¤t[voice-1];
158
WITH->chord_pitch = WITH->pitch;
159
WITH->chord_lastnote = WITH->lastnote;
163
boolean noBeamMelisma(voice)
166
return (current[voice-1].no_beam_melisma);
170
short afterSlur(voice)
176
WITH = ¤t[voice-1];
177
Result = WITH->after_slur;
178
if (WITH->after_slur > 0 && WITH->slur_level < 1)
179
error3(voice, "M-Tx system error: afterSlur and slur_level incompatible)");
187
return (current[voice-1].octave);
191
Void resetOctave(voice)
194
current[voice-1].octave = ' ';
198
Void initOctaves(octaves)
203
strcpy(init_oct, octaves);
204
while (i <= strlen(init_oct)) {
205
if (init_oct[i-1] == ' ')
206
delete1(init_oct, i);
213
Static Char initOctave(voice_stave)
214
stave_index voice_stave;
216
if (voice_stave > strlen(init_oct)) {
217
if (pos1(clef[voice_stave-1], "Gt08") > 0)
222
return (init_oct[voice_stave-1]);
226
Void setOctave(voice)
229
current[voice-1].octave = initOctave(voiceStave(voice));
233
Void newOctave(voice, dir)
239
WITH = ¤t[voice-1];
253
Static short newPitch(voice, note_, pitch, lastnote)
260
short interval, npitch;
265
write('New pitch for note ',note,' relative to ',lastnote,
266
' at pitch ',pitch);*/
267
oct = octaveCode(note);
269
oct = initOctave(voiceStave(voice));
271
pitch = (oct - '0') * 7 - 3;
273
removeOctaveCode(oct, note);
274
oct = octaveCode(note);
276
interval = note[0] - lastnote;
281
npitch = pitch + interval; /*if debugMode then write(' was ',npitch);*/
287
removeOctaveCode(oct, note);
288
oct = octaveCode(note);
290
/*if debugMode then writeln(' is ',npitch);*/
295
Local Void delins(note, c1, c2, l)
306
while (l > 0 && i <= n) {
313
if (strlen(note) < 2)
314
error("M-Tx program error", print);
319
insertChar(c2, note, i);
325
Static Void repitch(note, diff)
331
delins(note, '-', '+', diff);
333
delins(note, '+', '-', -diff);
337
Void setUnbeamed(voice)
340
current[voice-1].beamed = false;
344
Void setUnslurred(voice)
349
WITH = ¤t[voice-1];
350
WITH->slurred = false;
351
WITH->after_slur = 0;
355
Void beginBeam(voice, note)
361
WITH = ¤t[voice-1];
363
error3(voice, "Starting a forced beam while another is open");
364
if (WITH->beam_level > 0)
366
"Starting a forced beam while another is open (beamlevel>0)");
368
WITH->beamnext = true;
369
WITH->no_beam_melisma = startsWith(note, "[[");
370
if (WITH->no_beam_melisma)
380
WITH = ¤t[voice-1];
381
if (WITH->beam_level < 1)
382
error3(voice, "Closing a beam that was never opened");
388
short slurLevel(voice)
391
return (current[voice-1].slur_level);
395
short beamLevel(voice)
398
return (current[voice-1].beam_level);
402
boolean noSlurMelisma(voice, history)
403
short voice, history;
407
WITH = ¤t[voice-1];
408
return (WITH->no_slur_melisma[WITH->slur_level + history - 1]);
412
Static Char *slurLabel(Result, voice, note)
420
return strcpy(Result, "");
421
if (strlen(note) < 2)
422
return strcpy(Result, " ");
423
if (note[1] >= '0' && note[1] <= 'Z')
427
if (sl >= 'I' && sl <= 'T')
428
warning3(voice, "Slur label in the range I..T may cause conflict");
429
sprintf(Result, "%c", sl);
434
Static Void labelSlur(voice, note)
443
WITH = ¤t[voice-1];
446
else if (note[0] == '}')
448
/** CMO 0.60a: replace assigning tieID to sl by space charater
449
if (note[1]='(') or (note[1]=')') then sl:=slurID else sl:=tieID; */
450
if (note[0] == '(' || note[0] == ')')
454
/** CMO 0.60d: omit insertchar in case of tie
455
insertchar(sl,note,2); */
456
if (note[0] == '(' || note[0] == ')')
457
insertChar(sl, note, 2);
460
else if (note[0] == '{')
462
if (WITH->slurID < 'I')
463
warning3(voice, "Too many nested slurs may cause conflict");
464
if (WITH->tieID < 'I')
465
warning3(voice, "Too many nested ties may cause conflict");
469
Void beginSlur(voice, note)
475
Char STR1[256], STR2[256];
477
WITH = ¤t[voice-1];
479
if (WITH->slur_level > 12)
480
error3(voice, "Too many open slurs");
481
WITH->no_slur_melisma[WITH->slur_level - 1] = (startsWith(note, "((") ||
482
startsWith(note, "{{"));
483
if (WITH->no_slur_melisma[WITH->slur_level - 1])
485
if (!strcmp(slurLabel(STR1, voice, note), "0"))
488
if (!strcmp(slurLabel(STR2, voice, note), " "))
489
labelSlur(voice, note);
491
posblind = pos1('~', note);
493
if (hideBlindSlurs())
496
delete1(note, posblind);
498
WITH->slurnext = true;
502
Void endSlur(voice, note)
506
short poscontinue, posblind;
509
Char STR1[256], STR2[256];
511
WITH = ¤t[voice-1];
513
if (WITH->slur_level < 1)
514
error3(voice, "Ending a slur that was never started");
516
poscontinue = pos1('(', note);
517
else if (note[0] == '}')
518
poscontinue = pos1('{', note);
519
if (poscontinue == 0)
523
strcpy(contslur, note);
524
predelete(contslur, poscontinue);
525
shorten(note, poscontinue);
527
if (WITH->slur_level == 0)
529
if (!strcmp(slurLabel(STR1, voice, note), "0"))
532
if (!strcmp(slurLabel(STR2, voice, note), " "))
533
labelSlur(voice, note);
535
if (!strcmp(slurLabel(STR1, voice, contslur), "0"))
536
delete1(contslur, 2);
538
if (!strcmp(slurLabel(STR2, voice, contslur), " "))
539
labelSlur(voice, contslur);
541
if (poscontinue > 0) {
545
if (contslur[0] == '{')
546
strcat(contslur, "t");
549
posblind = pos1('~', note);
551
if (hideBlindSlurs())
554
delete1(note, posblind);
556
if (*note != '\0' && *contslur != '\0')
557
sprintf(note + strlen(note), " %s", contslur);
561
Void renewPitch(voice, note)
568
WITH = ¤t[voice-1];
569
pstat = newPitch(voice, note, WITH->chord_pitch, WITH->chord_lastnote);
571
printf("Current pitch in voice %d is %d, last note was %c, this note is %s",
572
voice, WITH->pitch, WITH->lastnote, note);
573
WITH->pitch = newPitch(voice, note, WITH->pitch, WITH->lastnote);
574
if (WITH->pitch != pstat)
575
repitch(note, WITH->pitch - pstat);
576
if (WITH->pitch < lowest_pitch && checkPitch()) {
577
printf("Pitch of note %s following %c reported as %d",
578
note, WITH->lastnote, WITH->pitch);
579
error3(voice, "Pitch too low");
581
if (WITH->pitch > highest_pitch && checkPitch()) {
582
printf("Pitch of note %s following %c reported as %d",
583
note, WITH->lastnote, WITH->pitch);
584
error3(voice, "Pitch too high");
586
WITH->lastnote = note[0];
588
printf(", repitched to %d\n", WITH->pitch);
589
if (debugMode() && WITH->pitch != pstat)
590
printf("Pitch from melodic line = %d from last chordal note = %d\n",
595
short chordPitch(voice)
598
return (current[voice-1].chord_pitch);
602
Void renewChordPitch(voice, note)
608
WITH = ¤t[voice-1];
609
WITH->chord_pitch = newPitch(voice, note, WITH->chord_pitch,
610
WITH->chord_lastnote);
611
if (WITH->chord_pitch < lowest_pitch)
612
error3(voice, "Pitch in chord too low");
613
if (WITH->chord_pitch > highest_pitch)
614
error3(voice, "Pitch in chord too high");
615
WITH->chord_lastnote = note[0];
625
for (voice = 1; voice <= FORLIM; voice++) {
626
WITH = ¤t[voice-1];
627
WITH->duration = default_duration;
628
WITH->octave_adjust = 0;
629
WITH->slur_level = 0;
630
WITH->beam_level = 0;
631
WITH->beamed = false;
632
WITH->beamnext = false;
633
WITH->slurred = false;
634
WITH->slurnext = false;
635
WITH->after_slur = 0;
636
WITH->octave = initOctave(voiceStave(voice));
639
WITH->lastnote = 'f';
640
WITH->pitch = (WITH->octave - '0') * 7 - 3;
641
*WITH->chord_tie_label = '\0';