| 1 |
/* Output from p2c 1.21alpha-07.Dec.93, the Pascal-to-C translator */ |
| 2 |
/* From input file "lyrics.pas" */ |
| 3 |
|
| 4 |
|
| 5 |
#include "p2c.h" |
| 6 |
|
| 7 |
|
| 8 |
#define LYRICS_G |
| 9 |
#include "lyrics.h" |
| 10 |
|
| 11 |
|
| 12 |
#ifndef CONTROL_H |
| 13 |
#include "control.h" |
| 14 |
#endif |
| 15 |
|
| 16 |
#ifndef STRINGS_H |
| 17 |
#include "strings.h" |
| 18 |
#endif |
| 19 |
|
| 20 |
#ifndef MTXLINE_H |
| 21 |
#include "mtxline.h" |
| 22 |
#endif |
| 23 |
|
| 24 |
#ifndef STATUS_H |
| 25 |
#include "status.h" |
| 26 |
#endif |
| 27 |
|
| 28 |
#ifndef MULTFILE_H |
| 29 |
#include "multfile.h" |
| 30 |
#endif |
| 31 |
|
| 32 |
#ifndef FILES_H |
| 33 |
#include "files.h" |
| 34 |
#endif |
| 35 |
|
| 36 |
#ifndef UTILITY_H |
| 37 |
#include "utility.h" |
| 38 |
#endif |
| 39 |
|
| 40 |
|
| 41 |
/* Symbols used in strings of melismatype */ |
| 42 |
|
| 43 |
#define beam_melisma '[' |
| 44 |
#define inhibit_beam_melisma '<' |
| 45 |
#define slur_melisma '(' |
| 46 |
#define inhibit_slur_melisma '{' |
| 47 |
|
| 48 |
|
| 49 |
typedef char other_index; |
| 50 |
|
| 51 |
typedef char other_index0; |
| 52 |
|
| 53 |
typedef Char melismatype[256]; |
| 54 |
|
| 55 |
typedef enum { |
| 56 |
nolyr, haslyr |
| 57 |
} haslyrtype; |
| 58 |
typedef enum { |
| 59 |
normal, aux |
| 60 |
} auxtype; |
| 61 |
typedef enum { |
| 62 |
asbefore, newassign |
| 63 |
} assigntype; |
| 64 |
typedef enum { |
| 65 |
virgin, active |
| 66 |
} inittype; |
| 67 |
|
| 68 |
typedef struct lyrinfotype { |
| 69 |
short lyr_adjust, slur_level, slur_change, beam_level, beam_change; |
| 70 |
melismatype melisma; |
| 71 |
boolean numbered; |
| 72 |
} lyrinfotype; |
| 73 |
|
| 74 |
typedef enum { |
| 75 |
none_given, global_lyrics, local_lyrics |
| 76 |
} lyrlinetype; |
| 77 |
|
| 78 |
typedef struct lyrtagtype { |
| 79 |
lyrlinetype lyrsource; |
| 80 |
haslyrtype has_lyrics; |
| 81 |
auxtype auxiliary; |
| 82 |
assigntype new_assign; |
| 83 |
inittype initialized; |
| 84 |
short linecount; |
| 85 |
Char tags[256]; |
| 86 |
} lyrtagtype; |
| 87 |
|
| 88 |
|
| 89 |
#define maxLyrNums 64 |
| 90 |
#define lyrtaglength 40 |
| 91 |
|
| 92 |
|
| 93 |
#define lyr_adjust_undef (-12345) |
| 94 |
#define interstave 24 |
| 95 |
|
| 96 |
|
| 97 |
Static short LyrNum = 0; |
| 98 |
|
| 99 |
Static boolean lyrmodealter[maxstaves], oldlyrmodealter[maxstaves]; |
| 100 |
Static lyrtagtype tag[maxvoices], oldtag[maxvoices]; |
| 101 |
Static lyrinfotype lyrinfo[maxvoices]; |
| 102 |
Static Char numberedParagraph[maxLyrNums][lyrtaglength + 1]; |
| 103 |
|
| 104 |
|
| 105 |
/* Information flow for verse numbers: at the SetLyrics stage, the first |
| 106 |
line of each lyrics paragraph is checked for a verse number, and if |
| 107 |
found, the paragraph tag is remembered. At the AssignLyrics stage, |
| 108 |
the first time that paragraph is encountered, the particular voice |
| 109 |
is marked in lyrinfo as being numbered. When that voice is later processed, |
| 110 |
the mark in lyrinfo is interrogated and turned off: if it was on, the |
| 111 |
mtxVerse pre-TeX string is put into the output. */ |
| 112 |
|
| 113 |
boolean hasVerseNumber(voice_index voice) |
| 114 |
{ |
| 115 |
boolean Result; |
| 116 |
|
| 117 |
Result = lyrinfo[voice-1].numbered; |
| 118 |
lyrinfo[voice-1].numbered = false; |
| 119 |
return Result; |
| 120 |
} |
| 121 |
|
| 122 |
|
| 123 |
Static boolean isNumberedLyricsParagraph(Char *tag) |
| 124 |
{ |
| 125 |
short i, FORLIM; |
| 126 |
|
| 127 |
FORLIM = LyrNum; |
| 128 |
for (i = 0; i <= FORLIM - 1; i++) { |
| 129 |
if (!strcmp(tag, numberedParagraph[i])) |
| 130 |
return true; |
| 131 |
} |
| 132 |
return false; |
| 133 |
} |
| 134 |
|
| 135 |
|
| 136 |
Static boolean anyTagNumbered(Char *tags_) |
| 137 |
{ |
| 138 |
boolean Result; |
| 139 |
Char tags[256]; |
| 140 |
Char s[256]; |
| 141 |
|
| 142 |
strcpy(tags, tags_); |
| 143 |
/* p2c: lyrics.pas: Note: Eliminated unused assignment statement [338] */ |
| 144 |
if (curtail(tags, '}') > 0) |
| 145 |
delete1(tags, 1); |
| 146 |
do { |
| 147 |
GetNextWord(s, tags, ',', dummy); |
| 148 |
if (*s == '\0') |
| 149 |
return false; |
| 150 |
if (isNumberedLyricsParagraph(s)) |
| 151 |
return true; |
| 152 |
} while (true); |
| 153 |
return false; |
| 154 |
} |
| 155 |
|
| 156 |
|
| 157 |
/* Save the tag in the numberedParagraph list, stripping off braces if any */ |
| 158 |
Static void markNumbered(Char *tag_) |
| 159 |
{ |
| 160 |
Char tag[256]; |
| 161 |
|
| 162 |
strcpy(tag, tag_); |
| 163 |
if (LyrNum >= maxLyrNums) { |
| 164 |
error("Too many numbered lines in the lyrics", !print); |
| 165 |
return; |
| 166 |
} |
| 167 |
LyrNum++; |
| 168 |
if (curtail(tag, '}') > 0) |
| 169 |
delete1(tag, 1); |
| 170 |
strcpy(numberedParagraph[LyrNum-1], tag); |
| 171 |
/* p2c: lyrics.pas, line 104: |
| 172 |
* Note: Possible string truncation in assignment [145] */ |
| 173 |
} |
| 174 |
|
| 175 |
|
| 176 |
/* --- end of procedures to keep track of verse numbering --- */ |
| 177 |
|
| 178 |
void lyricsParagraph(void) |
| 179 |
{ |
| 180 |
Char first[256], w[256]; |
| 181 |
paragraph_index0 l, line; |
| 182 |
other_index0 i; |
| 183 |
other_index0 nother = 0; |
| 184 |
Char other_[10][lyrtaglength + 1]; |
| 185 |
boolean numbered; |
| 186 |
Char STR1[256], STR3[256]; |
| 187 |
paragraph_index0 FORLIM; |
| 188 |
Char STR4[256]; |
| 189 |
Char STR5[256]; |
| 190 |
|
| 191 |
if (!doLyrics()) |
| 192 |
return; |
| 193 |
if (para_len < 2) |
| 194 |
fatalerror("empty lyrics paragraph"); |
| 195 |
NextWord(w, P[0], blank, dummy); |
| 196 |
l = strlen(w); |
| 197 |
line_no = orig_line_no[0]; |
| 198 |
if (w[l-1] != '}') |
| 199 |
strcat(w, "}"); |
| 200 |
GetNextWord(first, w, dummy, '}'); |
| 201 |
while (*w != '\0') { |
| 202 |
if (w[0] == '=') |
| 203 |
predelete(w, 1); |
| 204 |
if (w[0] != '{') |
| 205 |
sprintf(w, "{%s", strcpy(STR1, w)); |
| 206 |
nother++; |
| 207 |
GetNextWord(other_[nother-1], w, dummy, '}'); |
| 208 |
/* p2c: lyrics.pas, line 123: |
| 209 |
* Note: Possible string truncation in assignment [145] */ |
| 210 |
} |
| 211 |
if (beVerbose()) { |
| 212 |
printf("---- Paragraph %d starting at line %d has lyrics headed %s", |
| 213 |
paragraph_no, line_no, first); |
| 214 |
for (i = 0; i <= nother - 1; i++) |
| 215 |
printf("=%s", other_[i]); |
| 216 |
putchar('\n'); |
| 217 |
} |
| 218 |
sprintf(STR5, "%c Paragraph %s line %s bar %s", |
| 219 |
comment, toString(STR1, paragraph_no), toString(STR3, line_no), |
| 220 |
toString(STR4, bar_no)); |
| 221 |
TeXtype2(STR5); |
| 222 |
sprintf(STR3, "\\mtxSetLyrics%s{%%", first); |
| 223 |
TeXtype2(STR3); |
| 224 |
FORLIM = para_len; |
| 225 |
for (line = 2; line <= FORLIM; line++) { |
| 226 |
lyrTranslate(P[line-1], &numbered); |
| 227 |
if (numbered) { |
| 228 |
if (line > 2) |
| 229 |
warning("Verse number not in first line of paragraph treated as lyrics", |
| 230 |
print); |
| 231 |
else { |
| 232 |
markNumbered(first); |
| 233 |
for (i = 0; i <= nother - 1; i++) |
| 234 |
markNumbered(other_[i]); |
| 235 |
} |
| 236 |
} |
| 237 |
line_no = orig_line_no[line-1]; |
| 238 |
if (strlen(P[line-1]) > max_lyrics_line_length && pmx_preamble_done) |
| 239 |
error("Lyrics line too long", print); |
| 240 |
if (pmx_preamble_done) { |
| 241 |
if (line == 2) { |
| 242 |
sprintf(STR3, "\\\\\\:%s", P[line-1]); |
| 243 |
put(STR3, putspace); |
| 244 |
} else { |
| 245 |
sprintf(STR3, "\\\\\\ %s", P[line-1]); |
| 246 |
put(STR3, putspace); |
| 247 |
} |
| 248 |
} else |
| 249 |
put(P[line-1], putspace); |
| 250 |
if (line < para_len) { |
| 251 |
if (pmx_preamble_done) |
| 252 |
putLine(" %\\"); |
| 253 |
else |
| 254 |
putLine(" %"); |
| 255 |
} else if (pmx_preamble_done) |
| 256 |
putLine("}\\"); |
| 257 |
else |
| 258 |
putLine("}"); |
| 259 |
} |
| 260 |
for (i = 0; i <= nother - 1; i++) { |
| 261 |
sprintf(STR1, "\\mtxCopyLyrics%s%s", first, other_[i]); |
| 262 |
TeXtype2(STR1); |
| 263 |
} |
| 264 |
} |
| 265 |
|
| 266 |
|
| 267 |
Static Char *songraise(Char *Result, voice_index voice) |
| 268 |
{ |
| 269 |
Char s[256]; |
| 270 |
lyrtagtype *WITH; |
| 271 |
lyrinfotype *WITH1; |
| 272 |
Char STR1[256], STR3[256]; |
| 273 |
|
| 274 |
WITH = &tag[voice-1]; |
| 275 |
WITH1 = &lyrinfo[voice-1]; |
| 276 |
if (WITH->initialized == virgin && WITH1->lyr_adjust == 0) |
| 277 |
return strcpy(Result, ""); |
| 278 |
else { |
| 279 |
if (WITH->auxiliary == aux) |
| 280 |
strcpy(s, "Aux"); |
| 281 |
else |
| 282 |
*s = '\0'; |
| 283 |
sprintf(Result, "\\mtx%sLyricsAdjust{%s}{%s}", |
| 284 |
s, toString(STR1, PMXinstr(voiceStave(voice))), |
| 285 |
toString(STR3, WITH1->lyr_adjust)); |
| 286 |
return Result; |
| 287 |
} |
| 288 |
} |
| 289 |
|
| 290 |
|
| 291 |
Char *lyricsReport(Char *Result, voice_index voice) |
| 292 |
{ |
| 293 |
Char l[256]; |
| 294 |
lyrtagtype *WITH; |
| 295 |
|
| 296 |
WITH = &tag[voice-1]; |
| 297 |
if (WITH->has_lyrics == nolyr || |
| 298 |
WITH->lyrsource == none_given && *WITH->tags == '\0') |
| 299 |
return strcpy(Result, " but has no own lyrics"); |
| 300 |
else { |
| 301 |
strcpy(l, " with "); |
| 302 |
if (WITH->auxiliary == aux) |
| 303 |
strcat(l, "auxiliary "); |
| 304 |
strcat(l, "lyrics "); |
| 305 |
if (WITH->lyrsource == local_lyrics) |
| 306 |
strcat(l, "locally defined as \""); |
| 307 |
else |
| 308 |
strcat(l, "labelled \""); |
| 309 |
sprintf(l + strlen(l), "%s\"", WITH->tags); |
| 310 |
if (anyTagNumbered(WITH->tags)) |
| 311 |
strcat(l, " with verse numbers"); |
| 312 |
return strcpy(Result, l); |
| 313 |
} |
| 314 |
} |
| 315 |
|
| 316 |
|
| 317 |
void initLyrics(void) |
| 318 |
{ |
| 319 |
/* at the start only */ |
| 320 |
stave_index stave; |
| 321 |
voice_index voice, FORLIM; |
| 322 |
lyrinfotype *WITH; |
| 323 |
lyrtagtype *WITH1; |
| 324 |
stave_index FORLIM1; |
| 325 |
|
| 326 |
FORLIM = nvoices; |
| 327 |
for (voice = 0; voice <= FORLIM - 1; voice++) { |
| 328 |
WITH = &lyrinfo[voice]; |
| 329 |
WITH1 = &tag[voice]; |
| 330 |
WITH1->has_lyrics = nolyr; |
| 331 |
WITH->lyr_adjust = lyr_adjust_undef; |
| 332 |
*WITH->melisma = '\0'; |
| 333 |
WITH->slur_level = 0; |
| 334 |
WITH->beam_level = 0; |
| 335 |
WITH1->auxiliary = aux; |
| 336 |
WITH1->lyrsource = none_given; |
| 337 |
WITH1->new_assign = asbefore; |
| 338 |
WITH1->initialized = virgin; |
| 339 |
} |
| 340 |
FORLIM1 = nstaves; |
| 341 |
for (stave = 0; stave <= FORLIM1 - 1; stave++) |
| 342 |
oldlyrmodealter[stave] = false; |
| 343 |
} |
| 344 |
|
| 345 |
|
| 346 |
Static void registerLyrics(voice_index voice, Char *w) |
| 347 |
{ |
| 348 |
lyrtagtype *WITH; |
| 349 |
|
| 350 |
WITH = &tag[voice-1]; |
| 351 |
strcpy(oldtag[voice-1].tags, WITH->tags); |
| 352 |
oldtag[voice-1].lyrsource = WITH->lyrsource; |
| 353 |
WITH->lyrsource = global_lyrics; |
| 354 |
switch (strlen(w)) { |
| 355 |
|
| 356 |
case 0: |
| 357 |
*WITH->tags = '\0'; |
| 358 |
break; |
| 359 |
|
| 360 |
case 1: |
| 361 |
fatalerror("M-Tx system error in registerLyrics"); |
| 362 |
break; |
| 363 |
|
| 364 |
default: |
| 365 |
strcpy(WITH->tags, w); |
| 366 |
break; |
| 367 |
} |
| 368 |
} |
| 369 |
|
| 370 |
|
| 371 |
void extractLyrtag(voice_index voice, Char *note) |
| 372 |
{ |
| 373 |
/* inline lyrics change */ |
| 374 |
lyrtagtype *WITH; |
| 375 |
Char STR1[256], STR2[256]; |
| 376 |
|
| 377 |
WITH = &tag[voice-1]; |
| 378 |
if (WITH->has_lyrics == nolyr) { |
| 379 |
error3(voice, "Inline lyrics change on no-lyrics line"); |
| 380 |
return; |
| 381 |
} |
| 382 |
registerLyrics(voice, note); /* was: ''); */ |
| 383 |
sprintf(note, "\\mtxAssignLyrics{%s}%s", |
| 384 |
toString(STR1, PMXinstr(voiceStave(voice))), strcpy(STR2, note)); |
| 385 |
if (WITH->auxiliary == aux) |
| 386 |
sprintf(note, "\\mtxAuxLyr{%s}\\", strcpy(STR2, note)); |
| 387 |
else |
| 388 |
strcat(note, "\\"); |
| 389 |
} |
| 390 |
|
| 391 |
|
| 392 |
void clearTags(void) |
| 393 |
{ |
| 394 |
/* at start of paragraph analyis */ |
| 395 |
voice_index voice, FORLIM; |
| 396 |
lyrtagtype *WITH; |
| 397 |
|
| 398 |
memcpy(oldtag, tag, maxvoices * sizeof(lyrtagtype)); |
| 399 |
FORLIM = nvoices; |
| 400 |
for (voice = 0; voice <= FORLIM - 1; voice++) { |
| 401 |
WITH = &tag[voice]; |
| 402 |
WITH->lyrsource = none_given; |
| 403 |
*WITH->tags = '\0'; |
| 404 |
WITH->linecount = 0; |
| 405 |
} |
| 406 |
} |
| 407 |
|
| 408 |
|
| 409 |
#define maxlyrlen (PMXlinelength - 15) |
| 410 |
|
| 411 |
|
| 412 |
Local void convertlyrics(Char *lyn, voice_index voice, auxtype mx) |
| 413 |
{ |
| 414 |
static Char setlyr[256] = "%%\\\\\\mtxSetLyrics"; |
| 415 |
Char btag[256], thistag[256], w[256]; |
| 416 |
boolean numbered; |
| 417 |
Char STR1[256]; |
| 418 |
lyrtagtype *WITH; |
| 419 |
Char STR2[256]; |
| 420 |
|
| 421 |
NextWord(w, lyn, blank, dummy); |
| 422 |
WITH = &tag[voice-1]; |
| 423 |
if (*w == '\0') { |
| 424 |
*WITH->tags = '\0'; |
| 425 |
return; |
| 426 |
} |
| 427 |
WITH->has_lyrics = haslyr; |
| 428 |
WITH->auxiliary = mx; |
| 429 |
if (w[0] == '{') { |
| 430 |
registerLyrics(voice, w); |
| 431 |
return; |
| 432 |
} |
| 433 |
WITH->lyrsource = local_lyrics; |
| 434 |
WITH->linecount++; |
| 435 |
toString(thistag, voice * 10 + WITH->linecount); |
| 436 |
sprintf(btag, "{%s}", thistag); |
| 437 |
if (*WITH->tags == '\0') |
| 438 |
strcpy(WITH->tags, btag); |
| 439 |
else { |
| 440 |
WITH->tags[strlen(WITH->tags) - 1] = ','; |
| 441 |
sprintf(WITH->tags + strlen(WITH->tags), "%s}", thistag); |
| 442 |
} |
| 443 |
trim(lyn); |
| 444 |
lyrTranslate(lyn, &numbered); |
| 445 |
if (numbered) |
| 446 |
markNumbered(thistag); |
| 447 |
if (strlen(lyn) + strlen(btag) > maxlyrlen) |
| 448 |
sprintf(lyn, "%s%s{\\\n\\\\\\:%s}\\", setlyr, btag, strcpy(STR2, lyn)); |
| 449 |
else |
| 450 |
sprintf(lyn, "%s%s{%s}\\", setlyr, btag, strcpy(STR1, lyn)); |
| 451 |
} |
| 452 |
|
| 453 |
#undef maxlyrlen |
| 454 |
|
| 455 |
|
| 456 |
void maybeLyrics(voice_index voice, paragraph_index parline, Char *w_) |
| 457 |
{ |
| 458 |
/* during paragraph analysis, parline had L:, already stripped */ |
| 459 |
Char w[256]; |
| 460 |
voice_index0 k; |
| 461 |
|
| 462 |
/** Labelled lyrics line -- */ |
| 463 |
strcpy(w, w_); |
| 464 |
if (!doLyrics()) |
| 465 |
return; |
| 466 |
if (strlen(w) == 1 && voice == 0) |
| 467 |
warning("Lyrics line above top voice should be labelled", print); |
| 468 |
if (strlen(w) == 1) { /** Standard lyrics line -------- */ |
| 469 |
k = voice; |
| 470 |
if (k == 0) |
| 471 |
k = 1; |
| 472 |
convertlyrics(P[parline-1], k, normal); |
| 473 |
return; |
| 474 |
} |
| 475 |
predelete(w, 1); |
| 476 |
k = findVoice(w); |
| 477 |
if (k == 0) |
| 478 |
error("Lyrics line belongs to unknown voice", print); |
| 479 |
else |
| 480 |
convertlyrics(P[parline-1], k, aux); |
| 481 |
} |
| 482 |
|
| 483 |
|
| 484 |
void reviseLyrics(void) |
| 485 |
{ |
| 486 |
/* after paragraph analysis */ |
| 487 |
voice_index voice; |
| 488 |
stave_index stave; |
| 489 |
voice_index FORLIM; |
| 490 |
lyrtagtype *WITH; |
| 491 |
stave_index FORLIM1; |
| 492 |
|
| 493 |
FORLIM = nvoices; |
| 494 |
for (voice = 0; voice <= FORLIM - 1; voice++) { |
| 495 |
WITH = &tag[voice]; |
| 496 |
if (oldtag[voice].lyrsource == global_lyrics && |
| 497 |
WITH->lyrsource == none_given) { |
| 498 |
strcpy(WITH->tags, oldtag[voice].tags); |
| 499 |
WITH->lyrsource = global_lyrics; |
| 500 |
} |
| 501 |
WITH->new_assign = (assigntype)(WITH->has_lyrics == haslyr && |
| 502 |
strcmp(WITH->tags, oldtag[voice].tags)); |
| 503 |
if (*WITH->tags == '\0') |
| 504 |
WITH->has_lyrics = nolyr; |
| 505 |
strcpy(oldtag[voice].tags, WITH->tags); |
| 506 |
oldtag[voice].lyrsource = WITH->lyrsource; |
| 507 |
} |
| 508 |
FORLIM1 = nstaves; |
| 509 |
for (stave = 1; stave <= FORLIM1; stave++) { |
| 510 |
WITH = &tag[first_on_stave[stave-1] - 1]; |
| 511 |
lyrmodealter[stave-1] = (!aloneOnStave(stave) && |
| 512 |
WITH->has_lyrics == haslyr && |
| 513 |
WITH->auxiliary == normal); |
| 514 |
} |
| 515 |
} |
| 516 |
|
| 517 |
|
| 518 |
void assignLyrics(stave_index stave, Char *lyrassign) |
| 519 |
{ |
| 520 |
/* at start of new block */ |
| 521 |
Char atag[256], instr[256], l[256]; |
| 522 |
voice_index v1, v2, voice; |
| 523 |
lyrtagtype *WITH; |
| 524 |
Char STR2[256]; |
| 525 |
lyrinfotype *WITH1; |
| 526 |
|
| 527 |
*lyrassign = '\0'; |
| 528 |
toString(instr, PMXinstr(stave)); |
| 529 |
v1 = first_on_stave[stave-1]; |
| 530 |
v2 = v1 + number_on_stave[stave-1] - 1; |
| 531 |
/* don't reassign if other voice takes over */ |
| 532 |
if (tag[v1-1].auxiliary == tag[v2-1].auxiliary && |
| 533 |
tag[v1-1].has_lyrics != tag[v2-1].has_lyrics) { |
| 534 |
for (voice = v1 - 1; voice <= v2 - 1; voice++) { |
| 535 |
WITH = &tag[voice]; |
| 536 |
if (WITH->new_assign == newassign) |
| 537 |
WITH->new_assign = (assigntype)WITH->has_lyrics; |
| 538 |
} |
| 539 |
} |
| 540 |
for (voice = v1 - 1; voice <= v2 - 1; voice++) |
| 541 |
lyrinfo[voice].numbered = false; |
| 542 |
for (voice = v1; voice <= v2; voice++) { |
| 543 |
WITH = &tag[voice-1]; |
| 544 |
if (WITH->new_assign == newassign) { |
| 545 |
strcpy(atag, WITH->tags); |
| 546 |
if (*atag == '\0') |
| 547 |
strcpy(atag, "{}"); |
| 548 |
sprintf(l, "\\mtxAssignLyrics{%s}%s", instr, atag); |
| 549 |
if (WITH->auxiliary == aux) |
| 550 |
sprintf(l, "\\mtxAuxLyr{%s}", strcpy(STR2, l)); |
| 551 |
strcat(lyrassign, l); |
| 552 |
if (*WITH->tags == '\0') |
| 553 |
WITH->has_lyrics = nolyr; |
| 554 |
if (WITH->has_lyrics == haslyr && WITH->initialized == virgin) { |
| 555 |
WITH1 = &lyrinfo[voice-1]; |
| 556 |
if (WITH->auxiliary == aux && upper(voice)) |
| 557 |
WITH1->lyr_adjust = interstave; |
| 558 |
else |
| 559 |
WITH1->lyr_adjust = 0; |
| 560 |
strcat(lyrassign, songraise(STR2, voice)); |
| 561 |
WITH->initialized = active; |
| 562 |
} |
| 563 |
if (anyTagNumbered(atag)) |
| 564 |
lyrinfo[voice-1].numbered = true; |
| 565 |
} |
| 566 |
} |
| 567 |
if (lyrmodealter[stave-1] == oldlyrmodealter[stave-1]) |
| 568 |
return; |
| 569 |
if (lyrmodealter[stave-1]) |
| 570 |
sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeAlter{%s}", instr); |
| 571 |
else |
| 572 |
sprintf(lyrassign + strlen(lyrassign), "\\mtxLyrModeNormal{%s}", instr); |
| 573 |
oldlyrmodealter[stave-1] = lyrmodealter[stave-1]; |
| 574 |
} |
| 575 |
|
| 576 |
|
| 577 |
void lyricsAdjust(voice_index voice, Char *note) |
| 578 |
{ |
| 579 |
/* inline at-word */ |
| 580 |
short adj; |
| 581 |
boolean force, put_above, put_below; |
| 582 |
lyrinfotype *WITH; |
| 583 |
lyrtagtype *WITH1; |
| 584 |
Char STR2[256]; |
| 585 |
|
| 586 |
WITH = &lyrinfo[voice-1]; |
| 587 |
WITH1 = &tag[voice-1]; |
| 588 |
predelete(note, 1); |
| 589 |
force = (note[0] == '='); |
| 590 |
if (force) |
| 591 |
predelete(note, 1); |
| 592 |
put_above = (note[0] == '^'); |
| 593 |
if (put_above) |
| 594 |
predelete(note, 1); |
| 595 |
put_below = (note[0] == 'v'); |
| 596 |
if (put_below) |
| 597 |
predelete(note, 1); |
| 598 |
if (*note != '\0') |
| 599 |
getNum(note, &adj); |
| 600 |
else |
| 601 |
adj = 0; |
| 602 |
if (WITH1->has_lyrics == nolyr) { |
| 603 |
*note = '\0'; |
| 604 |
return; |
| 605 |
} |
| 606 |
if (put_above) |
| 607 |
WITH->lyr_adjust = interstave; |
| 608 |
else if (put_below) |
| 609 |
WITH->lyr_adjust = 0; |
| 610 |
if (force) |
| 611 |
WITH->lyr_adjust = adj; |
| 612 |
else |
| 613 |
WITH->lyr_adjust += adj; |
| 614 |
songraise(note, voice); |
| 615 |
if (*note != '\0') |
| 616 |
sprintf(note, "\\\\%s\\", strcpy(STR2, note)); |
| 617 |
} |
| 618 |
|
| 619 |
|
| 620 |
void lyrTranslate(Char *P, boolean *numbered) |
| 621 |
{ /* Test for starting number */ |
| 622 |
short k, l, number; |
| 623 |
Char Q[256], w[256]; |
| 624 |
|
| 625 |
NextWord(w, P, blank, dummy); |
| 626 |
*numbered = false; |
| 627 |
if (endsWith(w, ".")) { |
| 628 |
getNum(w, &number); |
| 629 |
*numbered = (number != 0); |
| 630 |
} |
| 631 |
/*Translate lyrics link */ |
| 632 |
*Q = '\0'; |
| 633 |
l = strlen(P); |
| 634 |
for (k = 1; k <= l - 1; k++) { |
| 635 |
if (P[k-1] != '_' || P[k] == '_' || P[k] == ' ' || pos1(P[k], digits) > 0) |
| 636 |
sprintf(Q + strlen(Q), "%c", P[k-1]); |
| 637 |
else if (k > 1 && P[k-2] == '\\') |
| 638 |
strcat(Q, "mtxLowLyrlink "); |
| 639 |
else |
| 640 |
strcat(Q, "\\mtxLyrlink "); |
| 641 |
} |
| 642 |
sprintf(Q + strlen(Q), "%c", P[l-1]); |
| 643 |
strcpy(P, Q); |
| 644 |
} |
| 645 |
|
| 646 |
|
| 647 |
typedef enum { |
| 648 |
beam, slur |
| 649 |
} melismaEnd; |
| 650 |
|
| 651 |
|
| 652 |
Static Char removeLast(Char *s, Char *t) |
| 653 |
{ |
| 654 |
Char Result; |
| 655 |
short i, l; |
| 656 |
|
| 657 |
l = strlen(s); |
| 658 |
for (i = l; i >= 1; i--) { |
| 659 |
if (pos1(s[i-1], t) > 0) { |
| 660 |
Result = s[i-1]; |
| 661 |
delete1(s, i); |
| 662 |
return Result; |
| 663 |
} |
| 664 |
} |
| 665 |
return dummy; |
| 666 |
} |
| 667 |
|
| 668 |
|
| 669 |
Static boolean OpenMelisma(Char *s) |
| 670 |
{ |
| 671 |
return (pos1(slur_melisma, s) > 0 || pos1(beam_melisma, s) > 0); |
| 672 |
} |
| 673 |
|
| 674 |
|
| 675 |
/* Local variables for getSyllable: */ |
| 676 |
struct LOC_getSyllable { |
| 677 |
voice_index voice; |
| 678 |
boolean BM, EM; |
| 679 |
} ; |
| 680 |
|
| 681 |
Local void startMelismas(Char *t, struct LOC_getSyllable *LINK) |
| 682 |
{ |
| 683 |
boolean open_before, open_now; |
| 684 |
short i, k; |
| 685 |
lyrinfotype *WITH; |
| 686 |
|
| 687 |
k = strlen(t); |
| 688 |
for (i = 0; i <= k - 1; i++) { |
| 689 |
WITH = &lyrinfo[LINK->voice-1]; |
| 690 |
open_before = OpenMelisma(WITH->melisma); |
| 691 |
sprintf(WITH->melisma + strlen(WITH->melisma), "%c", t[i]); |
| 692 |
open_now = OpenMelisma(WITH->melisma); |
| 693 |
LINK->BM = (LINK->BM || open_now && !open_before); |
| 694 |
} |
| 695 |
} |
| 696 |
|
| 697 |
Local boolean endMelisma(short voice, struct LOC_getSyllable *LINK) |
| 698 |
{ |
| 699 |
Char found; |
| 700 |
short i; |
| 701 |
short count[2]; |
| 702 |
melismaEnd t; |
| 703 |
short FORLIM1; |
| 704 |
lyrinfotype *WITH; |
| 705 |
Char STR1[4]; |
| 706 |
|
| 707 |
LINK->EM = false; |
| 708 |
count[(long)slur] = -lyrinfo[voice-1].slur_change; |
| 709 |
count[(long)beam] = -lyrinfo[voice-1].beam_change; |
| 710 |
for (t = beam; t <= slur; t = (melismaEnd)((long)t + 1)) { |
| 711 |
FORLIM1 = count[(long)t]; |
| 712 |
for (i = 1; i <= FORLIM1; i++) { |
| 713 |
WITH = &lyrinfo[voice-1]; |
| 714 |
switch (t) { |
| 715 |
|
| 716 |
case slur: |
| 717 |
sprintf(STR1, "%c%c", slur_melisma, inhibit_slur_melisma); |
| 718 |
found = removeLast(WITH->melisma, STR1); |
| 719 |
break; |
| 720 |
|
| 721 |
case beam: |
| 722 |
sprintf(STR1, "%c%c", beam_melisma, inhibit_beam_melisma); |
| 723 |
found = removeLast(WITH->melisma, STR1); |
| 724 |
break; |
| 725 |
} |
| 726 |
if (found == dummy) |
| 727 |
error3(voice, "Ending a melisma that was never started"); |
| 728 |
LINK->EM = (LINK->EM || |
| 729 |
(!OpenMelisma(WITH->melisma) && |
| 730 |
pos1(found, (sprintf(STR1, "%c%c", slur_melisma, beam_melisma), |
| 731 |
STR1)) > 0)); |
| 732 |
} |
| 733 |
} |
| 734 |
return LINK->EM; |
| 735 |
} |
| 736 |
|
| 737 |
Local void startSlurMelisma(voice_index voice, struct LOC_getSyllable *LINK) |
| 738 |
{ |
| 739 |
static Char start[2] = { |
| 740 |
slur_melisma, inhibit_slur_melisma |
| 741 |
}; |
| 742 |
|
| 743 |
Char slurs[256]; |
| 744 |
short k, FORLIM; |
| 745 |
Char STR1[256]; |
| 746 |
|
| 747 |
*slurs = '\0'; |
| 748 |
FORLIM = lyrinfo[voice-1].slur_change; |
| 749 |
for (k = 1; k <= FORLIM; k++) |
| 750 |
sprintf(slurs, "%c%s", |
| 751 |
start[noSlurMelisma(voice, 1 - k)], strcpy(STR1, slurs)); |
| 752 |
startMelismas(slurs, LINK); |
| 753 |
} |
| 754 |
|
| 755 |
Local void startBeamMelisma(voice_index voice, struct LOC_getSyllable *LINK) |
| 756 |
{ |
| 757 |
static Char start[2] = { |
| 758 |
beam_melisma, inhibit_beam_melisma |
| 759 |
}; |
| 760 |
|
| 761 |
Char beams[256]; |
| 762 |
short k, FORLIM; |
| 763 |
Char STR1[256]; |
| 764 |
|
| 765 |
*beams = '\0'; |
| 766 |
FORLIM = lyrinfo[voice-1].beam_change; |
| 767 |
for (k = 1; k <= FORLIM; k++) |
| 768 |
sprintf(beams, "%c%s", start[noBeamMelisma(voice)], strcpy(STR1, beams)); |
| 769 |
startMelismas(beams, LINK); |
| 770 |
} |
| 771 |
|
| 772 |
Local boolean startMelisma(short voice, struct LOC_getSyllable *LINK) |
| 773 |
{ |
| 774 |
LINK->BM = false; |
| 775 |
startSlurMelisma(voice, LINK); |
| 776 |
startBeamMelisma(voice, LINK); |
| 777 |
return LINK->BM; |
| 778 |
} |
| 779 |
|
| 780 |
|
| 781 |
/* Append mtxBM or mtxEM to pretex when appropriate */ |
| 782 |
void getSyllable(voice_index voice_, Char *pretex) |
| 783 |
{ |
| 784 |
struct LOC_getSyllable V; |
| 785 |
short t; |
| 786 |
lyrtagtype *WITH; |
| 787 |
lyrinfotype *WITH1; |
| 788 |
|
| 789 |
V.voice = voice_; |
| 790 |
WITH = &tag[V.voice-1]; |
| 791 |
WITH1 = &lyrinfo[V.voice-1]; |
| 792 |
if (WITH->has_lyrics != haslyr) |
| 793 |
return; |
| 794 |
t = WITH1->slur_level; |
| 795 |
WITH1->slur_level = slurLevel(V.voice); |
| 796 |
WITH1->slur_change = WITH1->slur_level - t; |
| 797 |
t = WITH1->beam_level; |
| 798 |
WITH1->beam_level = beamLevel(V.voice); |
| 799 |
WITH1->beam_change = WITH1->beam_level - t; |
| 800 |
if (startMelisma(V.voice, &V)) { |
| 801 |
if (WITH->auxiliary == aux) |
| 802 |
strcat(pretex, "\\mtxAuxBM"); |
| 803 |
else |
| 804 |
strcat(pretex, "\\mtxBM"); |
| 805 |
} |
| 806 |
if (!endMelisma(V.voice, &V)) |
| 807 |
return; |
| 808 |
if (WITH->auxiliary == aux) |
| 809 |
strcat(pretex, "\\mtxAuxEM"); |
| 810 |
else |
| 811 |
strcat(pretex, "\\mtxEM"); |
| 812 |
} |
| 813 |
|
| 814 |
|
| 815 |
Static void getSyllable1(voice_index voice, Char *pretex) |
| 816 |
{ |
| 817 |
lyrinfotype *WITH; |
| 818 |
|
| 819 |
WITH = &lyrinfo[voice-1]; |
| 820 |
printf("voice=%d, slurchange=%d, melisma=%s, beamchange=%d\n", |
| 821 |
voice, WITH->slur_change, WITH->melisma, WITH->beam_change); |
| 822 |
getSyllable1(voice, pretex); |
| 823 |
if (*pretex != '\0') |
| 824 |
printf("pretex = %s\n", pretex); |
| 825 |
} |
| 826 |
|
| 827 |
|
| 828 |
|
| 829 |
|
| 830 |
/* End. */ |