| 1 |
|
| 2 |
/* Copyright (C) 2014-23 R. D. Tennent School of Computing, |
| 3 |
* Queen's University, [email protected] |
| 4 |
* |
| 5 |
* This program is free software; you can redistribute it |
| 6 |
* and/or modify it under the terms of the GNU General |
| 7 |
* Public License as published by the Free Software |
| 8 |
* Foundation; either version 2 of the License, or (at your |
| 9 |
* option) any later version. |
| 10 |
* |
| 11 |
* This program is distributed in the hope that it will |
| 12 |
* be useful, but WITHOUT ANY WARRANTY; without even the |
| 13 |
* implied warranty of MERCHANTABILITY or FITNESS FOR A |
| 14 |
* PARTICULAR PURPOSE. See the GNU General Public License |
| 15 |
* for more details. |
| 16 |
* |
| 17 |
* You should have received a copy of the GNU General |
| 18 |
* Public License along with this program; if not, write to |
| 19 |
* the Free Software Foundation, Inc., 51 Franklin Street, |
| 20 |
* Fifth Floor, Boston, MA 02110-1301, USA. |
| 21 |
*/ |
| 22 |
|
| 23 |
# include "autosp.h" |
| 24 |
|
| 25 |
# define MAX_STAFFS 9 |
| 26 |
|
| 27 |
# define SMALL_NOTE 512 |
| 28 |
# define SP(note) (SMALL_NOTE/note) |
| 29 |
/* note = { 256 | 128 | 64 | 32 | 16 | 8 | 4 | 2 | 1 } */ |
| 30 |
# define MAX_SPACING 2*SP(1) |
| 31 |
int staffs[MAX_STAFFS]; /* number of staffs for ith instrument*/ |
| 32 |
bool active[MAX_STAFFS]; /* is staff i active? */ |
| 33 |
bool bar_rest[MAX_STAFFS]; |
| 34 |
int spacing; /* spacing for current notes */ |
| 35 |
int restbars; |
| 36 |
char global_skip_str[7][16]; |
| 37 |
int ninstr; /* number of instruments */ |
| 38 |
int nstaffs; /* number of staffs */ |
| 39 |
int nastaffs; /* number of active staffs; */ |
| 40 |
int old_spacing; |
| 41 |
int oldspacing_staff; |
| 42 |
bool Changeclefs; /* output \Changeclefs after \def\atnextbar */ |
| 43 |
char TransformNotes2[SHORT_LEN]; /* 2nd argument of \TransformNotes */ |
| 44 |
bool TransformNotesDefined; |
| 45 |
char instrument_size[MAX_STAFFS][SHORT_LEN]; |
| 46 |
/* instrument size as set by setsize or by default ("\\@one") */ |
| 47 |
float instr_numsize[MAX_STAFFS]; |
| 48 |
/* nummerical intrument size */ |
| 49 |
int staff_instr[MAX_STAFFS]; /* instrument for each staff */ |
| 50 |
|
| 51 |
char line[LINE_LEN]; /* line of input */ |
| 52 |
|
| 53 |
void process_line (); |
| 54 |
|
| 55 |
void process_command (char **ln); |
| 56 |
|
| 57 |
void process_line () |
| 58 |
{ |
| 59 |
char *ln; |
| 60 |
ln = &line[0]; |
| 61 |
while ( *ln != '\0') |
| 62 |
{ |
| 63 |
while (*ln == ' ') { ln++; fputc (' ', outfile); } |
| 64 |
if (*ln == '%') { |
| 65 |
fprintf (outfile, "%s", ln); |
| 66 |
return; |
| 67 |
} |
| 68 |
process_command (&ln); |
| 69 |
} |
| 70 |
} |
| 71 |
void process_score () |
| 72 |
/* process .aspc file */ |
| 73 |
{ |
| 74 |
int c; int i; |
| 75 |
lineno = 0; |
| 76 |
for (i=1; i < MAX_STAFFS; i++) |
| 77 |
{ |
| 78 |
staffs[i] = 1; |
| 79 |
active[i] = true; |
| 80 |
bar_rest[i] = false; |
| 81 |
append (instrument_size[i], NULL, "\\normalvalue", SHORT_LEN); |
| 82 |
instr_numsize[i] = 1.0; |
| 83 |
} |
| 84 |
spacing = MAX_SPACING; |
| 85 |
restbars = 0; |
| 86 |
ninstr = 1; /* number of instruments */ |
| 87 |
nstaffs = 1; /* number of staffs */ |
| 88 |
nastaffs = 1; /* number of active staffs; */ |
| 89 |
old_spacing = MAX_SPACING; |
| 90 |
oldspacing_staff = 0; |
| 91 |
Changeclefs = false; /* output \Changeclefs after \def\atnextbar */ |
| 92 |
|
| 93 |
TransformNotes2[0] = '\0'; |
| 94 |
TransformNotesDefined = false; |
| 95 |
|
| 96 |
append (global_skip_str[0], NULL, "", 16); |
| 97 |
append (global_skip_str[1], NULL, "\\qqsk", 16); |
| 98 |
append (global_skip_str[2], NULL, "\\hqsk", 16); |
| 99 |
append (global_skip_str[3], NULL, "\\tqsk", 16); |
| 100 |
append (global_skip_str[4], NULL, "\\qsk", 16); |
| 101 |
append (global_skip_str[5], NULL, "\\qsk\\qqsk", 16); |
| 102 |
append (global_skip_str[6], NULL, "\\qsk\\hqsk", 16); |
| 103 |
|
| 104 |
c = getc (infile); |
| 105 |
while ( c != EOF ) |
| 106 |
{ |
| 107 |
ungetc (c, infile); |
| 108 |
if (fgets(line, LINE_LEN, infile) == NULL) |
| 109 |
error ("Unexpected EOF."); |
| 110 |
if (strlen (line) == LINE_LEN-1) |
| 111 |
error ("Line too long."); |
| 112 |
lineno++; |
| 113 |
process_line (); |
| 114 |
c = getc (infile); |
| 115 |
} /* c == EOF */ |
| 116 |
} |
| 117 |
|