-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathmuscript_lua
More file actions
executable file
·5311 lines (5119 loc) · 189 KB
/
muscript_lua
File metadata and controls
executable file
·5311 lines (5119 loc) · 189 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
#!/usr/local/bin/lua
-- muscript: typesets music scores into PostScript. Peter Billam, may1994
-- www.pjb.com.au/muscript - and into MIDI apr2005, and into XML jan2007
---------------------------------------------------------------------
-- This Lua5 script is Copyright (c) 2015, Peter J Billam --
-- www.pjb.com.au --
-- --
-- This script is free software; you can redistribute it and/or --
-- modify it under the same terms as Lua5 itself. --
---------------------------------------------------------------------
Version = '3.3f for Lua5' -- # ps_pagenum converts explicitly to integer
VersionDate = '19may2018'
--require 'DataDumper'
local concat = table.concat
local find = string.find
local match = string.match
local gmatch = string.gmatch
local sub = string.sub
local gsub = string.gsub
-- Beginning of Configuration Stuff: mostly relative to stave height ...
SpaceAtBeginningOfBar = 0.60
AccidentalBeforeNote = 0.40
AccidentalDxInKeysig = 0.20
BlackBlobHalfWidth = 0.17
BlackBlobHalfHeight = 0.113
WhiteBlobHalfWidth = 0.183
BlobQuarterWidth = 0.085 -- 2.8z
WhiteBlobHalfHeight = 0.122
SmallNoteRatio = 0.61
SmallStemRatio = 0.76
StemFromBlobCentre = 0.176
DotRightOfNote = 0.36 -- 3.2m
DotRightOfRest = 0.29 -- 3.2m
DotAboveNote = 0.06
NoteShift = 0.28
AccidentalShift = 0.19
DoubleFlatSpacing = 0.25
SpaceLeftOfClef = 0.40
SpaceRightOfClef = 0.90
SpaceForClef = 0.80
SpaceForTimeSig = 0.50
SpaceForFatTimeSig = 0.60
SpaceAfterKeySig = 0.10
SpaceForStartRepeat = 0.35
SpaceForEndRepeat = 0.10
SpaceAtEndOfBar = 0.00
TieAfterNote = 0.17
TieAboveNote = 0.20
TieShift = 0.60
TieDy = 0.30
TieOverhang = 0.32
MustSquashTie = 0.80
MustReallySquashTie = 0.50
MaxTieGradient = 0.55 -- dimensionless; dy/dx
TextBelowStave = 0.50
TextSize = 0.55
SmallFontRatio = 0.707
StemLength = 0.85
OptionClearance = 0.19 -- 0.38
OptionDyDflt = 0.35
OptionDy = { dot=0.25, tenuto=0.26, upbow=0.43, gs=0.55,
blank=0.25, Is=0.35, is=0.33, bs=0.35, rs=0.33, I=0.47, i=0.45,
b=0.47, r=0.45, dim=0.0, cre=0.0, ['*']=0.35 }
MinBeamClearance = 0.70
FlatHalfHeight = 0.42 -- 3.2p
SharpHalfHeight = 0.28 -- 3.2p
BeamWidth = 0.13 -- used in ps_beam and in DATA
BeamSpacing = 0.22
MaxBeamStub = 0.35
BeamGapMult = 0.85 -- 3.2p
TailSpacing = 0.24
MaxBeamGradient = 0.45 -- dimensionless; dy/dx
SegnoHeight = 0.90
RegularFont = 'Times-Roman-ISO'
BoldFont = 'Times-Bold-ISO'
ItalicFont = 'Times-Italic-ISO'
BoldItalicFont = 'Times-BoldItalic-ISO'
PedalFont = 'ZapfChancery-MediumItalic'
-- XXX the next two should scale with systemsize, or boundarybox ?
HeaderFontSize = 9 -- in point
TitleFontSize = 17.5 -- in point
AmpleSysGap = 0.15 -- relative to page height
LetterFactor = 0.94074 -- US letter height relative to A4
LetterMargin = 8.4 -- in point
-- MIDI stuff ....
TPC = 96 -- MIDI Ticks Per Crochet
DefaultLegato = 0.85 -- MIDI default length of a crochet
DefaultVolume = 100 -- MIDI default volume (0..127)
-- End of Configuration Stuff.
-- use Text::ParseWords;
-- Command-line options ...
PageSize = 'a4'
Strip = false
Quiet = false
MIDI = nil
XmlOpt = false
PrePro = false
MidiBarlines = false
------ some globals set by initialise() -------------
NoteTable = {}
Ytable = {}
Nbeats = {}
Intl2en = {}
-- Other globals
Epsilon = 0.0005 -- less than .001 for good word spacing
TTY = nil -- filehandle for /dev/tty
PageNum = 0
Ibar = 0
Istave = 1 -- in Perl, CurrentStaveNum was the same but as a string
BarType = {}
CurrentPulse = 1 -- in Quarters
CurrentPulseText = 'cro'
Stave2clef = {}
Stave2channels = {} -- 3.1v now a hash of lists
Stave2volume = {}
Stave2pan = {}
Stave2bend = {} -- 3.2
Stave2transpose = {}
Stave2legato = {}
Stave2nullkeysigDx = {} -- 2.9y
Cha2transpose = {[0]=0,0,0,0,0,0,0,0,0,0,0,0,0,0,0} -- 3.1u see midi_global
MidiScore = {} -- list
MidiTempo = nil -- starts at nil, needed by midi_global & midi_timesig
OldMidiTempo = nil
MidiBarParts = '2.4'
MidiTimesig = ''
TicksPerMidiBeat = 0
TicksPerCro = 96 -- for debugging
CrosSoFar = 0
CrosPerPart = 0
Nstaves = {}
Nblines = {} -- number of barlines on this system
Nparts = {} -- used by newsystem(), newstave(), ps_event(), ps_beat2x()
Xpart = {} -- Xpart[ipart] within the current bar
Nbars = {} -- needed by bars() and newbar()
Keysig = {} -- [Istave] ; it's local within newstave() but persistent
TicksAtBarStart = 0
TicksThisBar = 0
MidiExpression = {} -- dict
XmlTimesig = nil
Proportion = {} -- shared by PS and XML
PartShare = {} -- shared by newsystem(), newstave(), bars()
StartBeamUp = false -- used by ps_event() and ps_note()
StartBeamDown = false -- used by ps_event() and ps_note()
StartedSlurs = {}
StartedTies = {} -- StartedTies[table.concat({Istave,starttie,cha},' ')]
-- ={'note',begin,fullduration,cha,note,velocity,pitch}
BeamUp = {} -- list
BeamDown = {} -- list
LineNum = 0
Accidentalled = {}
Options = {}
Opt_Cache = {} -- hash of lists
OptionMustGoBelow = { -- 3.1n
['P']=true, ['Ped']=true, ['*']=true, ['Sos']=true, ['*Sos']=true,
['Una']=true, ['Tre']=true,
}
DefaultStem = nil -- for this stave
Ystave = {} -- dict
local Ystv = nil -- timesaver
MaxStaveHeight = {}
StaveHeight = {}
local StvHgt = 0 -- timesaver for StaveHeight[Isyst][Istave]
Xbar = {}
GapHeight = {}
YblineBot = {{},}
YblineTop = {{},}
Isyst = 0
-- Nsystems = 0 -- just use RememberNsystems
RememberSystemsSizes = nil
RememberNsystems = nil
RememberHeader = {}
RememberBarsString = nil
RememberNbars = nil
Xstart = {} -- Xstart[concat({'tie',Isyst,Istave,itie},' ')] (or 'slur')
Ystart = {}
JustDidNewsystem = false
Xml = {} -- Policy: all keys and all values will be strings !
XmlDuration = {}
XmlAccidental = {}
Accidental2alter = {}
XmlDynamics = { p=true, pp=true, ppp=true, pppp=true, ppppp=true,
pppppp=true, f=true, ff=true, fff=true, ffff=true, fffff=true,
ffffff=true, mp=true, mf=true, sf=true, sfp=true, sfpp=true,
fp=true, rf=true, rfz=true, sfz=true, sffz=true, fz=true,
}
XmlCache = {} -- cache for music-data in a measure, to count staves
Midline = {} -- dict
Line2step = {} -- dict -- for shifting rests in xml
-- SlurOrTie = {} -- dict
SlurOrTieShift = {} -- dict
PS_Prolog = nil -- will be set later if MIDI is not defined
PS_prologAlready = false
Midi_off = false
MidiPedal = {} -- 3.0b
MidiSosPed = {} -- 3.0g
MidiUnaPed = {} -- 3.1n
Vars = {} -- set by set_var, sets up generators etc
RabbitSequence = {0,1,0,0,1,0,1,0, 0,1,0,0,1}
OldRabbitSequence = {0,1,0,0,1,0,1,0}
AabaSequence = {0,0,1,0, 0,0,1,0, 1,1,0,1, 0,0,1,0}
VariableFindRE = "^%s*%$[A-Z][A-Z0-9]*%s*==?%s*.+$"
VariableSetRE_f = "^%s*%$[A-Z][A-Z0-9]*%s*==?%s*.+$"
VariableSetRE_m = "^%s*%$([A-Z][A-Z0-9]*)%s*(==?)%s*(.+)$"
VariableGetRE_f = "%$[A-Z][A-Z0-9]*"
VariableGetRE_m = "%$([A-Z][A-Z0-9]*)"
VarArraySetRE = "^$([A-Z][A-Z0-9]*)(%d)-(%d)%s*(==?)%s*(.+)$"
-- next 2 lines used by ps_event() and ps_y_above_note() :
HighestStemUp = 0 ; HighestStemDown = 0 ; HighestNoStem = 0
LowestStemUp = 1000; LowestStemDown = 1000; LowestNoStem = 1000
-- "boundingbox" can override these ...
lmar = 40 -- these four for system-layout
rmar = 565
TopMar = 781
BotMar = 60
HeadMar = 811 -- for header and footer text
FootMar = 30
Lmargin = {}
Rmargin = {}
if not MIDI and not XmlOpt then PS_Prolog = [[
%%Creator: muscript $Version
%%EndComments
%
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
% This music was typeset by muscript, version: $Version. %
% Muscript was written by Peter Billam. See: www.pjb.com.au/muscript %
%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
%
%%BeginProlog
%%BeginResource: procset muscript
/blackblob { % usage: x y staveheight blackblob
gsave 3 1 roll translate
dup $BlackBlobHalfWidth mul exch $BlackBlobHalfHeight mul scale newpath
0 0 1 0 360 arc fill grestore
} bind def
/whiteblob { % usage: x y staveheight whiteblob
gsave 3 1 roll translate 0.14 setlinewidth
dup $WhiteBlobHalfWidth mul exch $WhiteBlobHalfHeight mul scale newpath
0 0 1 280 30 arc fill 0 0 1 100 210 arc fill
0 0 1 0 360 arc stroke grestore
} bind def
/breve { % usage: x y staveheight breve
gsave 3 1 roll translate $WhiteBlobHalfWidth mul dup scale newpath
0.1 setlinewidth -1.2 -1 moveto -1.2 1 lineto 1.2 -1 moveto
1.2 1 lineto stroke newpath 0.3 setlinewidth
-1.2 -0.4 moveto 1.2 -0.4 lineto -1.2 0.4 moveto 1.2 0.4 lineto
stroke grestore
} bind def
/dot { % usage: x y staveheight dot
gsave 3 1 roll translate dup scale newpath
0 0 0.04 0 360 arc fill grestore
} bind def
/doubledot { % usage: x y staveheight doubledot
gsave 3 1 roll translate dup scale newpath
0 0 0.04 0 360 arc fill newpath 0.2 0 0.04 0 360 arc fill grestore
} bind def
/tripledot { % usage: x y staveheight tripledot 3.3c
gsave 3 1 roll translate dup scale newpath
0 0 0.04 0 360 arc fill newpath 0.2 0 0.04 0 360 arc fill
newpath 0.4 0 0.04 0 360 arc fill grestore
} bind def
/stave { % usage: x_left x_right y_topline staveheight stave
/staveheight exch def /first exch def /x_right exch def /x_left exch def
/second first staveheight 0.25 mul sub def
/third first staveheight 0.5 mul sub def
/fourth first staveheight 0.75 mul sub def
/fifth first staveheight sub def
.015 staveheight mul setlinewidth newpath
x_left first moveto x_right first lineto
x_left second moveto x_right second lineto
x_left third moveto x_right third lineto
x_left fourth moveto x_right fourth lineto
x_left fifth moveto x_right fifth lineto stroke
} bind def
/ledger { % usage: x y staveheight ledger
/staveheight exch def /y exch def /x exch def
/x_left x staveheight 0.28 mul sub def
/x_right x staveheight 0.28 mul add def
.015 staveheight mul setlinewidth
newpath x_left y moveto x_right y lineto stroke % grestore
} bind def
/barline { % usage: x y_top y_bot staveheight barline
0.02 mul setlinewidth /y_bot exch def /y_top exch def /x exch def
newpath x y_bot moveto x y_top lineto stroke
} bind def
/notestem { % usage: x y_top y_bot staveheight notestem
0.02 mul setlinewidth /y_bot exch def /y_top exch def /x exch def
newpath x y_bot moveto x y_top lineto stroke
} bind def
/quaverstemup { % usage: x y_top y_bot staveheight quaverstemup
/staveheight exch def /y_bot exch def /y_top exch def /x exch def
staveheight 0.02 mul setlinewidth
newpath x y_bot moveto x y_top lineto stroke
gsave x y_top translate staveheight dup 0.85 mul scale
quavertail grestore
} bind def
/quaverstemdown { % usage: x y_top y_bot staveheight quaverstemdown
/staveheight exch def /y_bot exch def /y_top exch def /x exch def
staveheight 0.02 mul setlinewidth
newpath x y_bot moveto x y_top lineto stroke
gsave x y_bot translate staveheight 1.2 mul -0.8 staveheight mul scale
quavertail grestore
} bind def
/quavertail {
newpath 0 0 moveto 0 -0.10 0 -0.14 0.17 -0.33 curveto
0.27 -0.40 0.25 -0.70 0.15 -0.80 curveto
0.23 -0.70 0.24 -0.38 0 -0.28 curveto closepath fill
} bind def
/beam { % usage: x_mid_left y_mid_left x_mid_right y_mid_right staveheight beam
/staveheight exch def /y_mid_right exch def /x_mid_right exch def
/y_mid_left exch def /x_mid_left exch def
/halfbeamwidth staveheight $BeamWidth mul 0.5 mul def
newpath
x_mid_left y_mid_left halfbeamwidth add moveto
x_mid_left y_mid_left halfbeamwidth sub lineto
x_mid_right y_mid_right halfbeamwidth sub lineto
x_mid_right y_mid_right halfbeamwidth add lineto
closepath fill
} bind def
/tremolando { % usage: n x_mid y_mid staveheight tremolando
/staveheight_t exch def /y_mid exch def /x_mid exch def /n exch def
/dy staveheight_t $BeamWidth mul def /dx dy 1.6 mul def
n 1 eq {
x_mid dx sub y_mid dy sub x_mid dx add y_mid dy add
staveheight_t 0.85 mul beam
} if
n 2 eq {
x_mid dx sub y_mid dy 0.0 mul add x_mid dx add y_mid dy 1.4 mul add
staveheight_t 0.75 mul beam
x_mid dx sub y_mid dy 1.4 mul sub x_mid dx add y_mid dy 0.0 mul sub
staveheight_t 0.75 mul beam
} if
n 3 eq {
/dy dy 0.7 mul def
x_mid dx sub y_mid dy 0.6 mul add x_mid dx add y_mid dy 2.6 mul add
staveheight_t 0.5 mul beam
x_mid dx sub y_mid dy sub x_mid dx add y_mid dy add
staveheight_t 0.5 mul beam
x_mid dx sub y_mid dy 2.6 mul sub x_mid dx add y_mid dy 0.6 mul sub
staveheight_t 0.5 mul beam
} if
} bind def
/bracket { % usage: x y_top y_bot staveheight bracket
/staveheight exch def /y_bot exch def /y_top exch def /x exch def
staveheight .125 mul setlinewidth
newpath x y_top moveto x y_bot lineto stroke
staveheight .03 mul setlinewidth
/radius staveheight .25 mul def
newpath x y_top radius add radius 270 350 arc stroke
newpath x y_bot radius sub radius 10 90 arc stroke
} bind def
/repeatmark { % usage: x y_top staveheight repeatmark
/staveheight exch def /y_top exch def /x exch def
gsave x y_top staveheight 0.375 mul sub translate
staveheight staveheight scale
newpath 0 0 0.06 0 360 arc fill grestore
gsave x y_top staveheight 0.625 mul sub translate
staveheight staveheight scale
newpath 0 0 0.06 0 360 arc fill grestore
} bind def
/bassclef { % usage: x y_top staveheight bassclef
/staveheight exch def /y_top exch def /x exch def
/y_f y_top staveheight 0.25 mul sub def x y_f staveheight f_clef
} bind def
/bass8vaclef { % usage: x y_top staveheight bass8vaclef
/staveheight exch def /y_top exch def /x exch def
/Times-Italic findfont staveheight 0.58 mul scalefont setfont
x staveheight 0.15 mul sub y_top staveheight 0.05 mul add moveto (8) show
/y_f y_top staveheight 0.25 mul sub def x y_f staveheight f_clef
} bind def
/bass8vabclef { % usage: x y_top staveheight bass8vabclef
/staveheight exch def /y_top exch def /x exch def
/Times-Italic findfont staveheight 0.58 mul scalefont setfont
x staveheight 0.2 mul sub y_top staveheight 1.18 mul sub moveto (8) show
/y_f y_top staveheight 0.25 mul sub def x y_f staveheight f_clef
} bind def
/f_clef { % usage: x y_f staveheight f_clef
% gsave x y_f translate staveheight staveheight scale
gsave 3 1 roll translate dup scale % 2.4f
newpath .27 .15 .04 0 360 arc fill newpath .27 -.10 .04 0 360 arc fill
newpath -.214 0 0.086 0 360 arc fill newpath % start at left
-.3 0 moveto -.3 .18 -.23 .25 -.07 .25 curveto
-.07 .23 lineto -.21 .23 -.26 .16 -.21 0 curveto
closepath fill newpath % start at top
-.07 .25 moveto .11 .25 .18 .11 .18 -.07 curveto
.07 -.07 lineto .07 .11 0 .23 -.07 .23 curveto
closepath fill newpath % start at right
.18 -.07 moveto .18 -.25 .01 -.49 -.29 -.59 curveto
-.3 -.58 lineto -.08 -.51 .07 -.25 .07 -.07 curveto
closepath fill newpath -.3 -.58 0.02 0 360 arc fill grestore
} bind def
/tenorclef { % usage: x y_top staveheight tenorclef
/staveheight exch def /y_top exch def /x exch def
/y_2nd y_top staveheight 0.25 mul sub def x y_2nd staveheight c_clef
} bind def
/altoclef { % usage: x y_top staveheight altoclef
/staveheight exch def /y_top exch def /x exch def
/y_mid y_top staveheight 0.5 mul sub def x y_mid staveheight c_clef
} bind def
/c_clef { % usage: x y_middle_c staveheight c_clef
/staveheight exch def /y_middle_c exch def /x exch def
gsave x y_middle_c translate staveheight staveheight scale
newpath .09 setlinewidth -.18 .5 moveto -.18 -.5 lineto stroke
newpath .024 setlinewidth -.075 .5 moveto -.075 -.5 lineto stroke
newpath -.07 0 moveto .07 .24 lineto .03 0 lineto .07 -.24 lineto
closepath fill tophalf 1 -1 scale tophalf grestore
} bind def
/tophalf {
newpath .028 setlinewidth .07 .24 moveto .07 .08 .13 .08 .16 .08 curveto
stroke newpath .07 .39 .055 0 360 arc fill newpath .015 .39 moveto
.015 .46 .05 .49 .19 .49 curveto .12 .469 lineto
.07 .469 .05 .43 .05 .39 curveto closepath fill newpath .19 .49 moveto
.23 .49 .30 .43 .30 .28 curveto .30 .14 .21 .066 .16 .066 curveto
.16 .094 lineto .21 .094 .21 .28 .21 .28 curveto
.21 .43 .19 .469 .12 .469 curveto closepath fill
} bind def
/trebleclef { % usage: x y_top staveheight trebleclef
/staveheight exch def /y_top exch def /x exch def
/y_g y_top staveheight 0.75 mul sub def x y_g staveheight g_clef
} bind def
/treble8vaclef { % usage: x y_top staveheight treble8vaclef
/staveheight exch def /y_top exch def /x exch def
/Times-Italic findfont staveheight 0.58 mul scalefont setfont
x staveheight 0.15 mul add y_top staveheight 0.3 mul add moveto (8) show
/y_g y_top staveheight 0.75 mul sub def x y_g staveheight g_clef
} bind def
/treble8vabclef { % usage: x y_top staveheight treble8vabclef
/staveheight exch def /y_top exch def /x exch def
/Times-Italic findfont staveheight 0.58 mul scalefont setfont
x staveheight 0.05 mul add y_top staveheight 1.5 mul sub moveto (8) show
/y_g y_top staveheight 0.75 mul sub def x y_g staveheight g_clef
} bind def
/g_clef { % usage: x y_g staveheight g_clef
% gsave x y_g translate staveheight staveheight scale
gsave 3 1 roll translate dup scale % 2.4f
% start at bottom left blob ...
newpath -.17 -.479 .086 0 360 arc fill
newpath
-.256 -.479 moveto -.256 -.58 -.17 -.643 -.12 -.643 curveto
-.12 -.617 lineto -.21 -.622 -.13 -.58 -.21 -.479 curveto
closepath fill
newpath .026 setlinewidth
-.12 -.63 moveto .07 -.63 .11 -.48 .10 -.4 curveto -.05 .75 lineto stroke
newpath % from left of top loop
-.062 .751 moveto -.1 1.1 .06 1.18 .10 1.19 curveto % top
.125 1.12 lineto .06 1.09 -.084 1.05 -.038 .749 curveto
closepath fill
newpath % start at top
.10 1.19 moveto .36 .55 -.27 .45 -.27 .10 curveto % inside of left extreme
-.3 .16 lineto -.3 .6 .25 .65 .125 1.12 curveto
closepath fill
newpath % start at left
-.3 .16 moveto -.3 -.15 -.15 -.23 .02 -.23 curveto
.02 -.21 lineto -.15 -.21 -.27 -.15 -.27 .10 curveto
closepath fill
newpath % start at bottom
.02 -.23 moveto .2 -.23 .30 -.12 .30 .04 curveto % right extreme
.265 .04 lineto .27 -.11 .2 -.21 .02 -.21 curveto
closepath fill
newpath
.30 .04 moveto .30 .16 .17 .28 .07 .28 curveto % top of body
.07 .19 lineto .17 .19 .26 .16 .265 .04 curveto
closepath fill
newpath % start at top of body
.07 .28 moveto -.15 .28 -.15 .05 -.05 -.05 curveto % end
-.10 .05 -.08 .19 .07 .19 curveto
closepath fill
grestore
} bind def
/oldtrebleclef { % usage: x y_top staveheight trebleclef
/staveheight exch def /y_top exch def /x exch def
gsave x y_top staveheight 0.75 mul sub translate
staveheight staveheight scale
newpath 0.05 setlinewidth -0.3 -0.5 moveto
0 -0.75 0.3 -0.6 -0.25 1.05 curveto 0.3 1.07 lineto
-0.6 0 -0.4 -0.25 0 -0.3 curveto
0 -0.05 0.25 270 90 arc 0 0.1 0.1 90 270 arc stroke grestore
} bind def
/timesig { % usage (eg. for 6/8): x y_top staveheight (6) (8) timesig
/botnum exch def /topnum exch def
/staveheight exch def /y_top exch def /x exch def
gsave /Times-Bold findfont staveheight 0.6 mul scalefont setfont
x topnum stringwidth pop 0.5 mul sub y_top staveheight 0.45 mul sub moveto
topnum show
x botnum stringwidth pop 0.5 mul sub y_top staveheight 0.95 mul sub moveto
botnum show grestore
} bind def
/sharp { % usage: x y staveheight sharp
gsave 3 1 roll translate dup scale newpath
0.07 setlinewidth -0.13 0.02 moveto 0.13 0.12 lineto
-0.13 -0.12 moveto 0.13 -0.02 lineto stroke newpath
0.03 setlinewidth -0.065 -0.3 moveto -0.065 0.24 lineto
0.065 -0.24 moveto 0.065 0.28 lineto stroke grestore
} bind def
/natural { % usage: x y staveheight natural
gsave 3 1 roll translate dup scale newpath
0.07 setlinewidth -0.09 0.04 moveto 0.09 0.15 lineto
-0.09 -0.15 moveto 0.09 -0.04 lineto stroke
newpath 0.03 setlinewidth -0.09 -0.15 moveto -0.09 0.3 lineto
0.09 -0.3 moveto 0.09 0.15 lineto stroke grestore
} bind def
/flat { % usage: x y staveheight flat
gsave 3 1 roll translate dup scale newpath
0.03 setlinewidth -0.07 0.45 moveto -0.07 -0.15 lineto stroke
newpath 0.05 setlinewidth
-0.07 -0.15 moveto 0.15 0 0.3 0.2 -0.07 0.08 curveto stroke grestore
} bind def
/doublesharp { % usage: x y staveheight doublesharp
gsave 3 1 roll translate dup scale newpath
-.13 -.13 moveto -.11 -.03 lineto -.03 -.02 lineto
-.03 .02 lineto -.11 .03 lineto
-.13 .13 lineto -.03 .11 lineto -.02 .03 lineto
.02 .03 lineto .03 .11 lineto
.13 .13 lineto .11 .03 lineto .03 .02 lineto
.03 -.02 lineto .11 -.03 lineto
.13 -.13 lineto .03 -.11 lineto .02 -.03 lineto
-.02 -.03 lineto -.03 -.11 lineto
closepath fill grestore
} bind def
/hemidemisemiquaverrest { % x y staveheight hemidemisemiquaverrest 3.2m
gsave 3 1 roll translate dup scale 0.03 setlinewidth
newpath -0.10 0.180 0.048 0 360 arc fill
newpath 0.03 0.37 0.22 245 295 arc -0.02 -0.29 lineto stroke
newpath -0.107 0.065 0.048 0 360 arc fill
newpath -0.00 0.27 0.22 245 295 arc stroke
newpath -0.120 -0.060 0.048 0 360 arc fill
newpath -0.03 0.135 0.21 245 292 arc stroke
newpath -0.131 -0.175 0.048 0 360 arc fill
newpath -0.05 0.02 0.20 245 290 arc stroke grestore
} bind def
/demisemiquaverrest { % usage: x y staveheight demisemiquaverrest
gsave 3 1 roll translate dup scale 0.03 setlinewidth
newpath -0.09 0.18 0.048 0 360 arc fill
newpath 0.02 0.37 0.22 245 295 arc -0.01 -0.21 lineto stroke
newpath -0.10 0.065 0.048 0 360 arc fill
newpath -0.00 0.275 0.22 245 295 arc stroke
newpath -0.11 -0.065 0.048 0 360 arc fill
newpath -0.03 0.135 0.21 245 292 arc stroke grestore
} bind def
/semiquaverrest { % usage: x y staveheight semiquaverrest
gsave 3 1 roll translate dup scale 0.03 setlinewidth
newpath -0.09 0.07 0.05 0 360 arc fill
newpath 0.03 0.29 0.25 245 290 arc -0.02 -0.22 lineto stroke
newpath -0.11 -0.07 0.05 0 360 arc fill
newpath -0.01 0.14 0.22 245 285 arc stroke grestore
} bind def
/quaverrest { % usage: x y staveheight quaverrest
gsave 3 1 roll translate dup scale 0.035 setlinewidth
newpath -0.10 0.08 0.05 0 360 arc fill
newpath 0.02 0.29 0.24 245 290 arc -0.03 -0.2 lineto stroke
grestore
} bind def
/crochetrest { % usage: x y staveheight crochetrest
gsave 3 1 roll translate dup scale newpath
newpath 0.04 setlinewidth -0.1 0.3 moveto 0.1 0.1 lineto stroke
newpath 0.08 setlinewidth 0.03 0.17 moveto -0.07 0.07 lineto stroke
newpath 0.04 setlinewidth -0.098 0.098 moveto 0.08 -0.08 lineto
-0.1 -0.05 -0.2 -0.24 0.08 -0.3 curveto stroke grestore
} bind def
/minimrest { % usage: x y staveheight minimrest
gsave 3 1 roll translate dup scale newpath
0.07 setlinewidth -0.1 0.035 moveto 0.1 0.035 lineto stroke grestore
} bind def
/smbrest { % usage: x y staveheight smbrest
gsave 3 1 roll translate dup scale newpath
0.09 setlinewidth -0.13 -0.045 moveto 0.13 -0.045 lineto stroke grestore
} bind def
/breverest { % usage: x y staveheight breverest
gsave 3 1 roll translate dup scale newpath
0.25 setlinewidth -0.07 0.125 moveto 0.07 0.125 lineto stroke grestore
} bind def
/rightshow { % usage: x y font fontsize (string) rightshow
/s exch def /fontsize exch def /font exch def /y exch def /x exch def
gsave font findfont fontsize scalefont setfont
x s stringwidth pop sub y moveto s show grestore
} bind def
/leftshow { % usage: x y font fontsize (string) leftshow
/s exch def /fontsize exch def /font exch def /y exch def /x exch def
gsave font findfont fontsize scalefont setfont
x y moveto s show grestore
} bind def
/centreshow { % usage: x y font fontsize (string) centreshow
/s exch def /fontsize exch def /font exch def
gsave moveto font findfont fontsize scalefont setfont
gsave s false charpath flattenpath pathbbox grestore
exch 4 -1 roll pop pop s stringwidth pop -0.5 mul % dx/2
3 1 roll sub 0.5 mul % dy/2
rmoveto s show grestore
} bind def
/centrexshow { % usage: x y font fontsize (string) centrexshow
/s exch def /fontsize exch def /font exch def /y exch def /x exch def
gsave font findfont fontsize scalefont setfont
x s stringwidth pop 0.5 mul sub y moveto s show grestore
} bind def
/barnumber { % usage: x y staveheight (string) barnumber
/s exch def /staveheight exch def /y exch def /x exch def
gsave /Helvetica-Bold findfont staveheight 0.6 mul scalefont setfont
0.2 setgray x s stringwidth pop 0.5 mul sub y moveto
s show grestore
} bind def
/crescendo { % usage: x_left y_left x_right y_right staveheight crescendo
/staveheight exch def /y_right exch def /x_right exch def
/y_left exch def /x_left exch def
.015 staveheight mul setlinewidth newpath
x_right y_right staveheight 0.13 mul add moveto x_left y_left lineto
x_right y_right staveheight 0.13 mul sub lineto stroke
} bind def
/diminuendo { % usage: x_left y_left x_right y_right staveheight diminuendo
/staveheight exch def /y_right exch def /x_right exch def
/y_left exch def /x_left exch def
.015 staveheight mul setlinewidth newpath
x_left y_left staveheight 0.13 mul add moveto x_right y_right lineto
x_left y_left staveheight 0.13 mul sub lineto stroke
} bind def
/slur { % usage: x_l y_l x_r y_r updown staveheight slur
/staveheight exch def /updown exch def % updown = +1 or -1
/y_r exch def /x_r exch def /y_l exch def /x_l exch def
/dx x_r x_l sub def /dy y_r y_l sub def
dx staveheight 2.0 mul lt { % short round tie
/x_lmid x_l x_l add x_r add 0.3333 mul def
/y_lmid y_l y_l add y_r add 0.3333 mul def
/x_rmid x_l x_r add x_r add 0.3333 mul def
/y_rmid y_l y_r add y_r add 0.3333 mul def
/dy_top staveheight 0.37 mul updown mul def
/dy_bot staveheight 0.30 mul updown mul def
} { % longer flatter tie
/x_lmid x_l staveheight add def
/y_lmid y_l dy staveheight mul dx div add def
/x_rmid x_r staveheight sub def
/y_rmid y_r dy staveheight mul dx div sub def
/dy_top staveheight 0.52 mul updown mul def
/dy_bot staveheight 0.46 mul updown mul def
} ifelse
newpath x_l y_l moveto
x_lmid y_lmid dy_top add x_rmid y_rmid dy_top add x_r y_r curveto
x_rmid y_rmid dy_bot add x_lmid y_lmid dy_bot add x_l y_l curveto
closepath fill
} bind def
/fermata { % usage: x y staveheight fermata
gsave 3 1 roll translate dup scale
0 -0.11 translate
newpath 0 0 .07 0 360 arc fill
newpath -.33 -.06 moveto -.33 .41 .33 .41 .33 -.06 curveto
.31 -.06 lineto .31 .31 -.31 .31 -.31 -.06 curveto -.33 -.06 lineto fill
grestore
} bind def
/mordent { % usage: x y staveheight mordent
gsave 3 1 roll translate 0.035 mul dup scale
0.5 setlinewidth newpath -8 -2 moveto -4 2 lineto -2 -2 moveto 2 2 lineto
4 -2 moveto 8 2 lineto 0 -4 moveto 0 4 lineto stroke
newpath 1 1 moveto 2 2 lineto 5 -1 lineto 4 -2 lineto closepath fill
newpath -1 -1 moveto -2 -2 lineto -5 1 lineto -4 2 lineto closepath fill
grestore
} bind def
/trill { % usage: x y staveheight trill
/staveheight exch def gsave translate 1.2 1 scale
0 0 /$BoldItalicFont staveheight 0.5 mul (tr) centreshow grestore
} bind def
/trsharp { % usage: x y staveheight trsharp
/staveheight_sh exch def /y_sh exch def /x_sh exch def
x_sh y_sh staveheight_sh trill
x_sh staveheight_sh .28 mul add y_sh staveheight_sh .11 mul add
staveheight_sh 0.7 mul sharp
} bind def
/trflat { % usage: x y staveheight trflat
/staveheight_trf exch def /y_trf exch def /x_trf exch def
x_trf y_trf staveheight_trf trill
x_trf staveheight_trf .28 mul add y_trf staveheight_trf .11 mul add
staveheight_trf 0.7 mul flat
} bind def
/trnat { % usage: x y staveheight trnat
/staveheight_trn exch def /y_trn exch def /x_trn exch def
x_trn y_trn staveheight_trn trill
x_trn staveheight_trn .28 mul add y_trn staveheight_trn .11 mul add
staveheight_trn 0.7 mul natural
} bind def
/turn { % usage: x y staveheight turn
gsave 3 1 roll translate 0.8 mul dup scale
newpath .2 .09 .06 0 360 arc fill newpath .25 .15 moveto
.33 .06 .33 -.06 .23 -.13 curveto 0.1 -.13 .05 -.1 0 -.05 curveto
0 .05 lineto .05 .01 .1 -.09 .23 -.09 curveto
.28 -.05 .29 .05 .25 .13 curveto closepath fill
newpath -.2 -.09 .06 0 360 arc fill newpath -.25 -.15 moveto
-.33 -.06 -.33 .06 -.23 .13 curveto -0.1 .13 -.05 .1 0 .05 curveto
0 -.05 lineto -.05 -.01 -.1 .09 -.23 .09 curveto
-.28 .05 -.29 -.05 -.25 -.13 curveto closepath fill grestore
} bind def
/tenuto { % usage: x y staveheight tenuto
gsave 3 1 roll translate dup scale newpath 0.05 setlinewidth
-0.13 0 moveto 0.13 0 lineto stroke grestore
} bind def
/emphasis { % usage: x y staveheight emphasis
gsave 3 1 roll translate dup scale newpath 0.03 setlinewidth
-0.18 0.08 moveto 0.18 0 lineto -0.18 -0.08 lineto stroke grestore
} bind def
/segno { % usage: x y staveheight segno
gsave 3 1 roll translate 1.3 mul dup -1 mul scale 80 rotate 0 0 1 turn
newpath .03 setlinewidth 0.1 0.2 moveto -0.1 -0.2 lineto stroke
newpath -.05 0.16 .035 0 360 arc fill
newpath .05 -0.16 .035 0 360 arc fill grestore
} bind def
/upbow { % usage: x y staveheight upbow
gsave 3 1 roll translate dup scale newpath 0.03 setlinewidth
0.08 0.17 moveto 0.0 -0.19 lineto -0.08 0.17 lineto stroke grestore
} bind def
/downbow { % usage: x y staveheight downbow
gsave 3 1 roll translate dup scale newpath 0.03 setlinewidth
-0.12 -0.15 moveto -0.12 0.15 lineto stroke
0.12 -0.15 moveto 0.12 0.15 lineto stroke
newpath .10 setlinewidth -0.12 0.12 moveto 0.12 0.12 lineto stroke
grestore
} bind def
/guitar_string { % usage: n x y staveheight guitar_string
/staveheight exch def gsave translate staveheight dup scale
/n exch ( ) cvs def
0 0 (Helvetica-Bold) 0.36 n centreshow
newpath 0 0 0.22 0 360 arc .042 setlinewidth stroke grestore
} bind def
%%EndResource
/Times-Roman findfont dup length dict begin
{ 1 index /FID ne { def } { pop pop } ifelse } forall
/Encoding ISOLatin1Encoding def currentdict
end /Times-Roman-ISO exch definefont pop
/Times-Bold findfont dup length dict begin
{ 1 index /FID ne { def } { pop pop } ifelse } forall
/Encoding ISOLatin1Encoding def currentdict
end /Times-Bold-ISO exch definefont pop
/Times-BoldItalic findfont dup length dict begin
{ 1 index /FID ne { def } { pop pop } ifelse } forall
/Encoding ISOLatin1Encoding def currentdict
end /Times-BoldItalic-ISO exch definefont pop
/Times-Italic findfont dup length dict begin
{ 1 index /FID ne { def } { pop pop } ifelse } forall
/Encoding ISOLatin1Encoding def currentdict
end /Times-Italic-ISO exch definefont pop
%%EndProlog
]]
end
---- Here go all the functions ----
function warn(...)
local a = {}
for k,v in pairs{...} do table.insert(a, tostring(v)) end
io.stderr:write(table.concat(a),'\n') ; io.stderr:flush()
end
function warn_ln(...) warn(' line ',LineNum,': ', ...) end
function warning(...) warn('warning: ', ...) end
function die(...) warn(...) ; os.exit(1) end
function die_ln(...) warn_ln(...) ; os.exit(1) end -- 3.2w
function dump(x)
local function tost(x)
if type(x) == 'table' then return 'table['..tostring(#x)..']' end
if type(x) == 'string' then return "'"..x.."'" end
if type(x) == 'function' then return 'function' end
if x == nil then return 'nil' end
return tostring(x)
end
if type(x) == 'table' then
local n = 0 ; for k,v in pairs(x) do n=n+1 end
if n == 0 then return '{}' end
if n == #x then
local a = {} ; for i,v in ipairs(x) do a[i] = tost(v) end
return '{ '..table.concat(a, ', ')..' }'
end
local a = {} ; for k,v in pairs(x) do
a[#a+1] = tostring(k)..'='..tost(v)
end
return '{ '..table.concat(a, ', ')..' }'
end
return tost(x)
end
function round(x) return math.floor(x+0.5) end
function abs(x) if x<0 then return 0-x else return x end end
function is_empty(t)
local n=0 ; for k,v in pairs(t) do n=n+1; break end ; return n == 0
end
function split(s, pattern, maxNb) -- http://lua-users.org/wiki/SplitJoin
if not s or string.len(s)<2 then return {s} end
if not pattern then return {s} end
if maxNb and maxNb <2 then return {s} end
local result = { }
local theStart = 1
local theSplitStart,theSplitEnd = find(s,pattern,theStart)
local nb = 1
while theSplitStart do
table.insert( result, sub(s,theStart,theSplitStart-1) )
theStart = theSplitEnd + 1
theSplitStart,theSplitEnd = find(s,pattern,theStart)
nb = nb + 1
if maxNb and nb >= maxNb then break end
end
table.insert( result, sub(s,theStart,-1) )
return result
end
function printf (...) print(string.format(...)) end
function print_sp (...) -- like print() but uses spaces not tabs
local a2 = {}
for i,v in ipairs({...}) do table.insert(a2, tostring(v)) end
print(concat(a2, ' '))
end
function sorted_keys(t, f)
local a = {}
for k,v in pairs(t) do a[#a+1] = k end
table.sort(a, f)
return a
end
function parse_options(line) -- delimits by '-' respects quoting by "
if not line or line == '' then return {} end
local quotedline = gsub(line, '"[^"]-"', function(s)
return gsub(s, '-', '\a')
end)
local a = split(quotedline, '-')
for i=1,#a do a[i] = gsub( gsub(a[i],'\a','-'), '"','') end
return a
end
function parse_line(line, keep) -- only respects quoting by "
local quotedline = gsub(line, '%a"[^"]-"', function(s)
return gsub(s, '[- ]', {[' ']='\a', ['-']='\b'})
end)
local a = split(quotedline, '%s+')
for i=1,#a do a[i]=gsub(a[i],'[\a\b]',{['\a']=' ',['\b']='-'}) end
return a
end
------------------------- General muscript stuff -----------------------
function initialise ()
if not Quiet then TTY = assert(io.open('/dev/tty', 'a+')) end
Epsilon = 0.0005 -- should be less than .001 for correct word spacing
Ipage = 0
-- pitch to height-on-stave assocarray is defined for the alto clef ...
local raw_notetable = {}
if MIDI then
raw_notetable = { -- defined for alto clef
['f~~']=89, ['e~~']=88, ['d~~']=86, ['c~~']=84, ['b~']=83,
['a~']=81, ['g~']=79, ['f~']=77, ['e~']=76, ['d~']=74, ['c~']=72,
b=71, a=69, g=67, f=65, e=64, d=62, c=60,
B=59, A=57, G=55, F=53, E=52, D=50, C=48,
B_=47, A_=45, G_=43, F_=41, E_=40, D_=38, C_=36,
B__=12, A__=10,
}
for k,v in pairs(raw_notetable) do
NoteTable[k] = v
NoteTable[k..'#'] = v + 1
NoteTable[k..'b'] = v - 1
NoteTable[k..'##'] = v + 2
NoteTable[k..'bb'] = v - 2
NoteTable[k..'n'] = v -- the A#__ order is a syntax error
end
end
-- Ytable also needed by Midi, to keep track of stemup e.g. for slurs/ties
Ytable = {
['f~~']=1.625, ['e~~']=1.5, ['d~~']=1.375, ['c~~']=1.25, ['b~']=1.125,
['a~']=1.0, ['g~']=0.875, ['f~']=0.75, ['e~']=0.625, ['d~']=0.5,
['c~']=0.375, b=0.25, a=0.125, g=0.01, f=-0.125, e=-0.25,
d=-0.375, c=-0.5, B=-0.625, A=-0.75, G=-0.875, F=-1.0,
E=-1.125, D=-1.25, C=-1.375, B_=-1.5, A_=-1.625, G_=-1.75,
F_=-1.875, E_=-2.0, D_=-2.125, C_=-2.25, B__=-2.375, A__=-2.5,
}
-- note durations ... # 3.2 hds is .0625, not .0725
local en = { hds=.0625, dsq=.125, smq=.25,
qua=.5, cro=1.0, min=2.0, smb=4.0, bre=8.0, }
for k,v in pairs(en) do
Nbeats[k] = v
Nbeats[k..'2'] = v * 0.75 -- duplet
Nbeats[k..'3'] = v * 0.66667 -- triplet
Nbeats[k..'4'] = v * 0.75 -- quadruplet
Nbeats[k..'5'] = v * 0.8 -- quintuplet
Nbeats[k..'6'] = v * 0.66667 -- sextuplet
Nbeats[k..'7'] = v * 0.57142857 -- septuplet 3.1z
end
local a = {} ; for k,v in pairs(Nbeats) do -- dotted notes
a[k..'.' ] = v * 1.5
a[k..'..' ] = v * 1.75
a[k..'...'] = v * 1.875
end
for k,v in pairs(a) do Nbeats[k]=v end
a = {} ; for k,v in pairs(Nbeats) do -- tremolandi
if find(k,'^cro') or find(k,'^min') or find(k,'^smb') then
a[k..'/' ] = v -- tremolandi
a[k..'//' ] = v
a[k..'///'] = v
end
end
for k,v in pairs(a) do Nbeats[k]=v end
a = {} ; for k,v in pairs(Nbeats) do -- small notes
a[k..'-s'] = v
end
for k,v in pairs(a) do Nbeats[k]=v end
local en2intl = { hds='64',dsq='32',smq='16',
qua='8', cro='4',min='2',smb='1', }
for i,key in pairs(sorted_keys(Nbeats)) do -- International-style rhythm
-- sort means smb gets overwritten by smq, so 16-s maps to smq-s, 2.9n
local s1,s2
s1,s2 = match(key, '^([a-u][a-u][a-u])([2-6].*)$') ; if s2 then
if en2intl[s1] then Intl2en[en2intl[s1]..s2] = key end
else
s1,s2 = match(key, '^([a-u][a-u][a-u])(.*)$') ; if s2 then
if en2intl[s1] then Intl2en[en2intl[s1]..s2] = key end
end
end
end
-- foreach (sort keys %Intl2en) { warn "Intl2en{$_}=$Intl2en{$_}\n"; }
Options = {
down='downbow', ['.']='dot', emph='emphasis', gs='gs',
mordent='mordent', stac='dot', stacc='dot',
ten='tenuto', tenuto='tenuto',
tr='trill', ['tr#']='trsharp', trb='trflat', trn='trnat',
turn='turn', up='upbow',
}
-- SlurOrTie = {
-- ['(']='starttie',
-- ['{']='startslur',
-- [')']='endtie',
-- ['}']='endslur',
-- }
SlurOrTieShift = {
[""]=0, ["'"]=1, ["''"]=2, ["'''"]=3, ["''''"]=4,
[","]=-1, [",,"]=-2, [",,,"]=-3, [",,,,"]=-4,
}
if MIDI then
MidiScore = {} -- a LoL
MidiTimesig = ''
TicksPerMidiBeat = TPC
TicksAtBarStart = 0
TicksThisBar = 0 -- so as not to delay the start
MidiBarParts = '2.4' -- default guesses 4/4 at 100 cro/min
Stave2channels = {}
Istave = 1 -- 3.3a number ! not string !
elseif XmlOpt then
Stave2channels = {}
XmlTimesig = '4/4'
XmlDuration={
hds='64th',dsq='32nd',smq='16th',qua='eighth',
cro='quarter', min='half',smb='whole',bre='breve'
}