-
Notifications
You must be signed in to change notification settings - Fork 1
/
nl2xml.h
executable file
·297 lines (264 loc) · 6.96 KB
/
nl2xml.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
/*nl2xml include */
/***************************************************************************
structs
***************************************************************************/
typedef struct {
/* unsigned char modCode;*/
char letterSharp;
char letterFlat;
Boolean sharp;
Boolean flat;
} MIDINOTE;
typedef struct {
/* unsigned char modCode;*/
/* need to change this to accomodate 'Percussion' char sign[12]; */
char sign[12];
short line;
short octaveChange;
} CLEF;
typedef struct {
char xmlname[128];
} DURATION;
/***************************************************************************
function prototype definitions
***************************************************************************/
Boolean replaceSpecialChars (char* oldString);
Boolean init1dAryChar (char **array);
Boolean strcat1d (char **array, int part, char *thisString);
Boolean strcpy1d (char **array, int part, char *thisString);
Boolean init2dAryChar (char ***array);
Boolean strcat2d (char ***array, int part, int voice, char *thisString);
Boolean strcpy2d (char ***array, int part, int voice, char *thisString);
Boolean printBarline(int i);
/***************************************************************************
globals
***************************************************************************/
extern char gInBuf[MAX_LINELENGTH];
extern short gErrorCount;
extern short gNotelistVersion;
extern short gLineCount;
extern short gClefCount;
extern short gKeySigCount;
extern short gTimeSigCount;
extern short gNoteCount;
extern short gGraceNoteCount;
extern short gRestCount;
extern short gBarlineCount;
extern short gTupletCount;
extern short gDynamicCount;
extern short gTextCount;
extern short gTempoCount;
extern char gFilename[64];
extern short gPartStaves[MAXPARTS+1]; /* 1-based array giving number of staves (value) in each
part (index) */
extern short gNumNLStaves; /* number of staves in Notelist system */
extern short gFirstMNNumber; /* number of first measure */
short gPartCount = 0;
/***************************************************************************
global elements written to by multiple notelist handling functions
***************************************************************************/
short gBarlineHere = 0;
short gBarlineType = 1;
long gCurrentTime = -1;
char gAttributes[512] = "";
int gNumParts;
MIDINOTE gMidiNotes[12];
CLEF gClefs[14];
/***************************************************************************
items by part
***************************************************************************/
Boolean gDivisionsOutput[MAXPARTS+1]; /* if XML <divisions> have been output */
Boolean gNumStavesOutput[MAXPARTS+1]; /* if XML <staves> have been output for each part*/
short gClefCountPart[MAXPARTS+1]; /*clef number count for this part*/
short gKeySigNumAcc[MAXPARTS+1]; /* global key signature */
short gClefNum[MAXPARTS+1]; /* global clef value */
char gKeySigShpFlt[MAXPARTS+1]; /* pointers for global strings */
char **gKeySignatures;
char **gTimeSignatures;
char **gClefTags;
char **gDirections;
char **gFinalParts;
//char ***gFinalPartsMeasures;
/***************************************************************************
items by voice
***************************************************************************/
Boolean gChordZeroTimeOK[MAXPARTS+1][MAXVOICES+1];
int gDurationCountVoice[MAXPARTS+1][MAXVOICES+1]; /*duration total for this part/voice*/
int gChordPosVoice[MAXPARTS+1][MAXVOICES+1];
int gVoiceTimePosition[MAXPARTS+1][MAXVOICES+1];
int gSlurNum[MAXPARTS+1][MAXVOICES+1]; /* to keep track of slur numbers */
int gTupletNumerator[MAXPARTS+1][MAXVOICES+1]; /* tuplet values */
int gTupletDenominator[MAXPARTS+1][MAXVOICES+1];
int gTupletCurrent[MAXPARTS+1][MAXVOICES+1];
int gTupletTotal[MAXPARTS+1][MAXVOICES+1];
int gBeamsTotal[MAXPARTS+1][MAXVOICES+1];
int gBeams[MAXPARTS+1][MAXVOICES+1];
char ***gMeasures; /* pointers for global strings */
char ***gLyrics;
char ***gNotations;
/***************************************************************************
items by staff
***************************************************************************/
short gStaffPartMap[MAXSTAVES+1]; /* maps staves to their corresponding part */
short gStaffToStaffMap[MAXSTAVES+1]; /* maps notelist staff numbers (globally continuous)
to their corresponding MusicXML staff numbers (begin again from 1 on each part)*/
/* array to map Notelist durations to MusicXML Type
index [0] is unknown duration [displayed as a stemless quarter note]
*/
char gDurationTypes[10][8] = {
"quarter",
"full",
"whole",
"half",
"quarter",
"eighth",
"16th",
"32nd",
"64th",
"128th"};
/* numeric values for note's <duration> */
int gDurations[10] = {32,256,128,64,32,16,8,4,2,1};
/* basis of time division in MusicXML (based on the smallest division of a 128th note in Notelist
(we use 32 because a 128th note is 1/32 the duration of a quarter note)
*/
int gTimeDivisions = 32;
/* array to map Notelist note modifiers to MusicXML Tag */
char gNoteModTags[32][32] = {
"",
"<fingering>1</fingering>",
"<fingering>2</fingering>",
"<fingering>3</fingering>",
"<fingering>4</fingering>",
"<fingering>5</fingering>",
"",
"",
"",
"",
"<fermata/>",
"<trill-mark/>",
"<accent/>",
"<strong-accent/>",
"<staccato/>",
"<tenuto/>",
"",
"<mordent/>",
"<inverted-mordent/>",
"<turn/>",
"",
"<harmonic/>",
"<up-bow/>",
"<down-bow/>",
"",
"",
"",
"",
"",
"",
"<strong-accent/>",
"<inverted-mordent/>"};
/* array to map Notelist note modifiers to corresponding MusicXML tag's parent tag */
char gNoteModParentTags[32][32] = {
"",
"technical",
"technical",
"technical",
"technical",
"technical",
"",
"",
"",
"",
"notations",
"ornaments",
"articulations",
"articulations",
"articulations",
"articulations",
"",
"ornaments",
"ornaments",
"ornaments",
"",
"technical",
"technical",
"technical",
"",
"",
"",
"",
"",
"",
"articulations",
"ornaments"
};
/* array to map Notelist notehead types to corresponding MusicXML types */
char gNoteheadTags[11][16] = {
"none",
"",
"x",
"diamond",
"square",
"square",
"diamond",
"diamond",
"",
"slash",
"none"
};
/* Array to tell us whether or not a Notelist notehead type is filled or not.
Tried these as booleans, but doesn't work so well, because some should not
display at all, others should be yes and still others should be explicity "no"
*/
char gNoteheadTagsFilled[11][3] = {
"",
"",
"no",
"no",
"yes",
"no",
"yes",
"",
"",
""
};
/* array to map accidentals */
char gAccidentalVals[6][32] = {
"",
"flat-flat",
"flat",
"natural",
"sharp",
"double-sharp"
};
short gAccidentalDoubleFlat = 1;
short gAccidentalFlat = 2;
short gAccidentalNatural = 3;
short gAccidentalSharp = 4;
short gAccidentalDoubleSharp = 5;
/* array to map dynamics */
char gDynamicsMap[24][16] = {
"",
"pppp",
"ppp",
"pp",
"p",
"mp",
"mf",
"f",
"ff",
"fff",
"ffff",
"piu piano",
"meno piano",
"meno forte",
"piu forte",
"sf",
"fz",
"sfz",
"rf",
"rfz",
"fp",
"sfp",
"diminuendo",
"crescendo"
};