]> git.donarmstrong.com Git - lilypond.git/blob - mf/musixgen.mf
patch::: 0.0.75.jcn6: pats
[lilypond.git] / mf / musixgen.mf
1 % next changes: - redesigning accidentals
2 %               - new accents
3 %               - new gregorian symbols
4 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
5 %  this is musixgen.mf (c)
6 %
7 %  Version T.70 [March 97]
8 %               - double shap corrected by Julian Gilbey (strange paths)
9 %
10 %  Version T.59 [September 96]
11 %               - added one more gregorian symbol (126)
12 %
13 %  Version T.40 [September 95]
14 %               - corrected gregorianFclef (123)
15 %
16 %  Version 0.37 [March 95]
17 %               - introduced reverseAllabreve (122)
18 %
19 %  Version 0.25 [December 94]
20 %               - some new chars
21 %               - added the beamfonts at pos x+128 to save memory
22 %               - changed coda to be centered
23 %               - changed the flags
24 %               - changed the position of some chars to save time
25 %
26 %      ...      - trouble shooting, minor changes
27 %
28 %  Version 0.99b[April 94]
29 %               - added the new signs from Daniel Taupin
30 %
31 %  Version 0.99 [February 94]
32 %               -'bravely' changed the tfm informations to save memory
33 %               - redesigned chars 14, 15, 35, 36, 53, 71, 72, 80, 81, 86, 93
34 %               - removed * 'never used' chars 37-39, 55-57, 69-70,
35 %                                              77-79, 91-99, 101-119
36 %                         * (de)crescendi 16-23 -> now in musixlin
37 %               - introduced some new chars 0-11, 16-23, 37-39, 57, 77-79,
38 %                                           99-117
39 %               - changed the position of some chars to save memory
40 %%%%%%%%%%
41 %  this was musicgen.mf
42 %
43 %  Version 4.89 [September 93] Andreas Egler
44 %               - blacker influence now
45 %               - redesigned chars 71, 72, 53, 123
46 %
47 %  Version 4.88 [January 93] Ross Mitchell
48 %               - redesigned chars 63, 64, 65, 66
49 %
50 %  Version 4.87 [] Daniel Taupin
51 %
52 %  Version 2.00 [] Daniel Taupin
53 %
54 %  Version 1.00 [August 86] Angelika Schofer/Andrea Steinbach
55 %
56 %%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
57
58 % free positions: 125-127, 188-191, 252-255
59 % heights : 0, 0.5, 1, 1.5, 2.25, 3.25, 4, 4.75, 5.25
60 % depths  : 0, 0.5, 1, 1.5, 2.25
61
62 %{{{ This always indicates a lowres fix to avoid seperated points
63 %}}} and/or 'invisible' lines. It doesn't affect higher resolutions !!
64
65 pair pone, ptwo;
66 transform t;
67 path p;
68
69 hlthick=.2pt;
70 lthick=.4pt;
71
72 pen line_pen, med_pen, coda_pen, thin_pen;
73 med_pen:= pencircle scaled med;
74 line_pen:= pencircle scaled lthick;
75 coda_pen:= pencircle xscaled 1.25thick yscaled max(1,.75med);
76 thin_pen:= pencircle scaled max(1,.25pt);
77
78 apog_fact=.75;
79 apog_nhw#=apog_fact*nhw#;
80
81 picture save_pic, elem_pic;
82
83 %%%%%%%%%%%%%%%
84 % basic def's %
85 %%%%%%%%%%%%%%%
86
87 def savepic = save_pic:= currentpicture enddef;
88 def save_elempic = elem_pic:= currentpicture enddef;
89 def callpic = currentpicture:= save_pic enddef;
90
91 def mirror (expr pone, ptwo) =
92   currentpicture:=currentpicture reflectedabout(round(pone),round(ptwo))
93 enddef;
94
95 def add_mirror (expr pone, ptwo) =
96   addto currentpicture also currentpicture
97         reflectedabout (round(pone), round(ptwo))
98 enddef;
99
100 def call_mirror (expr pone, ptwo) = callpic; mirror (pone, ptwo) enddef;
101
102 def add_shift (expr pone, ptwo) =
103   addto currentpicture also currentpicture shifted (pone, ptwo)
104 enddef;
105
106 def call_add_shift (expr pone, ptwo) =
107   callpic; add_shift (pone, ptwo)
108 enddef;
109
110 def add_elempic (expr pone, ptwo) =
111   addto currentpicture also elem_pic shifted (pone, ptwo)
112 enddef;
113
114 def call_add_save_elempic (expr pone, ptwo) =
115   callpic; add_elempic(pone, ptwo); savepic
116 enddef;
117
118 def shift_pic (expr pone, ptwo) =
119   currentpicture:=currentpicture shifted (round(pone),round(ptwo))
120 enddef;
121
122 def fill_circle (expr diameter, zshift) =
123   fill fullcircle scaled diameter shifted zshift
124 enddef;
125
126 def fill_square (expr xwidth, ywidth, zshift) =
127   fill unitsquare xscaled xwidth yscaled ywidth shifted zshift
128 enddef;
129
130 %
131
132 def staff=
133   for i=0 upto 4:
134     pickup pencircle yscaled lthick;
135     draw (-5nhw,i*nhh)--(5nhw,i*nhh);
136   endfor
137 enddef;
138
139 def Staff=
140   for i=0 upto 4:
141     pickup pencircle yscaled lthick;
142     draw (-5nhw,(i*nhh-.5nhh))--(5nhw,(i*nhh-.5nhh));
143   endfor
144 enddef;
145
146 def upstem=
147   fill_square (lthick, 5nhh, (0,-5nhh))
148 enddef;
149
150 def downstem=
151   fill_square (lthick, 5nhh, (nhw-hlthick,0))
152 enddef;
153
154 % eobasicdefs ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
155
156 %%%%%%%
157 message ("<dots & par's>");
158 %%%%%%%
159
160 beginchar(0, 0, 0, 0); "duration dot"; % correct 3=>0 DT
161   fill_circle (1/3nhh+blacker, (1.5nhw, 0));
162   save_elempic;
163   savepic;
164 endchar;
165
166 beginchar(1, 0, 0, 0); "double duration dot";
167   call_add_shift (.5nhw, 0);
168   savepic;
169 endchar;
170
171 beginchar(2, 0, 0, 0); "triple duration dot";
172   callpic;
173   add_elempic (nhw, 0);
174 endchar;
175
176 beginchar(3, 0, nhh#, nhh#); "left parenthesis"; % correct 0=>3 DT
177   x11=x13=-.1nhw; y12=0; x12=-.3nhw; y11=-y13=-.75nhh;
178   pickup med_pen;
179   draw z11..z12..z13;
180   savepic;
181 endchar;
182
183 beginchar(4, 0, nhh#, nhh#); "right parenthesis";
184   call_mirror ((.5nhw,0),(.5nhw,1));
185 endchar;
186
187 beginchar(5, 0, nhh#, nhh#); "cautionary parentheses";
188   callpic;
189   add_mirror ((.3nhw, 0),(.3nhw, 1));
190 endchar;
191
192 beginchar(6, 0, nhh#, nhh#); "cautionary wide parentheses";% -> bb
193   callpic;
194   add_mirror ((.55nhw, 0),(.55nhw, 1));
195 endchar;
196
197 %%%%%%%
198 message("<accents>");
199 %%%%%%%
200
201 beginchar(120, 0, 1.5nhh#, 0); "harmonics";
202   pickup thin_pen;
203   draw fullcircle scaled .5nhw shifted (.5nhw, nhh);
204 endchar;
205
206 %beginchar(XX, 0, 1.5nhh#, 0); "???";
207 %  x1=0; x2=.5nhw; x3=nhw-x1; x3=x4+.25nhw; x6=x1+med;
208 %  y1=y6=y4=y3=nhh; y2=y1+nhh;
209 %  z5-z6=whatever*(z2-z1);
210 %  z5-z4=whatever*(z2-z3);
211 %  fill z1--z2--z3--z4--z5--z6--cycle;
212 %  fill_circle (thick, ((x5,y1+.5thick)));
213 %  savepic;
214 %endchar;
215
216 beginchar(20, 0, 2.25nhh#, 0); "upper sforzato";
217   x1=1/12nhw; x2=.5nhw; x3=nhw-x1; x3=x4+.25nhw; x6=x1+med;
218   y1=y6=y4=y3=nhh; y2=y1+nhh;
219   z5-z6=whatever*(z2-z1);
220   z5-z4=whatever*(z2-z3);
221   fill z1--z2--z3--z4--z5--z6--cycle;
222   savepic;
223 endchar;
224
225 beginchar(21, 0, 0, 2.25nhh#); "lower sforzato";
226   call_mirror (origin, right);
227 endchar;
228
229 beginchar(22, 0, nhh#, 0); "downbow";
230   fill_square (thin, nhh, (-thin, .4nhh));
231   fill_square (.5nhw+thin+1, .8beamht+thin, (-thin, nhh));
232   add_mirror ((.5nhw,0),(.5nhw,1));
233 endchar;
234
235 beginchar(23, 0, 1.5nhh#, 0); "upbow";
236   pickup med_pen;
237   draw (.15nhw, 1.7nhh)--(.5nhw, .2nhh);
238   add_mirror ((.5nhw,0),(.5nhw,1));
239 endchar;
240
241 beginchar(24, 0, nhh#, 0); "upper staccato";
242   fill_circle (.275nhw+blacker, (.5nhw, nhh));
243   savepic;
244 endchar;
245
246 beginchar(25, 0, 0, nhh#); "lower staccato";
247   call_mirror (origin, right);
248 endchar;
249
250 beginchar(18, 0, nhh#, 0); "upper tenuto/staccato";
251   fill_square (nhw, 1.25med, (0, 1.2nhh-.625med));
252   fill_circle (.275nhw+blacker, (.5nhw, .9nhh));
253   savepic;
254 endchar;
255
256 beginchar(19, 0, 0, nhh#); "lower tenuto/staccato";
257   call_mirror (origin, right);
258 endchar;
259
260 beginchar(26, 0, nhh#, 0); "upper portato (tenuto)";
261   fill_square (nhw, 1.25med, (0, nhh-.625med));
262   savepic;
263 endchar;
264
265 beginchar(27, 0, 0, nhh#); "lower portato (tenuto)";
266   call_mirror (origin, right);
267 endchar;
268
269 beginchar(28, 0, 1.5nhh#, 0); "upper staccatissimo";
270   rayon:= thin+.125nhh;
271   x1=x3=x2+rayon=x4-rayon=.5nhw;
272   y2=y4=y1-rayon=y3+.5nhh=1.15nhh;
273   fill z3--z4{up}..z1..{down}z2--cycle;
274   savepic;
275 endchar;
276
277 beginchar(29, 0, 0, 1.5nhh#); "lower staccatissimo";
278   call_mirror (origin, right);
279 endchar;
280
281 beginchar(30, 0, 2.25nhh#, 0); "upper marcato";
282   pickup med_pen;
283   draw (-.2nhw, 1.9nhh)--(1.2nhw, 1.5nhh)--(-.2nhw, 1.1nhh);
284   savepic;
285 endchar;
286
287 beginchar(31, 0, 0, 2.25nhh#); "lower marcato";
288   call_mirror (origin, right);
289 endchar;
290
291 %%%%%%%
292 message ("<noteheads>");
293 %%%%%%%
294
295 NHW=nhw+hlthick;
296
297 beginchar(7, 0, .5nhh#, .5nhh#); "quarter note";
298 % makeshift, expedience
299 if pixels_per_inch=600:
300   if NHW>50: corNHW=1.04*NHW; else: corNHW=1.04*NHW+1; fi
301     fill fullcircle xscaled corNHW yscaled 1.85h
302          rotated 20 shifted (.5NHW-.5, 0);
303 else:
304   corNHW=1.065*NHW;
305     fill fullcircle xscaled corNHW yscaled 1.85h
306          rotated 20 shifted (.5NHW, 0);
307 fi
308 endchar;
309
310 beginchar(8, 0, .5nhh#, .5nhh#); "half note";
311   penpos1(max(1,2hlthick), 0);
312   penpos3(max(1,2hlthick), 180);
313   penpos2(thick,-90);
314   penpos4(thick, 90);
315   -x1l = .53NHW;
316   x3l = .5NHW;
317   x2 = x4 = y1 = y3 = 0;
318   y2l =-y4l = h;
319   penstroke (z1e{up}..z2e{right}..z3e{down}..z4e{left}..cycle)
320              rotated 20 shifted (.5NHW, 0);
321 endchar;
322
323 beginchar(9, 0, .5nhh#, .5nhh#); "whole note";
324   x1= y1 = y3 = y5 = y7 = 0;
325   x3= 2x2 = 2x4 = 2x6 = 2x8 = 5/4nhw;
326   y2=-y4 = h;
327   x5= x3-x7 = x1+.375nhw-blacker;
328   y6=-y8 = y2-.1thin;
329   fill z1{curl3}..z2..{curl3}z3{curl3}..z4..{curl3}cycle;
330   unfill (z5..z6..z7..z8..cycle) rotatedaround ((x2,0), 45) shifted (.5,.5);
331 %{{{
332   currentpen:= pencircle;
333   draw rt z1{curl3}..bot z2..{curl3}lft z3{curl3}..top z4..{curl3}cycle;
334 %}}}
335   labels(range 1 thru 8);
336   savepic;
337 endchar;
338
339 beginchar(56, 0, .5nhh#, .5nhh#); "whole note with | --> |O|";
340   callpic;
341   fill_square (.6thick, nhh, (-.55thick,-.5nhh));
342   fill_square (.6thick, nhh, (5/4nhw-.05thick,-.5nhh));
343 endchar;
344
345 beginchar(32, 0, .5nhh#, .5nhh#); "brevis";% 2 whole notes
346   fill_square (5/4nhw, .25nhh, (0,.25nhh));
347   add_mirror (origin, right);
348   x1=x2=0; x3=x4=5/4nhw; y1=-y2=y3=-y4=.7nhh;
349   pickup line_pen;
350   draw z1--z2; draw z3--z4;
351   savepic;
352 endchar;
353
354 beginchar(39, 0, .5nhh#, .5nhh#); "longa";% 4 whole notes
355   callpic;
356   pickup line_pen;
357   draw (5/4nhw,-.7nhh)--(5/4nhw,-1.7nhh);
358 endchar;
359
360 beginchar(36, 0, .5nhh#, .5nhh#); "maxima";% 8 whole notes
361   fill_square (5/2nhw, .3nhh, (0,.2nhh));
362   add_mirror (origin, right);
363   pickup line_pen;
364   draw (0,.7nhh)--(0,-.7nhh); draw (5/2nhw,.7nhh)--(5/2nhw,-1.7nhh);
365 endchar;
366
367 beginchar(37, 0, .5nhh#, .5nhh#); "filled diamond";% -> triangle
368   fill unitsquare scaled (.5*sqrt(2)*NHW) rotated -45;
369 endchar;
370
371 def square (expr mw)=
372   fill_square (sqrt(2)*.5mw, max(1,thin), origin) rotated -45;
373   fill_square (sqrt(2)*.5mw, .15nhw, (0,-.15nhw)) rotated 45;
374   save_elempic;
375   mirror (origin,up);
376   mirror (origin,left);
377   shift_pic (mw+.5,0);
378   add_elempic(0,0);
379 %  mirror (origin,right);% I've seen this too, somewhere ...
380 enddef;
381
382 beginchar(38, 0, .5nhh#, .5nhh#); "unfilled diamond";% -> rimshot
383   square (NHW);
384 endchar;
385
386 beginchar(99, 0, .5nhh#, .5nhh#); "oldstyle quarter notehead up";
387   x1=x4=0; x2=x3=NHW; y1=y2=-y3=-y4=h-hlthick;
388   fill z1{dir-10}..z2--z3{dir-170}..z4--cycle;
389   savepic;
390 endchar;
391
392 beginchar(100, 0, .5nhh#, .5nhh#); "oldstyle quarter notehead down";
393   call_mirror(origin, right);
394 endchar;
395
396 beginchar(101, 0, .5nhh#, .5nhh#); "oldstyle half notehead up";
397   pthick:=.2nhh;
398   x1=0; x2=NHW; y1=y2=h-.5pthick+hlthick;
399   pickup penrazor scaled pthick rotated 90;
400   draw z1{dir-10}..z2;
401   add_shift (0, -nhh+pthick);
402   fill_square (lthick, nhh-hlthick, (0, -h+hlthick));
403   fill_square (lthick, nhh-hlthick, (nhw-hlthick, -h+hlthick));
404   savepic;
405 endchar;
406
407 beginchar(102, 0, .5nhh#, .5nhh#); "oldstyle half notehead down";
408   call_mirror(origin, right);
409 endchar;
410
411 beginchar(111, 0, .5nhh#, .5nhh#); "cross"; % -> closed hihat
412   x1=0; x2=nhw; y1=-.5nhw; y2=-y1;
413   pickup med_pen;
414   draw top rt z1--bot lft z2;
415   add_mirror((.5nhw,0),(.5nhw,1));
416   savepic;
417 endchar;
418
419 beginchar(112, 0, .5nhh#, .5nhh#); "halfcircled cross";% -> halfclosed hihat
420   callpic;
421   pickup thin_pen;
422   draw halfcircle scaled nhw shifted (.5nhw,0);
423 endchar;
424
425 beginchar(113, 0, .5nhh#, .5nhh#); "circled cross";% -> open hihat
426   callpic;
427   pickup thin_pen;
428   draw fullcircle scaled nhw shifted (.5nhw,0);
429 endchar;
430
431 def doublesharp (expr mw, xshift)=
432   x1=y2=x3=0; y1=x2=y4=.5mw; y3=.5mw-x4=.1mw;
433   z4'=.925[z3,z4]; z3'=.925[z4,z3];                        % ***
434   penpos2(max(1,thin),45);
435 %%% a 'nicer' look for 'high'res-printers gives
436 if pixels_per_inch > 500:
437   fill z1..{dir-125}z3'{dir35}..{se}z2l--z2r--(z1+(eps,0))--cycle;
438   fill z1..{dir35}z4'{dir-125}..{se}z2r--z2l--(z1-(eps,0))--cycle;   % ***
439 else :
440 %%% but this causes 'strange path' on lower resolutions
441   fill z1..{dir-110}z3'{dir30}..{se}z2l--z2r--(z1+(eps,0))--cycle;
442   fill z1..{dir20}z4'{dir-120}..{se}z2r--z2l--(z1-(eps,0))--cycle;   % ***
443 fi
444 %{{{
445   currentpen:= pencircle; draw z1--(x2+1,y2-1);% draw (x3'+1,y3'+1)--z5';
446 %}}}
447 % add_mirror ((0,.5mw),(.5mw,0));                          % ***
448   add_mirror ((.5mw,-.5mw),(.5mw,.5mw));
449   add_mirror (origin, right);
450   shift_pic (xshift, 0);
451 enddef;
452
453 beginchar(114, 0, .5nhh#, .5nhh#); "doublesharp notehead";% -> ride cymbal
454   doublesharp (.95nhw,0.025nhw);
455   savepic;
456 endchar;
457
458 beginchar(115,0, .5nhh#, .5nhh#);"circled doublesharp notehead";%->crash cymbal
459   callpic;
460   pickup thin_pen;
461   draw fullcircle scaled nhw shifted (.5nhw,0);
462 endchar;
463
464 beginchar(116, 0, .5nhh#, .5nhh#); "triangle";% -> rattle
465   x1=y1=y2=0; x2=2x3=nhw; y3=.8h;
466   pickup med_pen;
467   draw z1--z2--z3--z1;
468 endchar;
469
470 beginchar(117, 0, .5nhh#, .5nhh#); "bongo cross";
471   pickup med_pen;
472   draw (0,0)--(nhw,0);
473   draw (0.5nhw,-0.5nhw) -- (0.5nhw,0.5nhw);
474 endchar;
475
476 beginchar(118, 0, .5nhh#, .5nhh#); "rhombus";% -> shaker
477   x1=x4=y2=y4=0; y1=-y3=-h; x2=x3=NHW;
478   fill z1--z2--z3--z4--cycle;
479 endchar;
480
481 beginchar(95, 0, .5nhh#, .5nhh#); "gregorian square";
482   x1=x4=0; x2=x3=gregwidth; y1=y2=-y3=-y4=.5gregwidth-lthick;
483   fill z1{dir 15}..z2--z3{dir 165}..z4--cycle;
484   shift_pic(0,-hlthick);
485   savepic;
486 endchar;
487
488 beginchar(96, 0, .5nhh#, .5nhh#); "gregorian square left";
489   callpic;
490   fill_square (med, 1.5nhh,(0, -1.5nhh));
491 endchar;
492
493 beginchar(97, 0, .5nhh#, .5nhh#); "gregorian square right";
494   callpic;
495   fill_square (med, 1.5nhh,(gregwidth-med, -1.5nhh));
496   savepic;
497 endchar;
498
499 beginchar(124, 0, .5nhh#, .5nhh#); "porrectus";
500   x1=x4=0; x2=x3=2.5*gregwidth; y1=-y4=.5gregwidth-lthick; y2=y1-nhh; y3=y4-nhh;
501   fill z1..{right}z2--z3{left}..z4--cycle; shift_pic(0,hlthick);
502   fill_square (med, 1.5nhh,(0, -1.5nhh));
503 endchar;
504
505 beginchar(125, 0, .5nhh#, .5nhh#); "quilisma";
506   qdecalage:=.12*gregwidth;
507   x1=x4=-0.2*gregwidth; x2=x3=1.2*gregwidth;
508   y1+qdecalage=y2-qdecalage=.5gregwidth-lthick;y1=-y3; y2=-y4;
509   fill z1--z2--z3--z4--cycle;
510   pickup med_pen;
511   
512   draw z4--(z1+0.4*(z1-z4));
513   draw (0.667z4+0.333z3)--((0.667z1+0.333z2)+0.4*(z1-z4));
514   draw (0.333z4+0.667z3)--((0.333z1+0.667z2)+0.4*(z1-z4));
515   draw z3--(z2+0.4*(z1-z4));
516   shift_pic(0,-hlthick);
517 endchar;
518
519 beginchar(126, 0, .5nhh#, .5nhh#); "mirrored gregorian square";
520   x1=x4=0; x2=x3=gregwidth; y1=y2=-y3=-y4=-.5gregwidth+lthick;
521   fill z1{dir -15}..z2--z3{dir -165}..z4--cycle;
522   shift_pic(0,+hlthick);
523 endchar;
524
525
526
527 %%%%%%%
528 message ("<flags>");
529 %%%%%%%
530
531 flagw:=.8nhw;
532 flagthick:=nhh;
533 flagthin:=5thinwidth;
534
535 def flagshape
536 (expr contflag, width, height, flgthick, flgthin, shifty, flagsense) =
537   penpos1(flgthick+blacker, 90);   % .1
538   penpos2(3.25flgthin+blacker, 70);%
539   x1 = 0;                          %     .2
540   y1 = height+shifty-.5flgthick;   %
541   x2 = 3/8width;                   %         .3
542   y2 = y1-.45flgthick;             %
543   x3 = width-flgthin/2;            %      .4(.4)
544   y3 = y1-1.5flgthick;
545
546   if contflag=1:  x4 = x3-.4width; y4 = shifty;
547   else:           x4 = x3; y4 = 2.5flagthick-2flgthick; fi
548   if flagsense>0: penpos3(1.15flgthin, 35);
549   else:           penpos3(.8flgthin, 0); fi
550
551   penstroke z1e..z2e..z3e{down}..z4;
552 %{{{
553   currentpen:= pencircle; draw lft z1..z2..z3{down}..z4;
554 %}}}
555   penlabels(1,2,3,4)
556 enddef;
557
558 def mirror_flag(expr sense)= if sense<0: mirror((0,h/2),(1,h/2));fi enddef;
559
560 def cflag (expr sense) =
561   flagshape(1, flagw, 3nhh, flagthick, flagthin, 0, sense);
562   mirror_flag(sense);
563   savepic;
564 enddef;
565
566 def ccflag (expr sense) =
567   flagshape(5, flagw, 2.25nhh, 2/3flagthick, flagthin, flagthick, sense);
568   save_elempic;
569   clearxy;
570   flagshape(1, flagw, 2.5nhh, 2/3flagthick, flagthin, 0, sense);
571   savepic;
572   mirror_flag(sense);
573 enddef;
574
575 def addflag (expr sense, shifty) =
576   call_add_save_elempic (0, shifty*.75flagthick);
577   mirror_flag(sense);
578 enddef;
579
580 def cccflag (expr sense) = addflag(sense, 1) enddef;
581 def ccccflag (expr sense) = addflag(sense, 2) enddef;
582 def cccccflag (expr sense) = addflag(sense, 3) enddef;
583
584 beginchar(40, 0, 3.25nhh#, 0); "8th flag up";
585   cflag(1);
586   shift_pic (0, .5nhh+.5);
587 endchar;
588
589 beginchar(12, 0, 3.25nhh#, 0); "acciacaturra stem up";
590   callpic;
591   pickup med_pen;
592   x1=-.25nhw; y1=.2h; x2=1.1nhw; y2=y1+.6(x2-x1);
593   draw z1--z2;
594   shift_pic (0, .5nhh+.5);
595 endchar;
596
597 beginchar(41, 0, 3.25nhh#, 0); "16th flag up";
598   ccflag(1);
599   shift_pic (0, .25nhh);
600 endchar;
601
602 beginchar(42, 0, 4nhh#, 0); "32th flag up";
603   cccflag(1);
604   shift_pic (0, .25nhh);
605 endchar;
606
607 beginchar(43, 0, 4.75nhh#, 0); "64th flag up";
608   ccccflag(1);
609   shift_pic (0, .25nhh);
610 endchar;
611
612 beginchar(44, 0, 5.5nhh#, 0); "128th flag up";
613   cccccflag(1);
614   shift_pic (0, .25nhh);
615 endchar;
616
617 %%%
618 % flags up should be wider
619 %%%
620 flagw:=nhw;
621
622 beginchar(45, 0, 3.25nhh#, 0); "8th flag down";
623   cflag(-1);
624   shift_pic (0,-.5nhh-.5);
625 endchar;
626
627 beginchar(13, 0, 3.25nhh#, 0); "acciacaturra stem down";
628   callpic;
629   pickup med_pen;
630   x1=-.25nhw; y1=1.6nhh; x2=1.2nhw; y2=y1+.6(x2-x1);
631   draw z1--z2;
632   shift_pic (0,-.5nhh-.5);
633 endchar;
634
635 beginchar(46, 0, 3.25nhh#, 0); "16th flag down";
636   ccflag(-1);
637   shift_pic (0,-.25nhh);
638 endchar;
639
640 beginchar(47, 0, 4nhh#, 0); "32th flag down";
641   cccflag(-1);
642   shift_pic (0,-.25nhh);
643 endchar;
644
645 beginchar(48, 0, 4.75nhh#, 0); "64th flag down";
646   ccccflag(-1);
647   shift_pic (0,-.25nhh);
648 endchar;
649
650 beginchar(49, 0, 5.5nhh#, 0); "128th flag down";
651   cccccflag(-1);
652   shift_pic (0,-.25nhh);
653 endchar;
654
655 %%%%%%%
656 message("<accidentals>");
657 %%%%%%%
658
659 def flat (expr reduction, shiftx, flatsense) =
660   fthick:= reduction*thick;
661   penpos4(4/3fthick,0);   % 1
662   penpos3(1/2fthick,-90); %
663   penpos6(4/7fthick,90);  %   6
664   x1 = x2 = x3 = x5 = fthick;     %  / \
665   y1 = 6fthick; y2 = .5y4;        % 2   4
666   y3l=-2fthick; y5 = y3r;         %    /
667   x4 = 3.6fthick; y4 = .1fthick;  % 3,5
668   y6r= 2fthick; x6 = .5(x2+x4);
669   t:= identity shifted (round(shiftx),0);
670   p:= (z1--z5) transformed t;
671   pickup penrazor scaled max(1,(2sind40*thin)) rotated 40;
672   draw p;
673   penstroke (z2..{right}z6e..z4e{sw+down}..{sw}z3e) transformed t;
674   if flatsense<0: mirror (z5 transformed t, z1 transformed t); fi
675   penlabels (1,2,3,4,5,6)
676 enddef;
677
678 beginchar(50, nhw#, 1.5nhh#, .5nhh#); "flat";
679   flat (1, 0, 1);
680   savepic;
681 endchar;
682
683 beginchar(51, 1.7nhw#, 1.5nhh#, .5nhh#); "doubleflat";
684   call_add_shift (.7nhw, 0);
685 endchar;
686
687 def sharp (expr reduction, zshift) =
688   sthick:= .5reduction*thick;
689   nx:= reduction*1.5nhh;
690   ny:= reduction*.8nhw;
691   y1 =-y7= nx-1.5sthick; y2 =-y8 = .5sthick-nx;
692   x1 = x2 = y3 = -y6 = ny-x7 = ny-x8 = 2sthick;
693   y4 =-y5 = y3 + 3sthick;
694   x3 = x5 = 0; x4 = x6 = ny;
695   pickup penrazor scaled max(1,thin) rotated angle(z4-z3);
696   draw z1--z2; draw z8--z7;
697   pickup penrazor scaled 3sthick rotated 90;
698   draw z3--z4; draw z5--z6;
699   shift_pic (zshift, 0);
700   labels (range 1 thru 8)
701 enddef;
702
703 beginchar(52, nhw#, 1.5nhh#, 1.5nhh#); "sharp";
704   sharp (1, 0);
705 endchar;
706
707 beginchar(53, nhw#, .5nhh#, .5nhh#); "doublesharp";
708   doublesharp (w, -.1nhw);
709 endchar;
710
711 def natural (expr reduction, zshift) =
712   ny:= .8nhw*reduction;
713   nthick:= 3/4reduction*thick;
714   x1 = x2 = x3 = nthick+.5thin;
715   x5 = x6 = x4 = ny-x1;
716   y1 = -y6 = 1.5nhh*reduction;
717   y2 = -y5 = 1.6nthick;
718   y4 = -y3 = y2+4/3nthick;
719   pickup penrazor scaled max(1,thin) rotated angle(z4-z2);
720   draw lft z1--bot lft(x3,y3-nthick);
721   draw top rt(x4,y4+nthick)--rt z6;
722   pickup penrazor scaled 2nthick rotated 90;
723   draw (x2-.5,y2)--(x4+.5,y4);
724   draw (x3-.5,y3)--(x5+.5,y5);
725   shift_pic (zshift, 0);
726   labels(1,2,3,4,5,6)
727 enddef;
728
729 beginchar(54, nhw#, 1.5nhh#, 1.5nhh#); "natural";
730   natural (1, 0);
731 endchar;
732
733 beginchar(90, apog_nhw#, nhh#, .5nhh#); "small flat";
734   flat (apog_fact, -.05nhw, 1);
735   savepic;
736 endchar;
737
738 beginchar(91, 1.65apog_nhw#, nhh#, .5nhh#); "small doubleflat";
739   call_add_shift (.7apog_fact*nhw,0);
740 endchar;
741
742 beginchar(92, apog_nhw#, nhh#, nhh#); "small sharp";
743   sharp (apog_fact, 0);
744 endchar;
745
746 beginchar(93, apog_nhw#, .5nhh#, .5nhh#); "small doublesharp";
747   doublesharp (w, -.075nhw);
748 endchar;
749
750 beginchar(94, apog_nhw#, nhh#, nhh#); "small natural";
751   natural (apog_fact, 0);
752 endchar;
753
754 %%%%%%%
755 message ("<rests>");
756 %%%%%%%
757
758 beginchar(59, .5nhw#, 0, 0); "ddp";% doubledouble (4) pause
759   fill_square (.5nhw, 2nhh, (0, nhh));
760 endchar;
761
762 beginchar(58, .5nhw#, 0, 0); "dp";% double (2) pause
763   fill_square (.5nhw, nhh, (0, 2nhh));
764   savepic;
765 endchar;
766
767 beginchar(60, 5/4nhw#, .5nhh#, 0); "half rest";
768   fill_square (5/4nhw, .5nhh, (0, 0));
769   savepic;
770 endchar;
771
772 beginchar(10, 0, .5nhh#, 0); "half rest outside a staff";
773   callpic;
774   fill_square (2nhw, lthick, (-.375nhw, -hlthick));
775   savepic;
776 endchar;
777
778 beginchar(11, 0, 0, .5nhh#); "full rest outside a staff";
779   call_mirror(origin,right);
780 endchar;
781
782 beginchar(61, 5/4nhw#, 0, .5nhh#); "full rest";
783   fill_square (5/4nhw, .5nhh, (0, -.5nhh));
784 endchar;
785
786 beginchar(62, 0, 4nhh#, 0); "quarter rest";
787   rthin:= 1/8 nhh;           % .1
788   rthick:= 2 thick+rthin;    %       .2
789   alpha:= -50;               %    .3
790   penpos1(rthin, 90+alpha);  % .4
791   penpos5(rthin, alpha);     %       .5,10
792   penpos2(rthick, alpha);    %   .6
793   penpos4(rthick, alpha);    %
794   penpos3(3/4rthick, alpha); %       .7
795   penpos6(4/3thick, alpha);
796   penpos7(rthin, 45);
797   y1l = 4nhh - 1/2nhh;
798   x1l = 1/2nhh;
799   z2r = z1 +(nhh* right) rotated alpha;
800   z3  = 1/2[z2,z4];
801   z4  = (nhw,4nhh) scaled .55;
802   z5  = z4l+(nhh* right) rotated alpha;
803   x6l = x4l; y6r = 1.45nhh;
804   x7  = .9nhw; y7= nhh-1/8nhh;
805   z10 = z5r shifted (sqrt(2)*rthin/4,sqrt(2)*rthin/4);
806
807   pickup penrazor scaled rthin rotated 45;
808   draw z1--z2r; draw z4l--z10;
809   penstroke z2e..z3e..z4e;
810   penstroke z5e..z6e..z7e;
811   penlabels(1,2,3,4,5,6,7,10);
812   shift_pic (-.2nhw, 0);
813 endchar;
814
815 %%%
816 %   Draw the crook needed for quaver rests and shorter.
817 %   The crook extends left from the point z.i on the stem.
818 %%%
819 def crook(text i)=
820   forsuffixes $=i:
821   x3:=x.$-6.5fact; y3:=top y.$- 3fact;
822   x4:=x.$-6fact;   y4:=    y.$+.5fact;
823   draw z.${dir 240}..{dir 160}z3;
824   filldraw z3{dir 160}..z4{dir-20}..{dir 160}z3..cycle;
825   endfor
826 enddef;
827
828 beginchar(63, 0, 3.25nhh#, 0); "8th rest";
829   z1=(nhh,nhh);
830   z2-z1=whatever*dir 70;  %  Angle the stem at 70 degrees.
831 %%%
832 %   Define the scaling factor `fact' implicitly.
833 %   This value will be used for the shorter rests as well.
834 %%%
835   z2-z1=(5fact,1.7nhh);
836   pickup med_pen;
837   draw z1..z2;
838   crook(2);
839   shift_pic (-.35nhw, 0);
840   penlabels (1,2,3,4);
841 endchar;
842
843 beginchar(64, 0, 3.25nhh#, 0); "16th rest";
844   z1=(nhh,0);
845   z2-z1=whatever*dir 75;  %  Angle the stem at 75 degrees.
846   y2-y1=2.7nhh;
847   z5-z2=whatever*(z1-z2); y5=y2-nhh;
848   pickup med_pen;
849   draw z1..z2;
850   crook(2,5);
851   shift_pic (-.35nhw, 0);
852   penlabels (1,2,3,4,5);
853 endchar;
854
855 beginchar(65, 0, 4nhh#, 0); "32th rest";
856   z1=(nhh,0);
857   z2-z1=whatever*dir 80;  %  Angle the stem at 80 degrees.
858   y2-y1=3.7nhh;
859   z5-z2=whatever*(z1-z2); y5=y2-nhh;
860   z6-z2=whatever*(z1-z2); y6=y5-nhh;
861   pickup med_pen;
862   draw z1..z2;
863   crook(2,5,6);
864   shift_pic (-.35nhw, 0);
865   penlabels (1,2,3,4,5,6);
866 endchar;
867
868 beginchar(66, 0, 4.75nhh#, 0); "64th rest";
869   z1=(nhh,0);
870   z2-z1=whatever*dir 82;  %  Angle the stem at 82 degrees.
871   y2-y1=4.7nhh;
872   z5-z2=whatever*(z1-z2); y5=y2-nhh;
873   z6-z2=whatever*(z1-z2); y6=y5-nhh;
874   z7-z2=whatever*(z1-z2); y7=y6-nhh;
875   pickup med_pen;
876   draw z1..z2;
877   crook(2,5,6,7);
878   shift_pic (-.35nhw, 0);
879   penlabels (1,2,3,4,5,6,7);
880 endchar;
881
882 %%%%%%%
883 message ("<clefs>");
884 %%%%%%%
885
886 def violin(expr reduction) =
887   gx:=reduction*-nhw;
888   gy:=reduction*nhh;
889   gthick:=1.5reduction*thick;
890   gthin:=.75reduction*med;
891
892   x1=31/24gx+w; x4=23/24gx+w;  x2=x10=3/4gx+w;  x3r=w; x8l=15/16gx+w;
893   x5=x11r=15/8gx+w;  x6=gx+w;  x7=5/8gx+w;  x9=5/4gx+w;
894   y1=5/8gy;  y2r=y5r=2gy;  y3=gy;  y4r=0;  y6=27/8gy;
895   y7l=5gy;  y8l=11/2gy;  y9=17/4gy;  y10=y11=-7/8gy;
896   penpos1(gthin,160);
897   penpos2(gthick,90);
898   penpos3(gthick,0);
899   penpos4(5/4gthin,-90);
900   penpos5(3/2gthick,110);
901   penpos6(17/16gthick,130);
902   penpos7(gthin,-140);
903   penpos8(5/4gthick,-80);
904   penpos9(3/8gthick,0);
905   penpos10(gthin,0);
906   penpos11(1/2gthick,180);
907   penstroke z1e{nw}..z2e..z3e..z4e..z5e{up+ne}..z6e..{up+nw}z7e
908             ..z8e{sw}..{down}z9e{down}..{down}z10e..z11e;
909 %{{{
910   currentpen:= pencircle;
911   draw z1{nw}..z2..z3..z4..z5{up+ne}..z6..{up+nw}z7
912        ..z8{sw}..{down}z9{down}..{down}z10..z11;
913 %}}}
914   fill_circle ((3(x2-x4)), (x11+11/40gy, y11));
915   penlabels(range 1 thru 11)
916 enddef;
917
918 %beginchar(71, 8/3nhw#, 5.5nhh#, 1.5nhh#); "G-clef";
919 beginchar(71, 8/3nhw#, 4.5nhh#, 2.5nhh#); "G-clef";
920   violin(1);
921 % shift_pic (-.2nhw, 0);    % T.59
922   shift_pic (-.2nhw, -nhh); % T.60
923 endchar;
924
925 %beginchar(72, 7/3nhw#, 3nhh#, 2nhh#); "small G-clef";
926 beginchar(72, 7/3nhw#, 3nhh#, 3nhh#); "small G-clef";
927   violin(.8);
928 % shift_pic (-.3nhw, 0);    %T.59
929   shift_pic (-.3nhw, -nhh); %T.60
930 endchar;
931
932 def bass (expr reduction) =
933   fx:=reduction*nhw;
934   fy:=reduction*nhh;
935   fthick:=reduction*thick;
936
937   x2=.8fx; y2=3nhh;
938   x1=x2r+.26fx; y1=y2;
939   x3=x2+.71fx; y3r=y2+1fy;
940   x4=x3+.71fx; y4=y2-.2fy;
941   x6=x2-6reduction*thinwidth; y6=y2-2.2fy;
942   x7=x4+.50fx; y7=y2+.38fy;
943
944   penpos2(.6fthick,180);
945   penpos3(.6fthick, 90);
946   penpos4(2fthick,0);
947   penpos6(.4fthick,-10);
948
949   fill_circle (.35fx, z7);
950   add_mirror ((0,y2), (1,y2));
951   fill_circle ((2(x2r-x1)), z1);
952
953   penstroke z2e{up}..{right}z3e{right}..{down}z4e{down}..{left+.1down}z6e;
954 %{{{
955   currentpen:= pencircle;
956   draw z2{up}..{right}z3{right}..{down}z4{down}..{left+.1down}z6;
957 %}}}
958   penlabels(1,2,3,4,6)
959 enddef;
960
961 beginchar(73, 8/3nhw#, 4nhh#, 0); "F-clef";
962   bass(1);
963 % shift_pic (-.35nhw, 0);       % T.59
964   shift_pic (-.35nhw, -3nhh);   % T.60
965 endchar;
966
967 beginchar(74, 7/3nhw#, 4nhh#, 0); "small F-clef";
968   bass(.8);
969 % shift_pic (-4/15nhw, 0);      % T.59
970   shift_pic (-4/15nhw, -3nhh);  % T.59
971 endchar;
972
973 def alt(expr reduction, yshift) =
974   nh:=h*reduction;
975   athick:=1/10nh;
976   ahigh:=1/2nh;
977   radius:=5/4thick*reduction;
978
979   x4=13/16nh+3thinwidth; x5=9/16nh;
980   x6=1/2nh; x9=x10=2/3nh; x11=17/32nh;
981   y4=yshift+31/50ahigh; y5=yshift+1/2ahigh;
982   y6=yshift; y9=yshift+1/9ahigh;
983   y10=yshift+ahigh; y11=yshift+11/14ahigh;
984   penpos4(athick,180);
985   penpos5(1/8athick,0);
986   penpos6(athick,0);
987   penpos9(1/3athick,90);
988   penpos10(1/3athick,-90);
989   penpos11(1/2athick,0);
990
991   penstroke z5e..{sw+down}z6e;
992   penstroke z5e{se+3down}..{right}z9e{right}..{up}z4e{up}
993             ..{left}z10e{left}..{sw+3down}z11e;
994   fill_circle (2radius, (z11l+(radius, -.05nhh)));
995   fill_square (athick, ahigh, (5/16nh-1/2athick,yshift));
996   fill_square (.25athick, ahigh, (x6l-.25athick,yshift));
997   add_mirror ((0,yshift),(1,yshift));
998   penlabels(4,5,6,9,10,11)
999 enddef;
1000
1001 beginchar(75, 8/3nhw#, 4nhh#, 0); "Alto clef";
1002   alt(1, 2nhh);
1003 % shift_pic (-.45nhw, 0);     % T.59
1004   shift_pic (-.45nhw, -2nhh); % T.60
1005 endchar;
1006
1007 beginchar(76, 7/3nhw#, 4nhh#, 0); "small Alto clef";
1008   alt(.8 ,2nhh);
1009 % shift_pic (-.3nhw, 0);      % T.59
1010   shift_pic (-.3nhw, -2nhh);      % T.60
1011 endchar;
1012
1013 beginchar(77, 8/3nhw#, 4nhh#, 0); "drum clef";
1014   fill_square (.3nhw, .5h, (.85nhw,1nhh));
1015   add_mirror ((w/2,0),(w/2,1));
1016 % shift_pic (.2nhw, 0);    % T.59
1017   shift_pic (.2nhw, -2nhh); % T.60
1018 endchar;
1019
1020 beginchar(103, 8/3nhw#, 4nhh#, nhh#); "oldstyle G-clef";
1021   def penslopeI= (.35nhh/cosd45)+blacker,45 enddef;
1022   def penslopeII= (.35nhh/cosd32.5)+blacker,32.5 enddef;
1023   def penslopeIII= (.4nhh/cosd32.5)+blacker,32.5 enddef;
1024   def penslopeIV= (max(1,lthick/cosd32.5)),122.5 enddef;
1025
1026   x1l=1.5nhw; x2l=x3l=x4r=x1l+2/5nhw;
1027   x1l-x5l=x3r-x1l; x6l=x15r=x5l; x7r=x1=x14r; x8=x2;
1028   y1l=y2l=1.45nhh; y3l=y4r;
1029   y4l=0; y5=y3r; y6l=y15r; y7l=y8r=3nhh; y14r=y7r;
1030   z15r-z14r=whatever*dir(180+32.5);
1031   penpos1(penslopeI);
1032   penpos2(penslopeI);   %   /7\    6(15)
1033   penpos3(penslopeII);  %  6   8   7(14)
1034   penpos4(penslopeIII); %  |
1035   penpos5(penslopeII);  %  | 1-2
1036   penpos6(penslopeII);  %  |   |
1037   penpos7(penslopeII);  %  5   3
1038   penpos8(.35nhh,90);   %   \4/
1039   penpos14(penslopeIV);
1040   penpos15(penslopeIV);
1041   penstroke z1e--z2e--z3e;
1042   fill unitsquare xscaled (x3r-x4l) yscaled lthick
1043        shifted z4l rotatedaround (z4l,32.5);
1044   penstroke z4e--z5e{dir85}..z6e;
1045   penstroke z7e--z8e; penstroke z14e--z15e;
1046
1047   x9=x5l=x16-.25nhw; x10l=x1l; x11=x10-.1nhw; x12=x8;
1048   x17l=x2r+.05nhw; x13r=x2l-.1nhw;
1049   y9r=-nhh; y16l=y9l-.01nhh; y10=0;
1050   y11=3.5nhh; y12r=y8r; y17r=y8r+.2nhh; y13r=4nhh;
1051                                  %        13
1052   penpos12(2lthick,90);          %       /  \
1053   penpos17(3hlthick,180);        %     11    17
1054   penpos13(.35nhh+blacker,-90);  %      |  12
1055   penpos11(max(lthick,1),0);     %      |
1056   penpos10(max(lthick,1),0);     %     10
1057   penpos16(.475nhh+blacker,-90); %     /
1058   penpos9(.5nhh+blacker,-90);    % 9-16
1059
1060   penstroke z12e..z17e{dir80}..z13e..{down}z11e..{down}z10e{down}..
1061             {left}z16e..z9e;
1062   shift_pic (-.25nhw,0);
1063   penlabels (range 1 thru 12);
1064   shift_pic (0, -nhh); % T.60
1065 endchar;
1066
1067 beginchar(98, 8/3nhw#, 3.25nhh#, 0); "gregorian C clef";
1068   x1=x4=0; x2=x3=gregwidth; y1=y2=-y3=-y4=.5gregwidth-lthick;
1069   fill z1{dir 15}..z2--z3{dir 165}..z4--cycle;
1070   save_elempic;
1071   pickup med_pen; draw bot rt z1..{down}(-.01nhw,-.5nhh);
1072   shift_pic(nhw,2.5nhh);
1073   add_mirror ((0,2nhh),(1,2nhh));
1074   savepic;
1075   shift_pic (0,-2nhh);
1076 endchar;
1077
1078 beginchar(122, 8/3nhw#, 4.25nhh#, 0); "gregorian F clef";
1079   callpic;
1080   add_elempic (.1nhw,2nhh);
1081   fill_square (med, 1.5nhh, (.75nhw,.8nhh));
1082   shift_pic (1/3nhw,-2nhh);
1083 endchar;
1084
1085 %%%%%%%
1086 message ("<special signs>");
1087 %%%%%%%
1088
1089 beginchar(14, 0, nhh#, 0); "song system limit up";
1090   x1=y1=0; x2=1.5nhw; y2=nhh;
1091   penpos1(thick, 90); penpos2(thin, 90);
1092   penstroke z1e{right}..{dir80}z2e;
1093 %{{{
1094   currentpen:=pencircle; draw z1{right}..{dir80}z2;
1095 %}}}
1096   savepic;
1097 endchar;
1098
1099 beginchar(15, 0, 0, nhh#); "song system limit down";
1100   call_mirror (origin, right);
1101 endchar;
1102
1103 beginchar(16, 0, 0, 0); "used for volta";
1104   fill_square (lthick, 2.5nhh, (0,-.5nhh));
1105 endchar;
1106
1107 beginchar(17, 0, 0, 0); "used for volta";
1108   fill_square (lthick, 2.5nhh, (0,-2.5nhh));
1109 endchar;
1110
1111 % 'polyrhythmik' {\meterfrac{3+2+3}8}, e.g. Bart\'ok
1112 beginchar(57, 2nhh#, 1.5nhh#, 0); "big plus sign";
1113   pickup pencircle scaled .3nhh;
1114   draw lft(.5nhh,.9nhh)..rt(1.5nhh,.9nhh);
1115   draw bot(nhh,.4nhh)..top(nhh,1.4nhh);
1116 endchar;
1117
1118 beginchar(79, 0, 4nhh#, 0); "caesura";% other breathmark
1119   pickup penrazor scaled thick;
1120   draw (.3nhw+thick, 3.4nhh)--(.7nhw+thick, 4.6nhh);
1121 endchar;
1122
1123 beginchar(80, 0, 2.25nhh#, 0); "fermata up";
1124   x1 = -.5nhw;  x2=.5(x1+x3); x3 = 1.5nhw;
1125   y1 = y3 = nhh; y2 = 2.3nhh;
1126   penpos1(thinwidth,165);
1127   penpos2(.9beamht+thin,90);
1128   penpos3(thinwidth,15);
1129   penstroke z1e{dir75}..z2e..{dir-75}z3e;
1130   fill_circle (beamht, (x2, y1+.5beamht));
1131 %{{{
1132   currentpen:= pencircle; draw z1{dir 75}..z2..{dir-75}z3;
1133   add_mirror ((x2, 0),(x2, 1));
1134 %}}}
1135   savepic;
1136   penlabels(1,2,3);
1137 endchar;
1138
1139 beginchar(81, 0, 0, 2.25nhh#); "fermata down";
1140   call_mirror (origin, right);
1141 endchar;
1142
1143 beginchar(82, 5/3nhw#, 4nhh#, 0); "allabreve";
1144   fit:= .025nhw;
1145   2x2 = 2x4 = x1 + 1/2nhh = w;
1146   x3r = 0; 2y1 = 3y2 = y4r = 3nhh;
1147   y3r = 2nhh; x5 = w -1/2nhh; y5 = 3nhh -1/2nhh;
1148   z6r = z5r + (-1/40nhh, 1/20nhh);
1149   penpos1(max(1,med), 0);
1150   penpos2(max(1,med), -90);
1151   penpos3(1/4nhh+thick,180);
1152   penpos4(max(1,med), 90);
1153   penpos5(max(1,med), 0);
1154   penpos6(1/4nhh+med,45);
1155   penstroke z1e..z2e..z3e..z4e..z5e;
1156   fill rt z1r..lft z1l..cycle;
1157   fill_circle (.35nhw+blacker, (z6 + (-2fit, fit)));
1158   shift_pic (.5nhh,0);
1159   savepic;
1160
1161   pickup med_pen;
1162   draw (4/5nhw+.5nhh, y2r-3/8nhh)--(4/5nhw+.5nhh, y4r+3/8nhh);
1163   penlabels(1,2,3,4,5,6);
1164   save_elempic;
1165   shift_pic (0,-2nhh);
1166 endchar;
1167
1168 beginchar(83, 5/3nhw#, 3.25nhh#, 0); "C";
1169   callpic;
1170   shift_pic (0,-2nhh);
1171 endchar;
1172
1173 beginchar(84, 10/3nhw#, 3.25nhh#, 0); "reverseC";
1174   callpic;
1175   add_mirror ((11/6nhw,0),(11/6nhw,1));
1176   shift_pic (0,-2nhh);
1177 endchar;
1178
1179 beginchar(123, 5/3nhw#, 3.25nhh#, 0); "reverseallabreve";
1180   add_elempic (0,0);
1181   mirror ((13/12nhw,0),(13/12nhw,1));
1182   shift_pic (0,-2nhh);
1183 endchar;
1184
1185 beginchar(121, 0, 0, 0); "double thumb bracket";
1186   mh:=0.625nhh;
1187   fill_square (lthick, mh, origin);
1188   fill_square (.55nhw, lthick, origin);
1189   add_mirror ((0,mh),(1,mh));
1190   shift_pic (-.75nhw, -mh);
1191 endchar;
1192
1193 %%%%%%%
1194 message ("<repeat symbols>");
1195 %%%%%%%
1196
1197 beginchar(55, 0, 4nhh#, 0); "repeat colons";
1198   fill_circle (1/3nhw+blacker, (0, 3/2nhh));
1199   add_mirror ((0, 2nhh),(1, 2nhh));
1200   shift_pic(0,-2nhh);
1201 endchar;
1202
1203 beginchar(78, 0, 4nhh#, 0); "due volte";
1204   fill_circle ((1/3nhw+blacker),(-.75nhh,2.5nhh));
1205   addto currentpicture also currentpicture rotatedaround ((0,2nhh), 180);
1206   pickup penrazor scaled (1/3nhw+blacker);
1207   draw (-nhh, nhh)--(nhh, 3nhh);
1208 endchar;
1209
1210 beginchar(85, 0, 3.25nhh#, 0); "coda";
1211   mh:=3nhh;
1212   x2 = 2nhw-x4 = 1/6mh; y2 = y4 = 1/2mh;
1213   x3 = x5 = nhw; y3 = mh-y5 = 5/6mh;
1214   pickup thin_pen;
1215   draw (0,mh/2)--(2nhw,mh/2); draw (nhw,0)--(nhw,mh);
1216   savepic;
1217   pickup coda_pen;
1218   draw z2..z3..z4..z5..cycle;
1219   shift_pic (-nhw, 0);
1220   labels (1,2,3,4);
1221 endchar;
1222
1223 beginchar(105, 0, 3.25nhh#, 0); "coda II";
1224   mh:=3nhh;
1225   callpic;
1226   x2 = x5 = 1/6mh; y2 = y3 = 5/6mh;
1227   x3 = x4 = 2nhw-x2; y4 = y5 = 1/6mh;
1228   pickup coda_pen;
1229   draw z2--z3--z4--z5--cycle;
1230   shift_pic (-nhw, 0);
1231   labels (1,2,3,4);
1232 endchar;
1233
1234 beginchar(86, 0, 3.25nhh#, 0); "segno";
1235   x1= .5nhw; y1 = 1.75nhh; x4=-.5x1; y4=.4nhh;
1236   x5=.7x1; y5=y6=3.05nhh; x6=x5-x1;
1237   z1'= (x1+1,y1);
1238   penpos1'(.5nhh+blacker, 80);
1239   penpos5(max(1,thin), -110);
1240   penpos6(max(1,1.2thin), -70);
1241   fill_circle (.5nhh, (x5-.2nhh,y5l-.13nhh));
1242   fill_circle (thick+.1nhh, (x4, y4+.9nhh));
1243   penstroke z1'e{dir170}..{ne}z6e..z5e;
1244   pickup penrazor scaled max(1,thin);
1245   draw z4--z1;
1246   penlabels (1,5,6);
1247   addto currentpicture also currentpicture rotatedaround (z1, 180);
1248 endchar;
1249
1250 beginchar(110, 0, 5.5nhh#, 2nhh#); "segno II";
1251   mw:=2.5nhh;
1252   gamma:=36.9;
1253   dist:=1nhh+.75beamht;
1254   gthick:=beamht+blacker;
1255
1256   x1'=x3'=x7=x16=2x1=2x10=2x13=.5mw; x9=x14=x2; x3r=mw-.2nhh;
1257   x11=x5; x15=x3; mw-x8=x12=1/3nhh;
1258   y1'=dist; y3'=y1'-.5dist; y4'+dist=y9-2dist=y2; y10-2dist=y13+dist=y1;
1259   y11=y5+2dist; y14=y2-dist; y8=y6-.1dist+2dist; y12=y3+.1dist-dist;
1260   y15=y3-dist; y16r=-d; y7l=3.25nhh+2dist;
1261   z1-z1'=z1'-z2=whatever*dir-gamma;
1262   z3-z3'=whatever*dir-gamma; z2-z4=whatever*dir(-90-gamma);
1263   z2-z4'=whatever*dir-90; z4-z4'=whatever*dir-gamma;
1264   z5=z3 rotatedaround (z1',180); z6=z4 rotatedaround (z1',180);
1265
1266   penpos1(gthick, gamma); penpos2(gthick, gamma);
1267   penpos3(max(1,thin),-90+gamma); penpos4(.9gthick,-180+gamma);
1268   penpos5(max(1,thin),-90+gamma); penpos6(.9gthick,-180+gamma);
1269   penpos7(.3gthick,-90-gamma); penpos8(.5gthick,-180+gamma);
1270   penpos9(gthick, gamma); penpos10(gthick, gamma);
1271   penpos11(.5gthick,-90+gamma); penpos12(.5gthick,-180+gamma);
1272   penpos13(gthick, gamma); penpos14(gthick, gamma);
1273   penpos15(.5gthick,-90+gamma); penpos16(.3gthick+1,-90-gamma);
1274
1275   penstroke z6e{dir(180-gamma)}..z5e..z1e---z2e..z3e..{dir(180-gamma)}z4e;
1276   add_shift (0,2dist);
1277   add_shift (0,-dist);
1278   unfill (0,-nhh)--(mw,-nhh)--(mw,-d)--(0,-d)--cycle;
1279   unfill (0,5nhh)--(mw,5nhh)--(mw,6nhh)--(0,6nhh)--cycle; cullit;
1280
1281   penstroke z9e---z10e..z11e..z7e..z8e;
1282   penstroke z13e---z14e..z15e..z16e..z12e;
1283
1284   dotthick:=.65nhh+blacker; fit:=.15nhh;
1285   fill_circle(dotthick,(x8-fit,y8-.5dotthick+fit+.02nhh));
1286   fill_circle(dotthick,(x12+fit,y12+.5dotthick-fit-.02nhh));
1287
1288   pickup thin_pen;
1289   draw (3/8mw,1/3nhh)--(3/8mw,4nhh+1/3nhh);
1290   draw (5/8mw,-1/3nhh)--(5/8mw,4nhh-1/3nhh);
1291   penlabels (range 1 thru 16);
1292   shift_pic(-mw,0);
1293 endchar;
1294
1295 %%%%%%%
1296 message ("<trills>");
1297 %%%%%%%
1298
1299 beginchar (67, 0, nhh#, 0); "turn";
1300   x1=2nhw-x6=.4nhw; y1r=h; y6=h-y1;
1301   x2r=0; y2=.5h; x5=2nhw-x2; y5=h-y2;
1302   x3=.44nhw; y3r=0; x4=2nhw-x3; y4=h-y3;
1303   penpos1(med, 90);
1304   penpos2(med, 180);
1305   penpos3(thick,-40);
1306   penpos4(thick,-40);
1307   penpos5(med, 180);
1308   penpos6(med, 90);
1309   penstroke z1e..{down}z2e{down}..{right}z3e{right}
1310             ..{right}z4e{right}..{down}z5e{down}..z6e;
1311   fill_circle ((1/4nhh+thick), (x1,y1r-thick));
1312   fill_circle ((1/4nhh+thick), (x6,y6l+thick));
1313   shift_pic (-.5nhw, 0);
1314   penlabels(1,2,3,4,5,6);
1315   savepic;
1316 endchar;
1317
1318 beginchar (68, 0, nhh#, 0); "backturn";
1319   call_mirror ((.5nhw,0), (.5nhw,1));
1320 endchar;
1321
1322 def setpar =
1323   off:= .3nhw; x2=x1+off; x3=x2+off; x4=x3+off;
1324   y1= y3=.75nhh-y2=.75nhh-y4=.15nhh;
1325 enddef;
1326
1327 beginchar(87, 0, nhh#, 0); "shake";
1328   x1=-.15nhw; setpar;
1329   pickup pensquare xscaled (thick+.15nhh) yscaled med rotated 52;
1330   draw z1--z2--z3--z4;
1331   save_elempic;
1332   add_elempic (2off,0);
1333   savepic;
1334 endchar;
1335
1336 beginchar(88, 0, nhh#, 0); "(long or double) shake";
1337   callpic;
1338   add_elempic (2*2off,0);
1339   shift_pic (-.3nhw, 0);
1340   save_elempic;
1341 endchar;
1342
1343 beginchar(89, 0, nhh#, 0); "mordent";
1344   callpic;
1345   fill_square (med, 1.5nhh, (.5nhw,-.375nhh));
1346 endchar;
1347
1348 beginchar(119, 0, nhh#, 0); "(long or double) mordent";
1349   currentpicture:= elem_pic; savepic;
1350   fill_square (med, 1.5nhh, (.5nhw,-.375nhh));
1351 endchar;
1352
1353 beginchar(106, 0, 1.5nhh#, 0); "Pince with line";
1354   callpic;
1355   pickup med_pen;
1356   draw (-.55nhw, 0)--(-.55nhw, h);
1357 endchar;
1358
1359 beginchar(107, 0, 1.5nhh#, 0); "Pince with hook nw";
1360   callpic;
1361   x1=-.45nhw; setpar;
1362   pickup med_pen;
1363   z5=1.75[z3,z2]-(x3-x1,0); z6=z1 rotatedaround (z5,90);
1364   draw (z1..z5{z2-z3}..{z3-z2}z6) shifted -(.5thick, .15nhh);
1365 endchar;
1366
1367 beginchar(108, 0, nhh#, 0); "Pince with hook sw";
1368   callpic;
1369   x1=-.45nhw; setpar;
1370   pickup med_pen;
1371   z5=1.5[z2,z1]-.75(.5thick,.15nhh); z6=z2 rotatedaround (z5,-90);
1372   draw (z1..z5{z1-z2}..{z2-z1}z6);
1373 endchar;
1374
1375 beginchar(109, 0, 1.5nhh#, 0); "Pince with hook ne";
1376   callpic;
1377   x1=1.35nhw; setpar;
1378   pickup med_pen;
1379   z5=1.5[z1,z2]; z6=z1 rotatedaround (z5,-90);
1380   draw (z1..z5{z2-z1}..{z1-z2}z6);
1381 endchar;
1382
1383 beginchar(69, nhw#, .5nhh#, 0); "trille-element";
1384   x1=-1; y1=y2=y3=.5h; x3=2x2=nhw;
1385   pickup penrazor scaled 1.5thick rotated 50;
1386   draw z1{ne}..{se}z2{se}..{ne}z3;
1387 endchar;
1388
1389 beginchar(70, 0, nhh#, 0); "arpeggio-element";
1390   x1=x2=x3=.2nhw-1; y1=0; y3=2y2=nhh+1;
1391   pickup penrazor scaled (thick+.16nhh) rotated 45;
1392   draw z1{ne}..{nw}z2{nw}..{ne}z3;
1393   shift_pic (-nhw, 0);
1394 endchar;
1395
1396 %%%%%%%
1397 message ("<pedal signs>");
1398 %%%%%%%
1399
1400 def pedalstar (text rot)=
1401   x4=-x1=min(.05nhh,0.35pt); y1=y4=0; x3=-x2=.14nhh;
1402   y3=y2=2y5=2y6=.4nhh; x6=-x5=1.1x4;
1403   p:=(z1..z5..z2..z3..z6..z4--cycle) shifted (0, .2nhh);
1404   forsuffixes $=rot: fill p rotated $; endfor
1405   pickup med_pen;
1406   draw quartercircle scaled .4nhh;
1407   add_mirror (origin, up);
1408   add_mirror (origin, right);
1409   labels (1,2,3,4);
1410   shift_pic (.5nhw, .8nhh);
1411 enddef;
1412
1413 beginchar(33, 0, 1.5nhh#, 0); "pedal (release) star I";
1414   pedalstar (0,60);
1415 endchar;
1416
1417 beginchar(104, 0, 1.5nhh#, 0); "pedal star II";
1418   pedalstar (0,45,90);
1419 endchar;
1420
1421 beginchar(34, 0, 1.5nhh#, 0); "pedal I";
1422   mw:= 1.25nhw; mh:=1.7nhh;
1423
1424   x1=.425mw; y1=4/18mh;
1425   x2=.2mw;   y2=4/18mh;
1426   x3=x1;     y3r=0;
1427   x4=.65mw;  y4=.35mh;
1428   x5=.475mw; y5=.83mh;
1429   penpos1(.75thin,0);       penpos4(.275nhh+thin,60);
1430   penpos2(.15nhh+thin,135); penpos5(.025nhh+med,0);
1431   penpos3(.025nhh+med,-90);
1432
1433   penstroke z1e{up}..z2e..z3e..z4e..{up+.5right}z5e;
1434
1435   fill lft z1l{up+ne}..{down+se}rt z1r{down+sw}..{up+nw}cycle;
1436   fill rt z5l{up+ne}..{down+se}lft z5r{down+sw}..{up+nw}cycle;
1437 %{{{
1438   currentpen:= pencircle; draw z1{up}..z2..z3..z4..{up+.5right}z5;
1439 %}}}
1440
1441   x6=mw-x12;        y6=.75mh;
1442   x7=mw-x11;        y7=.65mh;
1443   x8=.25mw;         y8=y10;
1444   x9=x8+(x10-x8)/2; y9r=mh;
1445   x10=.8mw;         y10=.9mh;
1446   x11=.88mw;        y11=y7;
1447   x12=.7mw;         y12=.7mh;
1448   penpos6(thin,-80); penpos10(1.2med,90);
1449   penpos7(.25nhh+thin,-110);     penpos11(.25nhh+thin,-70);
1450   penpos8(med,90);          penpos12(thin,-100);
1451   penpos9(.9med,90);
1452
1453   penstroke z6e..z7e..z8e..z9e..z10e..z11e..z12e;
1454 %{{{
1455   currentpen:=pencircle; draw z6..z7..z8..z9..z10..z11..z12;
1456 %}}}
1457   penlabels (range 1 thru 12);
1458   savepic;
1459   shift_pic (-.125nhw, 0);
1460 endchar;
1461
1462 beginchar(35, 0, 1.5nhh#, 0); "pedal II";
1463   callpic; %%% ->P
1464   mw:=3nhw; mh:=1.7nhh;
1465   fill_circle (.15mh, (.945mw-.15mh/2, .15mh/2));%%% ->.
1466
1467   x1=.5mw;   y1=.9mh;
1468   x2=.77mw;  y2=.58mh;
1469   x3=.815mw; y3=.2mh;
1470   x4= x2;    y4r=0;
1471   x5=.63mw;  y5=.22mh;
1472   x6= x2;    y6=y2;
1473   penpos1(.75med,90);       penpos4(.025nhh+med,-90);
1474   penpos2(.1125nhh+med,30); penpos5(.1125nhh+thin,-135);
1475   penpos3(.05nhh+med,0);    penpos6(med,100);
1476
1477   penstroke (z1e{right}..z2e..z3e..z4e..z5e{dir 110}..z6e);%%% ->d
1478   fill lft z1l{ne}..{nw}rt z1r{sw}..{se}cycle;
1479
1480   x7=x5;        y7=y5;
1481   x8=.55mw;     y8r=0;
1482   x9=x1;        y9=.56mh;
1483   x10=x11+.1mw; y10=y11+.1mh;
1484   x11=.375mw;   y11r=0;
1485   x12=.28mw;    y12=.25mh;
1486   penpos7(thin,-75);         penpos10(1.2thin,-45);
1487   penpos8(.05nhh+med,-90);   penpos11(.225nhh,-100);
1488   penpos9(.0625nhh+thin,80); penpos12(thin,-125);
1489
1490   penstroke z7e..z8e..z9e & z9e{dir-30}..{dir-150}z10e..z11e;%%% ->e
1491   penstroke z12e..z11e;
1492   penlabels (range 1 thru 12);
1493   shift_pic (-(.125nhw+.25nhw), 0);
1494 endchar;
1495
1496 %^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
1497
1498 %%%%%%%
1499 message ("<beam elements>");
1500 %%%%%%%
1501
1502 pen beam_pen;
1503 beam_pen:= penrazor scaled beamht rotated 90;
1504
1505 for LOOP=0 upto 9:
1506   longueur:= 2;
1507   for loop=0 upto 5:
1508     beginchar(LOOP*6+loop+128, longueur, 0, 0);
1509       pickup beam_pen;
1510       draw origin--(lft w, w*(.05*(LOOP+1)));
1511       savepic;
1512     endchar;
1513
1514     beginchar(LOOP*6+loop+64+128, longueur, 0, 0);
1515       call_mirror (origin,right);
1516     endchar;
1517
1518     longueur:= 2*longueur;
1519   endfor
1520 endfor;
1521 end