Debian Codegraph @

utils/xml2pmx/xml2pmx-src/obsrc/Testbed.m

raw
1 MODULE Testbed;
2
3 (***************************************************************************)
4 (**************** Copyright 2015--2021 Dieter Gloetzel ********************)
5 (************************ Version016 multi platform ***********************)
6 (***************************************************************************)
7 (* This program is free software: you can redistribute it and/or modify
8 it under the terms of the GNU General Public License as published by
9 the Free Software Foundation, either version 3 of the License, or
10 (at your option) any later version.
11
12 This program is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with this program. If not, see <http://www.gnu.org/licenses/>. *)
19
20 (* corrections starting 09.07.2020 beam2pmx add "l" or "u" to "[j" *)
21 (* IMPORT Texts, Strings, Files, Oberon, b, Complete, Out; (* Import fuer Oberon Version *) *)
22 (* IMPORT Args32, Strings, Files, Out := WCout, b, Complete, Fifo ; *) (* Import fuer Windows-Exe Version *)
23 IMPORT Args, Files := MyFiles, Strings := Strings1, Out, b, Complete; (* Import for Linux-Version *)
24
25
26 CONST
27 NL = 0AX; BLANK = 20X; (* TAB = 09X; *) CR = 0DX; measurelimit = 600;
28 TYPE
29 LONGINT = INTEGER;
30 ControlDesc = RECORD (* data structure of input data *)
31 xml, dtd: ARRAY 256 OF CHAR;
32 title: ARRAY 128 OF CHAR;
33 composer, lyricist, info, software: ARRAY 128 OF CHAR;
34 rights: ARRAY 128 OF CHAR;
35 parts: ARRAY 30 OF ARRAY 16 OF CHAR;
36 instruments: ARRAY 30 OF ARRAY 32 OF CHAR;
37 worknumber: ARRAY 32 OF CHAR;
38 equalkeys : BOOLEAN;
39
40 END;
41 AttributesDesc = RECORD (* initial signature, meter , #staves,clef *)
42
43 measure, note, pickup: LONGINT;
44 divisions, duration: INTEGER;
45 fifth: INTEGER;
46 beats: INTEGER;
47 beattype, mtrdenp: INTEGER;
48 staves: INTEGER;
49 clefsign: ARRAY 4 OF CHAR; (* index is for staff *)
50 clefline: ARRAY 4 OF LONGINT;
51 diatonic, chromatic: LONGINT;
52 octave: LONGINT; (* parameters in <transpose> *)
53 END;
54 DirectionDesc = RECORD (* data structure for directions *)
55 part, staff, measure, note, lastnote, voice: LONGINT; (* voice ? implizit ueber lastnote definiert *)
56 before: BOOLEAN;
57 placement: CHAR; (* "h" or "l" for above and below *)
58 dirtype: CHAR; (* words, metronome, dynamics, wedge= hairpin, pedal, segno, coda, other *)
59 wedgetype: ARRAY 32 OF CHAR; (* crescendo, diminuendo, stop crescendo and stop diminuendo *)
60 dyntype: ARRAY 16 OF CHAR;
61 pedaltype: ARRAY 16 OF CHAR; (* start, stop, *)
62 text: ARRAY 128 OF CHAR;
63 pmxdirection: ARRAY 128 OF CHAR;
64 defaultx: INTEGER;
65 used: BOOLEAN; (* avoid duplication of dynamic marks in case of two voices in a staff
66 enable two directions at one note *)
67 END;
68 NoteDesc = RECORD (* properties of a note *)
69 accidental: ARRAY 10 OF CHAR;
70 actual: INTEGER;
71 (* arpeggio: BOOLEAN; *)
72 (* base : INTEGER; Base note of a chord *)
73 beam, closebeam: ARRAY 16 OF CHAR;
74 chord: CHAR; cue : BOOLEAN;
75 clef: CHAR;
76 clefchanged: CHAR;
77 defaultx: INTEGER;
78 dot: CHAR;
79 fermata: ARRAY 16 OF CHAR;
80 from, to, duration: INTEGER;
81 grace: INTEGER;
82 lefttext, righttext: ARRAY 256 OF CHAR;
83 maxbeam : LONGINT; (* number of beams for binary tremolo*)
84 normal: INTEGER;
85 pitchoctave: INTEGER;
86 pitchstep: CHAR;
87 pmxgrace: ARRAY 32 OF CHAR; (* Aenderung 16.11.2020 *)
88 pmxnote: ARRAY 64 OF CHAR;
89 probj: BOOLEAN; (* evaluates print-object = "no" TRUE means "print", FALSE don't print *)
90 rbleft, rbright: ARRAY 32 OF CHAR; (* blind rests to fill incomplete measures *)
91 repeat: ARRAY 16 OF CHAR;
92 rest, blind: CHAR;
93 slur: ARRAY 2 OF ARRAY 8 OF CHAR;
94 staccato, accent, trill, strongaccent: ARRAY 8 OF CHAR;
95 staff: INTEGER;
96 stem: CHAR;
97 tied: ARRAY 2 OF ARRAY 8 OF CHAR;
98 trembeam: LONGINT;
99 tremolotype : ARRAY 32 OF CHAR;
100 tuplet: ARRAY 16 OF CHAR;
101 type, normaltype: ARRAY 8 OF CHAR; (* begend begin and end of a series of Grace notes *)
102 voicetime: INTEGER;
103 END;
104 MeasureDesc = RECORD (* properties of measure *)
105 beattype, beats, fifth: INTEGER;
106 repeat: ARRAY 16 OF CHAR;
107 ending: ARRAY 16 OF CHAR;
108 barstyle, meterchange: ARRAY 16 OF CHAR;
109 voicetime: ARRAY 27 OF ARRAY 4 OF INTEGER;
110 duration, keys: ARRAY 27 OF INTEGER;
111 (* divisions : ARRAY 27 OF INTEGER; *)
112 dur : INTEGER; (* measure actual length of a measure *)
113 clefchange : ARRAY 27 OF CHAR; (* Maerz 2018 *)
114 END;
115
116 VAR
117
118 uptomeasure : LONGINT; (* global variable for reducing the number of measures *)
119
120 notes: POINTER TO ARRAY 24 OF ARRAY 3 OF ARRAY 600 OF ARRAY 83 OF POINTER TO NoteDesc; (*20-10-2020 Lilypond2 *)
121
122 (* notes: POINTER TO ARRAY 24 OF ARRAY 3 OF ARRAY 400 OF ARRAY 64 OF NoteDesc; *)
123
124 keytotal : ARRAY 132 OF CHAR;
125 unix: BOOLEAN; outputcont : ARRAY 32 OF CHAR; outputset : SET;
126 voicemeasure: POINTER TO ARRAY 30 OF ARRAY 600 OF SET;
127 voiceps: ARRAY 30 OF SET;
128 voicelimmps: ARRAY 30 OF LONGINT;
129 vmapps: ARRAY 30 OF ARRAY 5 OF LONGINT;
130 minvoice, maxvoice: POINTER TO ARRAY 27 OF ARRAY 600 OF LONGINT;
131 vmap: ARRAY 30 OF ARRAY 600 OF ARRAY 5 OF LONGINT;
132 (* notetypei : ARRAY 10 OF INTEGER; inverse of notetype index 0 => 64 *)
133
134 clefspec, lastclef: ARRAY 27 OF CHAR; (* special clef and valid clef in the actual measure *)
135
136 voicelimm: ARRAY 30 OF ARRAY 600 OF LONGINT;
137 sout : ARRAY 128 OF CHAR; (* target file path and directory *)
138
139 (* controls# voices within a staff and measure*)
140 voicecount: ARRAY 30 OF LONGINT; (* counts different voices within a staff *) countnote, countattr, countdir : LONGINT;
141
142 ingrace2pmx: LONGINT;
143 in, out: ARRAY 128 OF CHAR;
144 lastto, lastfrom: INTEGER; (* global variable for time progress in measure *)
145 pmxdur: ARRAY 16 OF CHAR; (* global variable: duration of notes in PMX *)
146 lastnote : LONGINT; (* global variable for position of last note *)
147 fi, fo: Files.File; ri: Files.Rider;
148 (* VAR notes : notestype; *)
149 voicetime: ARRAY 27 OF ARRAY 4 OF INTEGER; (* progress of notes duration in part,staff,voice, actual measure *)
150 lasttype: ARRAY 32 OF CHAR; (* beam type of preceding note *)
151 laststaff : LONGINT;
152 closebeam: ARRAY 8 OF CHAR; (* staff of preceding note for beam calculation *)
153 (* q: FIFO; *) (* global variable for sorted notes queue *)
154 maxdir, i, j, part, staff, voice, measure, note, count, maxpart, maxmeasure, itags, maxgrace, controlpart,
155 nostaves, nties, lfdnr, ps, dirnum, lastdirnum, attnum, lastattnum, lastgrace: LONGINT;
156 lastdyn: ARRAY 32 OF CHAR;
157 (* Global variables *)
158 stavesfound: BOOLEAN;
159 partlabel: ARRAY 27 OF ARRAY 5 OF CHAR;
160 directions: POINTER TO ARRAY 2000 OF ARRAY 5 OF DirectionDesc;
161 maxdirtype: ARRAY 2000 OF LONGINT; (* vorlaeufig, nur zum Daten sammeln. *)
162 attributes: ARRAY 30 OF AttributesDesc;
163 partstaff: ARRAY 30 OF ARRAY 2 OF LONGINT;
164 (* notes: ARRAY 30 OF ARRAY 2 OF ARRAY 500 OF ARRAY 64 OF NoteDesc; Aenderung wegen voice numerierung *)
165 maxnote, maxnote0, maxnote1, minnote0, minnote1, minnote: ARRAY 30 OF ARRAY 3 OF ARRAY 600 OF LONGINT;
166 (* number of last note in part/staff/measure *)
167 measures: POINTER TO ARRAY 600 OF MeasureDesc;
168 pmxcontrol: ControlDesc;
169 accidentaltag, parttag, measuretag, notetag, pitchtag, steptag, octavetag, durationtag, voicetag, dottag, stemtag, cleftag, clefoctavetag, staccatotag: ARRAY 32 OF CHAR;
170 attributestag, divisionstag, keytag, fifthstag, timetag, beatstag, beattypetag, stavestag, signtag, linetag, typetag, fermatatag, tuplettag: ARRAY 32 OF CHAR;
171 notationtag, lyrictag, syllabictag, texttag, resttag, chordtag, backuptag, repeattag, slurtag, stafftag, printtag, directiontag, tiedtag,
172 cleflinetag, actualtag, normaltag, beamtag, wordstag, eonotetag, eomeasuretag, barlinetag, endingtag, barstyletag, dynamicstag,
173 worktag, identificationtag, defaultstag, eoattributestag, forwardtag, eodirectiontag, credittag, gracetag, gracetag2, cuetag : ARRAY 32 OF CHAR;
174 staves: ARRAY 30 OF LONGINT; (* maximum staff of "part" *)
175
176 beamopen : ARRAY 30 OF ARRAY 3 OF BOOLEAN;
177 (* cl: Args32.LPSTR; (* Command line for Windows.Exe *) *)
178
179
180
181
182 PROCEDURE pmxtype( xmltype: INTEGER ): INTEGER;
183 VAR i: INTEGER;
184 BEGIN
185 CASE xmltype OF
186 1: i := 0;
187 | 2: i := 2;
188 | 4: i := 4;
189 | 8: i := 8;
190 | 16:
191 i := 1;
192 | 32:
193 i := 3;
194 | 64:
195 i := 6;
196 ELSE
197 Out.Ln(); i := -1; Out.String( "xml note type : " ); Out.Int( xmltype, 5 );
198 Out.String( " not implemented." ); Out.Ln();
199 END;
200 RETURN i;
201
202 END pmxtype;
203
204
205 PROCEDURE FillRests( notefrom, noteto, measure, ps, voice: LONGINT );
206 (* Fills incomplete measures with blind rests, as needed *)
207 VAR note, part, staff, lastnote: LONGINT; delta, lastto: INTEGER; (* global "lastnote" removed 29.11.2016 *)
208 BEGIN
209 part := partstaff[ps, 0]; staff := partstaff[ps, 1];
210 lastto := 0; lastnote := 0;
211
212 IF (measures[measure].voicetime[ps, voice] < measures[measure].duration[part]) THEN
213 (* Out.Ln(); Out.String( "Fillrests: notefrom. noteto " ); Out.Int( notefrom, 5 ); Out.Int( noteto, 5 ); *) note := notefrom;
214 WHILE note <= noteto DO
215 (* Out.Ln(); Out.Int( measure, 5 ); Out.Int( ps, 5 ); Out.Int( voice, 5 ); Out.Int( note, 5 ); *)
216 (* NoteOut(notes[ps,voice,measure,note]); *)
217 INC( note );
218 END;
219
220
221 (* left of first note *)
222 note := notefrom;
223 IF (notes[ps, voice, measure, note] # NIL) &
224 (notes[ps, voice, measure, note].from > 0) THEN
225
226 delta := notes[ps, voice, measure, note].from - 1; (* Out.Ln(); Out.String( " note delta : " );
227 Out.Int( note, 5 ); Out.Int( delta, 5 ); *)
228 IF delta > 0 THEN Complete.Int2br( attributes[part].divisions, delta, notes[ps, voice, measure, note].rbleft ); END;
229
230 lastnote := note; lastto := notes[ps, voice, measure, note].to;
231
232 ELSE
233 END;
234 (* left of 2nd to last note *)
235 INC( note );
236
237 WHILE (note <= noteto) DO
238 IF ( notes[ps, voice, measure, note] # NIL ) &
239 (notes[ps, voice, measure, note].from > 0) THEN
240 delta := notes[ps, voice, measure, note].from - lastto - 1;
241 (* Out.Ln(); Out.String( " note delta : " ); Out.Int( note, 5 ); Out.Int( delta, 5 ); *)
242
243 IF delta > 0 THEN
244 Complete.Int2br( attributes[part].divisions, delta, notes[ps, voice, measure, note].rbleft );
245
246
247 END;
248 lastnote := note;
249 IF notes[ps, voice, measure, note] # NIL
250 THEN
251 lastto := notes[ps, voice, measure, note].to;
252 END
253
254 END;
255
256 INC( note );
257 END;
258 (* right of last note *)
259 delta := measures[measure].duration[part] - lastto;
260 (* Out.Ln(); Out.Int(ps,5); Out.Int(measure,5);Out.String( " note delta : " );
261 Out.Ln(); Out.Int( lastnote, 5 ); Out.Int( delta, 5 ); *)
262 IF delta > 0 THEN
263 Complete.Int2br( attributes[part].divisions, delta, notes[ps, voice, measure, lastnote].rbright );
264
265 END;
266
267 END;
268
269 END FillRests;
270
271 PROCEDURE PMXdyn( XMLdyn: ARRAY OF CHAR; VAR out: ARRAY OF CHAR );
272 (* converts e.g. <f /> to " Df "*)
273 BEGIN
274 (* doubke on purpose *)
275 IF XMLdyn = "<f />" THEN COPY( " Df ", out ); END;
276 IF XMLdyn = "<ff />" THEN COPY( " Dff ", out ); END;
277 IF XMLdyn = "<fff />" THEN COPY( " Dfff ", out ); END;
278 IF XMLdyn = "<ffff/>" THEN COPY( " Dffff ", out ); END;
279 IF XMLdyn = "<mf />" THEN COPY( " Dmf ", out ); END;
280 IF XMLdyn = "<p />" THEN COPY( " Dp ", out ); END;
281 IF XMLdyn = "<pp />" THEN COPY( " Dpp ", out ); END;
282 IF XMLdyn = "<ppp />" THEN COPY( " Dppp ", out ); END;
283 IF XMLdyn = "<pppp />" THEN COPY( " Dpppp ", out ); END;
284 IF XMLdyn = "<mp />" THEN COPY( " Dmp ", out ); END;
285 IF XMLdyn = "<sf />" THEN COPY( " Dsfz ", out ); END;
286 IF XMLdyn = "<fp />" THEN COPY( " Dfp ", out ); END;
287 IF XMLdyn = "<f/>" THEN COPY( " Df ", out ); END;
288 IF XMLdyn = "<ff/>" THEN COPY( " Dff ", out ); END;
289 IF XMLdyn = "<fff/>" THEN COPY( " Dfff ", out ); END;
290 IF XMLdyn = "<ffff/>" THEN COPY( " Dffff ", out ); END;
291 IF XMLdyn = "<mf/>" THEN COPY( " Dmf ", out ); END;
292 IF XMLdyn = "<p/>" THEN COPY( " Dp ", out ); END;
293 IF XMLdyn = "<pp/>" THEN COPY( " Dpp ", out ); END;
294 IF XMLdyn = "<ppp/>" THEN COPY( " Dppp ", out ); END;
295 IF XMLdyn = "<pppp/>" THEN COPY( " Dpppp ", out ); END;
296 IF XMLdyn = "<mp/>" THEN COPY( " Dmp ", out ); END;
297 IF XMLdyn = "<sf/>" THEN COPY( " Dsfz ", out ); END;
298 IF XMLdyn = "<fp/>" THEN COPY( " Dfp ", out ); END;
299
300
301
302 IF ( XMLdyn = "crescendo") & (lastdyn # " D<" ) THEN COPY( " D<", out ); COPY( out, lastdyn ); END; (* 18.02.2017 *)
303
304 IF ( XMLdyn = "diminuendo" ) & (lastdyn # " D>" ) THEN COPY( " D>", out ); COPY( out, lastdyn );
305 END;
306 IF XMLdyn = "stop" THEN COPY( lastdyn, out );IF lastdyn # "" THEN Strings.Append( out, "+0+3" ); END;
307 b.loesch( lastdyn ); END;
308 (* Out.String( XMLdyn ); Out.Char( "|" ); Out.String( out ); *)
309 END PMXdyn;
310
311 PROCEDURE WriteLInt( VAR W: Files.Rider; i: LONGINT );
312 VAR si: ARRAY 10 OF CHAR;
313 BEGIN
314 Strings.IntToStr( i, si ); Files.Write( W, BLANK ); WriteString( W, si );
315 END WriteLInt;
316
317 PROCEDURE WriteString( VAR W: Files.Rider; s: ARRAY OF CHAR );
318 BEGIN
319 Files.WriteBytes( W, s, Strings.Length( s ) );
320 END WriteString;
321
322
323 PROCEDURE SetOutput*;
324 VAR c : CHAR; i : LONGINT;
325 BEGIN
326 i := 0; WHILE i < Strings.Length(outputcont) DO
327 c := outputcont[i];
328 CASE c OF
329
330 | "R" : INCL(outputset,10); (* remove notes with print-obj="no" in print phase; e.g. for xml-files with programmed Trill 20-11-2019 *)
331 | "P" : INCL(outputset,9); (* parser output 0 durch 9 ersetzt 20.05.2019 *)
332 | "D" : INCL(outputset,1); (* list directions *)
333 | "V" : INCL(outputset,2); (* list voices per measure and instrument *)
334 | "A" : INCL(outputset,3); (* Statistics of MusicXML tags *)
335 | "L" : INCL(outputset,4); (* store lyrics *)
336 | "S" : INCL(outputset,5); (* remove all slurs *)
337 | "T" : INCL(outputset,6); (* remove all ties *)
338 | "G" : INCL(outputset,7); (* eliminate slurs around grace notes, replace by PMX internal Grace notes. *)
339 | "X" : INCL(outputset,8); (* x-option for voice crossing slurs, only with PMX282 *)
340 | "N" : (* no option chosen *)
341
342 ELSE Out.String(" option not implemented.")
343 END;
344 INC(i); END;
345 END SetOutput;
346
347 (* PROCEDURE commandO*; (* Command for Oberon-Version *)
348 VAR R: Texts.Reader; i: LONGINT; c: CHAR;
349 BEGIN
350 (* 0. Read Filenames from Oberon.Par.text *)
351 Texts.OpenReader( R, Oberon.Par.text, Oberon.Par.pos ); Texts.Read( R, c ); i := 0;
352 WHILE (c # "~") & (~R.eot) & (i < LEN( comline )) DO comline[i] := c; Texts.Read( R, c ); INC( i ) END;
353 comline[i - 1] := 0X; Out.Ln(); Out.String("comline : ");Out.String (comline);
354 Filenames(FALSE, comline, in, out, outputcont );
355 Stripfilename(out,sout); InOut( in, out );
356
357 END commandO; *)
358
359 (* PROCEDURE commandX; (* WIndows EXE *)
360 VAR i: LONGINT; c: CHAR;
361 BEGIN
362 Args32.Str( "Program XML2PMX.EXE Copyright 2016 Dieter Gloetzel" ); Args32.Ln();
363
364 cl := Args32.GetCommandLine(); Args32.CopyString( cl, comline ); Args32.Str( comline ); Args32.Ln();
365 Filenames(TRUE,comline,in,out,outputcont);
366 Stripfilename(out,sout); InOut( in, out );
367 END commandX; *)
368 PROCEDURE CommandU;
369 VAR output : ARRAY 16 OF CHAR; kno : LONGINT;
370 BEGIN
371 kno := Args.argc;
372 IF ( kno >= 3 ) THEN
373 Args.GetArg(1, in);
374 Args.GetArg(2, out);
375 COPY(out,sout);
376 Strings.ChangeSuffix(sout,"txt");
377 IF ( kno >= 4 ) THEN Args.GetArg(3,output); END;
378 Strings.Upper(output,outputcont);
379 SetOutput; b.voutput := (2 IN outputset);
380 IF ( kno = 5 ) THEN Args.GetArg(4,output); Strings.StrToInt(output,uptomeasure); END;
381 Out.String( "Linux Binary XML2PMX Copyright 2015/2021 Dieter Gloetzel" ); Out.Ln();
382 InOut(in, out);
383 ELSE
384 Args.GetArg(0, in);
385 Out.String(in); Out.String(" error: argument number < 2 "); Out.Ln;
386 END;
387 END CommandU;
388
389 PROCEDURE Voicing( q: b.FIFO);
390 (* calculates an array of Sets vontaining the voices for part, staff and measure. *)
391 VAR n: b.Tag;
392 BEGIN
393 n := q.first;
394 WHILE (n.next # NIL ) DO
395 IF n.tagname = notetag THEN
396 ps := linstaff( nostaves, n.part, n.staff ); INCL( voicemeasure[ps, n.measure], n.voice );
397 INCL( voiceps[ps], n.voice ); maxvoice[ps, n.measure] := b.Max( maxvoice[ps, n.measure], n.voice );
398 minvoice[ps, n.measure] := b.Min( minvoice[ps, n.measure], n.voice );
399 END;
400 n := n.next;
401 END;
402 END Voicing;
403
404 PROCEDURE DeleteTag(deltag : b.Tag);
405 VAR n : b.Tag;
406 BEGIN
407 n := b.q.first;
408 REPEAT n := n.next UNTIL (n.next = NIL) OR (n.next = deltag);
409 IF n.next = deltag THEN n.next := deltag.next END;
410 (* Out.Ln(); Out.Int(deltag.nr, 5); Out.String("deleted"); *)
411 END DeleteTag;
412
413 PROCEDURE DeleteTS (tag : ARRAY OF CHAR); (* deletes all ties or slurs according to "tag" *)
414 VAR n : b.Tag; count : LONGINT;
415 BEGIN
416 n:= b.q.first; count := 0;
417 WHILE n.next # NIL DO
418
419 IF (n.tagname = tag) (* tags of type "tag" will be removed. *)
420 THEN
421 (* b.OutTag(n, TRUE); Out.String("deleted"); *)
422 DeleteTag(n); INC(count);
423 END;
424 n:= n.next END;
425 Out.Ln(); Out.String("********************************");
426 Out.Int (count,5); Out.String(tag); Out.String ("deleted");
427 END DeleteTS;
428
429
430
431
432 PROCEDURE InOut( infilename, outfilename: ARRAY OF CHAR );
433 VAR n: b.Tag; (* data structure for sorting notes *)
434 outfilenameprep: ARRAY 64 OF CHAR;
435 fprep: Files.File; rprep: Files.Rider; res : INTEGER;
436 BEGIN
437 Out.String( "This is XML2PMX Version 16. dyn. alloc." ); fi := Files.Old( infilename );
438 IF (fi # NIL ) THEN (* 1*)
439 Files.Set( ri, fi, 0 );
440 (***************************************)
441 (* 1. Analyze XML data *) AnalyzeXML2( ri );
442
443 (* n:= b.q.first; WHILE n.next # NIL DO b.OutTag(n, TRUE); n:= n.next END; *)
444
445 (* DeleteTies or Slurs; *)
446 IF (5 IN outputset) THEN DeleteTS("<slur>"); END;
447 IF (6 IN outputset) THEN DeleteTS("<tied>"); END;
448
449 (* 2. create temporary result storage for PMX-data *)
450 COPY( outfilename, outfilenameprep ); Strings.Append( outfilenameprep, "prep" );
451 fprep := Files.New( outfilenameprep ); Files.Set( rprep, fprep, 0 );
452 Out.Ln(); Out.String("Intermediate output file "); Out.String(outfilenameprep); Out.String(" created. ");
453
454 (* 3. map part/staff to a linear index. *) AllStaves( staves );
455 Out.Ln(); Out.String("3: Allstaves done!");
456 (* 4. Extract control data *) ControlProp;
457 Out.Ln(); Out.String("4: ControlProp done!");
458 (* 5. Enrich Data *) Enrich( b.q );
459 Out.Ln(); Out.String("5: Enrich done!");
460 (* n := b.q.first;
461 WHILE n.next # NIL DO b.OutTag( n, TRUE ); n := n.next END; *)
462 (****************************************************************************)
463 (*6. Calculate data for mapping of voices between PMX and XML *)
464
465 Voicing( b.q ); (* Store voices wrt part,stave and measure. *)
466 Out.Ln(); Out.String("6 : Voicing done!");
467
468 IF (2 IN outputset) THEN Out.Ln();
469 Out.String( "*************** voices per instrument (part/staff) " ); ps := 0;
470 Out.Ln(); Out.String( "nostaves" ); Out.Int( nostaves, 5 );
471 WHILE ps < nostaves DO
472 Out.Ln(); Out.Int( ps, 5 ); b.Outset( voiceps[ps], voicelimmps[ps], vmapps[ps] ); INC( ps );
473 END;
474 END;
475 ps := 0;
476 IF 2 IN outputset THEN
477 Out.Ln();
478 Out.String( "*************** voices per measure and instrument (part/staff) " ); Out.Ln();
479 END;
480 WHILE ps < nostaves DO;
481 measure := 1;
482 WHILE measure <= maxmeasure DO
483 IF (2 IN outputset) THEN
484 Out.Ln(); Out.Int( ps, 5 ); Out.Int( measure, 5 );
485 END;
486 b.Outset( voicemeasure[ps, measure], voicelimm[ps, measure], vmap[ps, measure] );
487 (* Out.Int(minvoice[ps,measure],5); Out.Int(maxvoice[ps,measure],5); *)
488 INC( measure );
489 END;
490 INC( ps );
491 END;
492 (****************************************************************************)
493
494
495
496 (* i := 1;
497 WHILE i <= maxpart DO
498 Out.Ln(); Out.String( "part, label : " ); Out.Int( i, 5 ); Out.String( partlabel[i] ); INC( i );
499 END; *)
500 (* 7. identify potential pickup *) Pickup( b.q, attributes[1].pickup );
501 Out.Ln(); Out.String("7: Pickup done!");
502
503
504
505 (* 8. Generate Control data for PMX (i.e everything before the notes and store in"outfilename"*)
506
507 ControlData( rprep );
508 Out.Ln(); Out.String("8: ControlData done!");
509
510
511
512
513 (* *)
514
515 (*9. Investigate time series of notes (e.g. incomplete measures) *)
516 progress( b.q );
517 Out.Ln(); Out.String("9: progress done!");
518 (* listmeter;*)
519
520
521 (* IF 1 = 0 THEN *)
522 (* 10. Store everything in arrays measurewise *)
523 EnumerateTags; Out.Ln(); Out.String( "10: EnumerateTags done!" );
524
525 IF 9 IN outputset THEN (* Option "p" *)
526 n := b.q.first; WHILE (n.next # NIL) & (n.measure < uptomeasure) DO b.OutTag(n,TRUE);
527 n:= n.next; END;
528 END;
529
530 (* listmeter;*)
531 (* 11.. Generate PMX and store in outfilename *)
532 (* 14.11.2020: Do not link directions to grace notes *)
533 (* IF (voice = 0) & (notes[ps,voice,measure,note].grace = 0 ) THEN *) DistributeDirections; (* END; *)
534 WritePMX( rprep ); Out.Ln(); Out.String( "11: nach WritePMX" );
535 (* 12. Remove multiple Blanks from result file and break lines after 100 Chars *)
536 Files.Register( fprep ); fo := Files.New( outfilename ); Copywo( fprep, fo, unix ); Files.Close( fi );
537 Files.Close(fprep); Files.Delete( outfilenameprep, res );
538 IF ( res = 0 ) THEN Out.Ln(); Out.String("Intermediate data deleted"); END;
539 Files.Register( fo ); Files.Close( fo ); Out.Ln(); Out.String(out); Out.String( " registered" );
540
541 (* END; *)
542
543 IF (4 IN outputset) THEN b.writetext; END; (* Lyrics is decoded in MODULE "b" and appears in "songtext.txt" in this directory. *)
544
545 IF (3 IN outputset) THEN b.SortTags END; (* lists all occurences of XML-Tags. *)
546 ELSE
547 Out.Ln(); Out.String("input file: "); Out.String(infilename); Out.String(" not found ");
548 END;
549
550 (* Out.Ln(); Out.String("countclefchanges : ");
551
552 Out.Int(countclefchanges,5); *)
553 Out.Ln()
554 END InOut;
555
556
557 PROCEDURE Copywo( VAR fin, fout: Files.File; unix: BOOLEAN );
558 (* Copies a File and eliminates multiple BLANKs. *)
559 VAR ch: CHAR; rin, rout: Files.Rider; column: LONGINT;
560 BEGIN
561 Files.Set( rin, fin, 0 ); Files.Set( rout, fout, 0 ); column := 0; Files.Read( rin, ch );
562 WHILE ~rin.eof DO
563 IF (~unix) THEN Files.Write( rout, Strings.OberonToISO[ORD( ch )] ); INC( column );
564 ELSIF unix & (ch # CR) THEN Files.Write( rout, Strings.OberonToISO[ORD( ch )] ); INC( column );
565 END;
566 IF (ch = NL) THEN column := 0; END;
567 IF (column > 100) & (ch = BLANK) THEN
568 column := 0;
569 IF (~unix) THEN Files.Write( rout, CR ); END;
570 Files.Write( rout, NL );
571 END;
572
573 (* IF ch =Strings.CR THEN Files.Write(R,NL); END; *)
574 IF (ch = BLANK) THEN
575 WHILE (ch = BLANK) DO Files.Read( rin, ch ); END;
576 ELSE Files.Read( rin, ch );
577
578 END;
579
580 END;
581 END Copywo;
582
583 PROCEDURE DistributeDirections;
584 VAR idir, j, lastnote, lastidir, lastj, lastmeasure, lastlastnote, lastps, noteto, firstnote, count: LONGINT;
585 lastdirtype: CHAR;
586 posnote: ARRAY 64 OF INTEGER;
587 BEGIN
588 lastnote := 0;
589 idir := 1;
590 WHILE idir <= maxdir DO
591 j := 1;
592 WHILE j <= maxdirtype[idir] DO
593
594
595 part := directions[idir, 0].part;
596 staff := directions[idir, 0].staff; lastmeasure := measure;
597 measure := directions[idir, 0].measure;
598 lastlastnote := lastnote; lastnote := directions[idir, 0].lastnote;
599
600
601 IF (1 IN outputset) THEN (* Print all directions *) OutDir( idir, j ); END;
602
603 (* IF lastnote = 0 THEN lastnote := 1 END; *)
604 lastps := ps; ps := linstaff( nostaves, part, staff ); firstnote := minnote0[part, staff, measure];
605 IF (notes[ps,0,measure,firstnote].grace > 0) THEN (* first note is grace note and cannot carry dynamic marks *)
606
607 (* Out.Ln(); Out.String("DistrDir : ");Out.Int(ps,5); Out.Int(measure,5); Out.Int(firstnote,5); Out.Char("|");
608 Out.Int(notes[ps,0,measure,firstnote].grace,5 ); Out.Int(lastnote,5); *)
609
610 REPEAT INC(firstnote) UNTIL notes[ps,0,measure,firstnote].grace = 0;
611 Out.Ln(); Out.String(" first real note at ps, measure, note :"); Out.Int(ps,5); Out.Int(measure,5); Out.Int(firstnote,5);
612 Out.Char("|"); Out.Int(notes[ps,0,measure,firstnote].grace,5 );
613
614 END;
615 CASE directions[idir, j].dirtype OF
616
617 "w": (* words, i.e. text *)
618 IF lastnote < firstnote THEN lastnote := firstnote END;
619
620 IF (notes[ps, 0, measure, lastnote].lefttext = "") THEN
621 Strings.Append( notes[ps, 0, measure, lastnote].lefttext, directions[idir, j].pmxdirection ); (* pmxdirection pruefen *)
622 (* Out.Ln(); Out.String("idir,j,pmxdirection "); Out.Int(idir,5); Out.Char("|");Out.Int(j,5); Out.Char("|");
623 Out.String(directions[idir,j].pmxdirection); *)
624
625 ELSE
626 b.APPzca( notes[ps, 0, measure, lastnote].lefttext, directions[idir, j].pmxdirection );
627 b.loesch( directions[idir, j].pmxdirection );
628 END;
629
630 | "h": (* hair pins *)
631 IF lastnote < firstnote THEN lastnote := firstnote END;
632 IF ( lastnote > maxnote0[part,staff,measure] ) THEN lastnote := maxnote0[part,staff,measure] END; (* Modification 23.12.2016 *)
633 Strings.Append( notes[ps, 0, measure, lastnote].righttext, directions[idir, j].pmxdirection );
634 lastdirtype := "h";
635 | "d": (* dynamic marks *)
636 IF (directions[idir, j].lastnote = 0) & (directions[idir, j].defaultx = 0) THEN
637 directions[idir, j].lastnote := firstnote; lastnote := directions[idir, j].lastnote
638 ELSIF (directions[idir, j].lastnote > 0) & (directions[idir, j].lastnote < maxnote0[part, staff, measure]) THEN
639 INC( directions[idir, j].lastnote ); lastnote := directions[idir, j].lastnote
640 ELSIF (directions[idir, j].lastnote = 0) & (directions[idir, j].defaultx > 0) THEN
641 (* Out.Ln(); Out.String( "Direction default-x: " ); Out.Int( directions[idir, j].defaultx, 5 ); *)
642 note := minnote0[part, staff, measure]; noteto := maxnote0[part, staff, measure];
643 (* Out.String( "note : " ); Out.Int( note, 5 ); Out.String( "noteto : " ); Out.Int( noteto, 5 ); *)
644 count := noteto - note + 1; (* Out.String( "count : " ); Out.Int( count, 5 ); *)
645
646 WHILE note <= noteto DO
647 posnote[note - minnote0[part, staff, measure]] := notes[ps, 0, measure, note].defaultx;
648 INC( note );
649 END;
650 lastnote := b.MinDist( directions[idir, j].defaultx, posnote, SHORT( count ) ) + 1;
651 (* Out.String( "lastnote : " ); Out.Int( lastnote, 5 ); *)
652
653 END;
654 (* IF (notes[ps, 0, measure, lastnote].rest = "r") THEN (* avoid dynamics on rests. *)
655 REPEAT INC( lastnote ) UNTIL notes[ps, 0, measure, lastnote].rest # "r";
656 END; *)
657 IF notes[ps, 0, measure, lastnote] # NIL THEN
658 Strings.Append( notes[ps, 0, measure, lastnote].righttext, directions[idir, j].pmxdirection );
659 (* Out.Ln(); Out.String("DistrDirections , lastnote, righttext :");
660 Out.Int(measure,5);Out.Int(lastnote,5); Out.String(notes[ps, 0, measure, lastnote].righttext); *)
661 END;
662
663 lastdirtype := "d";
664 | "p":
665 INC( lastnote );
666 IF lastnote < firstnote THEN lastnote := firstnote END;
667 Strings.Append( notes[ps, 0, measure, lastnote].lefttext, directions[idir, j].pmxdirection );
668 lastdirtype := "p";
669 | "s":
670 IF lastnote < firstnote THEN lastnote := firstnote END;
671 Strings.Append( notes[ps, 0, measure, lastnote].righttext, directions[idir, j].pmxdirection );
672 lastdirtype := "s";
673
674
675 | "c":
676 IF lastnote < firstnote THEN lastnote := firstnote END;
677 Strings.Append( notes[ps, 0, measure, lastnote].righttext, directions[idir, j].pmxdirection );
678 lastdirtype := "c";
679
680
681 ELSE Out.Ln(); Out.String( "DistributeDirections : dirtype unknown." );
682 END;
683 (* Out.Ln(); Out.String(" ps,measure,lastnote ");Out.Int(ps,5); Out.Int(measure,5); Out.Int(lastnote,5); Out.Char("|");Out.String(directions[idir,j].pmxdirection);
684
685 *)
686 lastj := j; INC( j );
687 END;
688
689 lastidir := idir; INC( idir );
690 END;
691
692 END DistributeDirections;
693
694
695 PROCEDURE PMXDuration( tuplettype,tremolotype : ARRAY OF CHAR; div, xmldur: INTEGER; actual, normal: INTEGER;
696 VAR pmxdur: ARRAY OF CHAR; istuplet: BOOLEAN; type: ARRAY OF CHAR );
697 (* Calculates the pmx-duration of a note (0,2,4,8,1,3,6) or rest from the XML-duration. Takes into account one dot and two dots *)
698 VAR double: CHAR; tupletdur,noteduration, i : INTEGER;
699
700
701 BEGIN
702
703 IF ( istuplet & (tremolotype = "") ) THEN (* 1 *)
704 double := 0X;
705 noteduration := xmldur;
706
707 tupletdur := Complete.tupletduration(div,type,normal); (* total duration of tuplet in terms of xml-duration *)
708 IF tuplettype = "start" THEN (* tuplets *) (* 2 *)
709 Complete.Dur2PMX(div,tupletdur,pmxdur );
710
711 ELSE
712 i := 0; WHILE i < 16 DO pmxdur[i] := 0X; INC(i) END;
713 END; (* 2 *)
714 IF ABS(actual * noteduration - tupletdur) > 5 THEN (* 3 *)
715
716 IF ABS(noteduration*actual - 2 * tupletdur) < 5 THEN double := "D" END; (* Das ist Swing *)
717
718 IF ABS (noteduration*actual * 2 - 3 * tupletdur) < 5 THEN double := "d" END; (* Das ist Punktierung *)
719
720 Strings.AppendCh( pmxdur, double );
721
722 END; (* 3 *)
723 ELSIF istuplet & ( tremolotype ="start" ) THEN (* binary tremolo *) (* 1a *)
724
725 tupletdur := Complete.tupletduration(div,type,normal);
726 Complete.Dur2PMX(div,tupletdur,pmxdur );
727
728 ELSIF ( tremolotype = "stop" ) THEN (* 1b *)
729 i := 0; WHILE i < 16 DO pmxdur[i] := 0X; INC(i) END;
730
731 ELSE (* normal notes *)
732 Complete.Dur2PMX(div,xmldur,pmxdur );
733
734
735 END;
736
737 END PMXDuration;
738
739
740 PROCEDURE DelTag*;
741 VAR nlast, n, m: b.Tag;
742 BEGIN
743 nlast := NIL;
744 n := b.q.first;
745 WHILE n.next # NIL DO
746 IF (n.next.tagname = notetag) & (n.next.probj = "n") THEN
747 (* OutTag(n); OutTag(n.next); *)
748 (* nlast := n; *) (* n.next ist Note *)
749 m := n.next;
750 REPEAT m := m.next
751 UNTIL m.tagname = eonotetag;
752 (* OutTag( m ); *)
753 nlast.next := m.next;
754
755 IF nlast.next.tagname ="<backup>" THEN nlast.next := nlast.next.next.next END;
756 (* eliminate backup *)
757
758 (* Out.Ln(); Out.String(" nlast.nr und m.next.nr : ");
759 Out.Int(nlast.nr,5); Out.Char("|");Out.Int(m.next.nr,5); *)
760 n := m;
761 ELSE
762 n := n.next; nlast := n;
763
764 (* Out.Ln(); Out.String("ELSE n, n.next, nlast : ");Out.Int(n.nr,5); Out.Int(n.next.nr,5); Out.Int(nlast.nr,5); *)
765 END;
766
767 END;
768 (* n := q.first; REPEAT n:= n.next UNTIL n.nr = 20530 ; WHILE i < 30 DO OutTag (n); n:= n.next; INC(i) END;*)
769 END DelTag;
770
771
772
773
774 PROCEDURE WriteNote2PMX( VAR W: Files.Rider; VAR Note: NoteDesc;
775 ps, voice, voicefrom, measure, note: LONGINT; VAR Dtext, Rtext: ARRAY OF CHAR;
776 VAR istuplet: BOOLEAN );
777 (* Writes the data for one note or rest to Files.Rider "W"; called by PROC. W ritePMX; *)
778 VAR pmxdur: ARRAY 16 OF CHAR; sactual : ARRAY 4 OF CHAR;
779 pmxnote: ARRAY 64 OF CHAR; blindrest : ARRAY 32 OF CHAR;
780 tremolo: ARRAY 32 OF CHAR;
781 octave: CHAR; stemchar: CHAR; maxnotelastmeasure : LONGINT;
782
783 BEGIN
784
785
786 IF ( Note.grace # -1 ) THEN (* avoid chords as grace notes *)
787
788 (* IF (Wpos := Files.Pos(W); *)
789 (* remove duplicate grace notes *)
790 (* Out.Ln(); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); Out.Int(Note.grace,5); *)
791 (*IF Note.grace > 1 THEN
792 Out.Ln(); Out.String("remove duplicates");Out.Int(Note.grace,5);
793
794 IF (Note.pmxnote # 0X) THEN Out.String(Note.pmxnote); END;
795 b.loesch ( Note.pmxnote) ;
796 Out.Ln(); IF (Note.pmxgrace # 0X) THEN Out.String(Note.pmxgrace);END;
797 b.loesch ( Note.pmxgrace) ;
798 END; *)
799
800
801 part := partstaff[ps, 0]; staff := partstaff[ps, 1]; pmxnote[0] := BLANK; pmxnote[1] := 0X;
802 COPY( Note.lefttext, Dtext ); (* 07.04.2017 *)
803
804 IF (Note.clefchanged # 0X) THEN Files.Write(W,BLANK); Files.Write(W,"C"); Files.Write(W,Note.clefchanged); Files.Write(W,BLANK); END;
805 IF (Dtext[0] # 0X) THEN WriteString( W, Dtext ); END;
806 IF (Note.rbleft[0] # 0X) THEN WriteString( W, Note.rbleft ); END;
807
808 IF (Note.pitchstep # 0X) THEN
809 (* Branch for normal notes, tuplet notes and grace notes , as opposed to rests*)
810 (* 1 *)
811 INC( count );
812
813 istuplet := Note.actual # 0;
814
815 IF Note.grace = 0 THEN (* d.h. es ist keine Gracenote! *)
816
817 PMXDuration( Note.tuplet, Note.tremolotype, attributes[part].divisions,
818 Note.duration, Note.actual, Note.normal, pmxdur, istuplet, Note.type );
819 END;
820 (* delete slur before gracenote *)
821 IF (7 IN outputset) & (Note.grace = 0) OR ~(7 IN outputset) (* option control via outputset 24.04.2017*)
822 THEN (* Aenderung 18.04.2017*)
823 IF (Note.slur[0,1] = "(") THEN (* 3*)
824 Strings.Append( pmxnote, Note.slur [0]);
825 END;
826
827
828 IF (Note.slur[1,1] ="(") THEN
829 Strings.Append(pmxnote,Note.slur[1]); END;
830
831 END; (* 3*)
832
833 IF (Note.grace = 1) THEN (* ist erste einer Folge von grace notes *)
834
835 Strings.Append( pmxnote, Note.pmxgrace );
836 (* Out.Ln(); Out.String( " $$$$pmxgrace " ); Out.String( pmxnote ); *)
837
838 END; (* 4*)
839
840 IF (Note.tied[0, 1] = "{") THEN (* 5*)
841
842 Strings.Append( pmxnote, Note.tied[0] )
843 ELSIF (Note.tied[1, 1] = "{") THEN Strings.Append( pmxnote, Note.tied[1] )
844
845 END; (* 5*)
846
847 (* IF ~istuplet & (Note.beam[1] = "[") & (Note.grace = 0) THEN *) (* 6 alter code 14.01.2017 *)
848 IF ( ~istuplet OR ( istuplet & ( Note.tuplet = "start") ) )
849
850 & (Note.beam[1] = "[") & (Note.grace = 0) & (Note.tremolotype # "start")
851 (* & ( ~beamopen[ps,voice] ) (*10. 05. 2017 *)
852 & ????????????? *)
853 THEN
854
855 Strings.Append( pmxnote, Note.beam );
856 beamopen[ps,voice] := TRUE; (* 10.5.2017 *)
857
858 END; (* 6*)
859 IF Note.trembeam > 0 THEN
860
861 b.pmxTremolo( Note.pitchstep, Note.pitchoctave, Note.stem, Note.clef, Note.trembeam, pmxdur[0],
862 tremolo );
863
864 Strings.Append( pmxnote, tremolo );
865
866 Out.Ln(); Out.String( "tremolo&&&&" ); Out.Int( ps, 5 );
867 Out.Int( measure, 5 ); Out.String( tremolo );
868
869 END;
870
871 Strings.AppendCh( pmxnote, Note.chord );
872 IF Note.grace = 0 THEN (* attention: suppress duplicate Grace notes *) (* 7*)
873 (* also normale Note "0" 18.11.2020*)
874
875
876
877 Strings.AppendCh( pmxnote, Note.pitchstep );
878 END; (* 7*)
879
880 IF (Note.chord # "z") THEN Strings.Append( pmxnote, pmxdur ); END; (* 8*)
881
882 octave := CHR( Note.pitchoctave + 48 );
883 IF Note.grace = 0 THEN Strings.AppendCh( pmxnote, octave ); (* also normale Note "0" 18.11.2020*)
884
885 (* IF Note.grace # 1 THEN Strings.AppendCh( pmxnote, octave ); (* also normale Note *) *)
886 Strings.Append( pmxnote, Note.accidental );
887 (* Out.Ln(); Out.String("accid in WriteNote2PMX"); Out.Int(measure,5);Out.String(Note.accidental); *)
888 END; (* Dont forget accidentals for gracenotes *) (* 9*)
889 (* test for basenote , find series of chord notes
890 IF Note.base # 0 THEN noteno := Note.base;
891 Out.Ln(); Out.String("test for abse of chord ");WHILE notes[ps,voice,measure,noteno].base = Note.base DO
892 Out.Ln(); Out.Int(ps,5); Out.Int(voice,2); Out.Int(measure,5); Out.Int(noteno,5);
893 Out.Int(notes[ps,voice,measure,noteno].base,5);INC(noteno); END; END; *)
894
895 IF (Note.tuplet = "start") & (Note.actual # 0)
896 THEN (* 10*)
897
898 Strings.AppendCh( pmxnote, "x" ); Strings.IntToStr(Note.actual,sactual);
899 Strings.Append( pmxnote, sactual );
900 END; (* 10*)
901 (* binary tremolo *)
902 IF (Note.tremolotype = "start") & (Note.actual # 0) (* first note of binary tremolo *)
903 THEN (* 18*)
904
905 Strings.AppendCh( pmxnote, "x" );
906 Strings.AppendCh(pmxnote,"T");
907 Strings.IntToStr(Note.maxbeam,sactual);
908 Strings.Append( pmxnote, sactual ); Strings.AppendCh(pmxnote, "0");
909 END; (* 18*)
910
911
912 IF (Note.chord # "z") & (Note.tuplet # "start") & (Note.grace = 0) & ( Note.tremolotype # "start" ) (* 11*)
913 THEN
914 (* no stem direction specified eventuell switch einbauen ! *)
915 stemchar := Note.stem;
916 IF stemchar = "d" THEN stemchar := "l" END;
917 Strings.AppendCh( pmxnote, stemchar );
918 END; (* 11*)
919 (* IF (Note.pmxdyn[0] # 0X) THEN
920 WriteString( W, Note.pmxdyn );
921 END; *)
922 (* Suppress fermata in tuplet *)
923 IF ( Note.actual = 0 ) THEN Strings.AppendCh( pmxnote, BLANK ); Strings.Append( pmxnote, Note.fermata ); END;
924 Strings.AppendCh( pmxnote, BLANK ); Strings.Append( pmxnote, Note.staccato );
925 Strings.AppendCh( pmxnote, BLANK ); Strings.Append( pmxnote, Note.accent );
926 Strings.AppendCh( pmxnote, BLANK ); Strings.Append( pmxnote, Note.strongaccent );
927 Strings.AppendCh( pmxnote, BLANK ); Strings.Append( pmxnote, Note.trill );
928
929
930 (* IF Note.arpeggio THEN Strings.Append( pmxnote, " ? " ); maxarp := Note.maxarp END; (* ???????? 22. Nov. 2019 *)
931 IF (maxarp > 0) & (Note.maxarp = maxarp) THEN Strings.Append( pmxnote, " ? " ); maxarp := 0; END; *)
932
933 (* No closing slur at gracenote or one after gracenote *)
934 maxnotelastmeasure := maxnote0[part,staff,measure-1];
935 IF voice = 1 THEN maxnotelastmeasure := maxnote1[part,staff,measure-1]; END;
936 IF (7 IN outputset) & ( ( note = 1 ) & (Note.grace = 0) & ( notes[ps,voice,measure,maxnotelastmeasure].grace= 0 )
937 OR ( note >1 ) &( Note.grace = 0) & (notes[ps,voice,measure,note - 1].grace = 0 ) ) (* Aenderung wg. Don 17022017 *)
938 OR ~(7 IN outputset)
939 THEN (* end of slur directly after gracenote not allowed *) (* Blinder Versuch 7 statt 5 *)
940
941 IF (Note.slur[0,1] = ")") THEN (* 13*)
942 IF Note.grace = 0 THEN
943 Strings.Append( pmxnote, Note.slur[0] ); END; END;
944 IF (Note.slur[1, 1] = ")") THEN
945 IF Note.grace = 0 THEN
946
947 Strings.Append( pmxnote, Note.slur[1] ); END; END;
948
949 END; (* 13*)
950
951 IF (Note.tied[0, 1] = "}") (* 14*)
952 THEN
953 Strings.Append( pmxnote, Note.tied[0] );
954 ELSIF (Note.tied[1, 1] = "}") THEN Strings.Append( pmxnote, Note.tied[1] );
955 END; (* 14*)
956
957
958 (* IF ~istuplet & (Note.beam[1] = "]") & (Note.grace = 0) THEN (* 15*) backchanged 16. 4. 2017 changed 14.01.2017 *)
959 IF ( ~istuplet OR ( istuplet & ( Note.tuplet = "stop" ) ) )
960 & (Note.beam[1] = "]") & (Note.grace = 0 ) & (Note.tremolotype # "stop")
961 THEN (* VErsion 12 *)
962 IF beamopen[ps,voice] THEN
963 Strings.Append( pmxnote, Note.beam );
964 beamopen[ps,voice] := FALSE;
965 END;
966 END; (* 15*)
967
968 IF ~istuplet & (Note.closebeam[1] = "]") & (Note.grace = 0) THEN (* 15a closing for single note beam *)
969 IF beamopen[ps,voice] THEN
970 Strings.Append( pmxnote, Note.closebeam );
971 beamopen[ps,voice] := FALSE;
972 END;
973
974
975
976
977 END; (* 15a*)
978
979
980
981 (************************ clef changed *******************)
982
983 (* IF (Note.clefchanged # 0X) THEN (* 16*)
984 (* There is a clef change after this note. *)
985 Out.String("Note clefchanged"); Out.Char(Note.clefchanged);
986
987 (* INC(countclefchanges); *)
988 (* IF note < maxnote[part,staff,measure] THEN *)
989 maxinote := maxnote0[part,staff,measure];
990 IF voice > voicefrom THEN maxinote := maxnote1[part, staff, measure] END;
991 IF note < maxinote THEN
992
993 Strings.Append( pmxnote, " C" ); Strings.AppendCh( pmxnote, Note.clefchanged );
994 Strings.AppendCh( pmxnote, BLANK );
995
996 Out.Ln(); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5);
997 Out.String( "cleffx" ); Out.Char( Note.clefchanged ); Out.Char("|"); Out.Char( Note.clef );
998 ELSE
999 Out.String( "clef change after last note "); Out.Int(maxinote,5);
1000 (* activated 14. Maerz 2018 , verschiebt clefchange vom Ende des Taktes vor die erste Note dwes folgenden Taktes*)
1001
1002 measures[measure + 1].clefchange[ps] := Note.clefchanged;
1003
1004
1005 END;
1006 (* NoteOut(Note); *)
1007 END; (* 16*) *)
1008
1009 (* Out.Ln(); Out.String("pmxnote vorher");Out.String(Note.pmxnote); *)
1010
1011 COPY( pmxnote, Note.pmxnote ); WriteString( W, Note.pmxnote );
1012
1013 (* IF Note.grace >1 THEN b.loesch(Note.pmxnote);
1014 b.loesch(Note.pmxgrace) END; Out.Ln(); Out.String(" Note.pmxnote" ); Out.Int(measure,5); Out.String( Note.pmxnote );
1015 Out.String( Note.pmxgrace ); Out.Char("|"); Out.Int (Note.grace,5); *)
1016
1017
1018 (* Out.Int( Note.staff, 5 ); Out.Char( "|" );
1019 Out.Int( Note.voice, 5 ); *)
1020
1021 ELSIF (Note.rest = "r") THEN (* Branch for Rests *) (* 1*)
1022
1023 INC( count ); (* this note is a rest! *)
1024
1025 istuplet := Note.actual # 0;
1026
1027
1028 PMXDuration( Note.tuplet, Note.tremolotype, attributes[part].divisions, Note.duration, Note.actual, Note.normal,
1029 pmxdur, istuplet, Note.type );
1030 pmxnote[0] := 20X;
1031 IF ( Note.blind = "b" ) THEN
1032
1033 Complete.CalcForward(Note.duration,attributes[part].divisions,blindrest);
1034
1035 Strings.Append(pmxnote,blindrest);
1036 ELSE
1037
1038 IF (Note.duration = attributes[part].duration) THEN (* rest of type "rp" *) (* 17*)
1039 Strings.Append( pmxnote, "rp" );
1040 ELSE (* 17*)
1041 Strings.AppendCh( pmxnote, Note.rest ); Strings.Append( pmxnote, pmxdur );
1042 IF (Note.tuplet = "start") & (Note.actual # 0) (* leading note of tuplet *)
1043 THEN (* 18*)
1044
1045 Strings.AppendCh( pmxnote, "x" ); Strings.IntToStr(Note.actual,sactual);
1046 Strings.Append( pmxnote, sactual );
1047 END; (* 18*)
1048
1049
1050 END; (* 17 *)
1051 (************************************************ first try for slur ending on rest ****************)
1052 IF (Note.slur[0,1] = ")")
1053 THEN (* 13*)
1054 Strings.Append( pmxnote, Note.slur[0] );
1055 END;
1056 IF (Note.slur[1, 1] = ")")
1057 THEN
1058 Strings.Append( pmxnote, Note.slur[1] );
1059 END;
1060
1061 (* END; 13*)
1062
1063
1064 END;
1065
1066
1067 Strings.AppendCh( pmxnote, BLANK );
1068 (* IF (Note.clefchanged # 0X) THEN (* 16*) (* clef change on the fly, activated 14. Maerz 2018 *)
1069 (* IF note < maxnote[part,staff,measure] THEN *)
1070 Strings.Append( pmxnote, " C" ); Strings.AppendCh( pmxnote, Note.clefchanged );
1071 Strings.AppendCh( pmxnote, BLANK );
1072 Out.Ln(); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5);
1073 Out.String( "cleffy" ); Out.Char( Note.clefchanged ); Out.Char( Note.clef );
1074 (* NoteOut(Note); *)
1075 END; (* 16*) *)
1076
1077 COPY( pmxnote, Note.pmxnote ); WriteString( W, pmxnote );
1078
1079 END; (*1*)
1080 (* IF (Note.direction > 0) THEN (* 19*)
1081
1082 (* OutDir( Note.direction ); *)
1083 Files.Write( W, Note.direction ); Files.Write( W, CR ); Files.Write( W, NL );
1084 END; (* 19*) *)
1085 (* directions within measures are written *)
1086 COPY( notes[ps, voice, measure, note].righttext, Rtext );
1087 (* Out.Ln(); Out.String("WriteNote2PMX : "); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); Out.String (Rtext);
1088
1089 Out.Int(notes[ps, voice, measure, note].grace,5); *)
1090
1091 IF (Rtext[0] # 0X) (* & ( ~written ) *) THEN WriteString( W, Rtext );
1092 END;
1093 IF (Note.rbright[0] # 0X) THEN WriteString( W, Note.rbright ); END;
1094 (* Out.Ln();Out.String("measure,ps,voice,note");
1095 Out.Int(measure,5); Out.Int(ps,5); Out.Int(voice,5); Out.Int(note,5); Out.Int(Note.voice,5);Out.String(pmxnote); *)
1096 (* "maxnote" is the last note in part/staff/measure, minnote is the first note in part/staff/measure *)
1097 (* IF ( note = maxnote[part, staff, measure] )*) (* Aenderung 22.12.2015: introduce voice dependence *)
1098 (* "maxnote" is the last note in part/staff/measure, minnote is the first note in part/staff/measure *)
1099 IF (note = maxnote[part, staff, measure]) OR ((note = maxnote0[part, staff, measure]) & (voice = 0)) OR
1100 ((note = maxnote1[part, staff, measure]) & (voice = 1))
1101
1102 THEN
1103 (* WriteString( W, " | " ); not needed in PMX *)
1104 IF (ps = nostaves - 1) & (voice = voicefrom) THEN
1105 IF (measures[measure].barstyle # 0X) THEN WriteString( W, measures[measure].barstyle ) END;
1106 IF (measures[measure].repeat = " Rr ") THEN
1107 Files.Write( W, CR ); Files.Write( W, NL ); WriteString( W, measures[measure].repeat );
1108 END;
1109 END;
1110
1111 Files.Write(W,BLANK); Files.Write( W, "/" ); (* Print "/" for end of single voice . *)
1112
1113 END;
1114 IF Note.tuplet = "stop" THEN istuplet := FALSE END;
1115 ELSE
1116 Out.Ln(); Out.String("grace = -1"); Out.Int(ps,5); Out.Int(measure,5); Out.Int(note,5);END;
1117 END WriteNote2PMX;
1118
1119
1120
1121
1122
1123 PROCEDURE WritePMX ( VAR W: Files.Rider );
1124 (* Creates and stores the notes part of the PMX file (starting with "% Bar 1"). after the Control Data *)
1125 VAR voice, staff, voicefrom, voiceto, nnotes, notefrom, noteto : LONGINT; concertkey : ARRAY 10 OF CHAR;
1126 Dtext, Rtext: ARRAY 128 OF CHAR;
1127 keychange, dummy: ARRAY 32 OF CHAR; keychanged : BOOLEAN;
1128 blindmeterchange: ARRAY 16 OF CHAR;
1129 istuplet: BOOLEAN; minmeasure: LONGINT; ipickup: INTEGER;
1130 (* decides whether direction is written before or after the note. *)
1131 restbefore, restafter: ARRAY 16 OF CHAR;
1132
1133 BEGIN
1134 ipickup := 0; keychanged := FALSE;
1135 IF attributes[1].pickup > 0 THEN ipickup := 1; END;
1136 (* Write transposition string s *)
1137 (* part := 1;
1138 WHILE part <= maxpart DO
1139 IF attributes[part].diatonic # 0 THEN WriteString( W, attributes[part].kstring );
1140 END;
1141 Files.Write( W, CR ); Files.Write( W, NL ); INC( part ); Out.Ln(); Out.String("diatonic");
1142 END; *)
1143 Files.Write( W, CR ); Files.Write( W, NL );
1144
1145 measure := 1; note := 1;
1146
1147 IF (attributes[1].pickup > 0) THEN minmeasure := 1
1148 ELSE minmeasure := 0
1149 END; (* do not extend 1st measure in case of pickup. *)
1150 IF ( uptomeasure > 0 ) & ( uptomeasure <= maxmeasure ) THEN maxmeasure := uptomeasure; END;
1151 WHILE measure <= maxmeasure DO
1152 (* Out.Ln(); Out.String("measure ="); Out.Int(measure,5); *)
1153
1154
1155
1156 Complete.erasetime( nostaves, voicetime ); ps := nostaves - 1;
1157 IF maxpart > 1 THEN
1158
1159
1160 IF ( measure = 1 ) OR ( ( measure > 1 ) & ( measures[measure].fifth # measures[measure-1].fifth ))
1161 THEN
1162
1163 keychanged := TRUE;
1164 ELSIF measure > 1 THEN i := 1 ;
1165 REPEAT
1166 keychanged := (measures[measure].keys[i] # measures[measure].keys[maxpart] ) & (* Aenderung2.2.2017 *)
1167 (measures[measure].keys[i] # measures[measure - 1].keys[i]);
1168 INC(i) ;
1169 UNTIL ( i = maxpart ) OR keychanged ;
1170 END;
1171 (* END; *)
1172 IF (keychanged & ~ pmxcontrol.equalkeys) THEN
1173 i := 1; WHILE i <=maxpart DO b.mkeys[i] := measures[measure].keys[i]; INC(i) END;
1174 b.testmakekey(maxpart,measure,keytotal);
1175 COPY("K+0",concertkey);
1176
1177 IF measures[measure].keys[maxpart] >= 0 THEN Strings.AppendCh(concertkey,"+"); END;
1178 Strings.IntToStr(measures[measure].keys[maxpart],dummy); Strings.Append(concertkey,dummy);
1179 IF measure >= 1 THEN
1180 WriteString( W, concertkey ); Files.Write( W, CR );
1181 Files.Write( W, NL ); END;
1182
1183
1184 WriteString( W, keytotal ); Files.Write( W, CR );
1185 Files.Write( W, NL ); END;
1186
1187 (* Out.Ln(); Out.String("concertkey : "); Out.String(concertkey);
1188 Out.Ln(); Out.String("keytotal : "); Out.String(keytotal); *)
1189 END;
1190
1191 WHILE (ps >= 0) DO
1192 part := partstaff[ps, 0]; staff := partstaff[ps, 1];
1193
1194
1195
1196
1197 (* neuer Code: shift to voice := 0,1 *)
1198 voiceto := voicelimm[ps, measure] - 1; voicefrom := 0; voice := voicefrom;
1199 (* IF voiceto < 0 THEN voiceto := 0; END; *)
1200
1201 (* Out.Ln(); Out.String("measure, part, staff, voicefrom, voiceto:");
1202
1203 Out.Int(measure,5); Out.Int(part,5); Out.Int(staff,5);
1204
1205 Out.Int(voicefrom,5); Out.Int(voiceto,5); *)
1206
1207
1208 (* IF voiceto > 1 THEN voiceto := 1 END; (* this line only for testing BWV0826; to be removed. *) *)
1209 WHILE voice <= voiceto DO
1210 nnotes := 0; WriteString( W, "% " ); Files.Write( W, "(" ); WriteLInt( W, part );
1211 Files.Write( W, "|" ); WriteLInt( W, staff ); Files.Write( W, "|" ); WriteLInt( W, vmap[ps, measure, voice] );
1212 Files.Write( W, ")" ); WriteLInt( W, measure - ipickup ); Files.Write( W, CR );
1213 Files.Write( W, NL );
1214
1215
1216
1217
1218 b.loesch( Dtext ); b.loesch( Rtext );
1219 (********************** Meter Change *******************)
1220 IF (measure > 1) THEN
1221 IF (measures[measure].beats # measures[measure - 1].beats) OR
1222 (measures[measure].beattype # measures[measure - 1].beattype) THEN
1223 IF measures[measure].beattype >0 THEN
1224 b.NewBeat( measures[measure].beats, measures[measure].beattype,
1225 measures[measure].meterchange, FALSE );
1226 (* 20-10-2020 Lilypond *)
1227 attributes[part].duration :=
1228 measures[measure].beats*4* attributes[part].divisions DIV measures[measure].beattype;
1229 ELSE
1230 Out.Ln();
1231 Out.String("PROC. WritePMX: measure = ");
1232 Out.Int(measure,5);
1233 END;
1234
1235 (* measures[measure].divisions[part] *)
1236 measures[measure].duration[part] := attributes[part].duration ;
1237 IF (ps = nostaves - 1) & (voice = voicefrom) THEN
1238 Files.Write( W, CR ); Files.Write( W, NL ); WriteString( W, measures[measure].meterchange );
1239 Files.Write( W, CR ); Files.Write( W, NL );
1240 END
1241 END;
1242 END;
1243 (* blind meter change in case of Pickup. *)
1244 IF (attributes[1].pickup > 0) & (measure = 2) & (ps = nostaves - 1) & (voice = voicefrom) THEN (* Change 09.05.2020 *)
1245 b.NewBeat( attributes[1].beats, attributes[1].beattype, blindmeterchange, TRUE );
1246
1247 WriteString( W, blindmeterchange ); Files.Write( W, CR ); Files.Write( W, NL );
1248 END;
1249
1250
1251 (********************** key change ***********************)
1252 IF pmxcontrol.equalkeys &(ps = nostaves - 1) & (measure > 1) & (voice = voicefrom) & (* change 03052018 *)
1253 (measures[measure].fifth # measures[measure - 1].fifth) THEN
1254 COPY( "K+0", keychange );
1255 IF ( measures[measure].fifth >= 0 ) THEN Strings.Append(keychange,"+"); END;
1256 Strings.IntToStr( measures[measure].fifth, dummy );
1257 Strings.Append( keychange, dummy ); WriteString( W, keychange ); Files.Write( W, CR );
1258 Files.Write( W, NL );
1259 END;
1260
1261 IF (measures[measure].ending # 0X) & (ps = nostaves - 1) THEN
1262 WriteString( W, measures[measure].ending );
1263 END;
1264
1265 IF (measures[measure].repeat = " Rl ") & (ps = nostaves - 1) & (voice = voicefrom) THEN
1266 WriteString( W, measures[measure].repeat );
1267 END;
1268 notefrom := minnote0[part, staff, measure]; noteto := maxnote0[part, staff, measure];
1269 (* IF measure = 25 THEN Out.Ln(); Out.String("voice = 0");
1270 Out.Ln(); Out.String("notefrom(to : "); Out.Int(notefrom,5); Out.Int(noteto,5); END; *)
1271
1272 IF (voice = 1) THEN
1273 notefrom := minnote1[part, staff, measure];
1274 noteto := maxnote1[part, staff, measure]; (* changed from note := 1; 22.12.2015 *)
1275 (* IF measure = 25 THEN Out.Ln(); Out.String("voice = 1");
1276 Out.Ln(); Out.String("notefrom(to : "); Out.Int(notefrom,5); Out.Int(noteto,5); END; *)
1277 END;
1278 note := notefrom;
1279
1280 IF (measure > minmeasure) THEN FillRests( notefrom, noteto, measure, ps, voice );
1281 END;
1282
1283 (* do not extend 1st measure in case of pickup. *)
1284
1285 WHILE note <= noteto DO (* 1 *)
1286 IF (notes[ps, voice, measure, note] # NIL) &
1287 (Strings.IsAlpha( notes[ps, voice, measure, note].pitchstep ) OR (notes[ps, voice, measure, note].rest = "r"))
1288 (* note OR rest *)
1289
1290
1291 (* remove print-object="no". 26.07.2019*)
1292 THEN (* CHANGE 11.Juli 2019: remove print-object = "no" notes *)
1293 IF ~ (10 IN outputset) OR ( notes[ps, voice, measure, note].probj = TRUE ) THEN
1294 (* Option "r" : remove notes with print_obj = "no" 04.05.2020 *)
1295
1296
1297 WriteNote2PMX( W, notes[ps, voice, measure, note]^, ps, voice, voicefrom, measure, note, Dtext,
1298 Rtext, istuplet );
1299 b.loesch( restbefore ); b.loesch( restafter );
1300
1301 INC( nnotes );
1302
1303 (* b.loesch(Rtext); b.loesch(Dtext); *)
1304 END;
1305
1306 END;
1307 INC( note ); (* IF voice = 1 THEN Out.Ln(); Out.String("Count notes of 2nd voice. ");Out.Int(note,5); END; *)
1308 END; (* 1 *) (* Loop over notes *)
1309
1310 (* Measure Properties go here *) ;
1311 (* WriteString(W," | /"); *)
1312 IF ( voicelimm[ps,measure] = 2 ) & (voice = 0) & (nnotes > 0)
1313
1314 & ( ((notes[ps,0,measure,minnote1[part,staff,measure]] # NIL)
1315 & (notes[ps, 0, measure, minnote1[part,staff,measure]].probj = TRUE))
1316 OR ~ ( 10 IN outputset ) )
1317 (* second slash removed because second voice eliminated. Change 04.05.2020 *)
1318 THEN
1319
1320 Files.Write( W, "/" ); END; (* Print second "/" for first voice of two voices *)
1321 Files.Write( W, CR ); Files.Write( W, NL );
1322
1323 INC( voice );
1324
1325 END; (* Loop over voices *)
1326
1327 DEC( ps );
1328 END;
1329 INC( measure );
1330 END; (* Out.Ln(); Out.String(" Divisions : ");
1331 i := 1; WHILE i <= maxpart DO Out.Ln(); Out.Int(i,5); Out.Int(attributes[i].divisions,5); INC(i);END; *)
1332 END WritePMX;
1333
1334 (* PROCEDURE ListMeasures*;
1335 VAR i,j : LONGINT;
1336 BEGIN
1337 Out.Ln(); Out.String("ListMeasures");
1338 i := 1;
1339 WHILE i <= maxmeasure DO
1340
1341 Out.Ln(); Out.Int(i, 5); Out.Int( measures[i].beats, 5); Out.Int(measures[i].beattype,5); Out.Int ( measures[i].fifth , 5);
1342 j := 1;
1343
1344 WHILE j<=maxpart DO Out.Int(measures[i].keys[j],5); INC(j); END; INC(i); END;
1345
1346
1347 (* j := 1; WHILE j<maxpart DO Out.Int(measures[i].duration[j],5); INC(j); END; INC(i); END; *)
1348
1349
1350
1351 END ListMeasures; *)
1352
1353
1354
1355
1356
1357
1358 PROCEDURE repeat2PMX( n: b.Tag; VAR pmxrepeat: ARRAY OF CHAR );
1359 (* translates a left or right repeat from XML to PMX *)
1360 VAR c: CHAR;
1361 direction: ARRAY 32 OF CHAR;
1362 BEGIN
1363 b.loesch( pmxrepeat ); COPY( BLANK, pmxrepeat ); b.FindAtt( n, "direction", direction );
1364 IF (direction = "backward") THEN Strings.Append( pmxrepeat, "Rr" );
1365 ELSIF (direction = "forward") THEN Strings.Append( pmxrepeat, "Rl" );
1366 END;
1367
1368 Strings.AppendCh( pmxrepeat, BLANK ); c := 0X; Strings.AppendCh( pmxrepeat, c );
1369
1370 END repeat2PMX;
1371
1372 PROCEDURE ending2PMX( n: b.Tag; VAR pmxending: ARRAY OF CHAR; VAR type: ARRAY OF CHAR );
1373 (* translates a Volta from XML to PMX, possibly not general enough *)
1374 VAR c: CHAR;
1375 number: ARRAY 32 OF CHAR;
1376 BEGIN
1377 COPY( BLANK, pmxending ); b.FindAtt( n, "number", number ); b.FindAtt( n, "type", type );
1378 IF (type = "start") THEN
1379 Strings.AppendCh( pmxending, "V" ); Strings.Append( pmxending, number );
1380 IF (number = "2") THEN Strings.AppendCh( pmxending, "b" ); END;
1381 END;
1382 IF (type = "discontinue") THEN COPY ("Vx",pmxending); END;
1383
1384 Strings.AppendCh( pmxending, BLANK ); c := 0X; Strings.AppendCh( pmxending, c );
1385
1386 END ending2PMX;
1387
1388 PROCEDURE beam2PMX( n: b.Tag; VAR pmxbeam: ARRAY OF CHAR; stem: CHAR; staff: LONGINT );
1389 (* Translates a beginning or ending or continued beam from XML to PMX. staff is the staff of the beam element *)
1390 VAR c, j, stemj: CHAR; m: b.Tag;
1391 type, number: ARRAY 32 OF CHAR;
1392 BEGIN
1393 b.loesch( pmxbeam ); COPY( n.between, type ); b.FindAtt( n, "number", number ); b.loesch( closebeam ); j := 0X;
1394 IF (number = "1") THEN (* 1*)
1395 COPY( BLANK, pmxbeam );
1396 IF (type = "begin") THEN c := "[";
1397 ELSIF (type = "end") THEN
1398 IF (lasttype = "continue") & (laststaff # staff) THEN
1399 c := "["; j := "j"; COPY( " ] ", closebeam );
1400 ELSE c := "]"; END;
1401 ELSIF (type = "continue") THEN
1402 IF (lasttype = "continue") & (laststaff # staff) THEN
1403 c := "["; j := "j";
1404 ELSE
1405
1406 b.findnextnote( n, m ); (* Out.Char("|"); Out.Int(n.nr,5); Out.Int(staff,5); Out.Char("|");Out.Int(m.nr,5);Out.Int(m.staff,5); *)
1407 (* Out.Ln(); Out.String(" beam : continue "); *)
1408 IF (m.staff # staff) THEN j := "j"; c := "]" ELSE c := "?" END;
1409 END;
1410 ELSE c := "?"
1411 END;
1412 Strings.AppendCh( pmxbeam, c );
1413 IF (j = "j") (* neuer Code fuer joined beams *)
1414 THEN
1415 Strings.AppendCh( pmxbeam, j );
1416 IF c = "[" THEN Strings.AppendCh( pmxbeam, "f" ); (* flip l/u *)
1417
1418 stemj := "u"; IF stem = "u" THEN stemj := "l"; END;
1419 Strings.AppendCh( pmxbeam, stemj ); Strings.AppendCh( pmxbeam, BLANK ); END;
1420 (* Out.String("pmxbeam"); Out.String(pmxbeam); Out.Char("|"); *)
1421 ELSE
1422 IF (c = "[") THEN
1423 IF (stem = "d") THEN Strings.AppendCh( pmxbeam, "l" );
1424 ELSIF (stem = "u") THEN Strings.AppendCh( pmxbeam, "u" );
1425 END;
1426 (* IF (stem = "u") THEN Strings.Append(pmxbeam,"+2");
1427 ELSIF (stem = "d") THEN Strings.Append(pmxbeam,"-2"); END; *)
1428 Strings.AppendCh( pmxbeam, BLANK );
1429 END;
1430 END;
1431 END;
1432 IF (type = "continue") & (j # "j") OR (number > "1") THEN b.loesch( pmxbeam ); END;
1433 COPY( type, lasttype ); laststaff := staff;
1434 END beam2PMX;
1435
1436 (* PROCEDURE tied2PMX( n: b.Tag; type: ARRAY OF CHAR; VAR pmxtied: ARRAY OF CHAR; voice: LONGINT);
1437 (* Translates a beginning or ending tie from XML to PMX.
1438 orientation = "d" => note with stem down yields tie with orientation "u".
1439 orientation = "u" => note with stem up yields tie with orientation "l". *)
1440 VAR c: CHAR;
1441 number: ARRAY 32 OF CHAR; orient : ARRAY 10 OF CHAR; orientation : CHAR;
1442 nt: Fifo.Node;
1443
1444 BEGIN
1445 b.loesch( pmxtied ); b.FindAtt( n, "number", number );
1446 b.FindAtt( n, "orientation", orient );
1447 IF orient = "over" THEN orientation := "u"; (* IF orient = "" THEN follow stem direction *)
1448 ELSIF orient = "under" THEN orientation := "l";
1449 ELSE orientation := " ";
1450 END;
1451
1452 (* Out.Char("|"); Out.String("tied : "); Out.Char("|");Out.String(type);Out.Char("|");
1453 Out.String(number);Out.Char("|");Out.Char(orientation); *)
1454 COPY( BLANK, pmxtied );
1455 IF (type = "start") THEN
1456 c := "{";
1457 Strings.AppendCh( pmxtied, c );
1458 NEW( nt ); nt.key := Fifo.smallfree( b.tieunusdnum[ps, voice] );
1459 EXCL( b.tieunusdnum[ps, voice], nt.key );
1460 Fifo.Enqueue( b.tieq[ps, voice], nt );
1461 Strings.IntToStr( nt.key, number );
1462 Strings.Append( pmxtied, number );
1463 Strings.AppendCh( pmxtied, orientation );
1464 ELSIF (type = "stop") THEN c := "}"; Strings.AppendCh( pmxtied, c );
1465
1466 nt := Fifo.DequeuedNode( b.tieq[ps, voice] );
1467 IF nt # NIL THEN INCL( b.tieunusdnum[ps, voice], nt.key ); (* avoid nt undefined *)
1468 Strings.IntToStr( nt.key, number ); Strings.Append( pmxtied, number ); END;
1469 ELSE Out.String( "wrong type of tie " );
1470 END;
1471 Strings.AppendCh( pmxtied, BLANK );
1472 END tied2PMX; *)
1473
1474 (* PROCEDURE slur2PMX( n: b.Tag; VAR pmxslur: ARRAY OF CHAR );
1475 (* Translates a beginning or ending slur from XML to PMX. *)
1476
1477 VAR c, cs : CHAR;
1478 type, number, placement: ARRAY 32 OF CHAR; inumber : LONGINT; res : ARRAY 4 OF CHAR;
1479 BEGIN
1480 b.loesch( pmxslur ); b.FindAtt( n, "type", type ); b.FindAtt( n, "number", number );
1481 IF ( number # "" ) THEN
1482 Strings.StrToInt(number, inumber);
1483 cs := CHR(inumber + 65)
1484 ELSE cs := "A";
1485 END;
1486 b.FindAtt( n, "placement", placement );
1487 IF (type # "continue") THEN (* gibt es das ueberhapt? *)
1488
1489 COPY( BLANK, pmxslur );
1490 IF (type = "start") THEN c := "(";
1491 ELSIF (type = "stop") THEN c := ")"
1492 END;
1493 Strings.AppendCh( pmxslur, c );
1494 Strings.AppendCh( pmxslur, cs );
1495 (* Achtung x-option for staff crossing slur *)
1496 IF 8 IN outputset THEN Strings.Append(pmxslur,"x"); END;
1497
1498 IF (type = "start") THEN (* gibt es slurs ohne placement Angabe? *)
1499 IF (placement = "below") THEN Strings.AppendCh( pmxslur, "l" )
1500 ELSIF (placement = "above") THEN Strings.AppendCh( pmxslur, "u" );
1501 END;
1502 END;
1503 Strings.AppendCh( pmxslur, BLANK ); c := 0X; Strings.AppendCh( pmxslur, c );
1504
1505 END;
1506 (* Out.Ln(); Out.String( "slur2pmx : " ); Out.String( pmxslur ); *)
1507
1508 (* Slur control according to grace property *)
1509
1510 END slur2PMX; *)
1511
1512 PROCEDURE grace( n: b.Tag; ps, voice, measure, note, maxgrace: LONGINT; VAR res: ARRAY OF CHAR );
1513 (* counts the calls in "ingrace2pmx", prerequisite n.tagname = notetag *)
1514
1515 VAR nograce: LONGINT; isgrace: BOOLEAN;
1516 slash, type, stem: ARRAY 32 OF CHAR;
1517 snograce,str,accpmx: ARRAY 4 OF CHAR; ns : CHAR; no : LONGINT;
1518 BEGIN
1519 isgrace := FALSE;
1520 b.loesch( res );
1521 WHILE (n.next # NIL ) & (n.tagname # eonotetag) DO (* loop over all tags of the note 1 *)
1522 (* Out.Ln(); Out.String( n.tagname ); *)
1523
1524 IF (n.tagname = gracetag) OR (n.tagname = gracetag2) THEN (* 2 *)
1525 b.FindAtt( n, "slash", slash ); nograce := 0; isgrace := TRUE;
1526
1527 (* Out.Ln(); Out.String( " ***********************grace : " ); Out.String( slash ); *)
1528 END;
1529
1530 IF (n.tagname) = steptag THEN (* 3 *)
1531 notes[ps, voice, measure, note].pitchstep := Strings.LowerCh( n.between[0] ); (* Out.String( n.between ); *)
1532 END;
1533
1534 IF (n.tagname) = octavetag THEN (* 4 *)
1535 notes[ps, voice, measure, note].pitchoctave := b.ExtractInt( n.between ); (* Out.String( n.between ); *)
1536 END;
1537 Accidentals(n,ps,voice,measure,note);
1538 (* Out.Ln(); Out.String("note1 accidental"); Out.String(notes[ps, voice, measure, note].accidental); *)
1539 IF (n.tagname = "<type>") THEN
1540 COPY( n.between, type ); (* Out.String( n.between ); *) (* 6 *)
1541 END;
1542
1543 IF (n.tagname = "stem") THEN (* 7 *)
1544 COPY( n.between, stem ); (* Out.Ln(); Out.String( n.between ); *)
1545 END;
1546
1547
1548 n := n.next;
1549 END; (* 1 *) (* Daten der ersten Grace-Note *)
1550
1551
1552 nograce := maxgrace; (* Out.Ln(); Out.String( "grace : n#gracenotes" ); Out.Int( nograce, 5 ); *) res[0] := BLANK;
1553
1554 Strings.IntToStr( nograce, snograce); res[0] := "G"; res[1] := 0X; Strings.Append( res, snograce );
1555 Strings.AppendCh( res, "m" );
1556 IF (type = "eighth") THEN Strings.AppendCh( res, "1" )
1557 ELSIF (type = "16th") THEN Strings.AppendCh( res, "2" )
1558 ELSIF (type = "32nd") THEN Strings.AppendCh( res, "3" )
1559 END;
1560 IF ( 7 IN outputset) THEN Strings.AppendCh( res, "s" ); END; (* slur internal to grace note, goes from first grace note to first non-grace note *)
1561 IF (slash = "yes") THEN Strings.Append( res, "x" ); END;
1562 IF (stem = "up") THEN Strings.AppendCh( res, "u" )
1563 ELSIF (stem = "down") THEN Strings.AppendCh( res, "l" )
1564 END;
1565
1566 Strings.AppendCh( res, notes[ps, voice, measure, note].pitchstep );
1567 Strings.IntToStr( notes[ps, voice, measure, note].pitchoctave, str ); Strings.Append( res, str );
1568 Strings.Append(res,notes[ps,voice,measure,note].accidental); Strings.AppendCh( res, BLANK ); Strings.AppendCh( res, 0X );
1569 (* 1st gracenote and config *)
1570 n := n.next;
1571 (* b.OutTag(n,TRUE); *)
1572
1573 WHILE (nograce >1) & isgrace DO
1574 (* Out.Ln(); Out.Int(nograce,5); *)
1575 Findnextgrace (n,isgrace,ns,no,accpmx);
1576 Strings.AppendCh(res,BLANK); Strings.AppendCh(res,ns);
1577 Strings.IntToStr( no,str); Strings.Append(res,str); IF(accpmx[0] # 0X) THEN Strings.Append(res,accpmx) END;
1578 n := n.next; DEC(nograce); (* Out.Ln(); Out.String(res); %%%%% *)
1579 END;
1580
1581
1582 END grace;
1583 PROCEDURE Findnextgrace* (VAR n : b.Tag; VAR isgrace : BOOLEAN; VAR notestep : CHAR;
1584 VAR noteoctave : LONGINT; VAR accpmx : ARRAY OF CHAR );
1585 (* Neu 14.11.2020: Anbindung der weiteren grace-Noten an Hauptnote
1586 prerequisite n ist zweite Note der Verzierung *)
1587
1588 BEGIN
1589 notestep := 0X; noteoctave := -1; accpmx[0] := 0X; isgrace := FALSE;
1590 WHILE ( n.next # NIL ) & (n.tagname # eonotetag) DO
1591 IF n.tagname = gracetag THEN isgrace := TRUE; END;
1592 IF n.tagname = steptag THEN notestep := Strings.LowerCh(n.between[0]); END;
1593 IF n.tagname = octavetag THEN noteoctave := b.ExtractInt(n.between); END;
1594 IF n.tagname = "<accidental>" THEN
1595 IF( n.between = "sharp") THEN COPY( "s", accpmx ); END;
1596 IF ( n.between = "flat") THEN COPY( "f", accpmx ); END;
1597 IF (n.between = "double-sharp") OR (n.between = "sharp-sharp") THEN COPY( "ss", accpmx ); END;
1598 IF (n.between = "flat-flat") OR (n.between = "double-flat") THEN COPY( "ff", accpmx ); END;
1599 IF (n.between = "natural") THEN COPY( "n", accpmx ); END;
1600 END;
1601
1602
1603
1604 n:= n.next;
1605 END; (* WHILE *)
1606 (* Out.Ln(); Out.String("Findnextgrace"); Out.Int(measure,5);
1607 Out.Char(notestep); Out.Int(noteoctave,5);Out.String(accpmx); *)
1608 END Findnextgrace;
1609
1610
1611
1612 PROCEDURE OutDir( i, j: LONGINT );
1613 BEGIN
1614 Out.Ln(); Out.String( " OutDir : " ); Out.Int( i, 5 ); Out.Int( j, 5 ); Out.Int( directions[i, 0].part, 5 );
1615 Out.Int( directions[i, 0].staff, 5 ); Out.Int( directions[i, 0].measure, 5 ); Out.Char( "|" );
1616 Out.Int( directions[i, 0].lastnote, 5 ); Out.Char( "|" ); Out.Int( directions[i, 0].voice, 5 ); Out.Char( "|" );
1617 Out.Int( directions[i, 0].note, 5 ); Out.Char( "|" );
1618 Out.Char( directions[i, j].dirtype ); Out.Char( "|" ); Out.Char( directions[i, j].placement ); Out.Char( "|" );
1619 Out.String( directions[i, j].wedgetype ); Out.Char( "|" ); Out.String( directions[i, j].dyntype ); Out.Char( "|" );
1620 Out.String( directions[i, j].pedaltype ); Out.Char( "|" ); Out.String( directions[i, j].text ); Out.Char( "|" );
1621 Out.String( directions[i, j].pmxdirection ); Out.Char( "|" ); Out.Int( directions[i, j].defaultx, 5 );
1622 (* IF directions[i,j].used THEN Out.String(" direction used "); ELSE Out.String(" direction not used ") END; *)
1623 END OutDir;
1624
1625 PROCEDURE NotesProp( part, staff, voice, measure: LONGINT; VAR note: LONGINT; VAR n: b.Tag );
1626 (* stores notes information in an array with indices [ps,voice,measure,note] for later use in the generation measure
1627 by measure; "part" and "staff" are combined in one index "ps". *)
1628 VAR pmxslur, pmxtied, pmxbeam, type, pmxrepeat, pmxgrace : ARRAY 32 OF CHAR;
1629 number, ntype, mtype: ARRAY 32 OF CHAR; placement : ARRAY 32 OF CHAR;
1630 m: b.Tag;
1631 defaultxs: ARRAY 32 OF CHAR; (* openslur : ARRAY 1000 OF OpenSlurDesc; *)
1632 ps, defaultx, long : LONGINT;
1633
1634 BEGIN
1635 nties := 0; ps := linstaff( nostaves, part, staff );
1636 NEW( notes[ps, voice, measure, note] );
1637 notes[ps, voice, measure, note].voicetime := n.voicetime;
1638 notes[ps, voice, measure, note].cue := n.cue;
1639 notes[ps, voice, measure, note].from := n.from; notes[ps, voice, measure, note].to := n.to;
1640 (* Out.Ln(); Out.String("NotesProp voice + voice : ");
1641 Out.Int(part,5);Out.Int(staff,5);Out.Int(measure,5);Out.Int(voice,5); Out.Int(n.voice,5);
1642 Out.Int(note,5);Out.Int(n.from,5);Out.Int(n.to,5); Out.Int(n.voicetime,5); *)
1643 IF voice = 0 THEN
1644 maxnote0[part, staff, measure] := b.Max( note, maxnote0[part, staff, measure] );
1645 minnote0[part, staff, measure] := b.Min( note, minnote0[part, staff, measure] );
1646 END;
1647 IF voice = 1 THEN
1648 maxnote1[part, staff, measure] := b.Max( note, maxnote1[part, staff, measure] );
1649 minnote1[part, staff, measure] := b.Min( note, minnote1[part, staff, measure] );
1650 END;
1651 IF (n.probj = "n") THEN notes[ps, voice, measure, note].probj := FALSE
1652 ELSE notes[ps, voice, measure, note].probj :=TRUE; END;
1653 notes[ps, voice, measure, note].clef := lastclef[ps];
1654 IF ( n.newclef # 0X ) THEN
1655 notes[ps,voice, measure, note].clefchanged := n.newclef; (* 17.10.2020 new Implemtation od clef *)
1656 (* Out.Ln(); Out.String("in NotesProp : "); Out.Char(n.newclef); *)
1657 END;
1658 b.FindAtt( n, "default-x", defaultxs ); Strings.StrToInt( defaultxs, defaultx );
1659 notes[ps, voice, measure, note].defaultx := SHORT( defaultx ); notes[ps, voice, measure, note].from := n.from;
1660 notes[ps, voice, measure, note].to := n.to;
1661
1662 (* clef change on bar change
1663 lastnotethismeasure := maxnote0[part,staff,measure];
1664 IF voice = 1 THEN lastnotethismeasure := maxnote1[part,staff,measure] END;
1665 firstnotenextmeasure := minnote0[part,staff,measure+1];
1666 IF voice = 1 THEN firstnotenextmeasure := minnote1[part,staff,measure+1] END;
1667 IF ( notes[ps,voice,measure,lastnotethismeasure].clefchanged # 0X )
1668 & ( measure < maxmeasure )THEN
1669
1670 notes[ps,voice,measure+1,firstnotenextmeasure].clefchanged :=
1671 notes[ps,voice,measure,lastnotethismeasure].clefchanged; END;
1672
1673 Ende: clcef change on bar change *)
1674
1675
1676
1677
1678
1679
1680 WHILE (n.next # NIL ) & (n.tagname # eonotetag) DO
1681
1682 (* OutTag( n ); &&&&&&&&&&&&&&&&&&& Alarm arpeggio *)
1683 (* IF (n.arpeggio > 0) THEN notes[ps, voice, measure, note].arpeggio := n.arpeggio; END;
1684 IF (n.arpeggio = 1) THEN
1685 b.arplen( n, maxarp ); notes[ps, voice, measure, note].maxarp := SHORT( maxarp ); Out.Ln();
1686 Out.String( "maxarp" ); Out.Int( maxarp, 5 );
1687 END; *)
1688 IF (n.grace > 0) THEN notes[ps, voice, measure, note].grace := n.grace;
1689 (* Out.Ln(); Out.String(" notesprop : "); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); Out.Int(n.grace,5); *)
1690 END;
1691 IF (n.grace > 0 ) & ( n.chord ="c" ) THEN notes[ps, voice, measure, note].grace :=-1 END;
1692 (* eliminate chord notes in grace *)
1693 IF (n.grace = 1) THEN b.gracelen( n, maxgrace ); (* Out.Ln(); Out.String( "maxgrace" ); Out.Int( maxgrace, 5 ); *)
1694
1695 grace( n, ps, voice, measure, note, maxgrace, pmxgrace );
1696
1697 (* Out.Ln(); Out.String( "NotesProp nach PROC grace : " ); Out.Int( ps, 5) ; Out.Int( part, 5 );
1698 Out.Int( staff, 5 ); Out.Int( voice, 5 ); Out.Int( measure, 5 ); Out.Int( note, 5 );
1699 Out.Int(notes[ps, voice, measure, note].grace,5); Out.Char("|"); *)
1700
1701
1702 COPY( pmxgrace, notes[ps, voice, measure, note].pmxgrace );
1703
1704 (* Out.String( notes[ps, voice, measure, note].pmxgrace ); *)
1705
1706
1707
1708
1709 (* ELSIF n.grace > 1 THEN
1710
1711 Out.Ln();Out.String("n.grace > 1");Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); *)
1712 ELSE (* not a grace note *)
1713
1714 IF (n.tagname = "<forward>") THEN
1715 notes[ps, voice, measure, note].blind := "b"; (* Out.Ln(); Out.String( "NotesProp : <forward>" );
1716 Out.Int( part, 5 ); Out.Int( staff, 5 ); Out.Int( voice, 5 ); Out.Int( measure, 5 ); Out.Int( note, 5 ); *)
1717 END;
1718 IF (n.tagname = steptag) THEN notes[ps, voice, measure, note].pitchstep := Strings.LowerCh( n.between[0] ) END;
1719
1720 IF (n.tagname = octavetag) THEN notes[ps, voice, measure, note].pitchoctave := b.ExtractInt( n.between )
1721 END;
1722 IF (n.tagname = "<unpitched>") THEN
1723 n := n.next;
1724 IF (n.tagname = "<display-step>") THEN
1725 notes[ps, voice, measure, note].pitchstep := Strings.LowerCh( n.between[0] )
1726 END;
1727 n := n.next;
1728 IF (n.tagname = "<display-octave>") THEN
1729 notes[ps, voice, measure, note].pitchoctave := b.ExtractInt( n.between )
1730 END;
1731 END;
1732 IF (n.tagname = durationtag) THEN notes[ps, voice, measure, note].duration := b.ExtractInt( n.between ); END;
1733 (* IF (n.tagname = stafftag) THEN notes[ps, voice, measure, note].staff := b.ExtractInt( n.between ) ;
1734 laststaff := notes[ps, voice, measure, note].staff END; *)
1735 (* IF (n.tagname = voicetag) THEN notes[ps, voice, measure, note].voice := b.ExtractInt( n.between ) END; *)
1736 IF (n.tagname = dottag) OR (n.tagname = "<dot />") OR (n.tagname = "<dot>") THEN
1737 IF notes[ps, voice, measure, note].dot = "d" THEN notes[ps, voice, measure, note].dot := "D";
1738 ELSE notes[ps, voice, measure, note].dot := "d"
1739 END;
1740 END;
1741 IF (n.tagname) = actualtag THEN
1742 Strings.StrToInt(n.between, long);
1743
1744 notes[ps, voice, measure, note].actual := SHORT(long);
1745 (* (Out.Ln(); Out.String("NotesProp .: ps, voice,measure, note, actual "); Out.Int(ps,5); Out.Int(voice,5);
1746 Out.Int(measure,5); Out.Int(note,5); Out.Int(notes[ps, voice, measure, note].actual,5); *)
1747 END;
1748 IF (n.tagname = stemtag ) THEN notes[ps, voice, measure, note].stem := n.between[0] END;
1749 IF (n.tagname = normaltag ) THEN Strings.StrToInt(n.between, long);
1750 notes[ps, voice, measure, note].normal := SHORT(long); END;
1751 IF (n.tagname = "<type>") THEN COPY( n.between, notes[ps, voice, measure, note].type ); END;
1752
1753 IF (n.tagname = "<normal-type>") THEN
1754 COPY( n.between, notes[ps, voice, measure, note].normaltype ); (* normal-type = type warum? 08.04.2017*)
1755 (* IF notes[ps, voice, measure, note].normaltype[0] #0X THEN *)
1756 COPY( n.between, notes[ps, voice, measure, note].type ); (* END; *)
1757 END;
1758 (* IF (n.tagname = "<actual-type>") THEN
1759 COPY( n.between, notes[ps, voice, measure, note].actualtype ); (* Baustelle Korrektur 24062019*)
1760 (* IF notes[ps, voice, measure, note].normaltype[0] #0X THEN *)
1761 COPY( n.between, notes[ps, voice, measure, note].type ); (* END; *)
1762 END; *)
1763
1764
1765 Accidentals (n,ps,voice,measure,note);
1766
1767 IF (n.tagname = resttag) OR (n.tagname = "<rest>") OR (n.tagname = "</rest>") THEN
1768 notes[ps, voice, measure, note].rest := "r";
1769 END;
1770 (* IF (n.tagname # chordtag) & ( n.tagname # "<chord>" ) THEN lastbase := SHORT( note ) END; store main note of a chord *)
1771 IF (n.tagname = chordtag) OR (n.tagname = "<chord>") THEN notes[ps, voice, measure, note].chord := "z";
1772 (* notes[ps, voice, measure, note].base := lastbase; *) END;
1773 IF (n.tagname = fermatatag) THEN (* keine Fermata im Tuplett. *)
1774 b.FindAtt( n, "type", type ); COPY( " of", notes[ps, voice, measure, note].fermata );
1775
1776 IF ( type = "inverted") THEN Strings.Append( notes[ps, voice, measure, note].fermata, "d " ); END;
1777 END;
1778 (* prepare for binary tremolo ! *)
1779 IF (n.tagname = beamtag) THEN (* counts the beams in one note *)
1780 b.FindAtt(n, "number",number);
1781 Strings.StrToInt(number,notes[ps,voice,measure,note].maxbeam)
1782 END;
1783 IF ( n.tagname = "<tremolo>" ) (* & (measure = 166) *) THEN
1784 b.FindAtt(n, "type",notes[ps,voice,measure,note].tremolotype);
1785 Out.Ln(); Out.String("tremolotype : "); Out.String(notes[ps,voice,measure,note].tremolotype);
1786 Out.Ln(); Out.String("BEams in tremolo : "); Out.String(n.between); (*&&&&&&&*)
1787 Strings.StrToInt(n.between, notes[ps,voice,measure,note].maxbeam);
1788
1789 END;
1790
1791 IF (n.tagname = slurtag) THEN
1792 b.slur2PMX( n, pmxslur , outputset); COPY(pmxslur, notes[ps, voice, measure, note].slur[0] ) ;
1793 (* Out.Ln(); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); Out.String(pmxslur);
1794 openslur.ps := ps; openslur.voice := voice; openslur.measure := measure; openslur.note := note;
1795 openslur.grace := notes[ps,voice,measure,note].grace;
1796 Out.Int(notes[ps,voice,measure,note].grace,5); *)
1797 n := n.next;
1798 IF (n.tagname = slurtag) THEN
1799 b.slur2PMX(n,pmxslur, outputset); COPY(pmxslur, notes[ps, voice, measure, note].slur[1] ) ;
1800 (* Out.Ln(); Out.Int(ps,5); Out.Int(voice,5); Out.Int(measure,5); Out.Int(note,5); Out.String(pmxslur);
1801 Out.Int(notes[ps,voice,measure,note].grace,5); *)
1802
1803 n := n.next;
1804 END;
1805
1806
1807 END;
1808
1809
1810
1811
1812
1813
1814 (* END; *)
1815
1816 IF (n.tagname = tiedtag) THEN (* 1*)
1817 b.FindAtt( n, "type", ntype );
1818
1819 IF ntype = "start" THEN (* 2 *)
1820 b.tied2PMX( n, ntype, pmxtied, ps,voice);
1821 COPY( pmxtied, notes[ps, voice, measure, note].tied[0] );
1822 ELSIF ntype = "stop" THEN
1823 m := n.next;
1824 IF m.tagname = tiedtag THEN (* 3 *)
1825 (* Out.Ln(); Out.String( "================== found 2nd tie" ); *)
1826
1827 b.FindAtt( m, "type", mtype );
1828 IF mtype = "start" THEN (* 4 *)
1829 b.tied2PMX( m, mtype, pmxtied, ps, voice);
1830 COPY( pmxtied, notes[ps, voice, measure, note].tied[0] );
1831 b.tied2PMX( n, ntype, pmxtied, ps,voice);
1832 COPY( pmxtied, notes[ps, voice, measure, note].tied[1] );
1833 ELSE
1834 Out.Ln(); Out.String( "===========Notesprop: tie inconsistent" ); Out.Int( ps, 5 );
1835 Out.Int( voice, 5 ); Out.Int( measure, 5 );
1836 END; (* 4 *)
1837
1838
1839 ELSE (* next Tag is not a tiedtag! *)
1840 (* ntype = "stop" *)
1841 b.tied2PMX( n, ntype, pmxtied, ps,voice);
1842 COPY( pmxtied, notes[ps, voice, measure, note].tied[1] );
1843 END; (* 3 *)
1844 IF m.tagname = tiedtag THEN n := n.next END;
1845 END; (* 2 *)
1846 END; (* 1 *)
1847 IF (n.tagname = beamtag) THEN
1848 b.FindAtt( n, "number", number );
1849
1850 IF (number = "1") THEN (* PMX needs only one beam *)
1851 beam2PMX( n, pmxbeam, notes[ps, voice, measure, note].stem, staff );
1852
1853 IF notes[ps, voice, measure, note].chord # "z" THEN
1854 COPY( pmxbeam, notes[ps, voice, measure, note].beam );
1855 COPY( closebeam, notes[ps, voice, measure, note].closebeam );
1856
1857 END;
1858 END;
1859 END;
1860 IF ( n.tagname = "<trill-mark>" ) OR ( n.tagname = "<trill-mark/>" ) THEN COPY (" oT0 ", notes[ps, voice, measure, note].trill); END;
1861 IF n.tagname = staccatotag THEN COPY( " o. ", notes[ps, voice, measure, note].staccato ); END;
1862 IF (n.tagname = "<accent>" ) OR (n.tagname = "<accent />" ) OR (n.tagname = "<accent/>" )
1863 THEN
1864 b.FindAtt( n, "placement", placement );
1865 COPY( " o>", notes[ps, voice, measure, note].accent );
1866 IF ( placement = "below") THEN
1867 Strings.Append(notes[ps, voice, measure, note].accent,"-12 ") END;
1868 Strings.AppendCh(notes[ps, voice, measure, note].accent," ");
1869 END;
1870 IF ( n.tagname = "<strong-accent>") OR ( n.tagname = "<strong-accent/>") OR ( n.tagname = "<strong-accent />")
1871 THEN COPY( " o^ ", notes[ps, voice, measure, note].strongaccent ); END;
1872
1873 (* IF n.tagname = "<arpeggiate>" THEN notes[ps,voice,measure,note].arpeggio := TRUE; END; (* 22. November 2019 $$$$$$$ *) *)
1874 IF n.tagname = tuplettag THEN
1875 b.FindAtt( n, "type", type ); COPY( type, notes[ps, voice, measure, note].tuplet )
1876 END;
1877 IF (n.tagname = stafftag) THEN notes[ps, voice, measure, note].staff := ORD( n.between[0] ) - 48; END;
1878 IF (n.tagname = repeattag) THEN
1879 repeat2PMX( n, pmxrepeat ); COPY( pmxrepeat, notes[ps, voice, measure, note].repeat );
1880 END;
1881 END;
1882
1883 IF (n.tagname = "<tremolo>") & ( notes[ps, voice, measure, note].tremolotype ="single" )
1884 THEN Strings.StrToInt( n.between, notes[ps, voice, measure, note].trembeam );
1885
1886 (* Out.Ln(); Out.String( " NotesProp-tremolo-beams : " ); Out.Int( ps, 5 ); Out.Int( measure, 5 );
1887 Out.Int( notes[ps, voice, measure, note].trembeam, 5 ); *)
1888 END; (* not a grace note *)
1889
1890 IF (4 IN outputset ) & ( n.tagname = lyrictag ) THEN b.lyric( ps, n ); END; (* stores lyric of a song *)
1891 IF (n.tagname # eonotetag) THEN n := n.next; END;
1892 END;
1893 (* Enumerate(part,staff,voice,measure,note); *)
1894 END NotesProp;
1895
1896
1897 PROCEDURE MeasureProp( measure: LONGINT; n: b.Tag );
1898 (* stores measure information in an array with index [measure] for later use in the PMX generation. *)
1899 VAR pmxrepeat, pmxending: ARRAY 16 OF CHAR;
1900 type: ARRAY 32 OF CHAR;
1901 BEGIN
1902 (* Out.Ln(); Out.String("in measure prop"); *)
1903 IF (n.tagname = barstyletag) THEN
1904 IF (n.between = "light-light") THEN COPY( " Rd ", measures[measure].barstyle )
1905 (* ELSIF (n.between = "light-heavy") THEN COPY( " RD ", measures[measure].barstyle ) RD not needed in PMX *)
1906 END;
1907 END;
1908 IF (n.tagname = repeattag) THEN repeat2PMX( n, pmxrepeat ); COPY( pmxrepeat, measures[measure].repeat ); END;
1909 IF (n.tagname = endingtag) THEN
1910 ending2PMX( n, pmxending, type );
1911 IF type = "start" THEN COPY( pmxending, measures[measure].ending ); END;
1912 IF type = "discontinue" THEN COPY (pmxending,measures[measure+1].ending); END;
1913 END;
1914
1915 END MeasureProp;
1916
1917 PROCEDURE ReadClef( VAR n: b.Tag; VAR sign: CHAR; VAR line, staff: LONGINT );
1918 VAR endtag, number: ARRAY 32 OF CHAR;
1919
1920 BEGIN
1921 IF (n.tagname = cleftag) THEN
1922 b.loesch( number ); b.FindAtt( n, "number", number ); (* Out.Ln(); Out.String( " ReadClef : " );
1923 Out.Int( n.nr, 5 ); Out.Char( "|" ); Out.String( number ); *)
1924 IF number[0] # 0X THEN Strings.StrToInt( number, staff ); ELSE staff := 1 END;
1925 COPY( n.endtag, endtag );
1926 WHILE (n.next # NIL ) & (n.tagname # endtag) DO
1927 (* OutTag( n ); *)
1928 IF (n.tagname = signtag) THEN sign := n.between[0]; END; (* "p" by percussion *)
1929 IF (n.tagname = cleflinetag) THEN Strings.StrToInt( n.between, line ); END;
1930 n := n.next;
1931 END;
1932 ELSE Out.String( "Readclef n.tagname = " ); Out.String( n.tagname )
1933 END;
1934 END ReadClef;
1935
1936 PROCEDURE AttributesProp( VAR n: b.Tag );
1937 (* stores initial structure ( divisions, fifths,beats,beattype,staves,clef and transposition)
1938 in an array with index [part] for later use in the PMX generation. *)
1939 VAR staff: LONGINT;
1940 endtag, symbol: ARRAY 32 OF CHAR;
1941 sign: CHAR; line: LONGINT;
1942 BEGIN
1943
1944 IF (n.tagname = attributestag) THEN
1945 COPY( n.endtag, endtag ); n.used := TRUE; stavesfound := FALSE;
1946 WHILE (n.next # NIL ) & (n.tagname # endtag) DO
1947 part := n.part; attributes[part].measure := n.measure; measure := n.measure; (* OutTag( n ); *)
1948
1949 attributes[part].note := n.note; (* Out.Ln(); Out.String( "AttributesProp : part " ); Out.Int( part, 5 ); *)
1950 IF (n.tagname = divisionstag) THEN attributes[part].divisions := b.ExtractInt( n.between ) ; END;
1951
1952 IF (n.tagname = fifthstag) THEN
1953 attributes[part].fifth := b.ExtractInt( n.between ); measures[measure].keys[part] := attributes[part].fifth;
1954 b.akeys[part] := attributes[part].fifth;
1955 END;
1956 IF (n.tagname = "<time>") THEN
1957 b.FindAtt( n, "symbol", symbol ); (* Out.Ln(); Out.String( "att. symbol :****************" ); *)
1958 Out.String( symbol );
1959 IF symbol = "common" THEN attributes[part].mtrdenp := 6;
1960 ELSIF symbol = "cut" THEN attributes[part].mtrdenp := 5;
1961 ELSE attributes[part].mtrdenp := 0;
1962 END;
1963 END;
1964
1965 IF (n.tagname = beatstag) THEN
1966 attributes[part].beats := b.ExtractInt( n.between ); (* measures[measure].beats := attributes[part].beats; versuch: 19.5.2017*)
1967 END;
1968 IF (n.tagname = beattypetag) THEN
1969 attributes[part].beattype := b.ExtractInt( n.between );
1970
1971 END;
1972
1973 IF (n.tagname = stavestag) THEN
1974 attributes[part].staves := b.ExtractInt( n.between ); stavesfound := TRUE;
1975 staves[n.part] := attributes[part].staves;
1976 END;
1977 IF (n.tagname = "<diatonic>") THEN
1978 Out.Ln(); Out.String( " diatonic" ); Out.Ln(); Strings.StrToInt( n.between, attributes[part].diatonic )
1979 END;
1980 IF (n.tagname = "<chromatic>") THEN Strings.StrToInt( n.between, attributes[part].chromatic ) END;
1981 IF (n.tagname = "<octave-change>") THEN Strings.StrToInt( n.between, attributes[part].octave ) END;
1982
1983 IF (n.tagname = cleftag) THEN
1984 ReadClef( n, sign, line, staff ); attributes[part].clefsign[staff] := sign;
1985 attributes[part].clefline[staff] := line; END;
1986
1987 n := n.next;
1988
1989 END;
1990 IF (stavesfound = FALSE ) THEN attributes[part].staves := 1; staves[n.part] := attributes[part].staves; END;
1991
1992 IF (attributes[part].diatonic # 0) & (attributes[part].chromatic # 0) THEN
1993 Out.Ln(); Out.String( " Transposition : part, fifths, dia, chrom, oct " ); Out.Int( part, 5 );
1994 Out.Int( attributes[part].fifth, 5 ); Out.Int( attributes[part].diatonic, 5 );
1995
1996 Out.Int( attributes[part].chromatic, 5 ); Out.Int( attributes[part].octave, 5 );
1997 END;
1998
1999 END;
2000 END AttributesProp;
2001
2002
2003
2004 PROCEDURE Enrich2( q: b.FIFO );
2005 (* determines last note with voice "0" for distributing directions. *)
2006 (* n.voice12 has the value "1" for the upper voice and "2" for the lower voice in one staff. *)
2007 VAR n: b.Tag; lastnote: LONGINT;
2008 BEGIN
2009 n := q.first; lastnote := 0;
2010 WHILE n.next # NIL DO
2011 IF (n.tagname = measuretag) THEN lastnote := 0; END;
2012 IF (n.tagname = notetag) THEN
2013 part := n.part; staff := n.staff; ps := linstaff( nostaves, part, staff );
2014 n.voice12 := VOICE01( ps, n.voice, n.measure ) + 1;
2015 (* IF (n.chord # "z") THEN n.lastnote := lastnote; END; Change: 26.07.2019 *)
2016 IF (n.chord # "c") THEN n.lastnote := lastnote; END;
2017 (* OutTag(n,TRUE); *)
2018 END;
2019 IF n.voice12 = 1 THEN lastnote := n.note END;
2020 n := n.next;
2021 END;
2022
2023 END Enrich2;
2024 PROCEDURE Enrich( q: b.FIFO );
2025 (* 1. Read voice and staff; store as notes attribute;
2026 2. Calculates maxnote, minvoice,maxvoice,minVoice,maxVoice; *)
2027 VAR n, m: b.Tag; notevoice, notestaff : LONGINT; duration, backup, B: LONGINT;
2028
2029 BEGIN
2030
2031 b.loeschint( voicecount );
2032 n := q.first; (* Out.Ln(); Out.String( "part, staff, measure, voice, note, minvoice " ); Out.Ln(); *)
2033 WHILE n.next # NIL DO
2034
2035 IF (n.tagname = notetag) THEN
2036
2037
2038 IF (n.next.tagname = gracetag) OR (n.next.tagname = gracetag2) THEN
2039 INC( lastgrace ); n.grace := SHORT( lastgrace ); (*b.OutTag(n,TRUE); Out.String("ist grace"); *)
2040 ELSE lastgrace := 0
2041 END;
2042
2043 b.FindProperty( n, notetag, "<arpeggiate>", B );
2044 IF B > 0 THEN n.arpeggio := TRUE ELSE n.arpeggio := FALSE END;
2045
2046 b.FindIProperty( n, notetag, voicetag, voice ); n.voice := voice; notevoice := voice;
2047
2048 b.FindIProperty( n, notetag, stafftag, staff ); n.staff := staff; notestaff := staff; note := n.note;
2049
2050 b.FindIProperty( n, notetag, durationtag, duration ); n.duration := SHORT( duration );
2051
2052 b.FindProperty( n, notetag, chordtag, B );
2053 IF B > 0 THEN n.chord := "c" END;
2054
2055 measure := n.measure; part := n.part;
2056
2057 maxnote[part, staff, measure] := b.Max( note, maxnote[part, staff, measure] );
2058 minnote[part, staff, measure] := b.Min( note, minnote[part, staff, measure] );
2059
2060 (* NEW( st ); b.psv2String( part, staff, voice, st.key ); InsertRanked( first, st ); NEW( psmv );
2061 b.psmv2String( part, staff, voice, measure, psmv.key ); InsertRanked( firstpsmv, psmv ); *)
2062
2063 END;
2064 IF (n.tagname = directiontag) THEN b.FindIProperty( n, directiontag, stafftag, staff ); n.staff := staff;
2065 b.findnextnote (n,m); IF m # NIL THEN n.nextnote := m.note;
2066 b.FindIProperty( m, notetag, voicetag, voice ); n.nextvoice := voice; END; (* voice of next note "m"&&&&& *)
2067 END;
2068 IF (n.tagname = backuptag) THEN
2069 (* Out.Ln();Out.String("******************* Backup"); *)
2070 b.FindIProperty( n, backuptag, durationtag, backup ); n.backup := SHORT( backup ); m := n;
2071 WHILE (m.next # NIL ) & (m.tagname # notetag) DO
2072 (* Out.Ln(); Out.String("backup-m"); b.OutTag(m,FALSE); *)
2073 m := m.next ;
2074 END; (* hier werden Daten weggelesen, bis zur naechsten Note *)
2075 (* und dann der backup der Note zugeordnet *)
2076 (* IF m.grace > 0 THEN
2077 WHILE
2078 m.grace > 0 DO b.OutTag(m,TRUE); m := m.next;
2079 END;
2080 END; (* Aenderung wg ala tiurca grace notes Takt 28 ff *) *)
2081 (* Store backup at next note *) ; m.backup := SHORT( backup ); (* b.OutTag(m,TRUE); *)
2082 END;
2083
2084 (* OutTag(n); *)
2085 n := n.next;
2086 END;
2087 Enrich2(b.q);
2088
2089
2090
2091 END Enrich;
2092
2093 PROCEDURE VOICE01( ps, voice, measure: LONGINT ): LONGINT;
2094 BEGIN
2095 IF vmap[ps, measure, 0] = voice THEN RETURN 0
2096 ELSIF vmap[ps, measure, 1] = voice THEN RETURN 1
2097 ELSE RETURN 2
2098 END;
2099
2100 END VOICE01;
2101
2102
2103 PROCEDURE Accidentals(n : b.Tag; ps, voice, measure, note : LONGINT);
2104 VAR
2105 cautionary, editorial, parentheses : ARRAY 32 OF CHAR;
2106 BEGIN
2107 IF (n.tagname) = accidentaltag THEN (* 5 *)
2108 b.FindAtt( n, "editorial", editorial );
2109 b.FindAtt( n, "cautionary", cautionary );
2110 b.FindAtt( n, "parentheses", parentheses );
2111 IF n.between = "sharp" THEN
2112 COPY( "s", notes[ps, voice, measure, note].accidental );
2113 IF editorial = "yes" THEN Strings.Append( notes[ps, voice, measure, note].accidental, " oes " ) END;
2114 ELSIF n.between = "flat" THEN
2115 COPY( "f", notes[ps, voice, measure, note].accidental );
2116 IF editorial = "yes" THEN Strings.Append( notes[ps, voice, measure, note].accidental, " oef " ) END;
2117 ELSIF (n.between = "double-sharp") OR (n.between = "sharp-sharp") THEN
2118 COPY( "ss", notes[ps, voice, measure, note].accidental )
2119 ELSIF (n.between = "flat-flat") OR (n.between = "double-flat") THEN
2120 COPY( "ff", notes[ps, voice, measure, note].accidental )
2121 ELSIF n.between = "natural" THEN COPY( "n", notes[ps, voice, measure, note].accidental );
2122 IF editorial = "yes" THEN Strings.Append( notes[ps, voice, measure, note].accidental, " oen " ) END;
2123 ELSE
2124 END;
2125 IF ( cautionary = "yes" ) OR ( parentheses = "yes")
2126 THEN Strings.AppendCh( notes[ps, voice, measure, note].accidental, "c" );
2127
2128 END;
2129
2130 END;
2131
2132 END Accidentals;
2133
2134
2135
2136 PROCEDURE EnumerateTags*;
2137 (* runs through the list of tags and calls NotesProp and MeasuresProp and lists the tag-data in System.Log *)
2138 VAR n: b.Tag; voice01: LONGINT;
2139 BEGIN
2140 n := b.q.first; voice01 := 0;
2141 WHILE n.next # NIL DO (* 1 *)
2142 part := n.part; measure := n.measure; note := n.note; (* voice := n.voice; staff := n.staff; *)
2143
2144
2145 IF (n.tagname = notetag) THEN (* 3 *)
2146
2147 voice := n.voice; staff := n.staff;
2148 (* store cue-property 11.07.2019 *)
2149 IF ( n.next.tagname = "<cue/>" ) THEN n.cue := TRUE; END;
2150
2151 ps := linstaff( nostaves, part, staff ); voice01 := VOICE01( ps, voice, measure );
2152
2153 (* directions are coded after notes in upper voice *)
2154 NotesProp( part, staff, voice01, measure, note, n ); INC(countnote);
2155 (* (* IF (countnote <10) THEN *) Out.Ln(); Out.String("cnote");Out.Int(countnote,5) (* END; *) ; *)
2156
2157
2158 END; (* 3 *)
2159
2160 IF (n.tagname = attributestag) THEN AttributesPropM( voice01, measure, n );
2161 INC (countattr); END;
2162 (* geaendert 8.1.2016: lastnote -> note *)
2163 (* IF 1 =0 THEN *)
2164 IF (n.tagname = directiontag) THEN DirectionProp( n,voice01 ); INC(countdir) ;END;
2165 MeasureProp( measure, n ); (* OutTag( n ); *)
2166 n := n.next
2167 END; (* 1 *)
2168 (* FillMeasures;
2169 Out.Ln(); Out.String(" nach attributesprom : "); ; ListMeasures; *)
2170
2171 (* ListDir; $$$$$$$$$$$$$$$$ *)
2172 (* Out.Ln(); Out.String( "part, transposition: fifth diatonic chromatic octave ");
2173 INC
2174 part := 1;
2175 WHILE part <= maxpart DO
2176 Out.Ln(); Out.Int( part, 5 ); Out.Int( attributes[part].fifth, 5 ); Out.Int( attributes[part].diatonic, 5 );
2177 Out.Ln(); Out.String("divisions in enumerate : "); Out.Int(attributes[part].divisions,5);
2178 (* Out.Int( attributes[part].chromatic, 5 ); Out.Int( attributes[part].octave, 5 ); *)
2179 (* pitch.pmxtranspose(part,attributes[part].fifth, remove automatic transposition based on XML-transpose
2180 attributes[part].diatonic,attributes[part].chromatic,attributes[part].octave,kstring);
2181 Out.Char("|"); Out.String(kstring); COPY(kstring,attributes[part].kstring); *)
2182 INC( part );
2183 END; *)
2184 ps := 0;
2185 WHILE ps < nostaves DO part := partstaff[ps, 0];
2186 (* Calculate durations for all instruments and measures *)
2187 measure := 1;
2188 WHILE measure <= maxmeasure DO
2189
2190 IF measures[measure].beattype > 0 THEN (* 20.10.2020 Lilypond *)
2191
2192 measures[measure].duration[part] :=
2193 measures[measure].beats*4*attributes[part].divisions
2194 DIV measures[measure].beattype; (* Division durch 0 *)
2195
2196
2197 END;
2198 INC( measure );
2199 END;
2200 INC( ps );
2201 END;
2202 (* END; (* Fake End *) *)
2203 (* ListMeasures; $$$$ *)
2204 (* prvoicetime; *)
2205 (* CopyClefVoice; *)
2206 END EnumerateTags;
2207
2208
2209
2210 PROCEDURE DirectionProp( VAR n: b.Tag; voice01 : LONGINT );
2211 VAR endtag, placement, type, res: ARRAY 128 OF CHAR;
2212 dirnum, dirtypenr : LONGINT; defaultx: LONGINT; sbeatunit : ARRAY 32 OF CHAR;
2213 defaultxs: ARRAY 32 OF CHAR; rehtext : ARRAY 32 OF CHAR; (* fuer rehearsal marks *)
2214 BEGIN
2215 (* Out.Ln(); Out.String("in direction prop"); *)
2216
2217 IF (n.tagname = directiontag) THEN (* 1 *)
2218
2219 (* b.OutTag( n, TRUE ); *)
2220 COPY( n.endtag, endtag ); part := n.part; measure := n.measure; dirnum := n.dirnum; staff := n.staff;
2221 directions[dirnum, 0].part := n.part; directions[dirnum, 0].measure := n.measure; voice := n.voice;
2222 directions[dirnum, 0].staff := staff; directions[dirnum, 0].used := FALSE; (* allow usage of direction only once. *)
2223 maxdirtype[dirnum] := 0; ps := linstaff( nostaves, part, staff ); (* voice01 := VOICE01( ps, voice, measure ); changed 22.12.2016 *)
2224 (* Voice01( ps, voice ); *)
2225
2226 directions[dirnum, 0].note := n.note; directions[dirnum, 0].lastnote := n.lastnote; (* -1 ; Versuch 21. Mai => Absturz *)
2227 directions[dirnum,0].voice := voice01; (* changed 22.12.2016 *)
2228
2229 IF measure = 96 THEN Out.Ln(); Out.String("DirectionProp : dirnum, note | lastnote ");
2230 Out.Int(dirnum,5); Out.Int(n.note,5); Out.Char("|");Out.Int(n.lastnote,5);
2231 END;
2232
2233 (* CheckVoice(ps,measure,n.lastnote); *)
2234 (* the direction is stored at this note *)
2235
2236 (* Out.Ln(); Out.String( "DirectionProp : lastnote " ); Out.Int( dirnum, 5 );
2237 Out.Int( directions[dirnum, 0].lastnote, 5 ); *)
2238 directions[dirnum, 0].before := FALSE; (*$$$$$$$$$$$$$$$$$$$$$$*)
2239
2240
2241 b.FindAtt( n, "placement", placement ); dirtypenr := 0;
2242 (* placement is valid for all direction-types under the direction *)
2243 WHILE (n.next # NIL ) & (n.tagname # endtag) DO (* 2 *)
2244 IF (n.tagname = "<direction-type>") THEN (* 3 *)
2245 INC( dirtypenr ); n := n.next; (* OutTag( n ); *)
2246 directions[dirnum, dirtypenr].lastnote := directions[dirnum, 0].lastnote;
2247 IF (n.tagname = "<dynamics>") THEN (* 3 .1*)
2248
2249 b.FindAtt( n, "default-x", defaultxs ); Strings.StrToInt( defaultxs, defaultx );
2250 directions[dirnum, dirtypenr].defaultx := SHORT( defaultx );
2251
2252 n := n.next; (* OutTag( n ); *) directions[dirnum, dirtypenr].dirtype := "d";
2253 COPY( n.tagname, directions[dirnum, dirtypenr].dyntype );
2254 directions[dirnum, dirtypenr].before := FALSE;
2255 IF directions[dirnum, dirtypenr].note = 0 THEN
2256 directions[dirnum, dirtypenr].note := 1; directions[dirnum, dirtypenr].placement := "l";
2257 END;
2258
2259 ELSIF (n.tagname = "<words>") THEN (* 3 .2*)
2260 IF (placement = "above") OR (placement = "") THEN
2261 directions[dirnum, dirtypenr].placement := "h"; (* Aenderung 19. Mai *)
2262
2263 ELSIF (placement = "below") THEN directions[dirnum, dirtypenr].placement := "l";
2264 END;
2265
2266 directions[dirnum, dirtypenr].dirtype := "w"; COPY( n.between, directions[dirnum, dirtypenr].text );
2267
2268 directions[dirnum, dirtypenr].before := TRUE;
2269
2270 ELSIF (n.tagname = "<pedal>") THEN (* 3 .3*)
2271 directions[dirnum, dirtypenr].dirtype := "p"; b.FindAtt( n, "type", type );
2272 directions[dirnum, dirtypenr].before := TRUE;
2273
2274 COPY( type, directions[dirnum, dirtypenr].pedaltype );
2275
2276 ELSIF (n.tagname = "<wedge>") THEN (* 3 .4*)
2277 directions[dirnum, dirtypenr].dirtype := "h"; b.FindAtt( n, "type", type );
2278 COPY( type, directions[dirnum, dirtypenr].wedgetype ); directions[dirnum, dirtypenr].before := FALSE;
2279 IF directions[dirnum, dirtypenr].note = 0 THEN directions[dirnum, dirtypenr].note := 1; END;
2280 directions[dirnum, dirtypenr].placement := "l";
2281 ELSIF (n.tagname = "<metronome>") THEN (* 3 .5*)
2282 directions[dirnum, dirtypenr].placement := "h"; directions[dirnum, dirtypenr].dirtype := "w"; (* Metronom ist "w" *)
2283 WHILE (n.next # NIL ) & (n.tagname # "</metronome>") DO
2284 IF n.tagname = "<beat-unit>" THEN COPY (n.between,sbeatunit) END;
2285
2286 IF n.tagname = "<per-minute>" THEN b.metron2PMX (sbeatunit,n.between,directions[dirnum,dirtypenr].text);
2287 (* Out.String( "metronome : " ); *)
2288 (* Out.String( directions[dirnum, dirtypenr].text ); *)
2289 directions[dirnum, dirtypenr].before := TRUE;
2290 END;
2291
2292 n := n.next;
2293 END;
2294 ELSIF (n.tagname = "<segno>" ) THEN directions[dirnum, dirtypenr].dirtype := "s";
2295 directions[dirnum, dirtypenr].before := FALSE;
2296 ELSIF (n.tagname = "<coda>" ) THEN directions[dirnum, dirtypenr].dirtype := "c";
2297 directions[dirnum, dirtypenr].before := FALSE;
2298 ELSIF (n.tagname = "<rehearsal>" ) THEN
2299 directions[dirnum, dirtypenr].placement := "h";
2300 directions[dirnum, dirtypenr].dirtype := "w"; (* 14.10.2020 "rehearsal" *)
2301 directions[dirnum, dirtypenr].before := TRUE;
2302 COPY (" \boxit{",rehtext);
2303 Strings.Append (rehtext,n.between);
2304 b.loesch(directions[dirnum,dirtypenr].text) ;
2305 Strings.Append(rehtext," } ") ;
2306
2307 COPY(rehtext,directions[dirnum,dirtypenr].text);
2308
2309
2310 Out.Ln(); Out.String( "rehearsal : "); Out.String(rehtext);
2311 Out.Ln();Out.String("text :"); Out.String ( directions[dirnum,dirtypenr].text ) ;
2312
2313
2314 ELSE
2315 Out.Ln(); Out.String( "<direction-type> " ); Out.String( n.tagname );
2316 Out.String( " not implemented. " );
2317 END;
2318 maxdirtype[dirnum] := b.Max( dirtypenr, maxdirtype[dirnum] );
2319 (* Out.Ln(); Out.String("dirtypenr : "); Out.Int(dirtypenr,5);*)
2320 pmxDirections( dirnum, dirtypenr, res ); COPY( res, directions[dirnum, dirtypenr].pmxdirection );
2321 (* OutDir(dirnum,dirtypenr); *)
2322
2323 (* Out.Int(dirnum,5); Out.String("| in directionprop "); Out.String(res); Out.String(directions[dirnum, dirtypenr].pmxdirection); *)
2324
2325 END; (* 3 *)
2326 (* IF (n.tagname = stafftag) THEN Strings.StrToInt( n.between, directions[dirnum].staff ) END; ??????? *)
2327 n := n.next; (* OutTag( n ); *)
2328 END; (* 2 *)
2329 END; (* 1 *)
2330
2331 END DirectionProp;
2332
2333 PROCEDURE AttributesPropM ( voice, measure: LONGINT; VAR n: b.Tag );
2334 (***************** voice = voice01 ********************)
2335 VAR sign: CHAR; line, number, part : LONGINT; clef: CHAR; m : b.Tag; staff : LONGINT;
2336 (* takes care of changes:
2337 - clefchange [part,staff] in the flow of notes
2338 - meter change: beats and beattype [measure]
2339 - fifth change
2340 - change of divisions
2341 links the changes to a note *)
2342 BEGIN (* Out.Ln(); Out.String(" in AttirbutesPropM ");*)
2343 IF (n.tagname = attributestag) & ~n.used THEN (* 1 *)
2344 part := n.part; staff := n.staff; (* REparaturversuch 31.10.2020 *)
2345 (* ps := linstaff( nostaves, part, staff ); *)
2346 WHILE n.tagname # "</attributes>" DO (* 2*)
2347 (* Out.Ln(); Out.String(n.tagname); *)
2348 IF (n.tagname = cleftag) THEN
2349 (* Out.Ln(); Out.String(cleftag);
2350 Out.Ln(); Out.String("part,staff,ps, measure :");Out.Int(part,5); Out.Int(staff,5); Out.Int(ps,5); Out.Int(measure,5); *)
2351
2352 (* neu Oktober 2020) find next note of same staff. *)
2353 ReadClef( n, sign, line, number );
2354 b.clefPMX( sign, SHORT( line ), clef, clefspec[ps] );
2355 b.findnextnotestaff ( n, m ,number); m.newclef := clef;
2356 (* lastclef[ps] := clef; *)
2357 (* notes[ps, voice, measure, n.lastnote].clefchanged := clef; *)
2358
2359
2360 (* b.OutTag(m,TRUE); *) (* INC (countclefchanges); Out.Ln();Out.Int(countclefchanges,5); *)
2361
2362 END;
2363
2364 (* Out.Ln(); Out.String("AttPropM"); Out.Char("|"); Out.Char( clef );
2365 Out.Char("|"); (* Out.Char( clefspec[ps] ); *)
2366
2367 Out.Ln();Out.String("n. lastnote"); Out.Int(n.lastnote,5);
2368
2369 IF ( n.lastnote # 0 ) THEN
2370 lastclef[ps] := clef; notes[ps, voice, measure, n.lastnote].clefchanged := clef;
2371
2372 Out.Ln(); Out.String("AttributesProp: n.lastnote # 0 "); Out.Int(measure,5); Out.Char("|"); Out.Char(clef);
2373 ELSE
2374 (* n.lastnote = 0 *)
2375 measures[measure ].clefchange[linstaff(nostaves,part,number)] := clef; (* Maerz 2018 *)
2376
2377
2378 Out.Ln(); Out.String("AttributesProp: n.lastnote = 0 "); Out.Int(measure,5); Out.Char("|"); Out.Char(clef);
2379 END; *)
2380 (* Out.Ln();
2381 Out.String( "clefs *******" ); Out.Int( ps, 5 ); Out.Int( voice, 5 ); Out.Int( measure, 5 );
2382 Out.Int( n.lastnote, 5 ); Out.Char( clef ); *)
2383
2384 (* IF part = 1 THEN Korrektur 12. Januar 2016: Taktwechsel bei Takt 209 Vivaldi fehlt in der zweiten und driitten
2385 Stimme.
2386 *)
2387 IF (n.tagname = beatstag) THEN (* change 19.5.2017 *)
2388
2389 measures[measure].beats := b.ExtractInt( n.between ); (* Out.String( " PropM : measure = " );
2390 Out.Int( measure, 5 ); Out.Int( measures[measure].beats, 5 ); *)
2391 END;
2392 IF (n.tagname = beattypetag) THEN
2393 measures[measure].beattype := b.ExtractInt( n.between );
2394 (* Out.Int( measures[easure].beattype, 5 ); *)
2395 END;
2396 IF (n.tagname = fifthstag) THEN
2397 attributes[part].fifth := b.ExtractInt( n.between );
2398 measures[measure].keys[part] := attributes[part].fifth;
2399 IF (part = maxpart) THEN measures[measure].fifth := attributes[part].fifth END;
2400 i := measure+1;
2401 WHILE i <= maxmeasure DO measures[i].keys[part] := attributes[part].fifth;
2402 IF ( part = maxpart ) THEN
2403 measures[i].fifth := attributes[maxpart].fifth; (* store concertkey *)
2404 END;
2405
2406 INC(i);
2407 END;
2408
2409 b.mkeys[part] := attributes[part].fifth;
2410
2411 END;
2412
2413
2414 IF (n.tagname = divisionstag) THEN attributes[part].divisions := b.ExtractInt( n.between ) ; END;
2415 (* END; *)
2416 n := n.next;
2417 END (* 2 *)
2418
2419 ELSE (* 1 *)
2420
2421 (* Out.Ln(); Out.String( " AttributesPropM : attributstag not found or already used ! " );
2422 Out.String( n.tagname ); *)
2423
2424 END; (* 1 *)
2425
2426 END AttributesPropM;
2427
2428 PROCEDURE Pickup( q: b.FIFO; VAR duration: LONGINT );
2429 (* finds out whether first measure is smaller, i.e. we have a pickup. *)
2430 VAR n: b.Tag; isnote: BOOLEAN;
2431 endtag: ARRAY 32 OF CHAR;
2432 chord: CHAR; noteduration: LONGINT;
2433 durationsv: ARRAY 25 OF ARRAY 10 OF LONGINT;
2434 BEGIN
2435 n := q.first; isnote := FALSE; chord := 0X;
2436 WHILE (n.next # NIL ) & (n.tagname # measuretag) DO n := n.next; END; (* first measure of first part found *)
2437 (* b.OutTag( n, TRUE ); *) COPY( n.endtag, endtag ); duration := 0;
2438 WHILE (n.next # NIL ) & (n.tagname # endtag) DO (* Loop over all elements of 1st measure / 1st instrument /1st staff *)
2439 IF (n.tagname = notetag) THEN
2440 isnote := TRUE; part := n.part; staff := n.staff; voice := n.voice; chord := n.chord; (* b.OutTag( n, TRUE ); *)
2441 END;
2442 IF (n.tagname = eonotetag) THEN isnote := FALSE; END;
2443 IF (n.tagname = durationtag) & isnote & (chord # "c") THEN
2444 Strings.StrToInt( n.between, noteduration );
2445 (* Out.Ln(); Out.String("staff :"); Out.Int(staff,5); Out.String("voice :"); Out.Int(voice,5);
2446 Out.String("duration : "); Out.Int(noteduration,5); *)
2447
2448 INC( durationsv[staff, voice], noteduration );
2449 (* b.OutTag( n, TRUE ); *)
2450 (* IF isnote THEN Out.String( "ist Note" ); END; *)
2451 END;
2452 n := n.next;
2453 END;
2454
2455 IF (duration = attributes[1].duration) THEN duration := 0;
2456 END;
2457 (* Out.Ln(); Out.String( "beats, beattype and divisions : " ); Out.Int( attributes[1].beats, 5 ); Out.Int( attributes[1].beattype, 5 );
2458 Out.Int( attributes[1].divisions, 5 );
2459
2460 Out.Ln(); Out.String( "Pickup : " ); Out.Int( duration, 5 ); Out.Int( attributes[1].duration, 5 ); *)
2461 END Pickup;
2462
2463
2464
2465
2466 PROCEDURE ControlProp*;
2467 (* Extracts metadata from XML file for later use in PMX *)
2468 VAR type, id, digits: ARRAY 32 OF CHAR;
2469 dummy: ARRAY 128 OF CHAR;
2470 n: b.Tag; part: LONGINT;
2471 BEGIN
2472 n := b.q.first;
2473 WHILE (n.next # NIL ) & (n.tagname # "</part-list>") DO
2474 IF n.tagname = "<work-number>" THEN COPY( n.between, pmxcontrol.worknumber ) END;
2475 IF n.tagname = "<work-title>" THEN b.FilterTeX( n.between, dummy ); COPY( dummy, pmxcontrol.title ); END;
2476 b.loesch( type );
2477 IF n.tagname = "<movement-title>" THEN COPY( n.between, pmxcontrol.title ); END;
2478 IF n.tagname = "<creator>" THEN
2479 b.FindAtt( n, "type", type );
2480 IF type = "composer" THEN COPY( n.between, pmxcontrol.composer );
2481 ELSIF (type = "lyricist") THEN COPY( n.between, pmxcontrol.lyricist )
2482 END;
2483 END;
2484 IF (n.tagname = "<rights>") THEN COPY( n.between, pmxcontrol.rights ); END;
2485 IF n.tagname = "<encoding-date>" THEN
2486 COPY( "encoding date : ", pmxcontrol.info ); Strings.Append( pmxcontrol.info, n.between );
2487 Strings.AppendCh( pmxcontrol.info, BLANK );
2488 END;
2489 IF n.tagname = "<software>" THEN
2490 IF pmxcontrol.software[0] = 0X THEN
2491 COPY( "Software : ", pmxcontrol.software ); Strings.Append( pmxcontrol.software, n.between );
2492 ELSE
2493 Strings.AppendCh( pmxcontrol.software, BLANK ); Strings.Append( pmxcontrol.software, n.between );
2494 END;
2495 Strings.AppendCh( pmxcontrol.info, BLANK );
2496 END;
2497 (* parts and instruments *)
2498 IF n.tagname = "<score-part>" THEN
2499 b.FindAtt( n, "id", id ); b.ExtractDigits( id, digits ); Strings.StrToInt( digits, controlpart );
2500
2501
2502 (* controlpart := ORD( id[1] ) - 48; old version single digit only *)
2503
2504 COPY( id, pmxcontrol.parts[controlpart] );
2505 END;
2506 IF n.tagname = "<instrument-name>" THEN b.FilterTeX( n.between, pmxcontrol.instruments[controlpart] ); END;
2507 n := n.next;
2508 END;
2509
2510 part := 1; pmxcontrol.equalkeys := TRUE;
2511 WHILE (part <= maxpart) DO
2512 WHILE (n.next # NIL ) & (n.tagname # parttag) DO n := n.next END; (* FInd next <part> ***************)
2513 WHILE (n.next # NIL ) & (n.tagname # attributestag) DO n := n.next END;
2514 (* FInd next <attributes> *********)
2515 IF (n.tagname = attributestag) THEN AttributesProp( n );
2516 (* determine length of measure in divisions. *******************************)
2517 attributes[part].duration :=
2518 attributes[part].divisions*attributes[part].beats*4 DIV attributes[part].beattype;
2519 (* Out.Ln(); Out.String( "AttributesProp : Part | XML-duration of measure : " ); Out.Int( part, 5 ); Out.Char("|");
2520 Out.Int( attributes[part].duration, 5 ); *)
2521 (* measures[1].duration[part] := attributes[part].duration; *)
2522 END;
2523 (* check for transposing instruments! *)
2524 IF ( part > 1 ) THEN pmxcontrol.equalkeys := pmxcontrol.equalkeys & ( attributes[part].fifth = attributes[part-1].fifth ) END;
2525
2526 INC( part ); END;
2527 IF ~ pmxcontrol.equalkeys THEN b.testmakekey(maxpart,1,keytotal); END; (* different keys in different parts *)
2528 END ControlProp;
2529
2530 PROCEDURE StaffInd( nostaves, part, staff: LONGINT ): LONGINT;
2531 (* finds the linear index for [part,staff] *)
2532 VAR i, dist: LONGINT;
2533 BEGIN
2534 i := -1;
2535 REPEAT INC( i ); dist := ABS( partstaff[i, 0] - part ) + ABS( partstaff[i, 1] - staff );
2536 UNTIL (i = nostaves - 1) OR (dist = 0);
2537 RETURN i;
2538 END StaffInd;
2539
2540 PROCEDURE AllStaves( VAR staves: ARRAY OF LONGINT );
2541 (* maps part/staff to a linear index. *)
2542 VAR part, staff, i, nostaves: LONGINT;
2543 BEGIN
2544 i := 0; part := 1;
2545 WHILE part <= maxpart DO
2546 staff := 1;
2547 WHILE staff <= staves[part] DO partstaff[i, 0] := part; partstaff[i, 1] := staff; INC( staff ); INC( i ); END;
2548
2549 INC( part );
2550 END;
2551 nostaves := i; i := 0; b.nostaves := nostaves; (* inform MODULE "b" about # of staves *)
2552 END AllStaves;
2553
2554 PROCEDURE progress( q: b.FIFO );
2555 (* Calculates the horizontal position of each note in a measure and stores it in the tag. *)
2556 VAR n: b.Tag; ps: LONGINT;
2557 BEGIN
2558 ps := 0;
2559 n := q.first;
2560
2561 WHILE (n.next # NIL ) DO (* 1 *)
2562 IF (n.tagname = measuretag) THEN Complete.erasetime( nostaves,voicetime ); lastto := 0; lastfrom := 0; END; (* 2 *)
2563 IF (n.tagname = notetag) THEN (* 3 *)
2564 part := n.part; staff := n.staff; measure := n.measure; ps := StaffInd( nostaves, part, staff );
2565 voice := VOICE01( ps, n.voice, n.measure );
2566
2567 IF (n.chord # "c") & ( n.grace = 0 ) THEN (* 4 *) (* war frueher "&" statt "OR" *)
2568 (* INC(measures[measure].dur,n.duration); Out.Int(n.duration,5); *)
2569 INC( voicetime[ps, voice], n.duration ); n.voicetime := voicetime[ps, voice];
2570 measures[measure].voicetime[ps, voice] := n.voicetime; n.from := lastto + 1 - n.backup;
2571 n.to := n.from + n.duration - 1; lastto := n.to; lastfrom := n.from;
2572 ELSIF (n.chord = "c" ) THEN n.voicetime := lastto; n.to := lastto; n.from := lastfrom;
2573 ELSIF ( n.grace = 1 ) THEN n.from := lastto - n.backup; n.to := n.from ; lastto := n.to;
2574 ELSIF ( n.grace > 1 ) THEN n.from := lastto; n.to := n.from; lastto := n.to;
2575 ELSE
2576 END; (* 4 *)
2577
2578 END; (* 3 *)
2579 IF ( n.tagname = eomeasuretag ) & (ps = nostaves - 1) THEN (* 5 *)
2580 measures[measure].dur := lastto;
2581 (* Out.Char("|");Out.Int(measure,5);Out.Int(ps,5);Out.Int(measures[measure].dur,5); Out.Ln(); *) END; (* 5 *)
2582
2583 n := n.next;
2584 END; (* 1 *)
2585 (* Out.Ln(); Out.String("measure duration"); *)
2586 measure := 1; WHILE measure <= maxmeasure DO (* Out.Ln(); Out.Int(measure,5);
2587 Out.Int (measures[measure].dur ,5); *)
2588 Complete.dur2beat(measures[measure].dur,attributes[part].divisions,
2589 measures[measure].beats, measures[measure].beattype);
2590 (* Out.Int(measures[measure].beats,5); Out.Int(measures[measure].beattype,5); *)
2591 INC(measure) END;
2592
2593 END progress;
2594
2595
2596 PROCEDURE linstaff( nostaves, part, staff: LONGINT ): LONGINT;
2597 (* calculates the linear index of the combination "part and staff" *)
2598 VAR i: LONGINT;
2599 BEGIN
2600 i := 0;
2601 WHILE (i < nostaves) & (partstaff[i, 0] # part) DO INC( i ) END;
2602 WHILE (i < nostaves) & (partstaff[i, 0] = part) & (partstaff[i, 1] # staff) DO INC( i ) END;
2603
2604 IF (i < nostaves) THEN RETURN i;
2605 ELSE RETURN -1;
2606 END;
2607 END linstaff;
2608
2609
2610 PROCEDURE ControlData( VAR W: Files.Rider );
2611 (* Writes PMX header information to intermediate Files.File "fprep" with Files.Rider "rprep" *)
2612 VAR i: LONGINT; xmtrnum0: LONGREAL; clef: CHAR;
2613 perclef, perline: ARRAY 32 OF CHAR;
2614 zeit, tag, xmtrnum0s: ARRAY 16 OF CHAR;
2615 BEGIN
2616
2617
2618 (* TeX Input type 4 *)
2619 WriteString( W, "---" ); Files.Write( W, CR ); Files.Write( W, NL );
2620 WriteString( W, "%\input musixlyr" ); Files.Write( W, CR ); Files.Write( W, NL );
2621 WriteString( W, "%\special{papersize=297mm,420mm}%" ); Files.Write( W, CR ); Files.Write( W, NL );
2622 WriteString( W, "---" ); Files.Write( W, CR ); Files.Write( W, NL );
2623
2624 Files.Write( W, "%" );
2625 (* DateTime(zeit,tag); *)
2626 WriteString( W, tag ); Files.Write( W, "|" ); WriteString( W, zeit ); Files.Write( W, CR ); Files.Write( W, NL );
2627
2628 Files.Write( W, "%" );
2629
2630 WriteString( W, pmxcontrol.xml ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" );
2631
2632 WriteString( W, pmxcontrol.dtd ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" );
2633
2634 WriteString( W, pmxcontrol.title ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" );
2635
2636 IF (pmxcontrol.worknumber[0] # 0X) THEN
2637 WriteString( W, "% work number : " ); WriteString( W, pmxcontrol.worknumber ); Files.Write( W, CR );
2638 Files.Write( W, NL ); Files.Write( W, "%" );
2639 END;
2640
2641 WriteString( W, pmxcontrol.composer ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" );
2642
2643 IF (pmxcontrol.lyricist[0] # 0X) THEN
2644 WriteString( W, pmxcontrol.lyricist ); Files.Write( W, CR ); Files.Write( W, NL );
2645
2646 Files.Write( W, "%" );
2647 END;
2648
2649 WriteString( W, pmxcontrol.info ); Files.Write( W, CR );
2650 Files.Write( W, NL ); Files.Write( W, "%" );
2651
2652 IF (pmxcontrol.rights[0] # 0X) THEN
2653 WriteString( W, " Rights : " ); WriteString( W, pmxcontrol.rights ); Files.Write( W, CR ); Files.Write( W, NL );
2654 Files.Write( W, "%" );
2655 END;
2656 WriteString( W, pmxcontrol.software ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" );
2657
2658 part := 1; nostaves := 0;
2659 WHILE part <= maxpart DO
2660
2661 WriteString( W, "Part " ); WriteString( W, pmxcontrol.parts[part] ); WriteString( W, " : " );
2662 WriteString( W, pmxcontrol.instruments[part] ); Files.Write( W, CR ); Files.Write( W, NL );
2663 Files.Write( W, "%" ); nostaves := nostaves + attributes[part].staves; INC( part );
2664 END;
2665
2666 AllStaves( staves ); Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" ); Files.Write( W, CR );
2667 Files.Write( W, NL );
2668
2669 WriteString( W, "% nv, -noinst, nostaves per instrument" ); Files.Write( W, CR ); Files.Write( W, NL );
2670
2671 WriteLInt( W, nostaves ); (* nv *)
2672 WriteLInt( W, -maxpart ); (* noinst *)
2673 i := maxpart;
2674 WHILE i > 0 DO WriteLInt( W, staves[i] ); DEC( i ) END;
2675 Files.Write( W, CR ); Files.Write( W, NL );
2676
2677 WriteString( W, "% mtrnuml,mtrdenl,mtrnmp,mtrdnp,xmtrnum0,isig" ); Files.Write( W, CR );
2678 Files.Write( W, NL );
2679
2680 WriteLInt( W, attributes[1].beats ); (* mtrnuml *)
2681 WriteLInt( W, pmxtype( attributes[1].beattype ) ); (* mtrdenl *)
2682 IF attributes[1].mtrdenp # 0 THEN WriteLInt( W, 0 ) ELSE WriteLInt( W, attributes[1].beats ); END; (* mtrnump *)
2683 IF attributes[1].mtrdenp # 0 THEN WriteLInt( W, attributes[1].mtrdenp )
2684 ELSE WriteLInt( W, attributes[1].beattype );
2685 END; (* mtrdenp *)
2686 IF (attributes[1].pickup > 0) THEN
2687 xmtrnum0 := attributes[1].pickup/attributes[1].divisions;
2688 IF attributes[1].beattype = 2 THEN xmtrnum0 := xmtrnum0/2;
2689 ELSIF attributes[1].beattype = 8 THEN xmtrnum0 := xmtrnum0*2;
2690 ELSIF attributes[1].beattype = 16 THEN xmtrnum0 := xmtrnum0*4;
2691 ELSE
2692 END;
2693
2694 ELSE xmtrnum0 := 0.;
2695 END;
2696 Strings.RealToStr( xmtrnum0, xmtrnum0s ); Files.Write( W, BLANK );
2697 WriteString( W, xmtrnum0s ); (*xmtrnum0 *)
2698 WriteLInt( W, attributes[maxpart].fifth ); (* isig *) (* this is the concert key *)
2699 Files.Write( W, CR ); Files.Write( W, NL ); Files.Write( W, "%" ); Files.Write( W, CR ); Files.Write( W, NL );
2700
2701 WriteString( W, "% npages,nsyst,musicsize,fracindent " ); Files.Write( W, CR ); Files.Write( W, NL );
2702
2703 WriteLInt( W, 0 ); WriteLInt( W, 5 ); WriteLInt( W, 16 ); Files.Write( W, BLANK ); WriteString( W, "0.07" );
2704 part := maxpart;
2705 WHILE (part >= 1) DO
2706 Files.Write( W, CR ); Files.Write( W, NL );
2707 IF pmxcontrol.instruments[part] = "Acoustic Grand Piano" THEN
2708 COPY( "Piano", pmxcontrol.instruments[part] );
2709 END;
2710 WriteString( W, pmxcontrol.instruments[part] ); DEC( part );
2711 END;
2712 Files.Write( W, CR ); Files.Write( W, NL );
2713
2714 i := nostaves - 1;
2715 WHILE i >= 0 DO part := partstaff[i, 0]; staff := partstaff[i, 1]; (* Out.Ln();
2716
2717 Out.String( "control data : i, part, staff, sign, line, clef special clef " ); Out.Int( i, 5 ); Out.Int( part, 5 );
2718 Out.Int( staff, 5 ); *)
2719
2720 b.clefPMX( attributes[part].clefsign[staff], SHORT( attributes[part].clefline[staff] ), clef, clefspec[i] );
2721 lastclef[i] := clef; Files.Write( W, clef );
2722 DEC( i );
2723 END;
2724
2725 Files.Write( W, CR ); Files.Write( W, NL ); WriteString( W, "./" ); Files.Write( W, CR ); Files.Write( W, NL );
2726
2727 WriteString( W, "Tt" ); Files.Write( W, CR ); Files.Write( W, NL );
2728
2729 WriteString( W, pmxcontrol.title ); Files.Write( W, CR ); Files.Write( W, NL );
2730
2731 WriteString( W, "Tc" ); Files.Write( W, CR ); Files.Write( W, NL );
2732
2733 WriteString( W, pmxcontrol.composer ); Files.Write( W, CR ); Files.Write( W, NL ); WriteString( W, "Abepl" );
2734 Files.Write( W, CR ); Files.Write( W, NL ); i := 0;
2735 WriteString(W,"\\input musixper\"); Files.Write( W, CR ); Files.Write( W, NL );
2736 WHILE i < nostaves DO
2737 IF clefspec[i] = "p" THEN Out.Ln(); Out.String("percussion");Out.Int(i,5); Out.Char(clefspec[i]); Out.Int(maxpart-i,5);
2738 b.percussionclef( maxpart - i , perclef, perline ); WriteString( W, perclef ); Files.Write( W, CR );
2739 Files.Write( W, NL ); WriteString( W, perline ); Files.Write( W, CR );
2740 Files.Write( W, NL );
2741
2742 END;
2743 INC( i );
2744 END;
2745 (* IF pmxcontrol.a3paper THEN *)
2746 WriteString( W, "%%w277m" ); Files.Write( W, CR ); Files.Write( W, NL ); WriteString( W, "%%h390m" );
2747 Files.Write( W, CR ); Files.Write( W, NL );
2748 (* END; *)
2749
2750
2751 (* Outclef; *)
2752 (* Files.Close( f ); Files.Register( f ); *)
2753 END ControlData;
2754
2755
2756 PROCEDURE pmxDirections( idir, dirtypenr: LONGINT; VAR res: ARRAY OF CHAR );
2757 (* determines the Direction-string to be appended to a note in the PMX file. *)
2758 VAR dirtype: CHAR;
2759 height: ARRAY 3 OF CHAR;
2760 BEGIN
2761 b.loesch( res ); dirtype := directions[idir, dirtypenr].dirtype;
2762
2763 CASE dirtype OF
2764 "w":
2765 IF (Strings.Length( directions[idir, dirtypenr].text ) > 0) THEN
2766 IF (directions[idir, dirtypenr].note = 0) THEN directions[idir, dirtypenr].note := 1 END; (* &&&&& *)
2767 IF directions[idir, dirtypenr].placement = "h" THEN COPY( "12", height );
2768 ELSIF directions[idir, dirtypenr].placement = "l" THEN COPY( "-6", height );
2769 END;
2770 COPY( " \zcharnote{", res ); Strings.Append( res, height ); Strings.AppendCh( res, "}" );
2771 Strings.AppendCh( res, "{" ); Strings.Append( res, directions[idir, dirtypenr].text );
2772 Strings.Append( res, "}\" );
2773 END;
2774 | "d":
2775
2776 PMXdyn( directions[idir, dirtypenr].dyntype, res );
2777 | "h":
2778 PMXdyn( directions[idir, dirtypenr].wedgetype, res );
2779 | "p":
2780 b.loesch( res );
2781 IF directions[idir, dirtypenr].pedaltype = "start" THEN COPY( " \PED\ ", res );
2782 ELSIF directions[idir, dirtypenr].pedaltype = "stop" THEN COPY( " \DEP\ ", res );
2783 END;
2784 | "s": b.loesch(res); COPY (" oG ",res);
2785
2786
2787 | "c": b.loesch(res); COPY (" oC ",res);
2788 ELSE Out.Ln(); Out.String( "Direction type " ); Out.Char( dirtype ); Out.String( " not implemented." )
2789
2790 END;
2791 END pmxDirections;
2792
2793 PROCEDURE AnalyzeXML2( VAR R: Files.Rider );
2794 (* Decodes MusicXML and stores data in a linked list. *)
2795 VAR dummy: ARRAY 256 OF CHAR; (* geaendert von 128. 28.07.2019 *)
2796 rec, rec1: ARRAY 256 OF CHAR;
2797
2798 tag, endtag, between: ARRAY 256 OF CHAR;
2799 note, voice, staff, savenote, novalues, length: LONGINT;
2800
2801 names, values: ARRAY 10 OF ARRAY 32 OF CHAR; (* Change 9.11.2016 32->64 *)
2802
2803
2804 BEGIN
2805
2806 attnum := 0; dirnum := 0; part := 0; measure := 0; note := 0; voice := 0;
2807
2808 (******************** Read XML-Information ****************************)
2809 b.ReadUntilTx( R, ">", pmxcontrol.xml ); Out.Ln(); Out.String( pmxcontrol.xml );
2810 b.ReadUntilTx( R, NL, dummy );
2811
2812 b.ReadUntilTx( R, ">", pmxcontrol.dtd ); Out.Ln(); Out.String( pmxcontrol.dtd );
2813 b.ReadUntilTx( R, NL, dummy );
2814
2815 WHILE ~R.eof (* & ( itags < 10) *) DO (* Loop over tags *)
2816 b.ReadRecn( R, rec, length ); (* Files.Read(R,c); Versuch zur Loesung eines Problems *)
2817
2818 (* Out.Ln(); Out.String("nach ReadRecn : "); Out.Int(itags,5); Out.Char("|"); Out.String(rec); Out.Char("|"); *)
2819 IF length = 0 THEN Out.Ln(); Out.String("empty record ");
2820 ELSIF length > 0 THEN
2821
2822 IF ~R.eof & (length > 0) & (rec[Strings.Length( rec ) - 1] # ">") THEN
2823 b.ReadRecn( R, rec1, length ); Strings.AppendCh( rec, BLANK ); Strings.Append( rec, rec1 );
2824 length := Strings.Length( rec );
2825 END;
2826 (* Out.Ln(); Out.Int(itags,5); Out.String(" rec : "); Out.String(rec); *)
2827 IF (* (rec[1] # "/") & *) (rec[1] # "!") THEN INC( itags );
2828 (* problem with lilypond test data *)
2829 IF tag = "<identification>" THEN b.SkipUntilPattern( R, endtag ); END;
2830 (*****************************************************************)
2831 b.AnalyzeTag2( rec, tag, endtag, between, names, values, novalues );
2832
2833 (* Out.Ln();Out.Int(zaehler,6); Out.String(rec); Out.String(tag); INC(zaehler); *)
2834 (*+******************************************************************)
2835 (* Out.Ln();Out.Int(itags,5); Out.Char("|");Out.String(tag); *)
2836
2837 (* IF (tag = printtag) THEN SkipUntilPattern( R, endtag ) END; *)
2838 (* print information not useful for PMX *)
2839 (* Verursacht ABbruch bei bestimmten Scans *)
2840 IF (tag = credittag) THEN b.SkipUntilPattern( R, endtag ) END; (* credit information not useful for PMX *)
2841 IF (tag = defaultstag) THEN b.SkipUntilPattern( R, endtag ) END;
2842 (* defaults information not useful for PMX *)
2843 IF (tag = "<appearance>") THEN b.SkipUntilPattern( R, endtag ) END;
2844 (* appearance information not useful for PMX *)
2845
2846
2847 IF (tag = parttag) THEN
2848 INC( part ); COPY( values[0], partlabel[part] );
2849 (* part :=
2850 ORD( values[0, 1] ) - 48; old code, only one digit for part *)
2851 (* ExtractDigits( values[0], digits ); Strings.StrToInt( digits, part ); *)
2852 (* Out.Ln(); Out.String (" global id of part : "); Out.Int(part,5); *)
2853 note := 0; maxpart := b.Max( part, maxpart ); voice := 0; staff := 0; measure := 0; savenote := 0;
2854 staves[part] := 1;
2855 END;
2856 IF (tag = measuretag) THEN
2857 (* Strings.StrToInt( values[0], measure ); *)
2858 IF measure < measurelimit THEN
2859 INC( measure ); lastnote := 0; note := 0; maxnote[part, 1, measure] := 0;
2860 maxnote0[part, 1, measure] := 0; maxnote[part, 2, measure] := 0; voice := 0;
2861 minnote[part, 1, measure] := 100; maxnote0[part, 2, measure] := 0;
2862 minnote[part, 2, measure] := 100;
2863 (* maxnote total count of notes/rests/forwards in part,staff,measure.
2864 maxnote0 total count of notes/rests/forwards in part,staff,measure for voice=0. *)
2865
2866
2867 (* Out.Ln(); Out.String (" global id of measure : "); Out.Int(measure,5); *)
2868 maxmeasure := b.Max( measure, maxmeasure ); voice := 0; staff := 0;
2869 (* attnum := 0; dirnum := 0; *)
2870 ELSE Out.Ln(); Out.String( "maximum measure reached; HALT! " ); HALT( 20 );
2871 END;
2872 END;
2873 IF (tag = stavestag) THEN staves[part] := 1; Strings.StrToInt( between, staves[part] ); END;
2874 IF (tag = directiontag) THEN dirnum := lastdirnum; INC( dirnum ); maxdir := b.Max( maxdir, dirnum ); END;
2875 IF (tag = eodirectiontag) THEN lastdirnum := dirnum; dirnum := 0; END;
2876 (*********************************************************************************)
2877 IF (tag = attributestag) THEN attnum := lastattnum; INC( attnum ); END;
2878 IF (tag = eoattributestag) THEN lastattnum := attnum; attnum := 0; END;
2879 (**********************************************************************************)
2880 IF (tag = notetag) OR (tag = forwardtag) THEN note := lastnote; INC( note ); END; (* Aenderung27. April *)
2881 IF (tag = eonotetag) THEN lastnote := note; note := 0 END;
2882 (**********************************************************************************)
2883 IF (tag = "<forward>") THEN (* <forward ist ein blind rest> *)
2884 note := lastnote; INC( note ); INC( lastnote ); (* Out.Ln(); Out.String( "note after forward " );
2885 Out.Int( part, 5 ); Out.Int( staff, 5 ); Out.Int( voice, 5 ); Out.Int( measure, 5 ); Out.Int( note, 5 ); *)
2886 b.StoreTag( itags, notetag, eonotetag, part, voice, measure, note, attnum, dirnum, lastnote, novalues, names, values, between );
2887 (********************************************************************************)
2888 (*************************Store Information in Tag "new"******************************)
2889 INC( itags );
2890 b.StoreTag( itags, "<rest/>", eonotetag, part, voice, measure, note, attnum, dirnum, lastnote, novalues, names, values, between );
2891
2892 INC( itags );
2893 END;
2894 b.StoreTag( itags, tag, endtag, part, voice, measure, note, attnum, dirnum, lastnote, novalues, names, values, between );
2895 IF (tag = "</forward>") THEN
2896 INC( itags );
2897 b.StoreTag( itags, eonotetag, eonotetag, part, voice, measure, note, attnum, dirnum, lastnote, novalues, names, values, between );
2898 END;
2899 END;
2900 END;
2901 END;
2902 part := 1;
2903 WHILE part <= maxpart DO
2904 nostaves := nostaves + staves[part]; (* Aenderung 5.11.2015 *)
2905 INC( part );
2906 END;
2907
2908 END AnalyzeXML2;
2909 (* PROCEDURE ListMeasure*;
2910 VAR i, measure : INTEGER;
2911 BEGIN
2912 Out.Ln(); Out.String("ListMeasure"); Out.Ln();
2913
2914 i := 1; WHILE i < maxmeasure DO Out.Ln(); Out.Int(i,5); INC(i); measure := i;
2915 Out.Char( measures[measure].clefchange[1]);
2916 Out.Char( measures[measure].clefchange[2]);
2917 Out.Char( measures[measure].clefchange[3]);
2918 Out.Char( measures[measure].clefchange[4]);END;
2919 END ListMeasure; *)
2920
2921
2922
2923
2924 BEGIN
2925 COPY( "<part>", parttag ); COPY( "<measure>", measuretag ); COPY( "<attributes>", attributestag );
2926 COPY( "</attributes>", eoattributestag ); COPY( "<divisions>", divisionstag ); COPY( "<key>", keytag );
2927 COPY( "<fifths>", fifthstag ); COPY( "<time>", timetag ); COPY( "<beats>", beatstag );
2928 COPY( "<beat-type>", beattypetag ); COPY( "<staves>", stavestag ); COPY( "<clef>", cleftag );
2929 COPY( "<sign>", signtag ); COPY( "<line>", linetag ); COPY( "<clef-octave-change>", clefoctavetag );
2930 COPY( "<note>", notetag ); COPY( "<pitch>", pitchtag ); COPY( "<step>", steptag );
2931 COPY( "<octave>", octavetag ); COPY( "<duration>", durationtag ); COPY( "<voice>", voicetag );
2932 COPY( "<type>", typetag ); COPY( "<dot/>", dottag ); COPY( "<stem>", stemtag );
2933 COPY( "<notations>", notationtag ); COPY( "<lyric>", lyrictag ); COPY( "<syllabic>", syllabictag );
2934 COPY( "<text>", texttag ); COPY( "<accidental>", accidentaltag ); COPY( "<rest/>", resttag );
2935 COPY( "<chord/>", chordtag ); COPY( "<backup>", backuptag ); COPY( "<slur>", slurtag );
2936 COPY( "<staff>", stafftag ); COPY( "<fermata>", fermatatag );
2937 COPY( "<print>", printtag ); COPY( "<direction>", directiontag ); COPY( "<tied>", tiedtag );
2938 COPY( "<beam>", beamtag ); COPY( "<tuplet>", tuplettag ); COPY( "<staccato/>", staccatotag );
2939 COPY( "<words>", wordstag ); COPY( "<repeat>", repeattag ); COPY( "</note>", eonotetag );
2940 COPY( "</measure>", eomeasuretag ); COPY( "<barline>", barlinetag ); COPY( "<ending>", endingtag );
2941 COPY( "<line>", cleflinetag ); COPY( "<actual-notes>", actualtag ); COPY( "<normal-notes>", normaltag );
2942 COPY( "<bar-style>", barstyletag ); COPY( "<dynamics>", dynamicstag ); COPY( "<work>", worktag );
2943 COPY( "<identification>", identificationtag ); COPY( "<defaults>", defaultstag ); COPY( "<credit>", credittag );
2944 COPY( "<grace/>", gracetag ); COPY( "</direction>", eodirectiontag ); COPY( "<grace>", gracetag2 );
2945 COPY("<cue/>",cuetag);
2946 (* initialize notes type conversion XML -> PMX *)
2947 pmxdur[0] := "0"; pmxdur[1] := "2"; pmxdur[2] := "4"; pmxdur[3] := "8"; pmxdur[4] := "1"; pmxdur[5] := "3";
2948 pmxdur[6] := "6"; pmxdur[7] := "7"; (*128th note ? *)
2949
2950 (* Initialization of voices count *)
2951 i := 0; j := 0; ingrace2pmx := 0; NEW( directions ); NEW( measures ); NEW( voicemeasure );
2952 NEW( minvoice ); NEW( maxvoice ); NEW( notes ) ;
2953
2954 itags := 0; lfdnr := 1; (* outarray(minvoice); *)
2955 (* Initialize tie numbering *)
2956 i := 0;
2957 WHILE i < 24 DO
2958 j := 0;
2959 WHILE j < 10 DO INCL( b.tieunusdnum[i, 0], j ); INCL( b.tieunusdnum[i, 1], j ); INC( j ); END;
2960 INC( i );
2961 END;
2962 (* Initialization of notes counter *)
2963
2964 part := 0;
2965 WHILE part < 24 DO
2966 measure := 1;
2967 WHILE measure < measurelimit DO
2968 maxnote[part, 1, measure] := 0;
2969 maxnote[part, 2, measure] := 0;
2970 minnote0[part, 1, measure] := 100;
2971 minnote0[part, 2, measure] := 100;
2972 minnote1[part, 1, measure] := 100;
2973 minnote1[part, 2, measure] := 100;
2974 minnote[part, 1, measure] := 100;
2975 minnote[part, 2, measure] := 100;
2976
2977 maxnote0[part, 2, measure] := 0;
2978 maxnote0[part, 1, measure] := 0;
2979 maxnote1[part, 2, measure] := 0;
2980 maxnote1[part, 1, measure] := 0;
2981 minvoice[part, measure] := 10;
2982 maxvoice[part, measure] := 0;
2983 INC( measure );
2984 END;
2985 INC( part );
2986 END;
2987 unix := TRUE; (* CRLF end of line; for LF end of line set unix := TRUE. *)
2988 b.unix := unix; (* inform MODULE "b" about end of line character. *)
2989 (********************* Read CommandLine ***************)
2990 (* commandO; never activate call externally for Oberon-Version ***********)
2991 (*****************************************************)
2992 (* commandX; *) (* activate for Windows-Exe Version *******)
2993 (**************** ******************************)
2994 CommandU; (* activate for Linux-Binary Version *************)
2995
2996 END Testbed.