1// abc2svg - ABC to SVG translator 2// @source: https://chiselapp.com/user/moinejf/repository/abc2svg 3// Copyright (C) 2014-2020 Jean-Francois Moine - LGPL3+ 4//abc2svg-abc2svg.js 5if(typeof abc2svg=="undefined") 6var abc2svg={};abc2svg.C={BLEN:1536,BAR:0,CLEF:1,CUSTOS:2,GRACE:4,KEY:5,METER:6,MREST:7,NOTE:8,PART:9,REST:10,SPACE:11,STAVES:12,STBRK:13,TEMPO:14,BLOCK:16,REMARK:17,FULL:0,EMPTY:1,OVAL:2,OVALBARS:3,SQUARE:4,SL_ABOVE:0x01,SL_BELOW:0x02,SL_AUTO:0x03,SL_HIDDEN:0x04,SL_DOTTED:0x08};abc2svg.sym_name=['bar','clef','custos','','grace','key','meter','Zrest','note','part','rest','yspace','staves','Break','tempo','','block','remark'] 7abc2svg.keys=[new Int8Array([-1,-1,-1,-1,-1,-1,-1]),new Int8Array([-1,-1,-1,0,-1,-1,-1]),new Int8Array([0,-1,-1,0,-1,-1,-1]),new Int8Array([0,-1,-1,0,0,-1,-1]),new Int8Array([0,0,-1,0,0,-1,-1]),new Int8Array([0,0,-1,0,0,0,-1]),new Int8Array([0,0,0,0,0,0,-1]),new Int8Array([0,0,0,0,0,0,0]),new Int8Array([0,0,0,1,0,0,0]),new Int8Array([1,0,0,1,0,0,0]),new Int8Array([1,0,0,1,1,0,0]),new Int8Array([1,1,0,1,1,0,0]),new Int8Array([1,1,0,1,1,1,0]),new Int8Array([1,1,1,1,1,1,0]),new Int8Array([1,1,1,1,1,1,1])] 8abc2svg.p_b40=new Int8Array([2,8,14,19,25,31,37]) 9abc2svg.b40_p=new Int8Array([0,0,0,0,0,0,1,1,1,1,1,1,2,2,2,2,2,3,3,3,3,3,3,4,4,4,4,4,4,5,5,5,5,5,5,6,6,6,6,6]) 10abc2svg.b40_a=new Int8Array([-2,-1,0,1,2,0,-2,-1,0,1,2,0,-2,-1,0,1,2,-2,-1,0,1,2,0,-2,-1,0,1,2,0,-2,-1,0,1,2,0,-2,-1,0,1,2]) 11abc2svg.b40_m=new Int8Array([-2,-1,0,1,2,0,0,1,2,3,4,0,2,3,4,5,6,3,4,5,6,7,0,5,6,7,8,9,0,7,8,9,10,11,0,9,10,11,12,13]) 12abc2svg.b40k=new Int8Array([36,1,2,3,8,2,2,7,8,13,14,2,8,13,14,19,20,13,14,19,20,25,2,19,24,25,30,31,2,25,30,31,36,37,2,31,36,37,38,3]) 13abc2svg.b40sf=new Int8Array([-2,-7,0,7,2,88,0,-5,2,-3,4,88,2,-3,4,-1,6,-3,4,-1,6,1,88,-1,-6,1,-4,3,88,1,-4,3,-2,5,88,3,-2,5,0,7]) 14abc2svg.isb40=new Int8Array([0,1,6,11,12,17,18,23,28,29,34,35]) 15abc2svg.ifb40=new Int8Array([0,5,6,11,12,17,22,23,28,29,34,39]) 16abc2svg.pab40=function(p,a){p+=19 17var b40=((p/7)|0)*40+abc2svg.p_b40[p%7] 18if(a&&a!=3) 19b40+=a 20return b40} 21abc2svg.b40p=function(b){return((b/40)|0)*7+abc2svg.b40_p[b%40]-19} 22abc2svg.b40a=function(b){return abc2svg.b40_a[b%40]} 23abc2svg.b40m=function(b){return((b/40)|0)*12+abc2svg.b40_m[b%40]} 24abc2svg.ch_alias={"maj":"","min":"m","-":"m","°":"dim","+":"aug","+5":"aug","maj7":"M7","Δ7":"M7","Δ":"M7","min7":"m7","-7":"m7","ø7":"m7b5","°7":"dim7","min+7":"m+7","aug7":"+7","7+5":"+7","7#5":"+7","sus":"sus4","7sus":"7sus4"} 25abc2svg.rat=function(n,d){var a,t,n0=0,d1=0,n1=1,d0=1 26while(1){if(d==0) 27break 28t=d 29a=(n/d)|0 30d=n%d 31n=t 32t=n0+a*n1 33n0=n1 34n1=t 35t=d0+a*d1 36d0=d1 37d1=t} 38return[n1,d1]} 39abc2svg.pitcmp=function(n1,n2){return n1.pit-n2.pit} 40abc2svg.Abc=function(user){"use strict";var C=abc2svg.C;var require=empty_function,system=empty_function,write=empty_function,XMLHttpRequest=empty_function;var OPEN_BRACE=0x01,CLOSE_BRACE=0x02,OPEN_BRACKET=0x04,CLOSE_BRACKET=0x08,OPEN_PARENTH=0x10,CLOSE_PARENTH=0x20,STOP_BAR=0x40,FL_VOICE=0x80,OPEN_BRACE2=0x0100,CLOSE_BRACE2=0x0200,OPEN_BRACKET2=0x0400,CLOSE_BRACKET2=0x0800,MASTER_VOICE=0x1000,IN=96,CM=37.8,YSTEP=256 41var errs={bad_char:"Bad character '$1'",bad_grace:"Bad character in grace note sequence",bad_transp:"Bad transpose value",bad_val:"Bad value in $1",bar_grace:"Cannot have a bar in grace notes",ignored:"$1: inside tune - ignored",misplaced:"Misplaced '$1' in %%score",must_note:"!$1! must be on a note",must_note_rest:"!$1! must be on a note or a rest",nonote_vo:"No note in voice overlay",not_ascii:"Not an ASCII character",not_enough_n:'Not enough notes/rests for %%repeat',not_enough_m:'Not enough measures for %%repeat',not_enough_p:"Not enough parameters in %%map",not_in_tune:"Cannot have '$1' inside a tune",notransp:"Cannot transpose with a temperament"} 42var self=this,glovar={meter:{type:C.METER,wmeasure:1,a_meter:[]},},info={},parse={ctx:{},prefix:'%',state:0,ottava:[],line:new scanBuf},tunes=[],psvg 43function clone(obj,lvl){if(!obj) 44return obj 45var tmp=new obj.constructor 46for(var k in obj) 47if(obj.hasOwnProperty(k)){if(lvl&&typeof obj[k]!="number") 48tmp[k]=clone(obj[k],lvl-1) 49else 50tmp[k]=obj[k]} 51return tmp} 52function errbld(sev,txt,fn,idx){var i,j,l,c,h 53if(user.errbld){switch(sev){case 0:sev="warn";break 54case 1:sev="error";break 55default:sev="fatal";break} 56user.errbld(sev,txt,fn,idx) 57return} 58if(idx!=undefined&&idx>=0){i=l=0 59while(1){j=parse.file.indexOf('\n',i) 60if(j<0||j>idx) 61break 62l++;i=j+1} 63c=idx-i} 64h="" 65if(fn){h=fn 66if(l) 67h+=":"+(l+1)+":"+(c+1);h+=" "} 68switch(sev){case 0:h+="Warning: ";break 69case 1:h+="Error: ";break 70default:h+="Internal bug: ";break} 71user.errmsg(h+txt,l,c)} 72function error(sev,s,msg,a1,a2,a3,a4){var i,j,regex,tmp 73if(!sev&&cfmt.quiet) 74return 75if(s){if(s.err) 76return 77s.err=true} 78if(user.textrans){tmp=user.textrans[msg] 79if(tmp) 80msg=tmp} 81if(arguments.length>3) 82msg=msg.replace(/\$./g,function(a){switch(a){case'$1':return a1 83case'$2':return a2 84case'$3':return a3 85default:return a4}}) 86if(s&&s.fname) 87errbld(sev,msg,s.fname,s.istart) 88else 89errbld(sev,msg)} 90function scanBuf(){this.index=0;scanBuf.prototype.char=function(){return this.buffer[this.index]} 91scanBuf.prototype.next_char=function(){return this.buffer[++this.index]} 92scanBuf.prototype.get_int=function(){var val=0,c=this.buffer[this.index] 93while(c>='0'&&c<='9'){val=val*10+Number(c);c=this.next_char()} 94return val}} 95function syntax(sev,msg,a1,a2,a3,a4){var s={fname:parse.fname,istart:parse.istart+parse.line.index} 96error(sev,s,msg,a1,a2,a3,a4)} 97function js_inject(js){if(!/eval *\(|Function|setTimeout|setInterval/.test(js)) 98eval('"use strict";\n'+js) 99else 100syntax(1,"Unsecure code")} 101var dd_tb={},a_de 102var decos={dot:"0 stc 5 1 1",tenuto:"0 emb 5 3 3",slide:"1 sld 3 7 0",arpeggio:"2 arp 12 10 0",roll:"3 roll 7 6 6",fermata:"3 hld 10 7 7",emphasis:"3 accent 7 4 4",lowermordent:"3 lmrd 10 5 5",coda:"3 coda 24 10 10",uppermordent:"3 umrd 10 5 5",segno:"3 sgno 22 8 8",trill:"3 trl 14 5 5",upbow:"3 upb 10 5 5",downbow:"3 dnb 9 5 5",gmark:"3 grm 6 5 5",wedge:"0 wedge 7 3 3",turnx:"3 turnx 10 0 5",breath:"3 brth 0 1 20",longphrase:"3 lphr 0 1 1",mediumphrase:"3 mphr 0 1 1",shortphrase:"3 sphr 0 1 1",invertedfermata:"3 hld 10 7 7",invertedturn:"3 turn 10 0 5",invertedturnx:"3 turnx 10 0 5","0":"3 fng 8 3 3 0","1":"3 fng 8 3 3 1","2":"3 fng 8 3 3 2","3":"3 fng 8 3 3 3","4":"3 fng 8 3 3 4","5":"3 fng 8 3 3 5",plus:"3 dplus 7 3 3","+":"3 dplus 7 3 3",accent:"3 accent 7 4 4",">":"3 accent 7 4 4",marcato:"3 marcato 9 3 3","^":"3 marcato 9 3 3",mordent:"3 lmrd 10 5 5",open:"3 opend 10 3 3",snap:"3 snap 14 3 3",thumb:"3 thumb 14 3 3",dacapo:"3 dacs 16 20 20 Da Capo",dacoda:"3 dacs 16 20 20 Da Coda","D.C.":"3 dcap 16 10 10","D.S.":"3 dsgn 16 10 10","D.C.alcoda":"3 dacs 16 38 38 D.C. al Coda","D.S.alcoda":"3 dacs 16 38 38 D.S. al Coda","D.C.alfine":"3 dacs 16 38 38 D.C. al Fine","D.S.alfine":"3 dacs 16 38 38 D.S. al Fine",fine:"3 dacs 16 10 10 Fine",turn:"3 turn 10 0 5","trill(":"3 ltr 8 4 0","trill)":"3 ltr 8 4 0",f:"6 f 18 1 7",ff:"6 ff 18 2 10",fff:"6 fff 18 4 13",ffff:"6 ffff 18 6 16",mf:"6 mf 18 6 13",mp:"6 mp 18 6 16",p:"6 p 18 2 8",pp:"6 pp 18 5 14",ppp:"6 ppp 18 8 20",pppp:"6 pppp 18 10 25",pralltriller:"3 umrd 10 5 5",sfz:"6 sfz 18 4 10",ped:"4 ped 18 6 10","ped-up":"4 pedoff 12 4 4","ped(":"4 lped 20 5 5","ped)":"4 lped 20 5 5","crescendo(":"6 cresc 18 0 0","crescendo)":"6 cresc 18 0 0","<(":"6 cresc 18 0 0","<)":"6 cresc 18 0 0","diminuendo(":"6 dim 18 0 0","diminuendo)":"6 dim 18 0 0",">(":"6 dim 18 0 0",">)":"6 dim 18 0 0","-(":"8 gliss 0 0 0","-)":"8 gliss 0 0 0","~(":"8 glisq 0 0 0","~)":"8 glisq 0 0 0","8va(":"3 8va 10 0 0","8va)":"3 8va 10 0 0","8vb(":"4 8vb 10 0 0","8vb)":"4 8vb 10 0 0","15ma(":"3 15ma 10 0 0","15ma)":"3 15ma 10 0 0","15mb(":"4 15mb 10 0 0","15mb)":"4 15mb 10 0 0",invisible:"32 0 0 0 0",beamon:"33 0 0 0 0",trem1:"34 0 0 0 0",trem2:"34 0 0 0 0",trem3:"34 0 0 0 0",trem4:"34 0 0 0 0",xstem:"35 0 0 0 0",beambr1:"36 0 0 0 0",beambr2:"36 0 0 0 0",rbstop:"37 0 0 0 0","/":"38 0 0 6 6","//":"38 0 0 6 6","///":"38 0 0 6 6","beam-accel":"39 0 0 0 0","beam-rall":"39 0 0 0 0",stemless:"40 0 0 0 0",rbend:"41 0 0 0 0",editorial:"42 0 0 0 0","sacc-1":"3 sacc-1 6,4 4 4",sacc3:"3 sacc3 6,5 4 4",sacc1:"3 sacc1 6,4 4 4",courtesy:"43 0 0 0 0","cacc-1":"3 cacc-1 0 0 0",cacc3:"3 cacc3 0 0 0",cacc1:"3 cacc1 0 0 0"},f_near=[true,true,true],f_note=[false,false,false,true,true,true,false,false,true],f_staff=[false,false,false,false,false,false,true,true] 103function y_get(st,up,x,w){var y,p_staff=staff_tb[st],i=(x/realwidth*YSTEP)|0,j=((x+w)/realwidth*YSTEP)|0 104if(i<0) 105i=0 106if(j>=YSTEP){j=YSTEP-1 107if(i>j) 108i=j} 109if(up){y=p_staff.top[i++] 110while(i<=j){if(y<p_staff.top[i]) 111y=p_staff.top[i];i++}}else{y=p_staff.bot[i++] 112while(i<=j){if(y>p_staff.bot[i]) 113y=p_staff.bot[i];i++}} 114return y} 115function y_set(st,up,x,w,y){var p_staff=staff_tb[st],i=(x/realwidth*YSTEP)|0,j=((x+w)/realwidth*YSTEP)|0 116if(i<0) 117i=0 118if(j>=YSTEP){j=YSTEP-1 119if(i>j) 120i=j} 121if(up){while(i<=j){if(p_staff.top[i]<y) 122p_staff.top[i]=y;i++}}else{while(i<=j){if(p_staff.bot[i]>y) 123p_staff.bot[i]=y;i++}}} 124function up_p(s,pos){switch(pos){case C.SL_ABOVE:return true 125case C.SL_BELOW:return false} 126if(s.multi&&s.multi!=0) 127return s.multi>0 128if(!s.p_v.have_ly) 129return false 130return s.pos.voc!=C.SL_ABOVE} 131function d_arp(de){var m,h,dx,s=de.s,dd=de.dd,xc=5 132if(s.type==C.NOTE){for(m=0;m<=s.nhd;m++){if(s.notes[m].acc){dx=5+s.notes[m].shac}else{dx=6-s.notes[m].shhd 133switch(s.head){case C.SQUARE:dx+=3.5 134break 135case C.OVALBARS:case C.OVAL:dx+=2 136break}} 137if(dx>xc) 138xc=dx}} 139h=3*(s.notes[s.nhd].pit-s.notes[0].pit)+4;m=dd.h 140if(h<m) 141h=m;de.has_val=true;de.val=h;de.x-=xc;de.y=3*(s.notes[0].pit-18)-3} 142function d_cresc(de){if(de.ldst) 143return 144var s,dd,dd2,up,x,dx,x2,i,s2=de.s,de2=de.start,de2_prev,de_next;s=de2.s;x=s.x+3;i=de2.ix 145if(i>0) 146de2_prev=a_de[i-1];de.st=s2.st;de.lden=false;de.has_val=true;up=up_p(s2,s2.pos.dyn) 147if(up) 148de.up=true 149if(de2_prev&&de2_prev.s==s&&((de.up&&!de2_prev.up)||(!de.up&&de2_prev.up))){dd2=de2_prev.dd 150if(f_staff[dd2.func]){x2=de2_prev.x+de2_prev.val+4 151if(x2>x) 152x=x2}} 153if(de.defl.noen){dx=de.x-x 154if(dx<20){x=de.x-20-3;dx=20}}else{x2=s2.x;de_next=a_de[de.ix+1] 155if(de_next&&de_next.s==s&&((de.up&&!de_next.up)||(!de.up&&de_next.up))){dd2=de_next.dd 156if(f_staff[dd2.func]) 157x2-=5} 158dx=x2-x-4 159if(dx<20){x-=(20-dx)*.5;dx=20}} 160de.val=dx;de.x=x;de.y=y_get(de.st,up,x,dx) 161if(!up){dd=de.dd;de.y-=dd.h}} 162function d_near(de){var y,up,s=de.s,dd=de.dd 163if(dd.str){return} 164if(s.multi) 165up=s.multi>0 166else 167up=s.stem<0 168if(up){y=s.ymx|0}else if(dd.name[0]=='w'){de.inv=true 169y=s.ymn}else{y=s.ymn-dd.h} 170if(y>-6&&y<24){if(up) 171y+=3;y=(((y+6)/6)|0)*6-6} 172if(up) 173s.ymx=y+dd.h 174else if(dd.name[0]=='w') 175s.ymn=y-dd.h 176else 177s.ymn=y 178de.y=y 179if(s.type==C.NOTE) 180de.x+=s.notes[s.stem>=0?0:s.nhd].shhd 181if(dd.name[0]=='d'&&s.nflags>=-1){if(up){if(s.stem>0) 182de.x+=3.5}else{if(s.stem<0) 183de.x-=3.5}}} 184function d_pf(de){var dd2,x2,x,up,s=de.s,dd=de.dd,de_prev;if(de.ldst) 185return 186if(de.start){d_cresc(de) 187return} 188de.val=dd.wl+dd.wr;up=up_p(s,s.pos.vol) 189if(up) 190de.up=true;x=s.x-dd.wl 191if(de.ix>0){de_prev=a_de[de.ix-1] 192if(de_prev.s==s&&((de.up&&!de_prev.up)||(!de.up&&de_prev.up))){dd2=de_prev.dd 193if(f_staff[dd2.func]){x2=de_prev.x+de_prev.val+4;if(x2>x) 194x=x2}}} 195de.x=x;de.y=y_get(s.st,up,x,de.val) 196if(!up) 197de.y-=dd.h} 198function d_slide(de){var m,dx,s=de.s,yc=s.notes[0].pit,xc=5 199for(m=0;m<=s.nhd;m++){if(s.notes[m].acc){dx=4+s.notes[m].shac}else{dx=5-s.notes[m].shhd 200switch(s.head){case C.SQUARE:dx+=3.5 201break 202case C.OVALBARS:case C.OVAL:dx+=2 203break}} 204if(s.notes[m].pit<=yc+3&&dx>xc) 205xc=dx} 206de.x-=xc;de.y=3*(yc-18)} 207function d_trill(de){if(de.ldst) 208return 209var up,y,w,tmp,dd=de.dd,de2=de.prev,s2=de.s,st=s2.st,s=de.start.s,x=s.x 210if(de2){x=de2.s.x+de.dd.wl+2 211de2.val-=de2.dd.wr 212if(de2.val<8) 213de2.val=8} 214de.st=st 215if(dd.func!=4){switch(dd.glyph){case"8va":case"15ma":up=1 216break 217default:up=s2.multi>=0 218break}} 219if(de.defl.noen){w=de.x-x 220if(w<20){x=de.x-20-3;w=20}}else{w=s2.x-x-6 221if(s2.type==C.NOTE) 222w-=6 223if(w<10){x-=10-w 224w=10}} 225dd=de.dd;y=y_get(st,up,x-dd.wl-5,w) 226if(up){tmp=staff_tb[s.st].topbar+2 227if(y<tmp) 228y=tmp}else{tmp=staff_tb[s.st].botbar-2 229if(y>tmp) 230y=tmp 231y-=dd.h} 232if(de2){if(up){if(y<de2.y) 233y=de2.y}else{if(y>=de2.y){y=de2.y}else{do{de2.y=y 234de2=de2.prev}while(de2)}}} 235de.lden=false;de.has_val=true;de.val=w;de.x=x;de.y=y 236if(up) 237y+=dd.h;y_set(st,up,x,w,y) 238if(up) 239s.ymx=s2.ymx=y 240else 241s.ymn=s2.ymn=y} 242function d_upstaff(de){if(de.ldst) 243return 244if(de.start){d_trill(de) 245return} 246var yc,up,inv,s=de.s,dd=de.dd,x=de.x,w=dd.wl+dd.wr,stafft=staff_tb[s.st].topbar+2,staffb=staff_tb[s.st].botbar-2 247if(s.nhd) 248x+=s.notes[s.stem>=0?0:s.nhd].shhd;up=-1 249if(dd.func==4){up=0}else if(s.pos){switch(s.pos.orn){case C.SL_ABOVE:up=1 250break 251case C.SL_BELOW:up=0 252break}} 253switch(dd.glyph){case"accent":case"roll":if(!up||(up<0&&(s.multi<0||(!s.multi&&s.stem>0)))){yc=y_get(s.st,false,s.x-dd.wl,w)-2 254if(yc>staffb) 255yc=staffb;yc-=dd.h;y_set(s.st,false,s.x,0,yc);inv=true;s.ymn=yc}else{yc=y_get(s.st,true,s.x-dd.wl,w)+2 256if(yc<stafft) 257yc=stafft;y_set(s.st,true,s.x-dd.wl,w,yc+dd.h);s.ymx=yc+dd.h} 258break 259case"brth":case"lphr":case"mphr":case"sphr":yc=stafft+1 260if(dd.glyph=="brth"&&yc<s.ymx) 261yc=s.ymx 262for(s=s.ts_next;s;s=s.ts_next) 263if(s.seqst) 264break 265x+=((s?s.x:realwidth)-x)*.45 266break 267default:if(dd.name.indexOf("invert")==0) 268inv=true 269if(dd.name!="invertedfermata"&&(up>0||(up<0&&s.multi>=0))){yc=y_get(s.st,true,s.x-dd.wl,w)+2+dd.hd 270if(yc<stafft) 271yc=stafft;y_set(s.st,true,s.x-dd.wl,w,yc+dd.h);s.ymx=yc+dd.h}else{yc=y_get(s.st,false,s.x-dd.wl,w)-3+dd.hd 272if(yc>staffb) 273yc=staffb;yc-=dd.h;y_set(s.st,false,s.x-dd.wl,w,yc-dd.hd) 274if(dd.name=="fermata") 275inv=true;s.ymn=yc} 276break} 277if(inv){yc+=dd.h;de.inv=true} 278de.x=x;de.y=yc} 279var func_tb=[d_near,d_slide,d_arp,d_upstaff,d_upstaff,d_trill,d_pf,d_cresc] 280function deco_add(param){var dv=param.match(/(\S*)\s+(.*)/);decos[dv[1]]=dv[2]} 281function deco_def(nm){var a,dd,dd2,name2,c,i,elts,str,hd,text=decos[nm] 282if(!text){if(cfmt.decoerr) 283error(1,null,"Unknown decoration '$1'",nm) 284return} 285a=text.match(/(\d+)\s+(.+?)\s+([0-9.,]+)\s+([0-9.]+)\s+([0-9.]+)/) 286if(!a){error(1,null,"Invalid decoration '$1'",nm) 287return} 288var c_func=Number(a[1]),h=a[3],wl=parseFloat(a[4]),wr=parseFloat(a[5]) 289if(isNaN(c_func)){error(1,null,"%%deco: bad C function value '$1'",a[1]) 290return} 291if(c_func>10&&(c_func<32||c_func>43)){error(1,null,"%%deco: bad C function index '$1'",c_func) 292return} 293if(c_func==5) 294c_func=3 295if(c_func==7) 296c_func=6 297if(h.indexOf(',')>0){h=h.split(',') 298hd=h[1] 299h=h[0]}else{hd=0} 300if(h>50||wl>80||wr>80){error(1,null,"%%deco: abnormal h/wl/wr value '$1'",text) 301return} 302dd=dd_tb[nm] 303if(!dd){dd={name:nm} 304dd_tb[nm]=dd} 305dd.func=dd.name.indexOf("head-")==0?9:c_func;dd.glyph=a[2];dd.h=Number(h) 306dd.hd=Number(hd) 307dd.wl=wl;dd.wr=wr;str=text.replace(a[0],'').trim() 308if(str){if(str[0]=='"') 309str=str.slice(1,-1);dd.str=str} 310if(dd.func==6&&dd.str==undefined) 311dd.str=dd.name 312c=dd.name.slice(-1) 313if(c=='('||(c==')'&&dd.name.indexOf('(')<0)){dd.str=null;name2=dd.name.slice(0,-1)+(c=='('?')':'(');dd2=dd_tb[name2] 314if(dd2){if(c=='('){dd.dd_en=dd2;dd2.dd_st=dd}else{dd.dd_st=dd2;dd2.dd_en=dd}}else{dd2=deco_def(name2) 315if(!dd2) 316return}} 317return dd} 318function deco_cnv(a_dcn,s,prev){var i,j,dd,dcn,note,nd=a_dcn.length 319for(i=0;i<nd;i++){dcn=a_dcn[i];dd=dd_tb[dcn] 320if(!dd){dd=deco_def(dcn) 321if(!dd) 322continue} 323switch(dd.func){case 0:if(s.type==C.BAR&&dd.name=="dot"){s.bar_dotted=true 324break} 325case 1:case 2:if(!s.notes){error(1,s,errs.must_note_rest,dd.name) 326continue} 327break 328case 8:if(s.type!=C.NOTE){error(1,s,errs.must_note,dd.name) 329continue} 330note=s.notes[s.nhd] 331if(!note.a_dcn) 332note.a_dcn=[] 333note.a_dcn.push(dd.name) 334continue 335case 9:if(!s.notes){error(1,s,errs.must_note_rest,dd.name) 336continue} 337for(j=0;j<=s.nhd;j++){note=s.notes[j] 338if(!note.a_dcn) 339note.a_dcn=[] 340note.a_dcn.push(dd.name)} 341continue 342default:break 343case 10:if(s.notes){for(j=0;j<=s.nhd;j++) 344s.notes[j].color=dd.name}else{s.color=dd.name} 345continue 346case 32:s.invis=true 347continue 348case 33:if(s.type!=C.BAR){error(1,s,"!beamon! must be on a bar") 349continue} 350s.beam_on=true 351continue 352case 34:if(s.type!=C.NOTE||!prev||prev.type!=C.NOTE||s.dur!=prev.dur){error(1,s,"!$1! must be on the last of a couple of notes",dd.name) 353continue} 354s.trem2=true;s.beam_end=true;s.beam_st=false;prev.beam_st=true;prev.beam_end=false;s.ntrem=prev.ntrem=Number(dd.name[4]);for(j=0;j<=s.nhd;j++) 355s.notes[j].dur*=2;for(j=0;j<=prev.nhd;j++) 356prev.notes[j].dur*=2 357continue 358case 35:if(s.type!=C.NOTE){error(1,s,errs.must_note,dd.name) 359continue} 360s.xstem=true;continue 361case 36:if(s.type!=C.NOTE){error(1,s,errs.must_note,dd.name) 362continue} 363if(dd.name[6]=='1') 364s.beam_br1=true 365else 366s.beam_br2=true 367continue 368case 37:s.rbstop=1 369continue 370case 38:if(s.type!=C.NOTE){error(1,s,errs.must_note,dd.name) 371continue} 372s.trem1=true;s.ntrem=dd.name.length 373continue 374case 39:if(s.type!=C.NOTE){error(1,s,errs.must_note,dd.name) 375continue} 376s.feathered_beam=dd.name[5]=='a'?1:-1;continue 377case 40:s.stemless=true 378continue 379case 41:s.rbstop=2 380continue 381case 42:if(!s.notes[0].acc) 382continue 383dcn="sacc"+s.notes[0].acc.toString() 384dd=dd_tb[dcn] 385if(!dd){dd=deco_def(dcn) 386if(!dd){error(1,s,errs.bad_val,"!editorial!") 387continue}} 388delete s.notes[0].acc 389curvoice.acc[s.notes[0].pit+19]=0 390break 391case 43:j=curvoice.acc[s.notes[0].pit+19] 392if(s.notes[0].acc||!j) 393continue 394if(!s.notes[0].a_dcn) 395s.notes[0].a_dcn=[] 396s.notes[0].a_dcn.push("cacc"+j) 397continue} 398if(!s.a_dd) 399s.a_dd=[] 400s.a_dd.push(dd)}} 401function deco_update(s,dx){var i,de,nd=a_de.length 402for(i=0;i<nd;i++){de=a_de[i] 403if(de.s==s) 404de.x+=dx}} 405function deco_width(s){var dd,i,wl=0,a_dd=s.a_dd,nd=a_dd.length 406for(i=0;i<nd;i++){dd=a_dd[i] 407switch(dd.func){case 1:if(wl<7) 408wl=7 409break 410case 2:if(wl<14) 411wl=14 412break 413case 3:switch(dd.glyph){case"brth":case"lphr":case"mphr":case"sphr":if(s.wr<20) 414s.wr=20 415break} 416break}} 417if(wl!=0&&s.prev&&s.prev.type==C.BAR) 418wl-=3 419return wl} 420Abc.prototype.draw_all_deco=function(){if(!a_de.length) 421return 422var de,de2,dd,s,note,f,st,x,y,y2,ym,uf,i,str,a,new_de=[],ymid=[] 423if(!cfmt.dynalign){st=nstaff;y=staff_tb[st].y 424while(--st>=0){y2=staff_tb[st].y;ymid[st]=(y+24+y2)*.5;y=y2}} 425while(1){de=a_de.shift() 426if(!de) 427break 428dd=de.dd 429if(!dd) 430continue 431if(dd.dd_en) 432continue 433s=de.s 434f=dd.glyph;i=f.indexOf('/') 435if(i>0){if(s.stem>=0) 436f=f.slice(0,i) 437else 438f=f.slice(i+1)} 439if(f_staff[dd.func]) 440set_sscale(s.st) 441else 442set_scale(s);st=de.st;if(!staff_tb[st].topbar) 443continue 444x=de.x;y=de.y+staff_tb[st].y 445if(de.m!=undefined){note=s.notes[de.m];if(note.shhd) 446x+=note.shhd*stv_g.scale}else if(f_staff[dd.func]&&!cfmt.dynalign&&((de.up&&st>0)||(!de.up&&st<nstaff))){if(de.up) 447ym=ymid[--st] 448else 449ym=ymid[st++];ym-=dd.h*.5 450if((de.up&&y<ym)||(!de.up&&y>ym)){y2=y_get(st,!de.up,de.x,de.val) 451+staff_tb[st].y 452if(de.up) 453y2-=dd.h 454if((de.up&&y2>ym)||(!de.up&&y2<ym)){y=ym}}} 455uf=user[f] 456if(uf&&typeof(uf)=="function"){uf(x,y,de) 457continue} 458if(self.psdeco(f,x,y,de)) 459continue 460anno_start(s,'deco') 461if(de.inv){g_open(x,y,0,1,-1);x=y=0} 462if(de.has_val){if(dd.func!=2||stv_g.st<0) 463out_deco_val(x,y,f,de.val/stv_g.scale,de.defl) 464else 465out_deco_val(x,y,f,de.val,de.defl) 466if(de.defl.noen) 467new_de.push(de.start)}else if(dd.str!=undefined){str=dd.str 468if(str[0]=='@'){a=str.match(/^@([0-9.-]+),([0-9.-]+);?/);x+=Number(a[1]);y+=Number(a[2]);str=str.replace(a[0],"")} 469out_deco_str(x,y,f,str)}else if(de.lden){out_deco_long(x,y,de)}else{xygl(x,y,f)} 470if(stv_g.g) 471g_close();anno_stop(s,'deco')} 472a_de=new_de} 473function draw_deco_near(){var s,g 474function ldeco_update(s){var i,de,x=s.x-s.wl,nd=a_de.length 475for(i=0;i<nd;i++){de=a_de[i];de.ix=i;de.s.x=de.x=x;de.defl.nost=true}} 476function create_deco(s){var dd,k,l,pos,de,x,nd=s.a_dd.length 477for(k=0;k<nd;k++){dd=s.a_dd[k] 478switch(dd.func){default:pos=0 479break 480case 3:case 4:pos=s.pos.orn 481break 482case 6:pos=s.pos.vol 483break 484case 7:pos=s.pos.dyn 485break} 486if(pos==C.SL_HIDDEN) 487continue 488de={s:s,dd:dd,st:s.st,ix:a_de.length,defl:{},x:s.x,y:s.y,} 489if(s.type==C.BAR) 490de.x-=s.wl/2-2 491a_de.push(de) 492if(dd.dd_en){de.ldst=true}else if(dd.dd_st){de.lden=true;de.defl.nost=true} 493if(!f_near[dd.func]) 494continue 495func_tb[dd.func](de)}} 496function create_dh(s,m){var f,str,de,uf,k,dcn,dd,note=s.notes[m],nd=note.a_dcn.length 497for(k=0;k<nd;k++){dcn=note.a_dcn[k];dd=dd_tb[dcn] 498if(!dd){dd=deco_def(dcn) 499if(!dd) 500continue} 501switch(dd.func){case 0:case 1:case 3:case 4:case 8:break 502default:error(1,null,"Cannot have !$1! on a head",dd.name) 503continue 504case 9:note.invis=true 505break 506case 10:note.color=dd.name 507continue 508case 32:note.invis=true 509continue 510case 40:s.stemless=true 511continue} 512de={s:s,dd:dd,st:s.st,m:m,ix:0,defl:{},x:s.x,y:3*(note.pit-18),} 513a_de.push(de) 514if(dd.dd_en){de.ldst=true}else if(dd.dd_st){de.lden=true;de.defl.nost=true}}} 515function create_all(s){if(s.a_dd) 516create_deco(s) 517if(s.notes){for(var m=0;m<s.notes.length;m++){if(s.notes[m].a_dcn) 518create_dh(s,m)}}} 519function ll_deco(){var i,j,de,de2,dd,dd2,v,s,st,n_de=a_de.length 520for(i=0;i<n_de;i++){de=a_de[i] 521if(!de.ldst) 522continue 523dd=de.dd;dd2=dd.dd_en;s=de.s;v=s.v 524for(j=i+1;j<n_de;j++){de2=a_de[j] 525if(!de2.start&&de2.dd==dd2&&de2.s.v==v) 526break} 527if(j==n_de){st=s.st;for(j=i+1;j<n_de;j++){de2=a_de[j] 528if(!de2.start&&de2.dd==dd2&&de2.s.st==st) 529break}} 530if(j==n_de){de2={s:s,st:de.st,dd:dd2,ix:a_de.length-1,x:realwidth-6,y:s.y,lden:true,defl:{noen:true}} 531if(de2.x<s.x+10) 532de2.x=s.x+10 533if(de.m!=undefined) 534de2.m=de.m;a_de.push(de2)} 535de2.start=de;de2.defl.nost=de.defl.nost 536if(i>0&&a_de[i-1].s.time==de.s.time&&a_de[i-1].dd.name.slice(0,dd.name.length-1)==dd.name.slice(0,dd.name.length-1)) 537de2.prev=a_de[i-1]} 538for(i=0;i<n_de;i++){de2=a_de[i] 539if(!de2.lden||de2.start) 540continue 541s=de2.s;de={s:prev_scut(s),st:de2.st,dd:de2.dd.dd_st,ix:a_de.length-1,y:s.y,ldst:true} 542de.x=de.s.x 543if(de2.m!=undefined) 544de.m=de2.m;a_de.push(de);de2.start=de}} 545for(s=tsfirst;s;s=s.ts_next){switch(s.type){case C.CLEF:case C.KEY:case C.METER:continue} 546break} 547if(a_de.length) 548ldeco_update(s) 549for(;s;s=s.ts_next){switch(s.type){case C.BAR:case C.MREST:case C.NOTE:case C.REST:case C.SPACE:break 550case C.GRACE:for(g=s.extra;g;g=g.next) 551create_all(g) 552break 553default:continue} 554create_all(s)} 555ll_deco()} 556function draw_deco_note(){var i,de,dd,f,nd=a_de.length 557for(i=0;i<nd;i++){de=a_de[i];dd=de.dd;f=dd.func 558if(f_note[f]&&de.m==undefined) 559func_tb[f](de)}} 560function draw_deco_staff(){var s,p_voice,y,i,v,de,dd,minmax=new Array(nstaff+1),nd=a_de.length 561function draw_repbra(p_voice){var s,s1,x,y,y2,i,p,w,wh,first_repeat;y=staff_tb[p_voice.st].topbar+25 562for(s=p_voice.sym;s;s=s.next){if(s.type!=C.BAR) 563continue 564if(!s.rbstart||s.norepbra) 565continue 566if(!s.next) 567break 568if(!first_repeat){first_repeat=s;set_font("repeat")} 569s1=s 570for(;;){if(!s.next) 571break 572s=s.next 573if(s.rbstop) 574break} 575y2=y_get(p_voice.st,true,s1.x,s.x-s1.x) 576if(y<y2) 577y=y2 578if(s1.text){wh=strwh(s1.text);y2=y_get(p_voice.st,true,s1.x+4,wh[0])+ 579wh[1] 580if(y<y2) 581y=y2} 582if(s.rbstart) 583s=s.prev} 584s=first_repeat 585if(!s) 586return 587set_dscale(p_voice.st,true);y2=y*staff_tb[p_voice.st].staffscale 588for(;s;s=s.next){if(!s.rbstart||s.norepbra) 589continue 590s1=s 591while(1){if(!s.next) 592break 593s=s.next 594if(s.rbstop) 595break} 596if(s1==s) 597break 598x=s1.x 599if(cfmt.measurenb>0&s.bar_num&&s.bar_num%cfmt.measurenb) 600x+=6 601if(s.type!=C.BAR){w=s.rbstop?0:s.x-realwidth+4}else if((s.bar_type.length>1&&s.bar_type!="[]")||s.bar_type=="]"){if(s1.st>0&&!(cur_sy.staves[s1.st-1].flags&STOP_BAR)) 602w=s.wl 603else if(s.bar_type.slice(-1)==':') 604w=12 605else if(s.bar_type[0]!=':') 606w=0 607else 608w=8}else{w=s.rbstop?0:8} 609w=(s.x-x-w) 610if(!s.next&&!s.rbstop&&!p_voice.bar_start){p_voice.bar_start=clone(s);p_voice.bar_start.type=C.BAR;p_voice.bar_start.bar_type="" 611delete p_voice.bar_start.text;p_voice.bar_start.rbstart=1 612delete p_voice.bar_start.a_gch} 613if(s1.text) 614xy_str(x+4,y2-gene.curfont.size-3,s1.text);xypath(x,y2);if(s1.rbstart==2) 615output+='m0 20v-20';output+='h'+w.toFixed(1) 616if(s.rbstop==2) 617output+='v20';output+='"/>\n';y_set(s1.st,true,x,w,y+2) 618if(s.rbstart) 619s=s.prev}} 620for(i=0;i<=nstaff;i++) 621minmax[i]={ymin:0,ymax:0} 622for(i=0;i<nd;i++){de=a_de[i];dd=de.dd 623if(!dd) 624continue 625if(!f_staff[dd.func]||de.m!=undefined) 626continue 627func_tb[dd.func](de) 628if(dd.dd_en) 629continue 630if(cfmt.dynalign){if(de.up){if(de.y>minmax[de.st].ymax) 631minmax[de.st].ymax=de.y}else{if(de.y<minmax[de.st].ymin) 632minmax[de.st].ymin=de.y}}} 633for(i=0;i<nd;i++){de=a_de[i];dd=de.dd 634if(!dd) 635continue 636if(dd.dd_en||!f_staff[dd.func]) 637continue 638if(cfmt.dynalign){if(de.up) 639y=minmax[de.st].ymax 640else 641y=minmax[de.st].ymin;de.y=y}else{y=de.y} 642if(de.up) 643y+=dd.h;y_set(de.st,de.up,de.x,de.val,y)} 644draw_all_chsy() 645for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 646if(p_voice.second||!p_voice.sym) 647continue 648draw_repbra(p_voice)}} 649function draw_measnb(){var s,st,bar_num,x,y,w,any_nb,font_size,w0,sy=cur_sy 650for(st=0;st<=nstaff;st++){if(sy.st_print[st]) 651break} 652if(st>nstaff) 653return 654set_dscale(st) 655if(staff_tb[st].staffscale!=1){font_size=get_font("measure").size;param_set_font("measurefont","* "+ 656(font_size/staff_tb[st].staffscale).toString())} 657set_font("measure");w0=cwidf('0');s=tsfirst;bar_num=gene.nbar 658if(bar_num>1){if(cfmt.measurenb==0){any_nb=true;y=y_get(st,true,0,20) 659if(y<staff_tb[st].topbar+14) 660y=staff_tb[st].topbar+14;xy_str(0,y,bar_num.toString());y_set(st,true,0,20,y+gene.curfont.size+2)}else if(bar_num%cfmt.measurenb==0){for(;;s=s.ts_next){switch(s.type){case C.CLEF:case C.KEY:case C.METER:case C.STBRK:continue} 661break} 662if(s.type!=C.BAR||!s.bar_num){if(s.prev) 663s=s.prev;any_nb=true;w=w0 664if(bar_num>=10) 665w*=bar_num>=100?3:2 666if(gene.curfont.pad) 667w+=gene.curfont.pad*2 668x=s.x+s.wr+1 669y=y_get(st,true,x,w) 670if(y<staff_tb[st].topbar+6) 671y=staff_tb[st].topbar+6;y+=2+gene.curfont.pad 672xy_str(x,y,bar_num.toString()) 673y+=gene.curfont.size+gene.curfont.pad 674y_set(st,true,x,w,y)}}} 675for(;s;s=s.ts_next){switch(s.type){case C.STAVES:sy=s.sy 676for(st=0;st<nstaff;st++){if(sy.st_print[st]) 677break} 678set_dscale(st) 679continue 680default:continue 681case C.BAR:if(!s.bar_num||s.bar_num<=1) 682continue 683break} 684bar_num=s.bar_num 685if(cfmt.measurenb==0||(bar_num%cfmt.measurenb)!=0||!s.next||s.bar_mrep) 686continue 687if(!any_nb) 688any_nb=true;w=w0 689if(bar_num>=10) 690w*=bar_num>=100?3:2 691if(gene.curfont.pad) 692w+=gene.curfont.pad*2 693x=s.x-w*(s.text?.6:.4) 694y=y_get(st,true,x,w) 695if(y<staff_tb[st].topbar+3) 696y=staff_tb[st].topbar+3 697if(s.next.type==C.NOTE){if(s.next.stem>0){if(y<s.next.ys-gene.curfont.size) 698y=s.next.ys-gene.curfont.size}else{if(y<s.next.y) 699y=s.next.y}} 700y+=2+gene.curfont.pad 701xy_str(x,y,bar_num.toString()) 702y+=gene.curfont.size+gene.curfont.pad 703y_set(st,true,x,w,y)} 704gene.nbar=bar_num 705if(font_size) 706param_set_font("measurefont","* "+font_size.toString())} 707function draw_partempo(st,top){var s,some_part,some_tempo,h,w,y,dy=0,ht=0 708var ymin=staff_tb[st].topbar+8,dosh=0,shift=1,x=-100 709for(s=tsfirst;s;s=s.ts_next){if(s.type!=C.TEMPO||s.invis) 710continue 711if(!some_tempo) 712some_tempo=s;w=s.tempo_wh[0] 713if(s.time==0&&s.x>40) 714s.x=40;y=y_get(st,true,s.x-16,w) 715if(y>ymin) 716ymin=y 717if(x>=s.x-16&&!(dosh&(shift>>1))) 718dosh|=shift;shift<<=1;x=s.x-16+w} 719if(some_tempo){set_sscale(-1);set_font("tempo");ht=gene.curfont.size+8;y=2-ht;h=y-ht 720if(dosh!=0) 721ht*=2 722if(top<ymin+ht) 723dy=ymin+ht-top 724for(s=some_tempo;s;s=s.ts_next){if(s.type!=C.TEMPO||s.invis) 725continue 726if(user.anno_start||user.anno_stop){s.wl=16;s.wr=30;s.ymn=(dosh&1)?h:y;s.ymx=s.ymn+14;anno_start(s)} 727writempo(s,s.x-16,(dosh&1)?h:y);anno_stop(s);dosh>>=1 728while(s.ts_next&&s.ts_next.type==C.TEMPO) 729s=s.ts_next}} 730ymin=staff_tb[st].topbar+6 731for(s=tsfirst;s;s=s.ts_next){if(s.type!=C.PART||s.invis) 732continue 733if(!some_part){some_part=s;set_font("parts");h=gene.curfont.size+2+ 734gene.curfont.pad*2} 735w=strwh(s.text)[0];y=y_get(st,true,s.x-10,w+3) 736if(ymin<y) 737ymin=y} 738if(some_part){set_sscale(-1) 739if(top+dy<ymin+h+ht) 740dy=ymin+h+ht-top 741for(s=some_part;s;s=s.ts_next){if(s.type!=C.PART||s.invis) 742continue 743s.x-=10;if(user.anno_start||user.anno_stop){w=strwh(s.text)[0];s.wl=0;s.wr=w;s.ymn=-ht-h;s.ymx=s.ymn+h;anno_start(s)} 744xy_str(s.x,2-ht-h,s.text);anno_stop(s) 745while(s.ts_next&&s.ts_next.type==C.PART) 746s=s.ts_next}} 747return dy} 748var STEM_MIN=16,STEM_MIN2=14,STEM_MIN3=12,STEM_MIN4=10,STEM_CH_MIN=14,STEM_CH_MIN2=10,STEM_CH_MIN3=9,STEM_CH_MIN4=9,BEAM_DEPTH=3.2,BEAM_OFFSET=.25,BEAM_SHIFT=5,BEAM_STUB=8,SLUR_SLOPE=.5,GSTEM=15,GSTEM_XOFF=2.3 749var cache,anno_a=[] 750function b_pos(grace,stem,nflags,b){var top,bot,d1,d2,shift=!grace?BEAM_SHIFT:3.5,depth=!grace?BEAM_DEPTH:1.8 751function rnd6(y){var iy=Math.round((y+12)/6)*6-12 752return iy-y} 753if(stem>0){bot=b-(nflags-1)*shift-depth 754if(bot>26) 755return 0 756top=b}else{top=b+(nflags-1)*shift+depth 757if(top<-2) 758return 0 759bot=b} 760d1=rnd6(top-BEAM_OFFSET);d2=rnd6(bot+BEAM_OFFSET) 761return d1*d1>d2*d2?d2:d1} 762function sym_dup(s){var m,note 763s=clone(s) 764s.invis=true 765delete s.extra;delete s.text 766delete s.a_gch 767delete s.a_ly 768delete s.a_dd;delete s.tp 769s.notes=clone(s.notes) 770for(m=0;m<=s.nhd;m++){note=s.notes[m]=clone(s.notes[m]) 771delete note.a_dcn} 772return s} 773var min_tb=[[STEM_MIN,STEM_MIN,STEM_MIN2,STEM_MIN3,STEM_MIN4,STEM_MIN4],[STEM_CH_MIN,STEM_CH_MIN,STEM_CH_MIN2,STEM_CH_MIN3,STEM_CH_MIN4,STEM_CH_MIN4]] 774Abc.prototype.calculate_beam=function(bm,s1){var s,s2,g,notes,nflags,st,v,two_staves,two_dir,x,y,ys,a,b,stem_err,max_stem_err,p_min,p_max,s_closest,stem_xoff,scale,visible,dy 775if(!s1.beam_st){s=sym_dup(s1);lkvsym(s,s1);lktsym(s,s1);s.x-=12 776if(s.x>s1.prev.x+12) 777s.x=s1.prev.x+12;s.beam_st=true 778delete s.beam_end;s.tmp=true 779delete s.sls;s1=s} 780notes=nflags=0;two_staves=two_dir=false;st=s1.st;v=s1.v;stem_xoff=s1.grace?GSTEM_XOFF:3.5 781for(s2=s1;;s2=s2.next){if(s2.type==C.NOTE){if(s2.nflags>nflags) 782nflags=s2.nflags;notes++ 783if(s2.st!=st) 784two_staves=true 785if(s2.stem!=s1.stem) 786two_dir=true 787if(!visible&&!s2.invis&&(!s2.stemless||s2.trem2)) 788visible=true 789if(s2.beam_end) 790break} 791if(!s2.next){for(;;s2=s2.prev){if(s2.type==C.NOTE) 792break} 793s=sym_dup(s2);s.next=s2.next 794if(s.next) 795s.next.prev=s;s2.next=s;s.prev=s2;s.ts_next=s2.ts_next 796if(s.ts_next) 797s.ts_next.ts_prev=s;s2.ts_next=s;s.ts_prev=s2 798delete s.beam_st;s.beam_end=true;s.tmp=true 799delete s.sls;s.x+=12 800if(s.x<realwidth-12) 801s.x=realwidth-12;s2=s;notes++ 802break}} 803if(!visible) 804return false;bm.s2=s2 805if(staff_tb[st].y==0){if(two_staves) 806return false}else{if(!two_staves){bm.s1=s1;bm.a=(s1.ys-s2.ys)/(s1.xs-s2.xs);bm.b=s1.ys-s1.xs*bm.a+staff_tb[st].y;bm.nflags=nflags 807return true}} 808s_closest=s1;p_min=100;p_max=0 809for(s=s1;;s=s.next){if(s.type!=C.NOTE) 810continue 811if((scale=s.p_v.scale)==1) 812scale=staff_tb[s.st].staffscale 813if(s.stem>=0){x=stem_xoff+s.notes[0].shhd 814if(s.notes[s.nhd].pit>p_max){p_max=s.notes[s.nhd].pit;s_closest=s}}else{x=-stem_xoff+s.notes[s.nhd].shhd 815if(s.notes[0].pit<p_min){p_min=s.notes[0].pit;s_closest=s}} 816s.xs=s.x+x*scale;if(s==s2) 817break} 818if(s.grace&&cfmt.flatbeams) 819a=0 820else if(!two_dir&¬es>=3&&s_closest!=s1&&s_closest!=s2) 821a=0 822y=s1.ys+staff_tb[st].y 823if(a==undefined) 824a=(s2.ys+staff_tb[s2.st].y-y)/(s2.xs-s1.xs) 825if(a!=0) 826a=cfmt.beamslope*a/(cfmt.beamslope+Math.abs(a)) 827b=(y+s2.ys+staff_tb[s2.st].y)/2-a*(s2.xs+s1.xs)/2 828max_stem_err=0;s=s1 829if(two_dir){ys=((s1.grace?3.5:BEAM_SHIFT)*(nflags-1)+ 830BEAM_DEPTH)*.5 831if(s1.stem!=s2.stem&&s1.nflags<s2.nflags) 832b+=ys*s2.stem 833else 834b+=ys*s1.stem}else if(!s1.grace){var beam_h=BEAM_DEPTH+BEAM_SHIFT*(nflags-1) 835while(s.ts_prev&&s.ts_prev.type==C.NOTE&&s.ts_prev.time==s.time&&s.ts_prev.x>s1.xs) 836s=s.ts_prev 837for(;s&&s.time<=s2.time;s=s.ts_next){if(s.type!=C.NOTE||s.invis||(s.st!=st&&s.v!=v)){continue} 838x=s.v==v?s.xs:s.x;ys=a*x+b-staff_tb[s.st].y 839if(s.v==v){stem_err=min_tb[s.nhd==0?0:1][s.nflags] 840if(s.stem>0){if(s.notes[s.nhd].pit>26){stem_err-=2 841if(s.notes[s.nhd].pit>28) 842stem_err-=2} 843stem_err-=ys-3*(s.notes[s.nhd].pit-18)}else{if(s.notes[0].pit<18){stem_err-=2 844if(s.notes[0].pit<16) 845stem_err-=2} 846stem_err-=3*(s.notes[0].pit-18)-ys} 847stem_err+=BEAM_DEPTH+BEAM_SHIFT*(s.nflags-1)}else{if(s1.stem>0){if(s.stem>0){if(s.ymn>ys+4||s.ymx<ys-beam_h-2) 848continue 849if(s.v>v) 850stem_err=s.ymx-ys 851else 852stem_err=s.ymn+8-ys}else{stem_err=s.ymx-ys}}else{if(s.stem<0){if(s.ymx<ys-4||s.ymn>ys-beam_h-2) 853continue 854if(s.v<v) 855stem_err=ys-s.ymn 856else 857stem_err=ys-s.ymx+8}else{stem_err=ys-s.ymn}} 858stem_err+=2+beam_h} 859if(stem_err>max_stem_err) 860max_stem_err=stem_err}}else{for(;;s=s.next){ys=a*s.xs+b-staff_tb[s.st].y;stem_err=GSTEM-2 861if(s.stem>0) 862stem_err-=ys-(3*(s.notes[s.nhd].pit-18)) 863else 864stem_err+=ys-(3*(s.notes[0].pit-18));stem_err+=3*(s.nflags-1) 865if(stem_err>max_stem_err) 866max_stem_err=stem_err 867if(s==s2) 868break}} 869if(max_stem_err>0) 870b+=s1.stem*max_stem_err 871if(!two_staves&&!two_dir) 872for(s=s1.next;;s=s.next){switch(s.type){case C.REST:g=s.ts_next 873if(!g||g.st!=st||(g.type!=C.NOTE&&g.type!=C.REST)) 874break 875case C.BAR:if(s.invis) 876break 877case C.CLEF:y=a*s.x+b 878if(s1.stem>0){y=s.ymx-y 879+BEAM_DEPTH+BEAM_SHIFT*(nflags-1) 880+2 881if(y>0) 882b+=y}else{y=s.ymn-y 883-BEAM_DEPTH-BEAM_SHIFT*(nflags-1) 884-2 885if(y<0) 886b+=y} 887break 888case C.GRACE:for(g=s.extra;g;g=g.next){y=a*g.x+b 889if(s1.stem>0){y=g.ymx-y 890+BEAM_DEPTH+BEAM_SHIFT*(nflags-1) 891+2 892if(y>0) 893b+=y}else{y=g.ymn-y 894-BEAM_DEPTH-BEAM_SHIFT*(nflags-1) 895-2 896if(y<0) 897b+=y}} 898break} 899if(s==s2) 900break} 901if(a==0) 902b+=b_pos(s1.grace,s1.stem,nflags,b-staff_tb[st].y) 903for(s=s1;;s=s.next){switch(s.type){case C.NOTE:s.ys=a*s.xs+b-staff_tb[s.st].y 904if(s.stem>0){s.ymx=s.ys+2.5 905if(s.ts_prev&&s.ts_prev.stem>0&&s.ts_prev.st==s.st&&s.ts_prev.ymn<s.ymx&&s.ts_prev.x==s.x&&s.notes[0].shhd==0){s.ts_prev.x-=3;s.ts_prev.xs-=3}}else{s.ymn=s.ys-2.5} 906break 907case C.REST:y=a*s.x+b-staff_tb[s.st].y 908dy=BEAM_DEPTH+BEAM_SHIFT*(nflags-1) 909+(s.head!=C.FULL?4:9) 910if(s1.stem>0){y-=dy 911if(s1.multi==0&&y>12) 912y=12 913if(s.y<=y) 914break}else{y+=dy 915if(s1.multi==0&&y<12) 916y=12 917if(s.y>=y) 918break} 919if(s.head!=C.FULL) 920y=(((y+3+12)/6)|0)*6-12;s.y=y 921break} 922if(s==s2) 923break} 924if(staff_tb[st].y==0) 925return false 926bm.s1=s1;bm.a=a;bm.b=b;bm.nflags=nflags 927return true} 928function draw_beams(bm){var s,i,beam_dir,shift,bshift,bstub,bh,da,k,k1,k2,x1,s1=bm.s1,s2=bm.s2 929function draw_beam(x1,x2,dy,h,bm,n){var y1,dy2,s=bm.s1,nflags=s.nflags 930if(s.ntrem) 931nflags-=s.ntrem 932if(s.trem2&&n>nflags){if(s.dur>=C.BLEN/2){x1=s.x+6;x2=bm.s2.x-6}else if(s.dur<C.BLEN/4){x1+=5;x2-=6}} 933y1=bm.a*x1+bm.b-dy;x2-=x1;x2/=stv_g.scale;dy2=bm.a*x2 934xypath(x1,y1,true);output+='l'+x2.toFixed(1)+' '+(-dy2).toFixed(1)+'v'+h.toFixed(1)+'l'+(-x2).toFixed(1)+' '+dy2.toFixed(1)+'z"/>\n'} 935anno_start(s1,'beam') 936if(!s1.grace){bshift=BEAM_SHIFT;bstub=BEAM_STUB;shift=.34;bh=BEAM_DEPTH}else{bshift=3.5;bstub=3.2;shift=.29;bh=1.8} 937beam_dir=s1.stem 938if(s1.stem!=s2.stem&&s1.nflags<s2.nflags) 939beam_dir=s2.stem 940if(beam_dir<0) 941bh=-bh;draw_beam(s1.xs-shift,s2.xs+shift,0,bh,bm,1);da=0 942for(s=s1;;s=s.next){if(s.type==C.NOTE&&s.stem!=beam_dir) 943s.ys=bm.a*s.xs+bm.b 944-staff_tb[s.st].y 945+bshift*(s.nflags-1)*s.stem 946-bh 947if(s==s2) 948break} 949if(s1.feathered_beam){da=bshift/(s2.xs-s1.xs) 950if(s1.feathered_beam>0){da=-da;bshift=da*s1.xs}else{bshift=da*s2.xs} 951da=da*beam_dir} 952shift=0 953for(i=2;i<=bm.nflags;i++){shift+=bshift 954if(da!=0) 955bm.a+=da 956for(s=s1;;s=s.next){if(s.type!=C.NOTE||s.nflags<i){if(s==s2) 957break 958continue} 959if(s.trem1&&i>s.nflags-s.ntrem){x1=(s.dur>=C.BLEN/2)?s.x:s.xs;draw_beam(x1-5,x1+5,(shift+2.5)*beam_dir,bh,bm,i) 960if(s==s2) 961break 962continue} 963k1=s 964while(1){if(s==s2) 965break 966k=s.next 967if(k.type==C.NOTE||k.type==C.REST){if(k.trem1){if(k.nflags-k.ntrem<i) 968break}else if(k.nflags<i){break}} 969if(k.beam_br1||(k.beam_br2&&i>2)) 970break 971s=k} 972k2=s 973while(k2.type!=C.NOTE) 974k2=k2.prev;x1=k1.xs 975if(k1==k2){if(k1==s1){x1+=bstub}else if(k1==s2){x1-=bstub}else if(k1.beam_br1||(k1.beam_br2&&i>2)){x1+=bstub}else{k=k1.next 976while(k.type!=C.NOTE) 977k=k.next 978if(k.beam_br1||(k.beam_br2&&i>2)){x1-=bstub}else{k1=k1.prev 979while(k1.type!=C.NOTE) 980k1=k1.prev 981if(k1.nflags<k.nflags||(k1.nflags==k.nflags&&k1.dots<k.dots)) 982x1+=bstub 983else 984x1-=bstub}}} 985draw_beam(x1,k2.xs,shift*beam_dir,bh,bm,i) 986if(s==s2) 987break}} 988if(s1.tmp) 989unlksym(s1) 990else if(s2.tmp) 991unlksym(s2) 992anno_stop(s1,'beam')} 993function draw_lstaff(x){var i,j,yb,h,fl,nst=cur_sy.nstaff,l=0 994function draw_sysbra(x,st,flag){var i,st_end,yt,yb 995while(!cur_sy.st_print[st]){if(cur_sy.staves[st].flags&flag) 996return 997st++} 998i=st_end=st 999while(1){if(cur_sy.st_print[i]) 1000st_end=i 1001if(cur_sy.staves[i].flags&flag) 1002break 1003i++} 1004yt=staff_tb[st].y+staff_tb[st].topbar*staff_tb[st].staffscale;yb=staff_tb[st_end].y+staff_tb[st_end].botbar*staff_tb[st_end].staffscale 1005if(flag&(CLOSE_BRACE|CLOSE_BRACE2)) 1006out_brace(x,yb,yt-yb) 1007else 1008out_bracket(x,yt,yt-yb)} 1009for(i=0;;i++){fl=cur_sy.staves[i].flags 1010if(fl&(OPEN_BRACE|OPEN_BRACKET)) 1011l++ 1012if(cur_sy.st_print[i]) 1013break 1014if(fl&(CLOSE_BRACE|CLOSE_BRACKET)) 1015l-- 1016if(i==nst) 1017break} 1018for(j=nst;j>i;j--){if(cur_sy.st_print[j]) 1019break} 1020if(i==j&&l==0) 1021return 1022yb=staff_tb[j].y+staff_tb[j].botbar*staff_tb[j].staffscale;h=staff_tb[i].y+staff_tb[i].topbar*staff_tb[i].staffscale-yb;xypath(x,yb);output+="v"+(-h).toFixed(1)+'"/>\n' 1023for(i=0;i<=nst;i++){fl=cur_sy.staves[i].flags 1024if(fl&OPEN_BRACE) 1025draw_sysbra(x,i,CLOSE_BRACE) 1026if(fl&OPEN_BRACKET) 1027draw_sysbra(x,i,CLOSE_BRACKET) 1028if(fl&OPEN_BRACE2) 1029draw_sysbra(x-6,i,CLOSE_BRACE2) 1030if(fl&OPEN_BRACKET2) 1031draw_sysbra(x-6,i,CLOSE_BRACKET2)}} 1032function draw_meter(s){if(!s.a_meter) 1033return 1034var dx,i,j,meter,x,st=s.st,p_staff=staff_tb[st],y=p_staff.y;if(p_staff.stafflines!='|||||') 1035y+=(p_staff.topbar+p_staff.botbar)/2-12 1036for(i=0;i<s.a_meter.length;i++){meter=s.a_meter[i];x=s.x+s.x_meter[i] 1037if(meter.bot){out_XYAB('\ 1038<g transform="translate(X,Y)" text-anchor="middle">\n\ 1039 <text y="-12">A</text>\n\ 1040 <text>B</text>\n\ 1041</g>\n',x,y+6,m_gl(meter.top),m_gl(meter.bot))}else{out_XYAB('\ 1042<text x="X" y="Y" text-anchor="middle">A</text>\n',x,y+12,m_gl(meter.top))}}} 1043var acc_nd={} 1044function draw_acc(x,y,a){if(typeof a!="number"){var c,n=a[0],d=a[1] 1045c=n+'_'+d 1046a=acc_nd[c] 1047if(!a){a=abc2svg.rat(Math.abs(n),d) 1048d=a[1] 1049a=(n<0?-a[0]:a[0]).toString() 1050if(d!=1) 1051a+='_'+d 1052acc_nd[c]=a}} 1053xygl(x,y,"acc"+a)} 1054function set_hl(p_st,n,x,dx1,dx2){var i,hl 1055if(n>=0){hl=p_st.hlu[n] 1056if(!hl) 1057hl=p_st.hlu[n]=[]}else{hl=p_st.hld[-n] 1058if(!hl) 1059hl=p_st.hld[-n]=[]} 1060for(i=0;i<hl.length;i++){if(x>=hl[i][0]) 1061break} 1062if(i==hl.length){hl.push([x,dx1,dx2])}else if(x>hl[i][0]){hl.splice(++i,0,[x,dx1,dx2])}else{if(dx1<hl[i][1]) 1063hl[i][1]=dx1 1064if(dx2>hl[i][2]) 1065hl[i][2]=dx2}} 1066Abc.prototype.draw_hl=function(s){var i,j,n,note,hla=[],st=s.st,p_staff=staff_tb[st] 1067if(!p_staff.hll) 1068return 1069for(i=0;i<=s.nhd;i++){note=s.notes[i] 1070if(!p_staff.hlmap[note.pit-p_staff.hll]) 1071hla.push([note.pit-18,note.shhd*stv_g.scale])} 1072n=hla.length 1073if(!n) 1074return 1075var dx1,dx2,hl,shhd,hlp,stafflines=p_staff.stafflines,top=stafflines.length-1,yu=top,bot=p_staff.botline/6,yl=bot,dx=s.grace?4:hw_tb[s.head]*1.3 1076note=s.notes[s.stem<0?s.nhd:0] 1077shhd=note.shhd 1078for(i=0;i<hla.length;i++){hlp=hla[i][0] 1079dx1=(hla[i][1]<shhd?hla[i][1]:shhd)-dx 1080dx2=(hla[i][1]>shhd?hla[i][1]:shhd)+dx 1081if(hlp<bot*2){if(hlp<yl*2) 1082yl=++hlp>>1 1083n--}else if(hlp>top*2){yu=hlp>>1 1084n--} 1085set_hl(p_staff,hlp>>1,s.x,dx1,dx2)} 1086dx1=shhd-dx 1087dx2=shhd+dx 1088while(++yl<bot) 1089set_hl(p_staff,yl,s.x,dx1,dx2) 1090while(--yu>top) 1091set_hl(p_staff,yu,s.x,dx1,dx2) 1092if(!n) 1093return 1094i=yl;j=yu 1095while(i>bot&&stafflines[i]=='-') 1096i-- 1097while(j<top&&stafflines[j]=='-') 1098j++ 1099for(;i<j;i++){if(stafflines[i]=='-') 1100set_hl(p_staff,i,s.x,dx1,dx2)}} 1101var sharp_cl=new Int8Array([24,9,15,21,6,12,18]),flat_cl=new Int8Array([12,18,24,9,15,21,6]),sharp1=new Int8Array([-9,12,-9,-9,12,-9]),sharp2=new Int8Array([12,-9,12,-9,12,-9]),flat1=new Int8Array([9,-12,9,-12,9,-12]),flat2=new Int8Array([-12,9,-12,9,-12,9]) 1102Abc.prototype.draw_keysig=function(x,s){if(s.k_none||s.k_play) 1103return 1104var old_sf=s.k_old_sf,st=s.st,staffb=staff_tb[st].y,i,shift,p_seq,clef_ix=s.k_y_clef 1105if(clef_ix&1) 1106clef_ix+=7;clef_ix/=2 1107while(clef_ix<0) 1108clef_ix+=7;clef_ix%=7 1109if(!s.k_a_acc){if(cfmt.cancelkey||s.k_sf==0){if(s.k_sf==0||old_sf*s.k_sf<0){shift=sharp_cl[clef_ix];p_seq=shift>9?sharp1:sharp2 1110for(i=0;i<old_sf;i++){xygl(x,staffb+shift,"acc3");shift+=p_seq[i];x+=5.5} 1111shift=flat_cl[clef_ix];p_seq=shift<18?flat1:flat2 1112for(i=0;i>old_sf;i--){xygl(x,staffb+shift,"acc3");shift+=p_seq[-i];x+=5.5} 1113if(s.k_sf!=0) 1114x+=3}} 1115if(s.k_sf>0){shift=sharp_cl[clef_ix];p_seq=shift>9?sharp1:sharp2 1116for(i=0;i<s.k_sf;i++){xygl(x,staffb+shift,"acc1");shift+=p_seq[i];x+=5.5} 1117if(cfmt.cancelkey&&i<old_sf){x+=2 1118for(;i<old_sf;i++){xygl(x,staffb+shift,"acc3");shift+=p_seq[i];x+=5.5}}} 1119if(s.k_sf<0){shift=flat_cl[clef_ix];p_seq=shift<18?flat1:flat2 1120for(i=0;i>s.k_sf;i--){xygl(x,staffb+shift,"acc-1");shift+=p_seq[-i];x+=5.5} 1121if(cfmt.cancelkey&&i>old_sf){x+=2 1122for(;i>old_sf;i--){xygl(x,staffb+shift,"acc3");shift+=p_seq[-i];x+=5.5}}}}else if(s.k_a_acc.length){var acc,last_acc=s.k_a_acc[0].acc,last_shift=100,s2={st:st,nhd:0,notes:[{}]} 1123for(i=0;i<s.k_a_acc.length;i++){acc=s.k_a_acc[i];shift=(s.k_y_clef 1124+acc.pit-18)*3 1125if(i!=0&&(shift>last_shift+18||shift<last_shift-18)) 1126x-=5.5 1127else if(acc.acc!=last_acc) 1128x+=3;last_acc=acc.acc;s2.x=x 1129s2.notes[0].pit=shift/3+18;self.draw_hl(s2) 1130last_shift=shift;draw_acc(x,staffb+shift,acc.acc) 1131x+=5.5}}} 1132function bar_cnv(bar_type){switch(bar_type){case"[":case"[]":return"" 1133case"|:":case"|::":case"|:::":return"["+bar_type 1134case":|":case"::|":case":::|":return bar_type+"]" 1135case"::":return cfmt.dblrepbar} 1136return bar_type} 1137function nrep_out(x,y,n){y-=3 1138if(n<10){xygl(x-4,y,"mtr"+n)}else{xygl(x-10,y,"mtr"+((n/10)|0)) 1139xygl(x-2,y,"mtr"+(n%10))}} 1140var rest_tb=["r128","r64","r32","r16","r8","r4","r2","r1","r0","r00"] 1141function draw_rest(s){var s2,i,j,x,y,yb,bx,p_staff=staff_tb[s.st] 1142if(s.dur_orig==s.p_v.meter.wmeasure||(s.rep_nb&&s.rep_nb>=0)){if(s.dur<C.BLEN*2) 1143s.nflags=-2 1144else if(s.dur<C.BLEN*4) 1145s.nflags=-3 1146else 1147s.nflags=-4;s.dots=0;s2=s.ts_next 1148while(s2.time!=s.time+s.dur&&s2.ts_next) 1149s2=s2.ts_next 1150x=s2.x-s2.wl 1151s2=s 1152while(!s2.seqst) 1153s2=s2.ts_prev;s2=s2.ts_prev;x=(x+s2.x+s2.wr)/2 1154if(s.a_dd) 1155deco_update(s,x-s.x);s.x=x}else{x=s.x 1156if(s.notes[0].shhd) 1157x+=s.notes[0].shhd*stv_g.scale} 1158if(s.invis) 1159return 1160yb=p_staff.y 1161if(s.rep_nb){set_sscale(s.st);anno_start(s);if(p_staff.stafflines=='|||||') 1162yb+=12 1163else 1164yb+=(p_staff.topbar+p_staff.botbar)/2 1165if(s.rep_nb<0){xygl(x,yb,"srep")}else{xygl(x,yb,"mrep") 1166if(s.rep_nb>2&&s.v==cur_sy.top_voice&&cfmt.measrepnb>0&&!(s.rep_nb%cfmt.measrepnb)) 1167nrep_out(x,yb+p_staff.topbar,s.rep_nb)} 1168anno_a.push(s) 1169return} 1170set_scale(s);anno_start(s);if(s.notes[0].color) 1171set_color(s.notes[0].color);y=s.y;i=5-s.nflags 1172if(i==7&&y==12&&p_staff.stafflines.length<=2) 1173y-=6 1174if(!s.notes[0].invis) 1175xygl(x,y+yb,rest_tb[i]) 1176if(i>=6){j=y/6 1177switch(i){default:switch(p_staff.stafflines[j+1]){case'|':case'[':break 1178default:set_hl(p_staff,j+1,x,-7,7) 1179break} 1180if(i==9){y-=6;j--} 1181break 1182case 7:y+=6;j++ 1183case 6:break} 1184switch(p_staff.stafflines[j]){case'|':case'[':break 1185default:set_hl(p_staff,j,x,-7,7) 1186break}} 1187if(s.dots){x+=8;y+=yb+3 1188j=s.dots 1189i=(s.dur_orig/12)>>((5-s.nflags)-j) 1190while(j-->0){xygl(x,y,(i&(1<<j))?"dot":"dot+") 1191x+=3.5}} 1192set_color();anno_a.push(s)} 1193function draw_gracenotes(s){var yy,x0,y0,x1,y1,x2,y2,x3,y3,bet1,bet2,slur,dy1,dy2,g,last,note,bm={} 1194for(g=s.extra;g;g=g.next){if(g.beam_st&&!g.beam_end){if(self.calculate_beam(bm,g)) 1195draw_beams(bm)} 1196anno_start(g);draw_note(g,!bm.s2) 1197if(g==bm.s2) 1198bm.s2=null 1199anno_a.push(s) 1200if(g.sls||g.sl2) 1201slur=true 1202if(!g.next) 1203break} 1204if(s.sappo){g=s.extra 1205if(!g.next){x1=9;y1=g.stem>0?5:-5}else{x1=(g.next.x-g.x)*.5+4;y1=(g.ys+g.next.ys)*.5-g.y 1206if(g.stem>0) 1207y1-=1 1208else 1209y1+=1} 1210note=g.notes[g.stem<0?0:g.nhd];out_acciac(x_head(g,note),y_head(g,note),x1,y1,g.stem>0)} 1211if(s.p_v.ckey.k_bagpipe||!cfmt.graceslurs||slur||s.tie_s||!s.next||s.next.type!=C.NOTE) 1212return 1213last=g 1214if(((g.stem>=0||s.multi<0)&&g.notes[0].pit<=28)||g.notes[0].pit<16){yy=127 1215for(g=s.extra;g;g=g.next){if(g.y<yy){yy=g.y;last=g}} 1216x0=last.x;y0=last.y-5 1217if(s.extra!=last){x0-=4;y0+=1} 1218s=s.next;x3=s.x-1 1219if(s.stem<0&&s.nflags>-2) 1220x3-=4;y3=3*(s.notes[0].pit-18)-5;dy1=(x3-x0)*.4 1221if(dy1>3) 1222dy1=3;dy2=dy1;bet1=.2;bet2=.8 1223if(y0>y3+7){x0=last.x-1;y0+=.5;y3+=6.5;x3=s.x-5.5;dy1=(y0-y3)*.8;dy2=(y0-y3)*.2;bet1=0}else if(y3>y0+4){y3=y0+4;x0=last.x+2;y0=last.y-4}}else{yy=-127 1224for(g=s.extra;g;g=g.next){if(g.y>yy){yy=g.y;last=g}} 1225x0=last.x;y0=last.y+5 1226if(s.extra!=last){x0-=4;y0-=1} 1227s=s.next;x3=s.x-1 1228if(s.stem>=0&&s.nflags>-2) 1229x3-=2;y3=3*(s.notes[s.nhd].pit-18)+5;dy1=(x0-x3)*.4 1230if(dy1<-3) 1231dy1=-3;dy2=dy1;bet1=.2;bet2=.8 1232if(y0<y3-7){x0=last.x-1;y0-=.5;y3-=6.5;x3=s.x-5.5;dy1=(y0-y3)*.8;dy2=(y0-y3)*.2;bet1=0}else if(y3<y0-4){y3=y0-4;x0=last.x+2;y0=last.y+4}} 1233x1=bet1*x3+(1-bet1)*x0-x0;y1=bet1*y3+(1-bet1)*y0-dy1-y0;x2=bet2*x3+(1-bet2)*x0-x0;y2=bet2*y3+(1-bet2)*y0-dy2-y0;anno_start(s,'slur');xypath(x0,y0+staff_tb[s.st].y);output+='c'+x1.toFixed(1)+' '+(-y1).toFixed(1)+' '+x2.toFixed(1)+' '+(-y2).toFixed(1)+' '+(x3-x0).toFixed(1)+' '+(-y3+y0).toFixed(1)+'"/>\n';anno_stop(s,'slur')} 1234function setdoty(s,y_tb){var m,m1,y 1235for(m=0;m<=s.nhd;m++){y=3*(s.notes[m].pit-18) 1236if((y%6)==0){if(s.dot_low) 1237y-=3 1238else 1239y+=3} 1240y_tb[m]=y} 1241for(m=0;m<s.nhd;m++){if(y_tb[m+1]>y_tb[m]) 1242continue 1243m1=m 1244while(m1>0){if(y_tb[m1]>y_tb[m1-1]+6) 1245break 1246m1--} 1247if(3*(s.notes[m1].pit-18)-y_tb[m1]<y_tb[m+1]-3*(s.notes[m+1].pit-18)){while(m1<=m) 1248y_tb[m1++]-=6}else{y_tb[m+1]=y_tb[m]+6}}} 1249function x_head(s,note){return s.x+note.shhd*stv_g.scale} 1250function y_head(s,note){return staff_tb[s.st].y+3*(note.pit-18)} 1251function draw_basic_note(x,s,m,y_tb){var i,p,yy,dotx,doty,inv,old_color=false,note=s.notes[m],staffb=staff_tb[s.st].y,y=3*(note.pit-18),shhd=note.shhd*stv_g.scale,x_note=x+shhd,y_note=y+staffb 1252var elts=identify_note(s,note.dur),head=elts[0],dots=elts[1],nflags=elts[2] 1253if(note.invis){}else if(s.grace){p="ghd";x_note-=4.5*stv_g.scale}else if(note.map&¬e.map[0]){i=s.head;p=note.map[0][i] 1254if(!p) 1255p=note.map[0][note.map[0].length-1] 1256i=p.indexOf('/') 1257if(i>=0){if(s.stem>=0) 1258p=p.slice(0,i) 1259else 1260p=p.slice(i+1)}}else if(s.type==C.CUSTOS){p="custos"}else{switch(head){case C.OVAL:p="HD" 1261break 1262case C.OVALBARS:if(s.head!=C.SQUARE){p="HDD" 1263break} 1264case C.SQUARE:if(nflags>-4){p="breve"}else{p="longa" 1265inv=s.stem>0} 1266if(!tsnext&&s.next&&s.next.type==C.BAR&&!s.next.next) 1267dots=0 1268x_note+=1 1269break 1270case C.EMPTY:p="Hd" 1271break 1272default:p="hd" 1273break}} 1274if(note.color!=undefined) 1275old_color=set_color(note.color) 1276if(p){if(inv){g_open(x_note,y_note,0,1,-1);x_note=y_note=0} 1277if(!self.psxygl(x_note,y_note,p)) 1278xygl(x_note,y_note,p) 1279if(inv) 1280g_close()} 1281if(dots){dotx=x+(7.7+s.xmx)*stv_g.scale 1282if(y_tb[m]==undefined){y_tb[m]=3*(s.notes[m].pit-18) 1283if((s.notes[m].pit&1)==0) 1284y_tb[m]+=3} 1285doty=y_tb[m]+staffb 1286i=(note.dur/12)>>((5-nflags)-dots) 1287while(dots-->0){xygl(dotx,doty,(i&(1<<dots))?"dot":"dot+") 1288dotx+=3.5}} 1289if(note.acc){x-=note.shac*stv_g.scale 1290if(!s.grace){draw_acc(x,y+staffb,note.acc)}else{g_open(x,y+staffb,0,.75);draw_acc(0,0,note.acc) 1291g_close()}} 1292if(old_color!=false) 1293set_color(old_color)} 1294function draw_note(s,fl){var s2,i,m,y,staffb,slen,c,nflags,x,y,note,y_tb=new Array(s.nhd+1) 1295if(s.dots) 1296setdoty(s,y_tb) 1297note=s.notes[s.stem<0?s.nhd:0];x=x_head(s,note) 1298staffb=staff_tb[s.st].y 1299self.draw_hl(s) 1300y=y_head(s,note) 1301if(!s.stemless){slen=s.ys-s.y;nflags=s.nflags 1302if(s.ntrem) 1303nflags-=s.ntrem 1304if(!fl||nflags<=0){if(s.nflags>0){if(s.stem>=0) 1305slen-=1 1306else 1307slen+=1} 1308out_stem(x,y,slen,s.grace)}else{out_stem(x,y,slen,s.grace,nflags,cfmt.straightflags)}}else if(s.xstem){s2=s.ts_prev;slen=(s2.stem>0?s2.y:s2.ys)-s.y;slen+=staff_tb[s2.st].y-staffb;out_stem(x,y,slen)} 1309if(fl&&s.trem1){var ntrem=s.ntrem||0,x1=x;slen=3*(s.notes[s.stem>0?s.nhd:0].pit-18) 1310if(s.head==C.FULL||s.head==C.EMPTY){x1+=(s.grace?GSTEM_XOFF:3.5)*s.stem 1311if(s.stem>0) 1312slen+=6+5.4*ntrem 1313else 1314slen-=6+5.4}else{if(s.stem>0) 1315slen+=5+5.4*ntrem 1316else 1317slen-=5+5.4} 1318slen/=s.p_v.scale;out_trem(x1,staffb+slen,ntrem)} 1319x=s.x 1320for(m=0;m<=s.nhd;m++) 1321draw_basic_note(x,s,m,y_tb)} 1322function prev_scut(s){while(s.prev){s=s.prev 1323if(s.rbstart) 1324return s} 1325s=s.p_v.sym 1326while(s.type!=C.CLEF) 1327s=s.ts_prev 1328if(s.next&&s.next.type==C.KEY) 1329s=s.next 1330if(s.next&&s.next.type==C.METER) 1331return s.next 1332return s} 1333function slur_direction(k1,k2){var s,some_upstem,low,dir 1334function slur_multi(s1,s2){if(s1.multi) 1335return s1.multi 1336if(s2.multi) 1337return s2.multi 1338return 0} 1339if(k1.grace&&k1.stem>0) 1340return-1 1341dir=slur_multi(k1,k2) 1342if(dir) 1343return dir 1344for(s=k1;;s=s.next){if(s.type==C.NOTE){if(!s.stemless){if(s.stem<0) 1345return 1 1346some_upstem=true} 1347if(s.notes[0].pit<22) 1348low=true} 1349if(s.time==k2.time) 1350break} 1351if(!some_upstem&&!low) 1352return 1 1353return-1} 1354function slur_out(x1,y1,x2,y2,dir,height,dotted){var dx,dy,dz,alfa=.3,beta=.45;dy=y2-y1 1355if(dy<0) 1356dy=-dy;dx=x2-x1 1357if(dx>40.&&dy/dx<.7){alfa=.3+.002*(dx-40.) 1358if(alfa>.7) 1359alfa=.7} 1360var mx=.5*(x1+x2),my=.5*(y1+y2),xx1=mx+alfa*(x1-mx),yy1=my+alfa*(y1-my)+height;xx1=x1+beta*(xx1-x1);yy1=y1+beta*(yy1-y1) 1361var xx2=mx+alfa*(x2-mx),yy2=my+alfa*(y2-my)+height;xx2=x2+beta*(xx2-x2);yy2=y2+beta*(yy2-y2);dy=2*dir;dz=.2+.001*dx 1362if(dz>.6) 1363dz=.6;dz*=dir 1364dx*=.03 1365var scale_y=1 1366if(!dotted) 1367output+='<path d="M' 1368else 1369output+='<path class="stroke" stroke-dasharray="5,5" d="M';out_sxsy(x1,' ',y1);output+='c'+ 1370((xx1-x1)/stv_g.scale).toFixed(1)+' '+ 1371((y1-yy1)/scale_y).toFixed(1)+' '+ 1372((xx2-x1)/stv_g.scale).toFixed(1)+' '+ 1373((y1-yy2)/scale_y).toFixed(1)+' '+ 1374((x2-x1)/stv_g.scale).toFixed(1)+' '+ 1375((y1-y2)/scale_y).toFixed(1) 1376if(!dotted) 1377output+='\n\tv'+ 1378(-dz).toFixed(1)+'c'+ 1379((xx2-dx-x2)/stv_g.scale).toFixed(1)+' '+ 1380((y2+dz-yy2-dy)/scale_y).toFixed(1)+' '+ 1381((xx1+dx-x2)/stv_g.scale).toFixed(1)+' '+ 1382((y2+dz-yy1-dy)/scale_y).toFixed(1)+' '+ 1383((x1-x2)/stv_g.scale).toFixed(1)+' '+ 1384((y2-y1)/scale_y).toFixed(1) 1385output+='"/>\n'} 1386function draw_slur(path,not1,sl){var i,k,g,x1,y1,x2,y2,height,addy,a,y,z,h,dx,dy,ty=sl.ty,dir=(ty&0x07)==C.SL_ABOVE?1:-1,n=path.length,i1=0,i2=n-1,k1=path[0],k2=path[i2] 1387var nn=1,upstaff=k1.st,two_staves=false 1388set_dscale(k1.st) 1389for(i=1;i<n;i++){k=path[i] 1390if(k.type==C.NOTE||k.type==C.REST){nn++ 1391if(k.st!=upstaff){two_staves=true 1392if(k.st<upstaff) 1393upstaff=k.st}}} 1394if(two_staves)error(2,k1,"*** multi-staves slurs not treated yet");x1=k1.x 1395if(k1.notes&&k1.notes[0].shhd) 1396x1+=k1.notes[0].shhd;x2=k2.x 1397if(k2.notes) 1398x2+=k2.notes[0].shhd 1399if(not1){y1=3*(not1.pit-18)+2*dir 1400x1+=3}else{y1=dir>0?k1.ymx+2:k1.ymn-2 1401if(k1.type==C.NOTE){if(dir>0){if(k1.stem>0){x1+=5 1402if(k1.beam_end&&k1.nflags>=-1&&!k1.in_tuplet){if(k1.nflags>0){x1+=2;y1=k1.ys-3}else{y1=k1.ys-6}}}}else{if(k1.stem<0){x1-=1 1403if(k2.grace){y1=k1.y-8}else if(k1.beam_end&&k1.nflags>=-1&&(!k1.in_tuplet||k1.ys<y1+3)){if(k1.nflags>0){x1+=2;y1=k1.ys+3}else{y1=k1.ys+6}}}}}} 1404if(sl.is_note){y2=3*(sl.note.pit-18)+2*dir 1405x2-=3}else{y2=dir>0?k2.ymx+2:k2.ymn-2 1406if(k2.type==C.NOTE){if(dir>0){if(k2.stem>0){x2+=1 1407if(k2.beam_st&&k2.nflags>=-1&&!k2.in_tuplet) 1408y2=k2.ys-6}}else{if(k2.stem<0){x2-=5 1409if(k2.beam_st&&k2.nflags>=-1&&!k2.in_tuplet) 1410y2=k2.ys+6}}}} 1411if(k1.type!=C.NOTE){y1=y2+1.2*dir;x1=k1.x+k1.wr*.5 1412if(x1>x2-12) 1413x1=x2-12} 1414if(k2.type!=C.NOTE){if(k1.type==C.NOTE) 1415y2=y1+1.2*dir 1416else 1417y2=y1 1418if(k1!=k2) 1419x2=k2.x-k2.wl*.3} 1420if(nn>=3){k=path[1] 1421if(k.type!=C.BAR&&k.x<x1+48){if(dir>0){y=k.ymx-2 1422if(y1<y) 1423y1=y}else{y=k.ymn+2 1424if(y1>y) 1425y1=y}} 1426k=path[i2-1] 1427if(k.type!=C.BAR&&k.x>x2-48){if(dir>0){y=k.ymx-2 1428if(y2<y) 1429y2=y}else{y=k.ymn+2 1430if(y2>y) 1431y2=y}}} 1432a=(y2-y1)/(x2-x1) 1433if(a>SLUR_SLOPE||a<-SLUR_SLOPE){a=a>SLUR_SLOPE?SLUR_SLOPE:-SLUR_SLOPE 1434if(a*dir>0) 1435y1=y2-a*(x2-x1) 1436else 1437y2=y1+a*(x2-x1)} 1438y=y2-y1 1439if(y>8) 1440y=8 1441else if(y<-8) 1442y=-8 1443z=y 1444if(z<0) 1445z=-z;dx=.5*z;dy=.3*y 1446if(y*dir>0){x2-=dx;y2-=dy}else{x1+=dx;y1+=dy} 1447if(k1.grace) 1448x1=k1.x-GSTEM_XOFF*.5 1449if(k2.grace) 1450x2=k2.x+GSTEM_XOFF*1.5;h=0;a=(y2-y1)/(x2-x1) 1451if(k1!=k2&&k1.v==k2.v){addy=y1-a*x1 1452for(i=1;i<i2;i++){k=path[i] 1453if(k.st!=upstaff) 1454continue 1455switch(k.type){case C.NOTE:case C.REST:if(dir>0){y=3*(k.notes[k.nhd].pit-18)+6 1456if(y<k.ymx) 1457y=k.ymx;y-=a*k.x+addy 1458if(y>h) 1459h=y}else{y=3*(k.notes[0].pit-18)-6 1460if(y>k.ymn) 1461y=k.ymn;y-=a*k.x+addy 1462if(y<h) 1463h=y} 1464break 1465case C.GRACE:for(g=k.extra;g;g=g.next){if(dir>0){y=3*(g.notes[g.nhd].pit-18)+6 1466if(y<g.ymx) 1467y=g.ymx;y-=a*g.x+addy 1468if(y>h) 1469h=y}else{y=3*(g.notes[0].pit-18)-6 1470if(y>g.ymn) 1471y=g.ymn;y-=a*g.x+addy 1472if(y<h) 1473h=y}} 1474break}} 1475y1+=.45*h;y2+=.45*h;h*=.65} 1476if(nn>3) 1477height=(.08*(x2-x1)+12)*dir 1478else 1479height=(.03*(x2-x1)+8)*dir 1480if(dir>0){if(height<3*h) 1481height=3*h 1482if(height>40) 1483height=40}else{if(height>3*h) 1484height=3*h 1485if(height<-40) 1486height=-40} 1487y=y2-y1 1488if(y<0) 1489y=-y 1490if(dir>0){if(height<.8*y) 1491height=.8*y}else{if(height>-.8*y) 1492height=-.8*y} 1493height*=cfmt.slurheight;slur_out(x1,y1,x2,y2,dir,height,ty&C.SL_DOTTED);dx=x2-x1;a=(y2-y1)/dx;addy=y1-a*x1 1494if(height>0) 1495addy+=4*Math.sqrt(height)-2 1496else 1497addy-=4*Math.sqrt(-height)-2 1498for(i=0;i<i2;i++){k=path[i] 1499if(k.st!=upstaff) 1500continue 1501y=a*k.x+addy 1502if(k.ymx<y) 1503k.ymx=y 1504else if(k.ymn>y) 1505k.ymn=y 1506if(i==i2-1){dx=x2 1507if(k2.sl1) 1508dx-=5;if(i) 1509y-=height/3}else{dx=path[i+1].x} 1510if(i!=0) 1511x1=k.x 1512else 1513y-=height/3 1514dx-=x1;y_set(upstaff,dir>0,x1,dx,y)}} 1515function draw_slurs(s,last){var gr1,i,m,note,sls,nsls 1516function draw_sls(s,sl,snote){var k,v,i,dir,path=[],enote=sl.note,s2=enote.s 1517if(last&&s2.time>last.time) 1518return 1519if(tsnext&&s2.time>=tsnext.time){s.p_v.sls.push(sl);s2=s.p_v.s_next.prev 1520while(s2.next) 1521s2=s2.next;sl=Object.create(sl);sl.note={s:s2}} 1522switch(sl.ty&0x07){case C.SL_ABOVE:dir=1;break 1523case C.SL_BELOW:dir=-1;break 1524default:dir=s.v!=s2.v?1:slur_direction(s,s2) 1525sl.ty&=~0x07 1526sl.ty|=dir>0?C.SL_ABOVE:C.SL_BELOW 1527break} 1528if(s.v==s2.v){v=s.v}if(!cur_sy.voices[s.v]||!cur_sy.voices[s2.v]){v=s.v>s2.v?s.v:s2.v}else if(dir*(cur_sy.voices[s.v].range<=cur_sy.voices[s2.v].range?1:-1)>0) 1529v=s.v 1530else 1531v=s2.v 1532if(gr1&&!(s2.grace&&s.v==s2.v&&s.time==s2.time)){do{path.push(s);s=s.next}while(s);s=gr1.next}else{path.push(s);if(s.grace) 1533s=s.next 1534else 1535s=s.ts_next} 1536if(!s2.grace){while(s){if(s.v==v) 1537path.push(s) 1538if(s==s2) 1539break 1540s=s.ts_next}}else if(s.grace){while(1){path.push(s) 1541if(s==s2) 1542break 1543s=s.next}}else{k=s2 1544while(k.prev) 1545k=k.prev 1546while(1){if(s.v==v) 1547path.push(s) 1548if(s.extra==k) 1549break 1550s=s.ts_next} 1551s=k 1552while(1){path.push(s) 1553if(s==s2) 1554break 1555s=s.next}} 1556for(i=1;i<path.length-1;i++){s=path[i] 1557if(s.sls||s.sl1) 1558draw_slurs(s,last) 1559if(s.tp) 1560draw_tuplet(s)} 1561draw_slur(path,snote,sl) 1562return 1} 1563while(1){if(!s||s==last){if(!gr1||!(s=gr1.next)||s==last) 1564break 1565gr1=null} 1566if(s.type==C.GRACE){gr1=s;s=s.extra 1567continue} 1568if(s.sls){sls=s.sls 1569s.sls=null 1570nsls=[] 1571for(i=0;i<sls.length;i++){if(!draw_sls(s,sls[i])) 1572nsls.push(sls[i])} 1573if(nsls.length) 1574s.sls=nsls} 1575if(s.sl1){for(m=0;m<=s.nhd;m++){note=s.notes[m] 1576if(note.sls){sls=note.sls 1577note.sls=null 1578nsls=[] 1579for(i=0;i<sls.length;i++){if(!draw_sls(s,sls[i],note)) 1580nsls.push(sls[i])} 1581if(nsls.length) 1582note.sls=nsls}}} 1583s=s.next}} 1584function draw_tuplet(s1){var s2,s3,g,upstaff,nb_only,some_slur,x1,x2,y1,y2,xm,ym,a,s0,yy,yx,dy,a,dir,r,tp=s1.tp.shift() 1585if(!s1.tp.length) 1586delete s1.tp 1587upstaff=s1.st 1588set_dscale(s1.st) 1589for(s2=s1;s2;s2=s2.next){switch(s2.type){case C.GRACE:for(g=s2.extra;g;g=g.next){if(g.sls||g.sl1) 1590draw_slurs(g)} 1591default:continue 1592case C.NOTE:case C.REST:break} 1593if(s2.sls||s2.sl1) 1594draw_slurs(s2) 1595if(s2.st<upstaff) 1596upstaff=s2.st 1597if(s2.tp) 1598draw_tuplet(s2) 1599if(s2.tpe) 1600break} 1601if(s2) 1602s2.tpe-- 1603if(tp.f[0]==1) 1604return 1605if(!s2){error(1,s1,"No end of tuplet in this music line") 1606return} 1607dir=tp.f[3] 1608if(!dir){s3=s1 1609while(s3.type!=C.NOTE) 1610s3=s3.next 1611dir=s3.stem>0?C.SL_ABOVE:C.SL_BELOW} 1612if(s1==s2||tp.f[1]==2){nb_only=true}else if(tp.f[1]==1){nb_only=true;draw_slur([s1,s2],null,{ty:dir})}else{if(tp.f[0]!=2&&s1.type==C.NOTE&&s2.type==C.NOTE){nb_only=true 1613for(s3=s1;;s3=s3.next){if(s3.type!=C.NOTE&&s3.type!=C.REST){if(s3.type==C.GRACE||s3.type==C.SPACE) 1614continue 1615nb_only=false 1616break} 1617if(s3==s2) 1618break 1619if(s3.beam_end){nb_only=false 1620break}} 1621if(nb_only&&!s1.beam_st&&!s1.beam_br1&&!s1.beam_br2){for(s3=s1.prev;s3;s3=s3.prev){if(s3.type==C.NOTE||s3.type==C.REST){if(s3.nflags>=s1.nflags) 1622nb_only=false 1623break}}} 1624if(nb_only&&!s2.beam_end){for(s3=s2.next;s3;s3=s3.next){if(s3.type==C.NOTE||s3.type==C.REST){if(!s3.beam_br1&&!s3.beam_br2&&s3.nflags>=s2.nflags) 1625nb_only=false 1626break}}}}} 1627if(nb_only){if(tp.f[2]==1) 1628return 1629set_font("tuplet") 1630xm=(s2.x+s1.x)/2 1631if(dir==C.SL_ABOVE) 1632ym=y_get(upstaff,1,xm-4,8) 1633else 1634ym=y_get(upstaff,0,xm-4,8)- 1635gene.curfont.size 1636if(s1.stem*s2.stem>0){if(s1.stem>0) 1637xm+=1.5 1638else 1639xm-=1.5} 1640if(tp.f[2]==0) 1641xy_str(xm,ym,tp.p.toString(),'c') 1642else 1643xy_str(xm,ym,tp.p+':'+tp.q,'c') 1644for(s3=s1;;s3=s3.next){if(s3.x>=xm) 1645break} 1646if(dir==C.SL_ABOVE){ym+=gene.curfont.size 1647if(s3.ymx<ym) 1648s3.ymx=ym;y_set(upstaff,true,xm-3,6,ym)}else{if(s3.ymn>ym) 1649s3.ymn=ym;y_set(upstaff,false,xm-3,6,ym)} 1650return} 1651x1=s1.x-4 1652if(s2.dur>s2.prev.dur){s3=s2.next 1653if(!s3||s3.time!=s2.time+s2.dur){for(s3=s2.ts_next;s3;s3=s3.ts_next){if(s3.seqst&&s3.time>=s2.time+s2.dur) 1654break}} 1655x2=s3?s3.x-s3.wl-5:realwidth-6}else{x2=s2.x+4 1656r=s2.stem>=0?0:s2.nhd 1657if(s2.notes[r].shhd>0) 1658x2+=s2.notes[r].shhd 1659if(s2.st==upstaff&&s2.stem>0) 1660x2+=3.5} 1661if(dir==C.SL_ABOVE){if(s1.st==s2.st){y1=y2=staff_tb[upstaff].topbar+2}else{y1=s1.ymx;y2=s2.ymx} 1662if(s1.st==upstaff){for(s3=s1;!s3.dur;s3=s3.next);ym=y_get(upstaff,1,s3.x-4,8) 1663if(ym>y1) 1664y1=ym 1665if(s1.stem>0) 1666x1+=3} 1667if(s2.st==upstaff){for(s3=s2;!s3.dur;s3=s3.prev);ym=y_get(upstaff,1,s3.x-4,8) 1668if(ym>y2) 1669y2=ym} 1670xm=.5*(x1+x2);ym=.5*(y1+y2);a=(y2-y1)/(x2-x1);s0=3*(s2.notes[s2.nhd].pit-s1.notes[s1.nhd].pit)/(x2-x1) 1671if(s0>0){if(a<0) 1672a=0 1673else if(a>s0) 1674a=s0}else{if(a>0) 1675a=0 1676else if(a<s0) 1677a=s0} 1678if(a*a<.1*.1) 1679a=0 1680dy=0 1681for(s3=s1;;s3=s3.next){if(!s3.dur||s3.st!=upstaff){if(s3==s2) 1682break 1683continue} 1684yy=ym+(s3.x-xm)*a;yx=y_get(upstaff,1,s3.x-4,8)+2 1685if(yx-yy>dy) 1686dy=yx-yy 1687if(s3==s2) 1688break} 1689ym+=dy;y1=ym+a*(x1-xm);y2=ym+a*(x2-xm);ym+=6 1690for(s3=s1;;s3=s3.next){if(s3.st==upstaff){yy=ym+(s3.x-xm)*a 1691if(s3.ymx<yy) 1692s3.ymx=yy 1693if(s3==s2) 1694break 1695y_set(upstaff,true,s3.x,s3.next.x-s3.x,yy)}else if(s3==s2){break}}}else{if(s1.stem<0) 1696x1-=2 1697if(s1.st==upstaff){for(s3=s1;!s3.dur;s3=s3.next);y1=y_get(upstaff,0,s3.x-4,8)}else{y1=0} 1698if(s2.st==upstaff){for(s3=s2;!s3.dur;s3=s3.prev);y2=y_get(upstaff,0,s3.x-4,8)}else{y2=0} 1699xm=.5*(x1+x2);ym=.5*(y1+y2);a=(y2-y1)/(x2-x1);s0=3*(s2.notes[0].pit-s1.notes[0].pit)/(x2-x1) 1700if(s0>0){if(a<0) 1701a=0 1702else if(a>s0) 1703a=s0}else{if(a>0) 1704a=0 1705else if(a<s0) 1706a=s0} 1707if(a*a<.1*.1) 1708a=0 1709dy=0 1710for(s3=s1;;s3=s3.next){if(!s3.dur||s3.st!=upstaff){if(s3==s2) 1711break 1712continue} 1713yy=ym+(s3.x-xm)*a;yx=y_get(upstaff,0,s3.x-4,8) 1714if(yx-yy<dy) 1715dy=yx-yy 1716if(s3==s2) 1717break} 1718ym+=dy-8 1719y1=ym+a*(x1-xm);y2=ym+a*(x2-xm);ym-=2 1720for(s3=s1;;s3=s3.next){if(s3.st==upstaff){if(s3==s2) 1721break 1722yy=ym+(s3.x-xm)*a 1723if(s3.ymn>yy) 1724s3.ymn=yy;y_set(upstaff,false,s3.x,s3.next.x-s3.x,yy)} 1725if(s3==s2) 1726break}} 1727if(tp.f[2]==1){out_tubr(x1,y1+4,x2-x1,y2-y1,dir==C.SL_ABOVE);return} 1728out_tubrn(x1,y1,x2-x1,y2-y1,dir==C.SL_ABOVE,tp.f[2]==0?tp.p.toString():tp.p+':'+tp.q);if(dir==C.SL_ABOVE) 1729y_set(upstaff,true,xm-3,6,yy+2) 1730else 1731y_set(upstaff,false,xm-3,6,yy)} 1732function draw_note_ties(not1,job){var m,x1,x2,s,y,h,time,not2=not1.tie_n,p=job==2?not1.pit:not2.pit,dir=(not1.tie_ty&0x07)==C.SL_ABOVE?1:-1,s1=not1.s,st=s1.st,s2=not2.s,x2=s2.x,sh=not1.shhd 1733for(m=0;m<s1.nhd;m++) 1734if(s1.notes[m]==not1) 1735break 1736if(dir>0){if(m<s1.nhd&&p+1==s1.notes[m+1].pit) 1737if(s1.notes[m+1].shhd>sh) 1738sh=s1.notes[m+1].shhd}else{if(m>0&&p==s1.notes[m-1].pit+1) 1739if(s1.notes[m-1].shhd>sh) 1740sh=s1.notes[m-1].shhd} 1741x1=s1.x+sh 1742if(job!=2){for(m=0;m<s2.nhd;m++) 1743if(s2.notes[m]==not2) 1744break 1745sh=s2.notes[m].shhd 1746if(dir>0){if(m<s2.nhd&&p+1==s2.notes[m+1].pit) 1747if(s2.notes[m+1].shhd<sh) 1748sh=s2.notes[m+1].shhd}else{if(m>0&&p==s2.notes[m-1].pit+1) 1749if(s2.notes[m-1].shhd<sh) 1750sh=s2.notes[m-1].shhd} 1751x2+=sh} 1752switch(job){case 0:p=(not1.pit&1)?not1.pit:not2.pit 1753break 1754case 3:dir=-dir 1755case 1:x1=s1.x 1756if(x1>x2-20) 1757x1=x2-20 1758p=not2.pit 1759st=s2.st 1760break 1761default:if(s1!=s2){x2-=s2.wl 1762if(s2.type==C.BAR) 1763x2+=5}else{time=s1.time+s1.dur 1764for(s=s1.ts_next;s;s=s.ts_next) 1765if(s.time>time) 1766break 1767x2=s?s.x:realwidth} 1768if(x2<x1+16) 1769x2=x1+16 1770break} 1771if(x2-x1>20){x1+=3.5 1772x2-=3.5}else{x1+=1.5 1773x2-=1.5} 1774if(s1.dots&&!(not1.pit&1)&&((dir>0&&!s1.dot_low)||(dir<0&&s1.dot_low))) 1775x1+=5 1776y=staff_tb[st].y+3*(p-18)+dir 1777h=(.03*(x2-x1)+16)*dir*cfmt.tieheight 1778slur_out(x1,y,x2,y,dir,h,not1.tie_ty&C.SL_DOTTED)} 1779function draw_ties(k1,k2,job){var k3,i,j,not1,not3,time,pit,pit2,mhead3=[],nh1=k1.nhd 1780if(job==2){for(i=0;i<=nh1;i++){not1=k1.notes[i] 1781if(not1.tie_ty){k3=not1.tie_n 1782not1.tie_n={s:k2||k1} 1783draw_note_ties(not1,job) 1784not1.tie_n=k3}} 1785return} 1786for(i=0;i<=nh1;i++){not1=k1.notes[i] 1787if(!not1.tie_ty) 1788continue 1789if(!not1.s) 1790not1.s=k1 1791if(not1.tie_n) 1792draw_note_ties(not1,job) 1793else 1794mhead3.push(not1)} 1795if(!mhead3.length) 1796return 1797time=k1.time+k1.dur 1798k3=k1.ts_next 1799if(job!=1) 1800job=0 1801while(k3&&k3.time<time) 1802k3=k3.ts_next 1803while(k3&&k3.time==time){if(k3.type!=C.NOTE||k3.st!=k1.st){k3=k3.ts_next 1804continue} 1805for(i=mhead3.length;--i>=0;){not1=mhead3[i] 1806pit=not1.opit||not1.pit 1807for(j=k3.nhd;j>=0;j--){not3=k3.notes[j] 1808pit2=not3.opit||not3.pit 1809if(pit2==pit){not1.tie_n=not3 1810if(!not3.s) 1811not3.s=k3 1812draw_note_ties(not1,job) 1813mhead3.splice(i,1) 1814break}}} 1815if(!mhead3.length) 1816break 1817k3=k3.ts_next} 1818if(mhead3.length) 1819error(1,k1,"Bad tie")} 1820function draw_all_ties(p_voice){var s,s1,s2,clef_chg,time,x,dx,s_next,m 1821function draw_ties_g(s1,s2,job){if(s1.type==C.GRACE){for(var g=s1.extra;g;g=g.next){if(g.tie_s) 1822draw_ties(g,s2,job)}}else{draw_ties(s1,s2,job)}} 1823s_next=p_voice.sym 1824set_color(s_next.color) 1825while(1){for(s1=s_next;s1;s1=s1.next){if(s1.ti2&&(s1!=s_next||!s_next.prev)){s=s1.ti2 1826s.x=s1.x 1827s2=s.next 1828s.next=s1 1829s.st=s1.st 1830s.time=s1.time-s.dur 1831draw_ties(s,s1,1) 1832s.next=s2} 1833if(s1.tie_s) 1834break} 1835if(!s1) 1836break 1837s2=s1.tie_s 1838if(s2.v==s1.v){s_next=s2 1839s=s1 1840while(1){if(!s.next){s2=s 1841s=null 1842break} 1843s=s.next 1844if(s==s2) 1845break}}else{s_next=s1.next 1846s=s1 1847while(1){if(!s.ts_next){s=null 1848break} 1849s=s.ts_next 1850if(s==s2) 1851break} 1852if(!s){s2=s1 1853while(s2.next) 1854s2=s2.next}} 1855if(!s){draw_ties_g(s1,s2,2);break} 1856time=s1.time+s.dur 1857for(s=s1.ts_next;s!=s2;s=s.ts_next){if(s.st!=s1.st) 1858continue 1859if(s.time>time) 1860break 1861if(s.type==C.CLEF){clef_chg=true 1862break}} 1863if(clef_chg||s1.st!=s2.st){clef_chg=false;dx=(s2.x-s1.x)*.4;x=s2.x;s2.x-=dx 1864if(s2.x>s1.x+32.) 1865s2.x=s1.x+32.;draw_ties_g(s1,s2,2);s2.x=x;x=s1.x;s1.x+=dx 1866if(s1.x<s2.x-24.) 1867s1.x=s2.x-24.;draw_ties(s1,s2,3);s1.x=x 1868continue} 1869draw_ties_g(s1,s2,s2.type==C.NOTE?0:2)}} 1870function draw_sym_near(){var p_voice,p_st,s,v,st,y,g,w,i,st,dx,top,bot,ymn,output_sav=output;function set_yab(s1,s2){var y,k=realwidth/YSTEP,i=(s1.x/k)|0,j=(s2.x/k)|0,a=(s1.ys-s2.ys)/(s1.xs-s2.xs),b=s1.ys-s1.xs*a,p_st=staff_tb[s1.st] 1871k*=a 1872if(s1.stem>0){while(i<=j){y=k*i+b 1873if(p_st.top[i]<y) 1874p_st.top[i]=y 1875i++}}else{while(i<=j){y=k*i+b 1876if(p_st.bot[i]>y) 1877p_st.bot[i]=y 1878i++}}} 1879output="" 1880for(st=0;st<=nstaff;st++){p_st=staff_tb[st] 1881if(!p_st.top){p_st.top=new Float32Array(YSTEP) 1882p_st.bot=new Float32Array(YSTEP)} 1883for(i=0;i<YSTEP;i++){p_st.top[i]=0 1884p_st.bot[i]=24}} 1885for(v=0;v<voice_tb.length;v++){var bm={},first_note=true;p_voice=voice_tb[v] 1886for(s=p_voice.sym;s;s=s.next){switch(s.type){case C.GRACE:for(g=s.extra;g;g=g.next){if(g.beam_st&&!g.beam_end){self.calculate_beam(bm,g) 1887if(bm.s2) 1888set_yab(g,bm.s2)}} 1889break 1890case C.NOTE:if((s.beam_st&&!s.beam_end)||(first_note&&!s.beam_st)){first_note=false;self.calculate_beam(bm,s) 1891if(bm.s2) 1892set_yab(s,bm.s2)} 1893break}}} 1894set_tie_room();draw_deco_near() 1895for(s=tsfirst;s;s=s.ts_next){if(s.invis) 1896continue 1897switch(s.type){case C.GRACE:for(g=s.extra;g;g=g.next){y_set(s.st,true,g.x-2,4,g.ymx+1);y_set(s.st,false,g.x-2,4,g.ymn-5)} 1898continue 1899case C.MREST:y_set(s.st,true,s.x+16,32,s.ymx+2) 1900continue 1901default:y_set(s.st,true,s.x-s.wl,s.wl+s.wr,s.ymx+2);y_set(s.st,false,s.x-s.wl,s.wl+s.wr,s.ymn-2) 1902continue 1903case C.NOTE:break} 1904if(s.stem>0){if(s.stemless){dx=-5;w=10}else if(s.beam_st){dx=3;w=s.beam_end?4:10}else{dx=-8;w=s.beam_end?11:16} 1905y_set(s.st,true,s.x+dx,w,s.ymx);ymn=s.ymn 1906if(s.notes[0].acc&&ymn>3*(s.notes[0].pit-18)-9) 1907ymn=3*(s.notes[0].pit-18)-9 1908y_set(s.st,false,s.x-s.wl,s.wl+s.wr,ymn)}else{y_set(s.st,true,s.x-s.wl,s.wl+s.wr,s.ymx);if(s.stemless){dx=-5;w=10}else if(s.beam_st){dx=-6;w=s.beam_end?4:10}else{dx=-8;w=s.beam_end?5:16} 1909dx+=s.notes[0].shhd;y_set(s.st,false,s.x+dx,w,s.ymn)} 1910if(s.notes[s.nhd].acc){y=s.y+8 1911if(s.ymx<y) 1912s.ymx=y;y_set(s.st,true,s.x,0,y)} 1913if(s.notes[0].acc){y=s.y 1914if(s.notes[0].acc==1||s.notes[0].acc==3) 1915y-=7 1916else 1917y-=5 1918if(s.ymn>y) 1919s.ymn=y;y_set(s.st,false,s.x,0,y)}} 1920draw_deco_note() 1921for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v];s=p_voice.sym 1922if(!s) 1923continue 1924set_color(s.color);st=p_voice.st;for(;s;s=s.next){if(s.play) 1925continue 1926if(s.tp) 1927draw_tuplet(s) 1928if(s.sls||s.sl1) 1929draw_slurs(s)}} 1930set_color() 1931for(st=0;st<=nstaff;st++){p_st=staff_tb[st];top=p_st.topbar+2;bot=p_st.botbar-2 1932for(i=0;i<YSTEP;i++){if(top>p_st.top[i]) 1933p_st.top[i]=top 1934if(bot<p_st.bot[i]) 1935p_st.bot[i]=bot}} 1936if(cfmt.measurenb>=0) 1937draw_measnb();draw_deco_staff();set_dscale(-1) 1938for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 1939if(p_voice.have_ly){draw_all_lyrics() 1940break}} 1941set_dscale(-1);output=output_sav} 1942function draw_vname(indent,stl){var p_voice,n,st,v,a_p,p,y,name_type,h,h2,staff_d=[] 1943for(st=stl.length;st>=0;st--){if(stl[st]) 1944break} 1945if(st<0) 1946return 1947for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 1948if(!p_voice.sym||!cur_sy.voices[v]) 1949continue 1950st=cur_sy.voices[v].st 1951if(!stl[st]) 1952continue 1953if(p_voice.new_name){name_type=2 1954break} 1955if(p_voice.snm) 1956name_type=1} 1957if(!name_type) 1958return 1959for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 1960if(!p_voice.sym||!cur_sy.voices[v]) 1961continue 1962st=cur_sy.voices[v].st 1963if(!stl[st]) 1964continue 1965if(p_voice.new_name) 1966delete p_voice.new_name;p=name_type==2?p_voice.nm:p_voice.snm 1967if(!p) 1968continue 1969if(!staff_d[st]) 1970staff_d[st]=p 1971else 1972staff_d[st]+="\n"+p} 1973if(!staff_d.length) 1974return 1975set_font("voice");h=gene.curfont.size 1976h2=h/2 1977indent=-indent*.5 1978for(st=0;st<staff_d.length;st++){if(!staff_d[st]) 1979continue 1980a_p=staff_d[st].split("\n");y=staff_tb[st].y 1981+staff_tb[st].topbar*.5*staff_tb[st].staffscale 1982+h2*(a_p.length-2) 1983if((cur_sy.staves[st].flags&OPEN_BRACE)&&(cur_sy.staves[st+1].flags&CLOSE_BRACE)&&!staff_d[st+1]) 1984y-=(staff_tb[st].y-staff_tb[st+1].y)*.5 1985for(n=0;n<a_p.length;n++){p=a_p[n];xy_str(indent,y,p,"c");y-=h}}} 1986function set_staff(){var s,i,st,prev_staff,v,y,staffsep,dy,maxsep,mbot,val,p_voice,p_staff,sy=cur_sy 1987for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 1988if(p_voice.scale!=1) 1989p_voice.scale_str='transform="scale('+p_voice.scale.toFixed(2)+')"'} 1990for(st=0;st<=nstaff;st++){if(gene.st_print[st]) 1991break} 1992y=0 1993if(st>nstaff){st--;p_staff=staff_tb[st]}else{p_staff=staff_tb[st] 1994for(i=0;i<YSTEP;i++){val=p_staff.top[i] 1995if(y<val) 1996y=val}} 1997y+=draw_partempo(st,y) 1998if(!gene.st_print[st]) 1999return y;y*=p_staff.staffscale;staffsep=cfmt.staffsep*.5+ 2000p_staff.topbar*p_staff.staffscale 2001if(y<staffsep) 2002y=staffsep 2003if(y<p_staff.ann_top) 2004y=p_staff.ann_top;p_staff.y=-y;prev_staff=st 2005var sy_staff_prev=sy.staves[prev_staff] 2006for(st++;st<=nstaff;st++){if(!gene.st_print[st]) 2007continue 2008p_staff=staff_tb[st] 2009staffsep=sy_staff_prev.sep||cfmt.sysstaffsep;maxsep=sy_staff_prev.maxsep||cfmt.maxsysstaffsep;dy=0 2010if(p_staff.staffscale==staff_tb[prev_staff].staffscale){for(i=0;i<YSTEP;i++){val=p_staff.top[i]- 2011staff_tb[prev_staff].bot[i] 2012if(dy<val) 2013dy=val} 2014dy*=p_staff.staffscale}else{for(i=0;i<YSTEP;i++){val=p_staff.top[i]*p_staff.staffscale 2015-staff_tb[prev_staff].bot[i]*staff_tb[prev_staff].staffscale 2016if(dy<val) 2017dy=val}} 2018staffsep+=p_staff.topbar*p_staff.staffscale 2019if(dy<staffsep) 2020dy=staffsep;maxsep+=p_staff.topbar*p_staff.staffscale 2021if(dy>maxsep) 2022dy=maxsep;y+=dy;p_staff.y=-y;prev_staff=st;while(1){sy_staff_prev=sy.staves[prev_staff] 2023if(sy_staff_prev) 2024break 2025sy=sy.next}} 2026mbot=0 2027for(i=0;i<YSTEP;i++){val=staff_tb[prev_staff].bot[i] 2028if(mbot>val) 2029mbot=val} 2030if(mbot>p_staff.ann_bot) 2031mbot=p_staff.ann_bot;mbot*=staff_tb[prev_staff].staffscale 2032for(st=0;st<=nstaff;st++){p_staff=staff_tb[st];dy=p_staff.y 2033if(p_staff.staffscale!=1){p_staff.scale_str='transform="translate(0,'+ 2034(posy-dy).toFixed(1)+') '+'scale('+p_staff.staffscale.toFixed(2)+')"'}} 2035if(mbot==0){for(st=nstaff;st>=0;st--){if(gene.st_print[st]) 2036break} 2037if(st<0) 2038return y} 2039dy=-mbot;staffsep=cfmt.staffsep*.5 2040if(dy<staffsep) 2041dy=staffsep;maxsep=cfmt.maxstaffsep*.5 2042if(dy>maxsep) 2043dy=maxsep;return y+dy} 2044function draw_systems(indent){var s,s2,st,x,x2,res,sy,staves_bar,bar_force,xstaff=[],stl=[],bar_bot=[],bar_height=[],ba=[],sb=[],thb=[] 2045function bar_set(){var st,staffscale,top,bot,dy=0 2046for(st=0;st<=cur_sy.nstaff;st++){if(xstaff[st]<0){bar_bot[st]=bar_height[st]=0 2047continue} 2048staffscale=staff_tb[st].staffscale;top=staff_tb[st].topbar*staffscale;bot=staff_tb[st].botbar*staffscale 2049if(dy==0) 2050dy=staff_tb[st].y+top;bar_bot[st]=staff_tb[st].y+bot;bar_height[st]=dy-bar_bot[st];dy=(cur_sy.staves[st].flags&STOP_BAR)?0:bar_bot[st]}} 2051function draw_staff(st,x1,x2){var w,ws,i,dy,ty,y=0,ln="",stafflines=staff_tb[st].stafflines,l=stafflines.length 2052if(!/[\[|]/.test(stafflines)) 2053return 2054w=x2-x1;set_sscale(st);ws=w/stv_g.scale 2055if(cache&&cache.st_l==stafflines&&cache.st_ws==(ws|0)){xygl(x1,staff_tb[st].y,'stdef'+cfmt.fullsvg) 2056return} 2057for(i=0;i<l;i++,y-=6){if(stafflines[i]=='.') 2058continue 2059dy=0 2060for(;i<l;i++,y-=6,dy-=6){switch(stafflines[i]){case'.':case'-':continue 2061case ty:ln+='m-'+ws.toFixed(1)+' '+dy+'h'+ws.toFixed(1);dy=0 2062continue} 2063if(ty!=undefined) 2064ln+='"/>\n';ty=stafflines[i] 2065ln+='<path class="'+ 2066(ty=='['?'slthW':'slW')+'" d="m0 '+y+'h'+ws.toFixed(1);dy=0} 2067ln+='"/>'} 2068y=staff_tb[st].y 2069if(!cache&&w>get_lwidth()-10){cache={st_l:stafflines,st_ws:ws|0} 2070i='stdef'+cfmt.fullsvg;if(ln.indexOf('<path',1)<0) 2071glyphs[i]=ln.replace('path','path id="'+i+'"') 2072else 2073glyphs[i]='<g id="'+i+'">\n'+ln+'\n</g>';xygl(x1,y,i) 2074return} 2075out_XYAB('<g transform="translate(X, Y)">\n'+ln+'\n</g>\n',x1,y)} 2076function draw_bar(s,bot,h){var i,s2,yb,w,bar_type=s.bar_type,st=s.st,p_staff=staff_tb[st],x=s.x 2077if(st!=0&&s.ts_prev&&s.ts_prev.type!=C.BAR) 2078h=p_staff.topbar*p_staff.staffscale;s.ymx=s.ymn+h;anno_start(s) 2079if(s.color) 2080set_color(s.color);yb=p_staff.y+12;if(p_staff.stafflines!='|||||') 2081yb+=(p_staff.topbar+p_staff.botbar)/2-12 2082if(s.bar_mrep){set_sscale(st) 2083if(s.bar_mrep==1){for(s2=s.prev;s2.type!=C.REST;s2=s2.prev);xygl(s2.x,yb,"mrep")}else{xygl(x,yb,"mrep2") 2084if(s.v==cur_sy.top_voice) 2085nrep_out(x,yb+p_staff.topbar,s.bar_mrep)}} 2086if(bar_type=='||:') 2087bar_type='[|:' 2088for(i=bar_type.length;--i>=0;){switch(bar_type[i]){case"|":if(s.bar_dotted){set_sscale(-1);w=(5*p_staff.staffscale).toFixed(1);out_XYAB('<path class="bW" stroke-dasharray="A,A" d="MX Yv-G"/>\n',x,bot,w,h)}else if(s.color){out_XYAB('<path class="bW" d="MX Yv-F"/>\n',x,bot,h)}else{sb.push(new Float32Array([x,bot,h]))} 2089break 2090default:x-=3;if(s.color) 2091out_XYAB('<path class="bthW" d="MX Yv-F"/>\n',x+1.5,bot,h) 2092else 2093thb.push(new Float32Array([x+1.5,bot,h])) 2094break 2095case":":x-=2;set_sscale(st);xygl(x+1,yb-12,"rdots") 2096break} 2097x-=3} 2098set_color();anno_stop(s)} 2099function out_bars(){var i,b,bx,l=ba.length 2100set_font("annotation");bx=gene.curfont.box 2101if(bx) 2102gene.curfont.box=0 2103for(i=0;i<l;i++){b=ba[i];draw_bar(b[0],b[1],b[2])} 2104if(bx) 2105gene.curfont.box=bx 2106set_sscale(-1) 2107l=sb.length 2108if(l){output+='<path class="bW" d="' 2109for(i=0;i<l;i++){b=sb[i];out_XYAB('MX Yv-F',b[0],b[1],b[2])} 2110output+='"/>\n'} 2111l=thb.length 2112if(l){output+='<path class="bthW" d="' 2113for(i=0;i<l;i++){b=thb[i];out_XYAB('MX Yv-F',b[0],b[1],b[2])} 2114output+='"/>\n'}} 2115for(st=0;st<=nstaff;st++){xstaff[st]=!cur_sy.st_print[st]?-1:0;stl[st]=cur_sy.st_print[st]} 2116bar_set();draw_lstaff(0) 2117for(s=tsfirst;s;s=s.ts_next){if(bar_force&&s.time!=bar_force){bar_force=0 2118for(st=0;st<=nstaff;st++){if(!cur_sy.st_print[st]) 2119xstaff[st]=-1} 2120bar_set()} 2121switch(s.type){case C.STAVES:staves_bar=s.ts_prev.type==C.BAR?s.ts_prev.x:0 2122if(!staves_bar){for(s2=s.ts_next;s2;s2=s2.ts_next){if(s2.time!=s.time) 2123break 2124switch(s2.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:staves_bar=s2.x 2125continue} 2126break} 2127if(!s2) 2128staves_bar=realwidth} 2129sy=s.sy 2130for(st=0;st<=nstaff;st++){x=xstaff[st] 2131if(x<0){if(sy.st_print[st]){xstaff[st]=staves_bar?staves_bar:(s.x-s.wl-2) 2132stl[st]=true} 2133continue} 2134if(sy.st_print[st]&&sy.staves[st].stafflines==cur_sy.staves[st].stafflines) 2135continue 2136if(staves_bar){x2=staves_bar;bar_force=s.time}else{x2=s.x-s.wl-2;xstaff[st]=-1} 2137draw_staff(st,x,x2) 2138if(sy.st_print[st]) 2139xstaff[st]=x2} 2140cur_sy=sy;bar_set() 2141continue 2142case C.BAR:if(s.second||s.invis||!s.bar_type) 2143break 2144ba.push([s,bar_bot[s.st],bar_height[s.st]]) 2145break 2146case C.STBRK:if(cur_sy.voices[s.v]&&cur_sy.voices[s.v].range==0){if(s.xmx>14){var nv=0 2147for(var i=0;i<voice_tb.length;i++){if(cur_sy.voices[i]&&cur_sy.voices[i].range>0) 2148nv++} 2149for(s2=s.ts_next;s2;s2=s2.ts_next){if(s2.type!=C.STBRK) 2150break 2151nv--} 2152if(nv==0) 2153draw_lstaff(s.x)}} 2154st=s.st;x=xstaff[st] 2155if(x>=0){s2=s.prev 2156if(!s2) 2157break 2158x2=s2.type==C.BAR?s2.x:s.x-s.xmx 2159if(x>=x2) 2160break 2161draw_staff(st,x,x2) 2162xstaff[st]=s.x} 2163break}} 2164for(st=0;st<=nstaff;st++){if(bar_force&&!cur_sy.st_print[st]) 2165continue 2166x=xstaff[st] 2167if(x<0||x>=realwidth) 2168continue 2169draw_staff(st,x,realwidth)} 2170out_bars() 2171draw_vname(indent,stl)} 2172Abc.prototype.draw_symbols=function(p_voice){var bm={},s,g,x,y,st;for(s=p_voice.sym;s;s=s.next){if(s.invis){switch(s.type){case C.KEY:p_voice.ckey=s 2173default:continue 2174case C.NOTE:break}} 2175st=s.st 2176x=s.x;set_color(s.color) 2177switch(s.type){case C.NOTE:set_scale(s) 2178if(s.beam_st&&!s.beam_end){if(self.calculate_beam(bm,s)) 2179draw_beams(bm)} 2180if(!s.invis){anno_start(s);draw_note(s,!bm.s2);anno_a.push(s)} 2181if(s==bm.s2) 2182bm.s2=null 2183break 2184case C.REST:if(!staff_tb[st].topbar) 2185break 2186draw_rest(s);break 2187case C.BAR:break 2188case C.CLEF:if(s.time>=staff_tb[st].clef.time) 2189staff_tb[st].clef=s 2190if(s.second||!staff_tb[st].topbar) 2191break 2192set_color();set_sscale(st);anno_start(s);y=staff_tb[st].y 2193if(s.clef_name) 2194xygl(x,y+s.y,s.clef_name) 2195else if(!s.clef_small) 2196xygl(x,y+s.y,s.clef_type+"clef") 2197else 2198xygl(x,y+s.y,"s"+s.clef_type+"clef") 2199if(s.clef_octave){if(s.clef_octave>0){y+=s.ymx-10 2200if(s.clef_small) 2201y-=1}else{y+=s.ymn+6 2202if(s.clef_small) 2203y+=1} 2204xygl(x-2,y,"oct")} 2205anno_a.push(s) 2206break 2207case C.METER:p_voice.meter=s 2208if(s.second||!staff_tb[s.st].topbar) 2209break 2210set_color();set_sscale(s.st);anno_start(s);draw_meter(s);anno_a.push(s) 2211break 2212case C.KEY:p_voice.ckey=s 2213if(s.second||!staff_tb[s.st].topbar) 2214break 2215set_color();set_sscale(s.st);anno_start(s);self.draw_keysig(x,s);anno_a.push(s) 2216break 2217case C.MREST:set_scale(s);x+=32;anno_start(s);xygl(x,staff_tb[s.st].y+12,"mrest");out_XYAB('<text style="font:bold 15px serif"\n\ 2218 x ="X" y="Y" text-anchor="middle">A</text>\n',x,staff_tb[s.st].y+28,s.nmes);anno_a.push(s) 2219break 2220case C.GRACE:set_scale(s);draw_gracenotes(s) 2221break 2222case C.SPACE:case C.STBRK:break 2223case C.CUSTOS:set_scale(s);draw_note(s,0) 2224break 2225case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:break 2226default:error(2,s,"draw_symbols - Cannot draw symbol "+s.type) 2227break}} 2228set_scale(p_voice.sym)} 2229function draw_all_sym(){var p_voice,v,n=voice_tb.length 2230function draw_all_hl(){var st,p_st 2231function hlud(hla,d){var hl,hll,i,xp,dx2,x2,n=hla.length 2232if(!n) 2233return 2234for(i=0;i<n;i++){hll=hla[i] 2235if(!hll||!hll.length) 2236continue 2237xp=sx(hll[0][0]) 2238output+='<path class="stroke" stroke-width="1" d="M'+ 2239xp.toFixed(1)+' '+ 2240sy(p_st.y+d*i).toFixed(1) 2241dx2=0 2242while(1){hl=hll.shift() 2243if(!hl) 2244break 2245x2=sx(hl[0]) 2246output+='m'+ 2247(x2-xp+hl[1]-dx2).toFixed(1)+' 0h'+(-hl[1]+hl[2]).toFixed(1) 2248xp=x2 2249dx2=hl[2]} 2250output+='"/>\n'}} 2251for(st=0;st<=nstaff;st++){p_st=staff_tb[st] 2252if(!p_st.hlu) 2253continue 2254set_sscale(st) 2255hlud(p_st.hlu,6) 2256hlud(p_st.hld,-6)}} 2257for(v=0;v<n;v++){p_voice=voice_tb[v] 2258if(p_voice.sym&&p_voice.sym.x!=undefined){self.draw_symbols(p_voice) 2259draw_all_ties(p_voice);set_color()}} 2260self.draw_all_deco() 2261draw_all_hl() 2262glout() 2263anno_put() 2264set_sscale(-1)} 2265function set_tie_dir(s){var i,ntie,dir,sec,pit,ty 2266for(;s;s=s.next){if(!s.tie_s) 2267continue 2268if(s.multi!=0){dir=s.multi>0?C.SL_ABOVE:C.SL_BELOW 2269for(i=0;i<=s.nhd;i++){ty=s.notes[i].tie_ty 2270if(!((ty&0x07)==C.SL_AUTO)) 2271continue 2272s.notes[i].tie_ty=(ty&C.SL_DOTTED)|dir} 2273continue} 2274sec=ntie=0;pit=128 2275for(i=0;i<=s.nhd;i++){if(s.notes[i].tie_ty){ntie++ 2276if(pit<128&&s.notes[i].pit<=pit+1) 2277sec++;pit=s.notes[i].pit}} 2278if(ntie<=1){dir=s.stem<0?C.SL_ABOVE:C.SL_BELOW 2279for(i=0;i<=s.nhd;i++){ty=s.notes[i].tie_ty 2280if(ty){if((ty&0x07)==C.SL_AUTO) 2281s.notes[i].tie_ty=(ty&C.SL_DOTTED)|dir 2282break}} 2283continue} 2284if(sec==0){if(ntie&1){ntie=(ntie-1)/2;dir=C.SL_BELOW 2285for(i=0;i<=s.nhd;i++){ty=s.notes[i].tie_ty 2286if(!ty) 2287continue 2288if(ntie==0){if(s.notes[i].pit>=22) 2289dir=C.SL_ABOVE} 2290if((ty&0x07)==C.SL_AUTO) 2291s.notes[i].tie_ty=(ty&C.SL_DOTTED)|dir 2292if(ntie--==0) 2293dir=C.SL_ABOVE} 2294continue} 2295ntie/=2;dir=C.SL_BELOW 2296for(i=0;i<=s.nhd;i++){ty=s.notes[i].tie_ty 2297if(!ty) 2298continue 2299if((ty&0x07)==C.SL_AUTO) 2300s.notes[i].tie_ty=(ty&C.SL_DOTTED)|dir 2301if(--ntie==0) 2302dir=C.SL_ABOVE} 2303continue} 2304pit=128 2305for(i=0;i<=s.nhd;i++){if(s.notes[i].tie_ty){if(pit<128&&s.notes[i].pit<=pit+1){ntie=i 2306break} 2307pit=s.notes[i].pit}} 2308dir=C.SL_BELOW 2309for(i=0;i<=s.nhd;i++){ty=s.notes[i].tie_ty 2310if(!ty) 2311continue 2312if(ntie==i) 2313dir=C.SL_ABOVE 2314if((ty&0x07)==C.SL_AUTO) 2315s.notes[i].tie_ty=(ty&C.SL_DOTTED)|dir}}} 2316function set_tie_room(){var p_voice,s,s2,v,dx,y,dy 2317for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v];s=p_voice.sym 2318if(!s) 2319continue 2320s=s.next 2321if(!s) 2322continue 2323set_tie_dir(s) 2324for(;s;s=s.next){if(!s.tie_s) 2325continue 2326if(s.notes[0].pit<20&&s.notes[0].tie_ty&&(s.notes[0].tie_ty&0x07)==C.SL_BELOW);else if(s.notes[s.nhd].pit>24&&s.notes[s.nhd].tie_ty&&(s.notes[s.nhd].tie_ty&0x07)==C.SL_ABOVE);else 2327continue 2328s2=s.next 2329while(s2&&s2.type!=C.NOTE) 2330s2=s2.next 2331if(s2){if(s2.st!=s.st) 2332continue 2333dx=s2.x-s.x-10}else{dx=realwidth-s.x-10} 2334if(dx<100) 2335dy=9 2336else if(dx<300) 2337dy=12 2338else 2339dy=16 2340if(s.notes[s.nhd].pit>24){y=3*(s.notes[s.nhd].pit-18)+dy 2341if(s.ymx<y) 2342s.ymx=y 2343if(s2&&s2.ymx<y) 2344s2.ymx=y;y_set(s.st,true,s.x+5,dx,y)} 2345if(s.notes[0].pit<20){y=3*(s.notes[0].pit-18)-dy 2346if(s.ymn>y) 2347s.ymn=y 2348if(s2&&s2.ymn>y) 2349s2.ymn=y;y_set(s.st,false,s.x+5,dx,y)}}}} 2350var musicfont='url("data:application/octet-stream;base64,\ 2351AAEAAAAOAIAAAwBgRkZUTYTd79wAAFggAAAAHEdERUYAFQAUAABYBAAAABxPUy8yWLxdCwAAAWgA\ 2352AABWY21hcFxKS5kAAAQIAAADemN2dCAAIgKIAAAHhAAAAARnYXNw//8AAwAAV/wAAAAIZ2x5Zp27\ 23536QgAAAiwAABGeGhlYWQPFh8MAAAA7AAAADZoaGVhCWn/GwAAASQAAAAkaG10eNzF+scAAAHAAAAC\ 2354SGxvY2GpopfcAAAHiAAAASZtYXhwANkBPQAAAUgAAAAgbmFtZbni4sIAAE8oAAADG3Bvc3Qtfw6A\ 2355AABSRAAABbUAAQAAAAEAAI87udRfDzz1AAsEAAAAAADRlyIXAAAAANncuoH/OPzvBUsEiAAAAA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1,'sans-serif':1,'sans-serifBold':1,Palatino:1.1,monospace:1.35},fmt_lock={} 2750var cfmt={annotationfont:{name:"sans-serif",size:12},aligncomposer:1,beamslope:.4,breaklimit:.7,breakoneoln:true,cancelkey:true,composerfont:{name:"serif",style:"italic",size:14},composerspace:6,dblrepbar:':][:',decoerr:true,dynalign:true,footerfont:{name:"serif",size:16},fullsvg:'',gchordfont:{name:"sans-serif",size:12},gracespace:new Float32Array([4,8,11]),graceslurs:true,headerfont:{name:"serif",size:16},historyfont:{name:"serif",size:16},hyphencont:true,indent:0,infofont:{name:"serif",style:"italic",size:14},infoname:'R "Rhythm: "\n\ 2751B "Book: "\n\ 2752S "Source: "\n\ 2753D "Discography: "\n\ 2754N "Notes: "\n\ 2755Z "Transcription: "\n\ 2756H "History: "',infospace:0,keywarn:true,leftmargin:1.4*CM,lineskipfac:1.1,linewarn:true,maxshrink:.65,maxstaffsep:2000,maxsysstaffsep:2000,measrepnb:1,measurefont:{name:"serif",style:"italic",size:10},measurenb:-1,musicfont:{name:"music",src:musicfont,size:24},musicspace:6,partsfont:{name:"serif",size:15},parskipfac:.4,partsspace:8,pagewidth:21*CM,printmargin:0,rightmargin:1.4*CM,rbdbstop:true,rbmax:4,rbmin:2,repeatfont:{name:"serif",size:13},scale:1,slurheight:1.0,staffsep:46,stemheight:21,stretchlast:.25,stretchstaff:true,subtitlefont:{name:"serif",size:16},subtitlespace:3,sysstaffsep:34,tempofont:{name:"serif",weight:"bold",size:12},textfont:{name:"serif",size:16},textspace:14,tieheight:1.0,titlefont:{name:"serif",size:20},titlespace:6,titletrim:true,topspace:22,tuplets:[0,0,0,0],tupletfont:{name:"serif",style:"italic",size:12},vocalfont:{name:"serif",weight:"bold",size:13},vocalspace:10,voicefont:{name:"serif",weight:"bold",size:13},writefields:"CMOPQsTWw",wordsfont:{name:"serif",size:16},wordsspace:5} 2757function get_bool(param){return!param||!/^(0|n|f)/i.test(param)} 2758function get_font_scale(param){var i,font,a=info_split(param) 2759if(a.length<=1) 2760return 2761var scale=parseFloat(a[a.length-1]) 2762if(isNaN(scale)||scale<=0.5){syntax(1,"Bad scale value in %%font") 2763return} 2764font_scale_tb[a[0]]=scale} 2765function set_font_fac(font){var scale=font_scale_tb[font.name] 2766if(!scale) 2767scale=1.1;font.swfac=font.size*scale} 2768function param_set_font(xxxfont,p){var font,n,a 2769if(xxxfont[xxxfont.length-2]=='-'){n=xxxfont[xxxfont.length-1] 2770if(n<'1'||n>'9') 2771return 2772xxxfont="u"+n+"font"} 2773font=cfmt[xxxfont];if(!font){font={pad:0}}else{font={name:font.name,size:font.size,box:font.box,pad:font.pad}} 2774cfmt[xxxfont]=font;a=p.match(/\s+(no)?box(\s|$)/) 2775if(a){if(a[1]){font.box=false 2776font.pad=0}else{font.box=true 2777font.pad=font.size*.4-3} 2778p=p.replace(a[0],a[2])} 2779a=p.match(/\s+padding=([\d.]+)(\s|$)/) 2780if(a){font.pad=a[1]?Number(a[1]):0 2781p=p.replace(a[0],a[2])} 2782a=p.match(/\s+class=(.*?)(\s|$)/) 2783if(a){font.class=a[1];p=p.replace(a[0],a[2])} 2784a=p.match(/\s+wadj=(.*?)(\s|$)/) 2785if(a){if(typeof document=="undefined") 2786switch(a[1]){case'none':font.wadj='' 2787break 2788case'space':font.wadj='spacing' 2789break 2790case'glyph':font.wadj='spacingAndGlyphs' 2791break 2792default:syntax(1,errs.bad_val,"%%"+xxxfont) 2793break} 2794p=p.replace(a[0],a[2])} 2795a=p.match(/\s+([0-9.]+|\*)$/) 2796if(a){if(a[1]!="*") 2797font.size=Number(a[1]) 2798p=p.replace(a[0],"")} 2799a=p.match(/[- ]?[nN]ormal/) 2800if(a){font.normal=true 2801p=p.replace(a[0],'')} 2802a=p.match(/[- ]?[bB]old/) 2803if(a){font.weight="bold" 2804p=p.replace(a[0],'')} 2805a=p.match(/[- ]?[iI]talic/) 2806if(a){font.style="italic" 2807p=p.replace(a[0],'')} 2808a=p.match(/[- ]?[oO]blique/) 2809if(a){font.style="oblique" 2810p=p.replace(a[0],'')} 2811if(font.size) 2812set_font_fac(font) 2813else 2814font.swfac=0 2815switch(p){case"":case"*":return 2816case"Times-Roman":case"Times":p="serif";break 2817case"Helvetica":p="sans-serif";break 2818case"Courier":p="monospace";break} 2819if(p[3]=='('){font.src=p 2820font.fid=font_tb.length 2821font_tb.push(font) 2822p='ft'+font.fid} 2823font.name=p} 2824function get_unit(param){var v=param.toLowerCase().match(/([\d.]+)(.*)/) 2825if(!v) 2826return NaN 2827v[1]=Number(v[1]) 2828switch(v[2]){case"cm":return v[1]*CM 2829case"in":return v[1]*IN 2830case"pt":return v[1]*.75 2831case"px":case"":return v[1]} 2832return NaN} 2833function set_infoname(param){var tmp=cfmt.infoname.split("\n"),letter=param[0] 2834for(var i=0;i<tmp.length;i++){var infoname=tmp[i] 2835if(infoname[0]!=letter) 2836continue 2837if(param.length==1) 2838tmp.splice(i,1) 2839else 2840tmp[i]=param 2841cfmt.infoname=tmp.join('\n') 2842return} 2843cfmt.infoname+="\n"+param} 2844var textopt={align:'j',center:'c',fill:'f',justify:'j',ragged:'f',right:'r',skip:'s'} 2845function get_textopt(param){return textopt[param]} 2846var posval={above:C.SL_ABOVE,auto:0,below:C.SL_BELOW,down:C.SL_BELOW,hidden:C.SL_HIDDEN,opposite:C.SL_HIDDEN,under:C.SL_BELOW,up:C.SL_ABOVE} 2847function set_pos(k,v){k=k.slice(0,3) 2848if(k=="ste") 2849k="stm" 2850set_v_param("pos",k+' '+v)} 2851function set_writefields(parm){var c,i,a=parm.split(/\s+/) 2852if(get_bool(a[1])){for(i=0;i<a[0].length;i++){c=a[0][i] 2853if(cfmt.writefields.indexOf(c)<0) 2854cfmt.writefields+=c}}else{for(i=0;i<a[0].length;i++){c=a[0][i] 2855if(cfmt.writefields.indexOf(c)>=0) 2856cfmt.writefields=cfmt.writefields.replace(c,'')}}} 2857function set_v_param(k,v){k=[k+'=',v] 2858if(curvoice) 2859set_kv_parm(k) 2860else 2861memo_kv_parm('*',k)} 2862function set_page(){if(!img.chg) 2863return 2864img.chg=false;img.lm=cfmt.leftmargin-cfmt.printmargin 2865if(img.lm<0) 2866img.lm=0;img.rm=cfmt.rightmargin-cfmt.printmargin 2867if(img.rm<0) 2868img.rm=0;img.width=cfmt.pagewidth-2*cfmt.printmargin 2869if(img.width-img.lm-img.rm<100){error(0,undefined,"Bad staff width");img.width=img.lm+img.rm+150} 2870set_posx()} 2871Abc.prototype.set_format=function(cmd,param){var f,f2,v,i 2872if(/.+font(-[\d])?$/.test(cmd)){param_set_font(cmd,param) 2873return} 2874switch(cmd){case"aligncomposer":case"barsperstaff":case"infoline":case"measurenb":case"rbmax":case"rbmin":case"measrepnb":case"shiftunison":v=parseInt(param) 2875if(isNaN(v)){syntax(1,"Bad integer value");break} 2876cfmt[cmd]=v 2877break 2878case"bgcolor":case"fgcolor":case"dblrepbar":case"titleformat":cfmt[cmd]=param 2879break 2880case"beamslope":case"breaklimit":case"lineskipfac":case"maxshrink":case"pagescale":case"parskipfac":case"scale":case"slurheight":case"stemheight":case"stretchlast":case"tieheight":f=parseFloat(param) 2881if(isNaN(f)){syntax(1,errs.bad_val,'%%'+cmd) 2882break} 2883switch(cmd){case"scale":f/=.75 2884case"pagescale":cmd="scale";img.chg=true 2885break} 2886cfmt[cmd]=f 2887break 2888case"annotationbox":case"gchordbox":case"measurebox":case"partsbox":param_set_font(cmd.replace("box","font"),"* * "+(get_bool(param)?"box":"nobox")) 2889break 2890case"bstemdown":case"breakoneoln":case"cancelkey":case"checkbars":case"contbarnb":case"custos":case"decoerr":case"dynalign":case"flatbeams":case"graceslurs":case"graceword":case"hyphencont":case"keywarn":case"linewarn":case"quiet":case"rbdbstop":case"singleline":case"squarebreve":case"splittune":case"straightflags":case"stretchstaff":case"timewarn":case"titlecaps":case"titleleft":cfmt[cmd]=get_bool(param) 2891break 2892case"chordalias":v=param.split(/\s+/) 2893if(!v.length) 2894syntax(1,errs.bad_val,"%%chordalias") 2895else 2896abc2svg.ch_alias[v[0]]=v[1]||"" 2897break 2898case"composerspace":case"indent":case"infospace":case"maxstaffsep":case"maxsysstaffsep":case"musicspace":case"partsspace":case"staffsep":case"subtitlespace":case"sysstaffsep":case"textspace":case"titlespace":case"topspace":case"vocalspace":case"wordsspace":f=get_unit(param) 2899if(isNaN(f)) 2900syntax(1,errs.bad_val,'%%'+cmd) 2901else 2902cfmt[cmd]=f 2903break 2904case"page-format":user.page_format=get_bool(param) 2905break 2906case"print-leftmargin":syntax(0,"$1 is deprecated - use %%printmargin instead",'%%'+cmd) 2907cmd="printmargin" 2908case"printmargin":case"leftmargin":case"pagewidth":case"rightmargin":f=get_unit(param) 2909if(isNaN(f)){syntax(1,errs.bad_val,'%%'+cmd) 2910break} 2911cfmt[cmd]=f;img.chg=true 2912break 2913case"concert-score":if(cfmt.sound!="play") 2914cfmt.sound="concert" 2915break 2916case"writefields":set_writefields(param) 2917break 2918case"dynamic":case"gchord":case"gstemdir":case"ornament":case"stemdir":case"vocal":case"volume":set_pos(cmd,param) 2919break 2920case"font":get_font_scale(param) 2921break 2922case"fullsvg":if(parse.state!=0){syntax(1,errs.not_in_tune,"%%fullsvg") 2923break} 2924cfmt[cmd]=param 2925break 2926case"gracespace":v=param.split(/\s+/) 2927for(i=0;i<3;i++) 2928if(isNaN(Number(v[i]))){syntax(1,errs.bad_val,"%%gracespace") 2929break} 2930for(i=0;i<3;i++) 2931cfmt[cmd][i]=Number(v[i]) 2932break 2933case"tuplets":cfmt[cmd]=param.split(/\s+/);v=cfmt[cmd][3] 2934if(v&&(posval[v])) 2935cfmt[cmd][3]=posval[v] 2936break 2937case"infoname":set_infoname(param) 2938break 2939case"notespacingfactor":f=parseFloat(param) 2940if(isNaN(f)||f<1||f>2){syntax(1,errs.bad_val,"%%"+cmd) 2941break} 2942i=5;f2=space_tb[i] 2943for(;--i>=0;){f2/=f;space_tb[i]=f2} 2944i=5;f2=space_tb[i] 2945for(;++i<space_tb.length;){f2*=f;space_tb[i]=f2} 2946break 2947case"play":cfmt.sound="play" 2948break 2949case"pos":cmd=param.split(/\s+/);set_pos(cmd[0],cmd[1]) 2950break 2951case"sounding-score":if(cfmt.sound!="play") 2952cfmt.sound="sounding" 2953break 2954case"staffwidth":v=get_unit(param) 2955if(isNaN(v)){syntax(1,errs.bad_val,'%%'+cmd) 2956break} 2957if(v<100){syntax(1,"%%staffwidth too small") 2958break} 2959v=cfmt.pagewidth-v-cfmt.leftmargin 2960if(v<2){syntax(1,"%%staffwidth too big") 2961break} 2962cfmt.rightmargin=v;img.chg=true 2963break 2964case"textoption":cfmt[cmd]=get_textopt(param) 2965break 2966case"titletrim":v=Number(param) 2967if(isNaN(v)) 2968cfmt[cmd]=get_bool(param) 2969else 2970cfmt[cmd]=v 2971break 2972case"combinevoices":syntax(1,"%%combinevoices is deprecated - use %%voicecombine instead") 2973break 2974case"voicemap":set_v_param("map",param) 2975break 2976case"voicescale":set_v_param("scale",param) 2977break 2978default:if(parse.state==0) 2979cfmt[cmd]=param 2980break}} 2981function st_font(font){var n=font.name,r="" 2982if(font.weight) 2983r+=font.weight+" " 2984if(font.style) 2985r+=font.style+" " 2986if(n.indexOf('"')<0&&n.indexOf(' ')>0) 2987n='"'+n+'"' 2988return r+font.size.toFixed(1)+'px '+n} 2989function style_font(font){return'font:'+st_font(font)} 2990Abc.prototype.style_font=style_font 2991function font_class(font){var f='f'+font.fid+cfmt.fullsvg 2992if(font.class) 2993f+=' '+font.class 2994if(font.box) 2995f+=' '+'box' 2996return f} 2997function use_font(font){if(!font.used){font.used=true;if(font.fid==undefined){font.fid=font_tb.length 2998font_tb.push(font) 2999if(!font.swfac) 3000set_font_fac(font) 3001if(!font.pad) 3002font.pad=0} 3003add_fstyle(".f"+font.fid+ 3004(typeof document=="undefined"?cfmt.fullsvg:"")+"{"+style_font(font)+"}") 3005if(font.src) 3006add_fstyle("@font-face{\n\ 3007 font-family:"+font.name+";\n\ 3008 src:"+font.src+"}")}} 3009function get_font(fn){var font,font2,fid,st 3010fn+="font" 3011font=cfmt[fn] 3012if(!font){syntax(1,"Unknown font $1",'$'+fn[1]);return gene.curfont} 3013if(!font.name||!font.size){font2=Object.create(gene.curfont) 3014if(font.name) 3015font2.name=font.name 3016if(font.normal){if(font2.weight) 3017font2.weight=null 3018if(font2.style) 3019font2.style=null}else{if(font.weight) 3020font2.weight=font.weight 3021if(font.style) 3022font2.style=font.style} 3023if(font.size) 3024font2.size=font.size 3025st=st_font(font2) 3026if(font.class){font2.class=font.class 3027st+=' '+font.class} 3028fid=font_st[st] 3029if(fid!=undefined) 3030return font_tb[fid] 3031font_st[st]=font_tb.length 3032font2.fid=font2.used=undefined 3033font=font2} 3034use_font(font) 3035return font} 3036var sav={},mac={},maci={} 3037var abc_utf={"=D":"Đ","=H":"Ħ","=T":"Ŧ","=d":"đ","=h":"ħ","=t":"ŧ","/O":"Ø","/o":"ø","/L":"Ł","/l":"ł","vL":"Ľ","vl":"ľ","vd":"ď",".i":"ı","AA":"Å","aa":"å","AE":"Æ","ae":"æ","DH":"Ð","dh":"ð","OE":"Œ","oe":"œ","ss":"ß","TH":"Þ","th":"þ"} 3038var oct_acc={"1":"\u266f","2":"\u266d","3":"\u266e","4":"𝄪","5":"𝄫"} 3039function cnv_escape(src,flag){var c,c2,dst="",i,j=0 3040while(1){i=src.indexOf('\\',j) 3041if(i<0) 3042break 3043dst+=src.slice(j,i);c=src[++i] 3044if(!c) 3045return dst+'\\' 3046switch(c){case'0':case'2':if(src[i+1]!='0') 3047break 3048c2=oct_acc[src[i+2]] 3049if(c2){dst+=c2;j=i+3 3050continue} 3051break 3052case'u':j=Number("0x"+src.slice(i+1,i+5));if(isNaN(j)||j<0x20){dst+=src[++i]+"\u0306" 3053j=i+1 3054continue} 3055c=String.fromCharCode(j) 3056if(c=='\\'){i+=4 3057break} 3058dst+=c 3059j=i+5 3060continue 3061case't':dst+=' ';j=i+1 3062continue 3063case'n':dst+='\n';j=i+1 3064continue 3065default:c2=abc_utf[src.slice(i,i+2)] 3066if(c2){dst+=c2;j=i+2 3067continue} 3068c2=src[i+1] 3069if(!/[A-Za-z]/.test(c2)) 3070break 3071switch(c){case'`':dst+=c2+"\u0300" 3072j=i+2 3073continue 3074case"'":dst+=c2+"\u0301" 3075j=i+2 3076continue 3077case'^':dst+=c2+"\u0302" 3078j=i+2 3079continue 3080case'~':dst+=c2+"\u0303" 3081j=i+2 3082continue 3083case'=':dst+=c2+"\u0304" 3084j=i+2 3085continue 3086case'_':dst+=c2+"\u0305" 3087j=i+2 3088continue 3089case'.':dst+=c2+"\u0307" 3090j=i+2 3091continue 3092case'"':dst+=c2+"\u0308" 3093j=i+2 3094continue 3095case'o':dst+=c2+"\u030a" 3096j=i+2 3097continue 3098case'H':dst+=c2+"\u030b" 3099j=i+2 3100continue 3101case'v':dst+=c2+"\u030c" 3102j=i+2 3103continue 3104case'c':dst+=c2+"\u0327" 3105j=i+2 3106continue 3107case';':dst+=c2+"\u0328" 3108j=i+2 3109continue} 3110break} 3111if(flag=='w') 3112dst+='\\' 3113dst+=c 3114j=i+1} 3115return dst+src.slice(j)} 3116var include=0 3117function do_include(fn){var file,parse_sav 3118if(!user.read_file){syntax(1,"No read_file support") 3119return} 3120if(include>2){syntax(1,"Too many include levels") 3121return} 3122file=user.read_file(fn) 3123if(!file){syntax(1,"Cannot read file '$1'",fn) 3124return} 3125include++;parse_sav=clone(parse);tosvg(fn,file);parse_sav.state=parse.state;parse=parse_sav;include--} 3126function tosvg(in_fname,file,bol,eof){var i,c,eol,end,select,line0,line1,last_info,opt,text,a,b,s,pscom,txt_add='\n' 3127function tune_selected(){var re,res,i=file.indexOf('K:',bol) 3128if(i<0){return false} 3129i=file.indexOf('\n',i) 3130if(parse.select.test(file.slice(parse.bol,i))) 3131return true 3132re=/\n\w*\n/;re.lastIndex=i;res=re.exec(file) 3133if(res) 3134eol=re.lastIndex 3135else 3136eol=eof 3137return false} 3138function uncomment(src,flag){if(!src) 3139return src 3140var i=src.indexOf('%') 3141if(i==0) 3142return'' 3143if(i>0) 3144src=src.replace(/([^\\])%.*/,'$1').replace(/\\%/g,'%');src=src.replace(/\s+$/,'') 3145if(flag&&src.indexOf('\\')>=0) 3146return cnv_escape(src,flag) 3147return src} 3148function end_tune(){generate() 3149set_page() 3150if(info.W) 3151put_words(info.W);put_history();parse.state=0 3152blk_flush() 3153cfmt=sav.cfmt;info=sav.info;char_tb=sav.char_tb;glovar=sav.glovar;maps=sav.maps;mac=sav.mac;maci=sav.maci;parse.tune_v_opts=null;parse.scores=null;init_tune() 3154img.chg=true;set_page()} 3155function do_voice(select,in_tune){var opt,bol 3156if(select=="end") 3157return 3158if(in_tune){if(!parse.tune_v_opts) 3159parse.tune_v_opts={};opt=parse.tune_v_opts}else{if(!parse.voice_opts) 3160parse.voice_opts={};opt=parse.voice_opts} 3161opt[select]=[] 3162while(1){bol=++eol 3163if(file[bol]!='%') 3164break 3165eol=file.indexOf('\n',eol);if(file[bol+1]!=line1) 3166continue 3167bol+=2 3168if(eol<0) 3169text=file.slice(bol) 3170else 3171text=file.slice(bol,eol);a=text.match(/\S+/) 3172switch(a[0]){default:opt[select].push(uncomment(text,true)) 3173continue 3174case"score":case"staves":case"tune":case"voice":bol-=2 3175break} 3176break} 3177eol=parse.eol=bol-1} 3178function tune_filter(){var o,opts,j,pc,h,i=file.indexOf('K:',bol) 3179i=file.indexOf('\n',i);h=file.slice(parse.bol,i) 3180for(i in parse.tune_opts){if(!parse.tune_opts.hasOwnProperty(i)) 3181continue 3182if(!(new RegExp(i)).test(h)) 3183continue 3184opts=parse.tune_opts[i] 3185for(j=0;j<opts.t_opts.length;j++){pc=opts.t_opts[j] 3186switch(pc.match(/\S+/)[0]){case"score":case"staves":if(!parse.scores) 3187parse.scores=[];parse.scores.push(pc) 3188break 3189default:self.do_pscom(pc) 3190break}} 3191opts=opts.v_opts 3192if(!opts) 3193continue 3194for(j in opts){if(!opts.hasOwnProperty(j)) 3195continue 3196if(!parse.tune_v_opts) 3197parse.tune_v_opts={};if(!parse.tune_v_opts[j]) 3198parse.tune_v_opts[j]=opts[j] 3199else 3200parse.tune_v_opts[j]=parse.tune_v_opts[j].concat(opts[j])}}} 3201if(abc2svg.modules&&(abc2svg.modules.hooks.length||abc2svg.modules.g_hooks.length)) 3202set_hooks() 3203parse.file=file;parse.fname=in_fname 3204if(bol==undefined) 3205bol=0 3206if(!eof) 3207eof=file.length 3208for(;bol<eof;bol=parse.eol+1){eol=file.indexOf('\n',bol) 3209if(eol<0||eol>eof) 3210eol=eof;parse.eol=eol 3211while(1){eol-- 3212switch(file[eol]){case' ':case'\t':continue} 3213break} 3214eol++ 3215if(eol==bol){if(parse.state==1){parse.istart=bol;syntax(1,"Empty line in tune header - ignored")}else if(parse.state>=2){end_tune() 3216if(parse.select){eol=file.indexOf('\nX:',parse.eol) 3217if(eol<0) 3218eol=eof 3219parse.eol=eol}} 3220continue} 3221parse.istart=parse.bol=bol;parse.iend=eol;parse.line.index=0;line0=file[bol];line1=file[bol+1] 3222if(line0=='%'){if(parse.prefix.indexOf(line1)<0) 3223continue 3224if(file[bol+2]=='a'&&file[bol+3]=='b'&&file[bol+4]=='c'&&file[bol+5]==' '){bol+=6;line0=file[bol];line1=file[bol+1]}else{pscom=true}}else if(line0=='I'&&line1==':'){pscom=true} 3225if(pscom){pscom=false;bol+=2 3226text=file.slice(bol,eol) 3227a=text.match(/([^\s]+)\s*(.*)/) 3228if(!a||a[1][0]=='%') 3229continue 3230switch(a[1]){case"abcm2ps":case"ss-pref":parse.prefix=a[2] 3231continue 3232case"abc-include":do_include(uncomment(a[2])) 3233continue} 3234if(a[1].slice(0,5)=='begin'){b=a[1].substr(5);end='\n'+line0+line1+"end"+b;i=file.indexOf(end,eol) 3235if(i<0){syntax(1,"No $1 after %%$2",end.slice(1),a[1]);parse.eol=eof 3236continue} 3237self.do_begin_end(b,uncomment(a[2]),file.slice(eol+1,i).replace(new RegExp('^'+line0+line1,'gm'),''));parse.eol=file.indexOf('\n',i+6) 3238if(parse.eol<0) 3239parse.eol=eof 3240continue} 3241switch(a[1]){case"select":if(parse.state!=0){syntax(1,errs.not_in_tune,"%%select") 3242continue} 3243select=uncomment(text.slice(7)) 3244if(select[0]=='"') 3245select=select.slice(1,-1);if(!select){delete parse.select 3246continue} 3247select=select.replace(/\(/g,'\\(');select=select.replace(/\)/g,'\\)');parse.select=new RegExp(select,'m') 3248continue 3249case"tune":if(parse.state!=0){syntax(1,errs.not_in_tune,"%%tune") 3250continue} 3251select=uncomment(a[2]) 3252if(!select){parse.tune_opts={} 3253continue} 3254if(select=="end") 3255continue 3256if(!parse.tune_opts) 3257parse.tune_opts={};parse.tune_opts[select]=opt={t_opts:[]};while(1){bol=++eol 3258if(file[bol]!='%') 3259break 3260eol=file.indexOf('\n',eol);if(file[bol+1]!=line1) 3261continue 3262bol+=2 3263if(eol<0) 3264text=file.slice(bol) 3265else 3266text=file.slice(bol,eol);a=text.match(/([^\s]+)\s*(.*)/) 3267switch(a[1]){case"tune":break 3268case"voice":do_voice(uncomment(a[2],true),true) 3269continue 3270default:opt.t_opts.push(uncomment(text,true)) 3271continue} 3272break} 3273if(parse.tune_v_opts){opt.v_opts=parse.tune_v_opts;parse.tune_v_opts=null} 3274parse.eol=bol-1 3275continue 3276case"voice":if(parse.state!=0){syntax(1,errs.not_in_tune,"%%voice") 3277continue} 3278select=uncomment(a[2]) 3279if(!select){parse.voice_opts=null 3280continue} 3281do_voice(select) 3282continue} 3283self.do_pscom(uncomment(text,true)) 3284continue} 3285if(line1!=':'||!/[A-Za-z+]/.test(line0)){last_info=undefined;if(parse.state<2) 3286continue 3287parse.line.buffer=uncomment(file.slice(bol,eol)) 3288if(parse.line.buffer) 3289parse_music_line() 3290continue} 3291bol+=2 3292while(1){switch(file[bol]){case' ':case'\t':bol++ 3293continue} 3294break} 3295if(line0=='+'){if(!last_info){syntax(1,"+: without previous info field") 3296continue} 3297txt_add=' ';line0=last_info} 3298text=uncomment(file.slice(bol,eol),line0) 3299switch(line0){case'X':if(parse.state!=0){syntax(1,errs.ignored,line0) 3300continue} 3301if(parse.select&&!tune_selected()){eol=file.indexOf('\nX:',parse.eol) 3302if(eol<0) 3303eol=eof;parse.eol=eol 3304continue} 3305sav.cfmt=clone(cfmt);sav.info=clone(info,2) 3306sav.char_tb=clone(char_tb);sav.glovar=clone(glovar);sav.maps=clone(maps,1);sav.mac=clone(mac);sav.maci=clone(maci);info.X=text;parse.state=1 3307if(user.page_format&&blkdiv<1) 3308blkdiv=1 3309if(parse.tune_opts) 3310tune_filter() 3311continue 3312case'T':switch(parse.state){case 0:continue 3313case 1:case 2:if(info.T==undefined) 3314info.T=text 3315else 3316info.T+="\n"+text 3317continue} 3318s=new_block("title");s.text=text 3319continue 3320case'K':switch(parse.state){case 0:continue 3321case 1:info.K=text 3322break} 3323do_info(line0,text) 3324continue 3325case'W':if(parse.state==0||cfmt.writefields.indexOf(line0)<0) 3326break 3327if(info.W==undefined) 3328info.W=text 3329else 3330info.W+=txt_add+text 3331break 3332case'm':if(parse.state>=2){syntax(1,errs.ignored,line0) 3333continue} 3334a=text.match(/(.*?)[= ]+(.*)/) 3335if(!a||!a[2]){syntax(1,errs.bad_val,"m:") 3336continue} 3337mac[a[1]]=a[2];maci[a[1][0]]=true 3338break 3339case's':if(parse.state!=3||cfmt.writefields.indexOf(line0)<0) 3340break 3341get_sym(text,txt_add==' ') 3342break 3343case'w':if(parse.state!=3||cfmt.writefields.indexOf(line0)<0) 3344break 3345get_lyrics(text,txt_add==' ') 3346if(text.slice(-1)=='\\'){txt_add=' ';last_info=line0 3347continue} 3348break 3349case'|':if(parse.state<2) 3350continue 3351parse.line.buffer=text 3352parse_music_line() 3353continue 3354default:if("ABCDFGHNOSZ".indexOf(line0)>=0){if(parse.state>=2){syntax(1,errs.ignored,line0) 3355continue} 3356if(!info[line0]) 3357info[line0]=text 3358else 3359info[line0]+=txt_add+text 3360break} 3361do_info(line0,text) 3362continue} 3363txt_add='\n';last_info=line0} 3364if(include) 3365return 3366if(parse.state>=2) 3367end_tune();parse.state=0} 3368Abc.prototype.tosvg=tosvg 3369var gene,staff_tb,nstaff,tsnext,realwidth,insert_meter,spf_last,space_tb=new Float32Array([8.4,11.2,14.9,19.8,26.3,35,46.6,61.9,82.3,109.5]),smallest_duration 3370var dx_tb=new Float32Array([10,10,11,13,15]) 3371var hw_tb=new Float32Array([4.7,5,6,7.2,7.5]) 3372var w_note=new Float32Array([3.5,3.7,5,6,7]) 3373function identify_note(s,dur_o){var head,flags,dots=0,dur=dur_o 3374if(dur%12!=0) 3375error(1,s,"Invalid note duration $1",dur);dur/=12 3376if(!dur) 3377error(1,s,"Note too short") 3378for(flags=5;dur!=0;dur>>=1,flags--){if(dur&1) 3379break} 3380dur>>=1 3381if((dur+1)&dur){if(s.type!=C.REST||dur_o!=s.p_v.wmeasure) 3382error(0,s,"Non standard note duration $1",dur_o)} 3383while(dur>>dots>0) 3384dots++ 3385flags-=dots 3386if(flags>=0){head=C.FULL}else switch(flags){default:error(1,s,"Note too long") 3387flags=-4 3388case-4:head=C.SQUARE 3389break 3390case-3:head=cfmt.squarebreve?C.SQUARE:C.OVALBARS 3391break 3392case-2:head=C.OVAL 3393break 3394case-1:head=C.EMPTY 3395break} 3396return[head,dots,flags]} 3397function set_head_shift(s){var i,i1,i2,d,ps,dx,dx_head=dx_tb[s.head],dir=s.stem,n=s.nhd 3398if(!n) 3399return 3400dx=dx_head*.78 3401if(s.grace) 3402dx*=.5 3403if(dir>=0){i1=1;i2=n+1;ps=s.notes[0].pit}else{dx=-dx;i1=n-1;i2=-1;ps=s.notes[n].pit} 3404var shift=false,dx_max=0 3405for(i=i1;i!=i2;i+=dir){d=s.notes[i].pit-ps;ps=s.notes[i].pit 3406if(!d){if(shift){var new_dx=s.notes[i].shhd=s.notes[i-dir].shhd+dx 3407if(dx_max<new_dx) 3408dx_max=new_dx 3409continue} 3410if(i+dir!=i2&&ps+dir==s.notes[i+dir].pit){s.notes[i].shhd=-dx 3411if(dx_max<-dx) 3412dx_max=-dx 3413continue}} 3414if(d<0) 3415d=-d 3416if(d>3||(d>=2&&s.head!=C.SQUARE)){shift=false}else{shift=!shift 3417if(shift){s.notes[i].shhd=dx 3418if(dx_max<dx) 3419dx_max=dx}}} 3420s.xmx=dx_max} 3421function acc_shift(notes,dx_head){var i,i1,i2,dx,dx1,dx2,ps,p1,acc,n=notes.length 3422for(i=n-1;--i>=0;){dx=notes[i].shhd 3423if(!dx||dx>0) 3424continue 3425dx=dx_head-dx;ps=notes[i].pit 3426for(i1=n;--i1>=0;){if(!notes[i1].acc) 3427continue 3428p1=notes[i1].pit 3429if(p1<ps-3) 3430break 3431if(p1>ps+3) 3432continue 3433if(notes[i1].shac<dx) 3434notes[i1].shac=dx}} 3435for(i1=n;--i1>=0;){if(notes[i1].acc){p1=notes[i1].pit 3436dx1=notes[i1].shac 3437if(!dx1){dx1=notes[i1].shhd 3438if(dx1<0) 3439dx1=dx_head-dx1 3440else 3441dx1=dx_head} 3442break}} 3443if(i1<0) 3444return 3445for(i2=0;i2<i1;i2++){if(notes[i2].acc){ps=notes[i2].pit 3446dx2=notes[i2].shac 3447if(!dx2){dx2=notes[i2].shhd 3448if(dx2<0) 3449dx2=dx_head-dx2 3450else 3451dx2=dx_head} 3452break}} 3453if(i1==i2){notes[i1].shac=dx1 3454return} 3455if(p1>ps+4){if(dx1>dx2) 3456dx2=dx1 3457notes[i1].shac=notes[i2].shac=dx2}else{notes[i1].shac=dx1 3458notes[i2].shac=dx2=dx1+7} 3459dx2+=7 3460for(i=i1;--i>i2;){acc=notes[i].acc 3461if(!acc) 3462continue 3463dx=notes[i].shac 3464if(dx<dx2) 3465dx=dx2 3466ps=notes[i].pit 3467for(i1=n;--i1>i;){if(!notes[i1].acc) 3468continue 3469p1=notes[i1].pit 3470if(p1>=ps+4){if(p1>ps+4||acc<0||notes[i1].acc<0) 3471continue} 3472if(dx>notes[i1].shac-6){dx1=notes[i1].shac+7 3473if(dx1>dx) 3474dx=dx1}} 3475notes[i].shac=dx}} 3476function set_acc_shft(){var s,s2,st,i,acc,st,t,dx_head,notes 3477s=tsfirst 3478while(s){if(s.type!=C.NOTE||s.invis){s=s.ts_next 3479continue} 3480st=s.st;t=s.time;acc=false 3481for(s2=s;s2;s2=s2.ts_next){if(s2.time!=t||s2.type!=C.NOTE||s2.st!=st) 3482break 3483if(acc) 3484continue 3485for(i=0;i<=s2.nhd;i++){if(s2.notes[i].acc){acc=true 3486break}}} 3487if(!acc){s=s2 3488continue} 3489dx_head=dx_tb[s.head] 3490notes=[] 3491for(;s!=s2;s=s.ts_next) 3492Array.prototype.push.apply(notes,s.notes) 3493notes.sort(abc2svg.pitcmp) 3494acc_shift(notes,dx_head)}} 3495function lkvsym(s,next){s.next=next;s.prev=next.prev 3496if(s.prev) 3497s.prev.next=s 3498else 3499s.p_v.sym=s;next.prev=s} 3500function lktsym(s,next){s.ts_next=next 3501if(next){s.ts_prev=next.ts_prev 3502if(s.ts_prev) 3503s.ts_prev.ts_next=s;next.ts_prev=s}else{error(2,s,"Bad linkage") 3504s.ts_prev=null} 3505s.seqst=!s.ts_prev||s.time!=s.ts_prev.time||(w_tb[s.ts_prev.type]!=w_tb[s.type]&&w_tb[s.ts_prev.type]!=0) 3506if(!next) 3507return 3508next.seqst=next.time!=s.time||(w_tb[s.type]!=w_tb[next.type]&&w_tb[s.type]!=0) 3509if(next.seqst){self.set_width(next) 3510next.shrink=next.prev.wr+next.wl 3511next.space=0}} 3512function unlksym(s){if(s.next) 3513s.next.prev=s.prev 3514if(s.prev) 3515s.prev.next=s.next 3516else 3517s.p_v.sym=s.next 3518if(s.ts_next){if(s.seqst){if(s.ts_next.seqst){s.ts_next.shrink+=s.shrink;s.ts_next.space+=s.space}else{s.ts_next.seqst=true;s.ts_next.shrink=s.shrink;s.ts_next.space=s.space}}else{if(s.ts_next.seqst&&s.ts_prev&&s.ts_prev.seqst&&!w_tb[s.ts_prev.type]){s.ts_next.seqst=false 3519s.shrink=s.ts_next.shrink 3520s.space=s.ts_next.space}} 3521s.ts_next.ts_prev=s.ts_prev} 3522if(s.ts_prev) 3523s.ts_prev.ts_next=s.ts_next 3524if(tsfirst==s) 3525tsfirst=s.ts_next 3526if(tsnext==s) 3527tsnext=s.ts_next} 3528function insert_clef(s,clef_type,clef_line){var p_voice=s.p_v,new_s,st=s.st 3529if(s.type==C.BAR&&s.prev&&s.prev.type==C.BAR&&s.prev.bar_type[0]!=':') 3530s=s.prev;p_voice.last_sym=s.prev 3531if(!p_voice.last_sym) 3532p_voice.sym=null;p_voice.time=s.time;new_s=sym_add(p_voice,C.CLEF);new_s.next=s;s.prev=new_s;new_s.clef_type=clef_type;new_s.clef_line=clef_line;new_s.st=st;new_s.clef_small=true 3533delete new_s.second;new_s.notes=[] 3534new_s.notes[0]={pit:s.notes[0].pit} 3535new_s.nhd=0;while(!s.seqst) 3536s=s.ts_prev;lktsym(new_s,s) 3537return new_s} 3538function set_float(){var p_voice,st,staff_chg,v,s,s1,up,down 3539for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 3540staff_chg=false;st=p_voice.st 3541for(s=p_voice.sym;s;s=s.next){if(!s.floating){while(s&&!s.floating) 3542s=s.next 3543if(!s) 3544break 3545staff_chg=false} 3546if(!s.dur){if(staff_chg) 3547s.st++ 3548continue} 3549if(s.notes[0].pit>=19){staff_chg=false 3550continue} 3551if(s.notes[s.nhd].pit<=12){staff_chg=true 3552s.st++ 3553continue} 3554up=127 3555for(s1=s.ts_prev;s1;s1=s1.ts_prev){if(s1.st!=st||s1.v==s.v) 3556break 3557if(s1.type==C.NOTE) 3558if(s1.notes[0].pit<up) 3559up=s1.notes[0].pit} 3560if(up==127){if(staff_chg) 3561s.st++ 3562continue} 3563if(s.notes[s.nhd].pit>up-3){staff_chg=false 3564continue} 3565down=-127 3566for(s1=s.ts_next;s1;s1=s1.ts_next){if(s1.st!=st+1||s1.v==s.v) 3567break 3568if(s1.type==C.NOTE) 3569if(s1.notes[s1.nhd].pit>down) 3570down=s1.notes[s1.nhd].pit} 3571if(down==-127){if(staff_chg) 3572s.st++ 3573continue} 3574if(s.notes[0].pit<down+3){staff_chg=true 3575s.st++ 3576continue} 3577up-=s.notes[s.nhd].pit 3578down=s.notes[0].pit-down 3579if(!staff_chg){if(up<down+3) 3580continue 3581staff_chg=true}else{if(up<down-3){staff_chg=false 3582continue}} 3583s.st++}}} 3584function set_graceoffs(s){var next,m,dx,x,gspleft=cfmt.gracespace[0],gspinside=cfmt.gracespace[1],gspright=cfmt.gracespace[2],g=s.extra;if(s.prev&&s.prev.type==C.BAR) 3585gspleft-=3;x=gspleft;g.beam_st=true 3586for(;;g=g.next){set_head_shift(g) 3587acc_shift(g.notes,7);dx=0 3588for(m=g.nhd;m>=0;m--){if(g.notes[m].shac>dx) 3589dx=g.notes[m].shac} 3590x+=dx;g.x=x 3591if(g.nflags<=0){g.beam_st=true;g.beam_end=true} 3592next=g.next 3593if(!next){g.beam_end=true 3594break} 3595if(next.nflags<=0) 3596g.beam_end=true 3597if(g.beam_end){next.beam_st=true;x+=gspinside/4} 3598if(g.nflags<=0) 3599x+=gspinside/4 3600if(g.y>next.y+8) 3601x-=1.5 3602x+=gspinside} 3603next=s.next 3604if(next&&next.type==C.NOTE){if(g.y>=3*(next.notes[next.nhd].pit-18)) 3605gspright-=1 3606else if(g.beam_st&&g.y<3*(next.notes[next.nhd].pit-18)-4) 3607gspright+=2} 3608x+=gspright;return x} 3609function set_w_chs(s){var i,ch,w0,s0,dw,x=0,n=0 3610for(;s;s=s.ts_next){if(s.shrink){x+=s.shrink;n++} 3611if(!s.a_gch) 3612continue 3613for(i=0;i<s.a_gch.length;i++){ch=s.a_gch[i] 3614if(ch.type!='g'||ch.y<0) 3615continue 3616if(w0){if(w0>x+ch.x){if(s.prev&&s.prev.type==C.BAR) 3617n-- 3618dw=(w0-x-ch.x)/n 3619while(1){s0=s0.ts_next 3620if(s0.shrink) 3621s0.shrink+=dw 3622if(s0==s||s0.type==C.BAR) 3623break}}} 3624s0=s;w0=ch.text.wh[0];n=0;x=0 3625break}}} 3626function gchord_width(s,wlnote,wlw){var gch,w,ix,arspc=0 3627for(ix=0;ix<s.a_gch.length;ix++){gch=s.a_gch[ix] 3628switch(gch.type){case'<':w=gch.text.wh[0]+wlnote 3629if(w>wlw) 3630wlw=w 3631break 3632case'>':w=gch.text.wh[0]+s.wr 3633if(w>arspc) 3634arspc=w 3635break}} 3636if(s.wr<arspc) 3637s.wr=arspc 3638return wlw} 3639Abc.prototype.set_width=function(s){var s2,i,m,xx,w,wlnote,wlw,acc,bar_type,meter,last_acc,n1,n2,esp,tmp 3640if(s.play){s.wl=s.wr=0 3641return} 3642switch(s.type){case C.NOTE:case C.REST:s.wr=wlnote=hw_tb[s.head] 3643if(s.xmx>0) 3644s.wr+=s.xmx+4;for(s2=s.prev;s2;s2=s2.prev){if(w_tb[s2.type]!=0) 3645break} 3646if(s2){switch(s2.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:wlnote+=3 3647break}} 3648for(m=0;m<=s.nhd;m++){xx=s.notes[m].shhd 3649if(xx<0){if(wlnote<-xx+5) 3650wlnote=-xx+5} 3651acc=s.notes[m].acc 3652if(acc){tmp=s.notes[m].shac+ 3653(typeof acc!="number"?5.5:3.5) 3654if(wlnote<tmp) 3655wlnote=tmp}} 3656if(s2){switch(s2.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:wlnote-=3 3657break}} 3658if(s.a_dd) 3659wlnote+=deco_width(s) 3660if(s.beam_st&&s.beam_end&&s.stem>0&&s.nflags>0){if(s.wr<s.xmx+9) 3661s.wr=s.xmx+9} 3662if(s.dots){if(s.wl==undefined) 3663switch(s.head){case C.SQUARE:case C.OVALBARS:s.xmx+=3 3664break 3665case C.OVAL:s.xmx+=1 3666break} 3667if(s.wr<s.xmx+8) 3668s.wr=s.xmx+8 3669if(s.dots>=2) 3670s.wr+=3.5*(s.dots-1)} 3671if(s.trem2&&s.beam_end&&wlnote<20) 3672wlnote=20 3673wlw=wlnote 3674if(s2){switch(s2.type){case C.NOTE:if(s2.stem>0&&s.stem<0){if(wlw<7) 3675wlw=7} 3676if((s.y>27&&s2.y>27)||(s.y<-3&&s2.y<-3)){if(wlw<6) 3677wlw=6} 3678if(s2.tie){if(wlw<14) 3679wlw=14} 3680break 3681case C.CLEF:if(s2.second||s2.clef_small) 3682break 3683wlw+=8 3684break 3685case C.KEY:wlw+=4 3686break}} 3687if(s.a_gch) 3688wlw=gchord_width(s,wlnote,wlw) 3689if(s.a_ly) 3690wlw=ly_width(s,wlw) 3691if(s2&&s2.type==C.GRACE) 3692s.wl=wlnote-4.5 3693else 3694s.wl=wlw 3695return 3696case C.SPACE:xx=s.width/2;s.wr=xx 3697if(s.a_gch) 3698xx=gchord_width(s,xx,xx) 3699if(s.a_dd) 3700xx+=deco_width(s);s.wl=xx 3701return 3702case C.BAR:bar_type=s.bar_type 3703switch(bar_type){case"|":w=5 3704break 3705default:w=2+2.8*bar_type.length 3706for(i=0;i<bar_type.length;i++){switch(bar_type[i]){case"[":case"]":w+=3 3707break 3708case":":w+=2 3709break}} 3710break} 3711s.wl=w 3712if(s.next&&s.next.type!=C.METER) 3713s.wr=7 3714else 3715s.wr=5 3716for(s2=s.prev;s2;s2=s2.prev){if(w_tb[s2.type]!=0){if(s2.type==C.GRACE) 3717s.wl-=8 3718break}} 3719if(s.a_dd) 3720s.wl+=deco_width(s) 3721if(s.text&&s.text.length<4&&s.next&&s.next.a_gch){set_font("repeat");s.wr+=strwh(s.text)[0]+2 3722if(cfmt.measurenb>0&s.bar_num&&s.bar_num%cfmt.measurenb) 3723s.wr+=4} 3724return 3725case C.CLEF:if(s.invis){s.wl=s.wr=1 3726return} 3727s.wl=s.clef_small?11:12 3728s.wr=s.clef_small?10:12 3729if(s.next&&s.next.type==C.BAR) 3730s.wr-=4 3731return 3732case C.KEY:if((!s.k_a_acc&&!s.k_sf&&!s.k_old_sf)||s.k_none||s.k_play){s.wl=s.wr=0 3733return} 3734s.wl=3;esp=4 3735if(!s.k_a_acc){n1=s.k_sf 3736if(s.k_old_sf&&(cfmt.cancelkey||n1==0)) 3737n2=s.k_old_sf 3738else 3739n2=0 3740if(n1*n2>=0){if(n1<0) 3741n1=-n1 3742if(n2<0) 3743n2=-n2 3744if(n2>n1) 3745n1=n2}else{n1-=n2 3746if(n1<0) 3747n1=-n1;esp+=3}}else{n1=n2=s.k_a_acc.length 3748if(n2) 3749last_acc=s.k_a_acc[0].acc 3750for(i=1;i<n2;i++){acc=s.k_a_acc[i] 3751if(acc.pit>s.k_a_acc[i-1].pit+6||acc.pit<s.k_a_acc[i-1].pit-6) 3752n1-- 3753else if(acc.acc!=last_acc) 3754esp+=3;last_acc=acc.acc}} 3755s.wr=5.5*n1+esp 3756return 3757case C.METER:wlw=0;s.x_meter=[] 3758for(i=0;i<s.a_meter.length;i++){meter=s.a_meter[i] 3759switch(meter.top[0]){case'C':case'c':case'o':s.x_meter[i]=wlw+6;wlw+=12 3760break 3761case'.':case'|':s.x_meter[i]=s.x_meter[i-1] 3762break 3763default:w=0 3764if(!meter.bot||meter.top.length>meter.bot.length) 3765meter=meter.top 3766else 3767meter=meter.bot;for(m=0;m<meter.length;m++){switch(meter[m]){case'(':wlw+=4 3768case')':case'1':w+=4 3769break 3770default:w+=12 3771break}} 3772s.x_meter[i]=wlw+w/2 3773wlw+=w}} 3774s.wl=0;s.wr=wlw+6 3775return 3776case C.MREST:s.wl=6;s.wr=66 3777return 3778case C.GRACE:if(s.invis) 3779break 3780s.wl=set_graceoffs(s);s.wr=0 3781if(s.a_ly) 3782ly_width(s,wlw) 3783return 3784case C.STBRK:s.wl=s.xmx 3785if(s.next&&s.next.type==C.CLEF){s.wr=2 3786delete s.next.clef_small}else{s.wr=8} 3787return 3788case C.CUSTOS:s.wl=s.wr=4 3789return 3790case C.TEMPO:tempo_build(s) 3791break 3792case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:break 3793default:error(2,s,"set_width - Cannot set width for symbol $1",s.type) 3794break} 3795s.wl=s.wr=0} 3796function time2space(s,len){var i,l,space 3797if(smallest_duration>=C.BLEN/2){if(smallest_duration>=C.BLEN) 3798len/=4 3799else 3800len/=2}else if(!s.next&&len>=C.BLEN){len/=2} 3801if(len>=C.BLEN/4){if(len<C.BLEN/2) 3802i=5 3803else if(len<C.BLEN) 3804i=6 3805else if(len<C.BLEN*2) 3806i=7 3807else if(len<C.BLEN*4) 3808i=8 3809else 3810i=9}else{if(len>=C.BLEN/8) 3811i=4 3812else if(len>=C.BLEN/16) 3813i=3 3814else if(len>=C.BLEN/32) 3815i=2 3816else if(len>=C.BLEN/64) 3817i=1 3818else 3819i=0} 3820l=len-((C.BLEN/16/8)<<i) 3821space=space_tb[i] 3822if(l){if(l<0){space=space_tb[0]*len/(C.BLEN/16/8)}else{if(i>=9) 3823i=8 3824space+=(space_tb[i+1]-space_tb[i])*l/((C.BLEN/16/8)<<i)}} 3825return space} 3826function set_space(s,ptime){var space,len,s2,stemdir 3827len=s.time-ptime 3828if(!len){switch(s.type){case C.MREST:return s.wl} 3829return 0} 3830if(s.ts_prev.type==C.MREST) 3831return 71 3832space=time2space(s,len) 3833while(!s.dur){switch(s.type){case C.BAR:return space*.9-7 3834case C.CLEF:return space-s.wl-s.wr 3835case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:s=s.ts_next 3836if(!s) 3837return space 3838continue} 3839break} 3840if(s.dur&&len<=C.BLEN/4){s2=s 3841while(s2){if(!s2.beam_st){space*=.9 3842break} 3843s2=s2.ts_next 3844if(!s2||s2.seqst) 3845break}} 3846if(s.type==C.NOTE&&s.nflags>=-1&&s.stem>0){stemdir=true 3847for(s2=s.ts_prev;s2&&s2.time==ptime;s2=s2.ts_prev){if(s2.type==C.NOTE&&(s2.nflags<-1||s2.stem>0)){stemdir=false 3848break}} 3849if(stemdir){for(s2=s.ts_next;s2&&s2.time==s.time;s2=s2.ts_next){if(s2.type==C.NOTE&&(s2.nflags<-1||s2.stem<0)){stemdir=false 3850break}} 3851if(stemdir) 3852space*=.9}} 3853return space} 3854function set_sp_tup(s,s_et){var tim=s.time,ttim=s_et.time-tim,sp=time2space(s,ttim),s2=s,wsp=0 3855while(1){s2=s2.ts_next 3856if(s2.seqst){wsp+=s2.space 3857if(s2.bar_type) 3858wsp+=10} 3859if(s2==s_et) 3860break} 3861sp=(sp+wsp)/2/ttim 3862while(1){s=s.ts_next 3863if(s.seqst){s.space=sp*(s.time-tim) 3864tim=s.time} 3865if(s==s_et) 3866break}} 3867function _bar(s){return{type:C.BAR,bar_type:"|",fname:s.fname,istart:s.istart,iend:s.iend,v:s.v,p_v:s.p_v,st:s.st,dur:0,nhd:0,notes:[{pit:s.notes?s.notes[0].pit:22}],prev:s}} 3868function add_end_bar(s){var b=_bar(s) 3869b.seqst=true 3870b.invis=true 3871b.time=s.time+s.dur/2 3872b.wl=0 3873b.wr=0 3874b.ts_prev=s 3875b.next=s.next 3876b.ts_next=s.ts_next 3877b.shrink=s.wr+3 3878if(s.next) 3879s.next.prev=b 3880if(s.ts_next) 3881s.ts_next.ts_prev=b 3882s.next=s.ts_next=b 3883b.space=set_space(b,s.time) 3884return b} 3885function set_allsymwidth(){var maxx,val,st,s_chs,tim,stup,s=tsfirst,s2=s,xa=0,xl=[],wr=[] 3886maxx=xa 3887tim=s.time 3888while(1){do{if(s.a_gch&&!s_chs) 3889s_chs=s;self.set_width(s);st=s.st 3890if(xl[st]==undefined) 3891xl[st]=0 3892if(wr[st]==undefined) 3893wr[st]=0;val=xl[st]+wr[st]+s.wl 3894if(val>maxx) 3895maxx=val 3896s=s.ts_next}while(s&&!s.seqst);s2.shrink=maxx-xa 3897s2.space=s2.ts_prev?set_space(s2,tim):0 3898if(s2.dur&&s2.dur!=s2.notes[0].dur){if(!stup){stup=s2 3899while(stup.prev&&stup.prev.dur&&stup.prev.dur!=stup.prev.notes[0].dur) 3900stup=stup.prev 3901while(!stup.seqst) 3902stup=stup.ts_prev}}else if(stup&&stup.v==s2.v){set_sp_tup(stup,s2) 3903stup=null} 3904if(!s2.shrink&&!s2.space&&s2.type==C.CLEF){delete s2.seqst;s2.time=tim} 3905tim=s2.time 3906if(!s) 3907break 3908for(st=0;st<wr.length;st++) 3909wr[st]=0;xa=maxx 3910do{st=s2.st;xl[st]=xa 3911if(s2.wr>wr[st]) 3912wr[st]=s2.wr 3913s2=s2.ts_next}while(!s2.seqst)} 3914if(s_chs) 3915set_w_chs(s_chs)} 3916function to_rest(so){var s=clone(so) 3917s.prev.next=so.ts_prev=so.prev=s.ts_prev.ts_next=s 3918s.next=s.ts_next=so 3919so.seqst=false 3920so.invis=so.play=true 3921s.type=C.REST 3922delete s.in_tuplet 3923delete s.sl1 3924delete s.a_dd 3925delete s.a_gch 3926delete s.sls 3927return s} 3928function set_repeat(s){var s2,s3,i,j,dur,n=s.repeat_n,k=s.repeat_k,st=s.st,v=s.v 3929s.repeat_n=0 3930if(n<0){n=-n;i=n 3931for(s3=s.prev;s3;s3=s3.prev){if(!s3.dur){if(s3.type==C.BAR){error(1,s3,"Bar in repeat sequence") 3932return} 3933continue} 3934if(--i<=0) 3935break} 3936if(!s3){error(1,s,errs.not_enough_n) 3937return} 3938dur=s.time-s3.time;i=k*n 3939for(s2=s;s2;s2=s2.next){if(!s2.dur){if(s2.type==C.BAR){error(1,s2,"Bar in repeat sequence") 3940return} 3941continue} 3942if(--i<=0) 3943break} 3944if(!s2||!s2.next){error(1,s,errs.not_enough_n) 3945return} 3946for(s2=s.prev;s2!=s3;s2=s2.prev){if(s2.type==C.NOTE){s2.beam_end=true 3947break}} 3948for(j=k;--j>=0;){i=n 3949if(s.dur) 3950i--;s2=s.ts_next 3951while(i>0){if(s2.st==st){s2.invis=s2.play=true 3952if(s2.seqst&&s2.ts_next.seqst) 3953s2.seqst=false 3954if(s2.v==v&&s2.dur) 3955i--} 3956s2=s2.ts_next} 3957s=to_rest(s) 3958s.dur=s.notes[0].dur=dur;s.rep_nb=-1;s.beam_st=true;self.set_width(s) 3959s.head=C.SQUARE;for(s=s2;s;s=s.ts_next){if(s.st==st&&s.v==v&&s.dur) 3960break}} 3961return} 3962i=n 3963for(s2=s.prev.prev;s2;s2=s2.prev){if(s2.type==C.BAR||s2.time==tsfirst.time){if(--i<=0) 3964break}} 3965if(!s2){error(1,s,errs.not_enough_m) 3966return} 3967dur=s.time-s2.time 3968if(n==1) 3969i=k 3970else 3971i=n 3972for(s2=s;s2;s2=s2.next){if(s2.type==C.BAR){if(--i<=0) 3973break}} 3974if(!s2){error(1,s,errs.not_enough_m) 3975return} 3976i=k 3977if(n==2&&i>1){s2=s2.next 3978if(!s2){error(1,s,errs.not_enough_m) 3979return} 3980s2.repeat_n=n;s2.repeat_k=--i} 3981dur/=n 3982if(n==2){s3=s 3983for(s2=s.ts_next;;s2=s2.ts_next){if(s2.st!=st) 3984continue 3985if(s2.type==C.BAR){if(s2.v==v) 3986break 3987continue} 3988s2.invis=s2.play=true 3989if(s2.seqst&&s2.ts_next.seqst) 3990s2.seqst=false} 3991s3=to_rest(s3) 3992s3.dur=s3.notes[0].dur=dur;s3.invis=true 3993s2.bar_mrep=2 3994s3=s2.next;for(s2=s3.ts_next;;s2=s2.ts_next){if(s2.st!=st) 3995continue 3996if(s2.type==C.BAR){if(s2.v==v) 3997break 3998continue} 3999s2.invis=s2.play=true 4000if(s2.seqst&&s2.ts_next.seqst) 4001s2.seqst=false} 4002s3=to_rest(s3) 4003s3.dur=s3.notes[0].dur=dur;s3.invis=true;self.set_width(s3) 4004return} 4005s3=s 4006for(j=k;--j>=0;){for(s2=s3.ts_next;;s2=s2.ts_next){if(s2.st!=st) 4007continue 4008if(s2.type==C.BAR){if(s2.v==v) 4009break 4010continue} 4011s2.invis=s2.play=true 4012if(s2.seqst&&s2.ts_next.seqst) 4013s2.seqst=false} 4014s3=to_rest(s3) 4015s3.dur=s3.notes[0].dur=dur;s3.beam_st=true 4016if(k==1){s3.rep_nb=1 4017break} 4018s3.rep_nb=k-j+1;s3=s2.next}} 4019function custos_add(s){var p_voice,new_s,i,s2=s 4020while(1){if(s2.type==C.NOTE) 4021break 4022s2=s2.next 4023if(!s2) 4024return} 4025p_voice=s.p_v;p_voice.last_sym=s.prev;p_voice.time=s.time;new_s=sym_add(p_voice,C.CUSTOS);new_s.next=s;s.prev=new_s;lktsym(new_s,s);new_s.shrink=s.shrink 4026if(new_s.shrink<8+4) 4027new_s.shrink=8+4;new_s.space=s2.space;new_s.wl=0;new_s.wr=4;new_s.nhd=s2.nhd;new_s.notes=[] 4028for(i=0;i<s.notes.length;i++){new_s.notes[i]={pit:s2.notes[i].pit,shhd:0,dur:C.BLEN/4}} 4029new_s.stemless=true} 4030function set_nl(s){var p_voice,done,tim,ptyp 4031function bardiv(so){var s,s1,s2,t1,t2,i 4032function new_type(s){var t=s.bar_type.match(/(:*)([^:]*)(:*)/) 4033if(!t[3]){t1=t[1]+t[2] 4034t2='['}else if(!t[1]){t1=t[2][0]=='['?t[2].slice(1):t[2] 4035t2='[|'+t[3]}else{i=(t[2].length/2)|0 4036t1=t[1]+'|'+t[2].slice(0,i) 4037t2=t[2].slice(i)+'|'+t[3]}} 4038s=so 4039while(s.ts_prev&&s.ts_prev.time==so.time){s=s.ts_prev 4040if(s.bar_type) 4041s1=s} 4042if(!s1) 4043return so 4044for(s=so;;s=s.ts_next){switch(s.type){default:if(w_tb[s.type]) 4045break 4046case C.KEY:case C.METER:case C.CLEF:continue} 4047break} 4048while(s1!=so){if(s1.bar_type&&(s1.bar_type.slice(-1)==':'||s1.text)&&s1.bar_type!=':'){new_type(s1) 4049s2=clone(s1) 4050s1.bar_type=t1 4051s2.bar_type=t2 4052lkvsym(s2,s1.next) 4053while(1){if(s.type!=C.BAR||s.v>s2.v) 4054break 4055s=s.ts_next} 4056lktsym(s2,s) 4057if(s==so) 4058so=s2 4059if(s1.text){s2.invis=true 4060delete s1.text 4061delete s1.rbstart} 4062delete s2.a_dd} 4063s1=s1.ts_next} 4064return so} 4065function set_eol(s){if(cfmt.custos&&voice_tb.length==1) 4066custos_add(s) 4067s.nl=true 4068s=s.ts_prev 4069if(s.type!=C.BAR) 4070add_end_bar(s)} 4071function do_warn(s){var s1,s2,s3 4072for(s2=s;s2;s2=s2.ts_next){switch(s2.type){case C.KEY:if(!cfmt.keywarn||(!s2.k_a_acc&&!s2.k_sf&&!s2.k_old_sf)||s2.k_none||s2.k_play) 4073continue 4074for(s1=s.ts_prev;s1;s1=s1.ts_prev){if(s1.type!=C.METER) 4075break} 4076case C.METER:if(s2.type==C.METER){if(!cfmt.timewarn) 4077continue 4078s1=s.ts_prev} 4079case C.CLEF:if(!s2.prev) 4080continue 4081if(s2.type==C.CLEF){for(s1=s.ts_prev;s1;s1=s1.ts_prev){switch(s1.type){case C.BAR:case C.KEY:case C.METER:continue} 4082break}} 4083s3=clone(s2) 4084lktsym(s3,s1.ts_next) 4085if(s3.ts_next==s) 4086s.seqst=true 4087s1=s3 4088while(1){s1=s1.ts_next 4089if(s1.v==s2.v) 4090break} 4091lkvsym(s3,s1) 4092if(s3.seqst){s3.shrink=s3.wl 4093if(s3.prev) 4094s3.shrink+=s3.prev.wr 4095s3.space=set_space(s3,s3.ts_prev.time) 4096s3.next.shrink=s3.wr+s3.next.wl} 4097continue} 4098if(w_tb[s2.type]) 4099break}} 4100s=bardiv(s) 4101do_warn(s) 4102switch(s.ts_prev.type){case C.STAVES:break 4103case C.GRACE:s=s.next 4104if(!s) 4105return s 4106default:set_eol(s) 4107return s} 4108for(s=s.ts_prev;s;s=s.ts_prev){if(s.seqst&&s.type!=C.CLEF) 4109break} 4110done=0 4111ptyp=s.type 4112for(;;s=s.ts_next){if(!s) 4113return s 4114if(s.type==ptyp) 4115continue 4116ptyp=s.type 4117if(done<0) 4118break 4119switch(s.type){case C.STAVES:if(!s.ts_prev) 4120return 4121if(s.ts_prev.type==C.BAR) 4122break 4123while(s.ts_next){if(w_tb[s.ts_next.type]!=0&&s.ts_next.type!=C.CLEF) 4124break 4125s=s.ts_next} 4126if(!s.ts_next||s.ts_next.type!=C.BAR) 4127continue 4128s=s.ts_next 4129case C.BAR:if(done) 4130break 4131done=1;continue 4132case C.STBRK:if(!s.stbrk_forced) 4133unlksym(s) 4134else 4135done=-1 4136continue 4137case C.CLEF:if(done) 4138break 4139continue 4140default:if(!done||(s.prev&&s.prev.type==C.GRACE)) 4141continue 4142break} 4143break} 4144set_eol(s) 4145return s} 4146function get_ck_width(){var r0,r1,p_voice=voice_tb[0] 4147self.set_width(p_voice.clef);self.set_width(p_voice.ckey);self.set_width(p_voice.meter) 4148return[p_voice.clef.wl+p_voice.clef.wr+ 4149p_voice.ckey.wl+p_voice.ckey.wr,p_voice.meter.wl+p_voice.meter.wr]} 4150function get_width(s,next){var shrink,space,w=0,wmx=0,sp_fac=(1-cfmt.maxshrink) 4151while(s!=next){if(s.seqst){shrink=s.shrink 4152wmx+=shrink 4153if((space=s.space)<shrink) 4154w+=shrink 4155else 4156w+=shrink*cfmt.maxshrink 4157+space*sp_fac 4158s.x=w} 4159s=s.ts_next} 4160if(next) 4161wmx+=next.wr 4162return[w,wmx]} 4163function set_lines(s,next,lwidth,indent){var first,s2,s3,x,xmin,xmid,xmax,wwidth,shrink,space,ws,nlines,last=next?next.ts_prev:null 4164ws=get_width(s,next) 4165if(cfmt.keywarn&&next&&next.type==C.KEY&&!last.dur){ws[0]+=next.wr 4166ws[1]+=next.wr} 4167if(ws[1]+indent<lwidth){if(next) 4168next=set_nl(next) 4169return next||last} 4170wwidth=ws[0]+indent 4171while(1){nlines=Math.ceil(wwidth/lwidth) 4172if(nlines<=1){if(next) 4173next=set_nl(next) 4174return next||last} 4175s2=first=s;xmin=s.x-s.shrink-indent;xmax=xmin+lwidth;xmid=xmin+wwidth/nlines;xmin+=wwidth/nlines*cfmt.breaklimit;for(s=s.ts_next;s!=next;s=s.ts_next){if(!s.x) 4176continue 4177if(s.type==C.BAR) 4178s2=s 4179if(s.x>=xmin) 4180break} 4181if(s==next){if(next) 4182next=set_nl(next) 4183return next} 4184s3=null 4185for(;s!=next;s=s.ts_next){x=s.x 4186if(!x) 4187continue 4188if(x>xmax) 4189break 4190if(s.type!=C.BAR) 4191continue 4192if(x<xmid){s3=s 4193continue} 4194if(!s3||x-xmid<xmid-s3.x) 4195s3=s 4196break} 4197if(!s3){var beam=0,bar_time=s2.time;xmax-=8;s=s2;for(;s!=next;s=s.ts_next){if(s.beam_st) 4198beam++ 4199if(s.beam_end&&beam>0) 4200beam-- 4201x=s.x 4202if(!x) 4203continue 4204if(x+s.wr>=xmax) 4205break 4206if(beam||s.in_tuplet) 4207continue 4208if((s.time-bar_time)%(C.BLEN/4)==0){s3=s 4209continue} 4210if(!s3||s.x<xmid){s3=s 4211continue} 4212if(s3>xmid) 4213break 4214if(xmid-s3.x<s.x-xmid) 4215break 4216s3=s 4217break}} 4218if(!s3){s3=s=s2 4219for(;s!=next;s=s.ts_next){x=s.x 4220if(!x) 4221continue 4222if(s.x<xmid){s3=s 4223continue} 4224if(s3>xmid) 4225break 4226if(xmid-s3.x<s.x-xmid) 4227break 4228s3=s 4229break}} 4230s=s3 4231while(s.ts_next){s=s.ts_next 4232if(s.seqst) 4233break} 4234if(s.nl){error(0,s,"Line split problem - adjust maxshrink and/or breaklimit");nlines=2 4235for(s=s.ts_next;s!=next;s=s.ts_next){if(!s.x) 4236continue 4237if(--nlines<=0) 4238break}} 4239s=set_nl(s) 4240if(!s||(next&&s.time>=next.time)) 4241break 4242wwidth-=s.x-first.x;indent=0} 4243return s} 4244function cut_tune(lwidth,indent){var s2,i,s=tsfirst 4245if(indent){i=set_indent() 4246lwidth-=i;indent-=i} 4247i=get_ck_width();lwidth-=i[0];indent+=i[1] 4248if(cfmt.custos&&voice_tb.length==1) 4249lwidth-=12 4250if(cfmt.barsperstaff){i=cfmt.barsperstaff;for(s2=s;s2;s2=s2.ts_next){if(s2.type!=C.BAR||!s2.bar_num||--i>0) 4251continue 4252while(s2.ts_next&&s2.ts_next.type==C.BAR) 4253s2=s2.ts_next 4254if(s2.ts_next) 4255s2.ts_next.soln=true 4256i=cfmt.barsperstaff}} 4257s2=s 4258for(;s;s=s.ts_next){if(!s.ts_next){s=null}else if(!s.soln){continue}else{s.soln=false 4259while(!s.seqst) 4260s=s.ts_prev} 4261s2=set_lines(s2,s,lwidth,indent) 4262if(!s2) 4263break 4264s=s2 4265indent=0}} 4266function set_yval(s){switch(s.type){case C.CLEF:if(s.second||s.invis){s.ymx=s.ymn=12 4267break} 4268s.y=(s.clef_line-1)*6 4269switch(s.clef_type){default:s.ymx=s.y+28 4270s.ymn=s.y-14 4271break 4272case"c":s.ymx=s.y+13 4273s.ymn=s.y-11 4274break 4275case"b":s.ymx=s.y+7 4276s.ymn=s.y-12 4277break} 4278if(s.clef_small){s.ymx-=2;s.ymn+=2} 4279if(s.ymx<26) 4280s.ymx=26 4281if(s.ymn>-1) 4282s.ymn=-1 4283if(s.clef_octave){if(s.clef_octave>0) 4284s.ymx+=12 4285else 4286s.ymn-=12} 4287break 4288case C.KEY:if(s.k_sf>2) 4289s.ymx=24+10 4290else if(s.k_sf>0) 4291s.ymx=24+6 4292else 4293s.ymx=24+2;s.ymn=-2 4294break 4295default:s.ymx=24;s.ymn=0 4296break}} 4297function set_ottava(){var s,st,delta,note,g,o,m=nstaff+1,staff_d=new Int16Array(new Array(m*2)),staff_noo=new Int8Array(new Array(m)) 4298function ottava_add(s,ottava,start){var dc_st=["15mb(","8vb(",null,"8va(","15ma("],dc_en=["15mb)","8vb)",null,"8va)","15ma)"];deco_cnv([(start?dc_st:dc_en)[2+ottava]],s)} 4299for(st=0;st<=nstaff;st++){staff_d[st]=0;staff_noo[st]=0} 4300for(s=tsfirst;s;s=s.ts_next){st=s.st 4301if(s.ottava!=undefined) 4302while(s.ottava.length){o=s.ottava.shift() 4303if(o){if(staff_noo[st]++==0){ottava_add(s,o,true) 4304staff_d[st]=-o*7}}else{if(--staff_noo[st]==0){ottava_add(s,-staff_d[st]/7);staff_d[st]=0}}} 4305switch(s.type){case C.REST:if(voice_tb.length==1) 4306break 4307case C.NOTE:delta=staff_d[st] 4308if(delta&&!s.p_v.ckey.k_drum){for(m=s.nhd;m>=0;m--){note=s.notes[m];if(!note.opit) 4309note.opit=note.pit;note.pit+=delta}} 4310break 4311case C.GRACE:for(g=s.extra;g;g=g.next){delta=staff_d[st] 4312if(delta&&!s.p_v.ckey.k_drum){for(m=0;m<=g.nhd;m++){note=g.notes[m] 4313if(!note.opit) 4314note.opit=note.pit 4315note.pit+=delta}}} 4316break}}} 4317function mrest_expand(){var s,s2 4318function mexp(s){var s2,s3,s4,next,tim,nbar,nb=s.nmes,dur=s.dur/nb 4319s.type=C.REST 4320s.dur=s.dur_orig=dur 4321s.nflags=-2 4322s.head=C.FULL 4323tim=s.time+dur 4324s2=next=s.next 4325while(!s2.bar_num) 4326s2=s2.ts_prev 4327nbar=s2.bar_num-s.nmes 4328s3=s2=s 4329while(--nb>0){if(next){s2=clone(next) 4330delete s2.soln 4331delete s2.a_gch 4332delete s2.a_dd 4333lkvsym(s2,next)}else{s2=_bar(s) 4334s.next=s2} 4335s2.time=tim 4336while(s3.time<tim) 4337s3=s3.ts_next 4338while(s3&&s3.v<s.v&&s3.type==C.BAR) 4339s3=s3.ts_next 4340if(s3){lktsym(s2,s3) 4341if(s3.type==C.BAR) 4342delete s3.bar_num}else{s3=s 4343while(s3.ts_next) 4344s3=s3.ts_next 4345s3.ts_next=s2 4346s2.ts_prev=s3 4347s2.ts_next=null} 4348nbar++ 4349if(s2.seqst){s2.bar_num=nbar 4350s4=s2.ts_next}else{delete s2.bar_num 4351s4=s2.ts_prev} 4352s2.bar_type=s4.bar_type||"|" 4353if(s4.bar_num&&!s4.seqst) 4354delete s4.bar_num 4355s4=clone(s) 4356delete s4.a_dd 4357delete s4.soln 4358if(s2.next){s4.next=s2.next 4359s4.next.prev=s4}else{s4.next=null} 4360s2.next=s4 4361s4.prev=s2 4362s4.time=tim 4363while(s3&&!s3.dur&&s3.time==tim) 4364s3=s3.ts_next 4365while(s3&&s3.v<s.v){s3=s3.ts_next 4366if(s3&&s3.seqst) 4367break} 4368if(s3){lktsym(s4,s3)}else{s3=s 4369while(s3.ts_next) 4370s3=s3.ts_next 4371s3.ts_next=s4 4372s4.ts_prev=s3 4373s4.ts_next=null} 4374tim+=dur 4375s=s3=s4}} 4376for(s=tsfirst;s;s=s.ts_next){if(s.type!=C.MREST) 4377continue 4378if(!s.seqst&&w_tb[s.ts_prev.type]){s2=s}else{s2=s.ts_next 4379while(!s2.seqst){if(s2.type!=C.MREST||s2.nmes!=s.nmes) 4380break 4381s2=s2.ts_next}} 4382if(!s2.seqst){while(s.type==C.MREST){mexp(s) 4383s=s.ts_next}}else{s=s2.ts_prev}}} 4384function set_auto_clef(st,s_start,clef_type_start){var s,min,max,time,s2,s3;max=12;min=20 4385for(s=s_start;s;s=s.ts_next){if(s.type==C.STAVES&&s!=s_start) 4386break 4387if(s.st!=st) 4388continue 4389if(s.type!=C.NOTE){if(s.type==C.CLEF){if(s.clef_type!='a') 4390break 4391unlksym(s)} 4392continue} 4393if(s.notes[0].pit<min) 4394min=s.notes[0].pit 4395if(s.notes[s.nhd].pit>max) 4396max=s.notes[s.nhd].pit} 4397if(min>=19||(min>=13&&clef_type_start!='b')) 4398return't' 4399if(max<=13||(max<=19&&clef_type_start!='t')) 4400return'b' 4401if(clef_type_start=='a'){if((max+min)/2>=16) 4402clef_type_start='t' 4403else 4404clef_type_start='b'} 4405var clef_type=clef_type_start,s_last=s,s_last_chg=null 4406for(s=s_start;s!=s_last;s=s.ts_next){if(s.type==C.STAVES&&s!=s_start) 4407break 4408if(s.st!=st||s.type!=C.NOTE) 4409continue 4410time=s.time 4411if(clef_type=='t'){if(s.notes[0].pit>12||s.notes[s.nhd].pit>20){if(s.notes[0].pit>20) 4412s_last_chg=s 4413continue} 4414s2=s.ts_prev 4415if(s2&&s2.time==time&&s2.st==st&&s2.type==C.NOTE&&s2.notes[0].pit>=19) 4416continue 4417s2=s.ts_next 4418if(s2&&s2.st==st&&s2.time==time&&s2.type==C.NOTE&&s2.notes[0].pit>=19) 4419continue}else{if(s.notes[0].pit<12||s.notes[s.nhd].pit<20){if(s.notes[s.nhd].pit<12) 4420s_last_chg=s 4421continue} 4422s2=s.ts_prev 4423if(s2&&s2.time==time&&s2.st==st&&s2.type==C.NOTE&&s2.notes[0].pit<=13) 4424continue 4425s2=s.ts_next 4426if(s2&&s2.st==st&&s2.time==time&&s2.type==C.NOTE&&s2.notes[0].pit<=13) 4427continue} 4428if(!s_last_chg){clef_type=clef_type_start=clef_type=='t'?'b':'t';s_last_chg=s 4429continue} 4430s3=s 4431for(s2=s.ts_prev;s2!=s_last_chg;s2=s2.ts_prev){if(s2.st!=st) 4432continue 4433if(s2.type==C.BAR&&s2.v==s.v){s3=s2.bar_type[0]!=':'?s2:s2.next 4434break} 4435if(s2.type!=C.NOTE) 4436continue 4437if(s2.beam_st&&!s2.p_v.second) 4438s3=s2} 4439if(s3.time==s_last_chg.time){s_last_chg=s 4440continue} 4441s_last_chg=s;clef_type=clef_type=='t'?'b':'t';s2=insert_clef(s3,clef_type,clef_type=="t"?2:4);s2.clef_auto=true} 4442return clef_type_start} 4443function set_clefs(){var s,s2,st,v,p_voice,g,new_type,new_line,p_staff,pit,staff_clef=new Array(nstaff+1),sy=cur_sy,mid=[] 4444staff_tb=new Array(nstaff+1) 4445for(st=0;st<=nstaff;st++){staff_clef[st]={autoclef:true} 4446staff_tb[st]={output:"",sc_out:""}} 4447for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 4448if(!sy.voices[v]) 4449continue 4450st=sy.voices[v].st 4451if(!sy.voices[v].second){sy.staves[st].staffnonote=p_voice.staffnonote 4452if(p_voice.staffscale) 4453sy.staves[st].staffscale=p_voice.staffscale 4454if(sy.voices[v].sep) 4455sy.staves[st].sep=sy.voices[v].sep 4456if(sy.voices[v].maxsep) 4457sy.staves[st].maxsep=sy.voices[v].maxsep;if(!p_voice.clef.clef_auto) 4458staff_clef[st].autoclef=false}} 4459for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 4460if(!sy.voices[v]||sy.voices[v].second) 4461continue 4462st=sy.voices[v].st;s=p_voice.clef 4463if(staff_clef[st].autoclef){s.clef_type=set_auto_clef(st,tsfirst,s.clef_type);s.clef_line=s.clef_type=='t'?2:4} 4464staff_clef[st].clef=staff_tb[st].clef=s} 4465for(st=0;st<=sy.nstaff;st++) 4466mid[st]=(sy.staves[st].stafflines.length-1)*3 4467for(s=tsfirst;s;s=s.ts_next){if(s.repeat_n) 4468set_repeat(s) 4469switch(s.type){case C.STAVES:sy=s.sy 4470for(st=0;st<=nstaff;st++) 4471staff_clef[st].autoclef=true 4472for(v=0;v<voice_tb.length;v++){if(!sy.voices[v]) 4473continue 4474p_voice=voice_tb[v];st=sy.voices[v].st 4475if(!sy.voices[v].second){sy.staves[st].staffnonote=p_voice.staffnonote 4476if(p_voice.staffscale) 4477sy.staves[st].staffscale=p_voice.staffscale 4478if(sy.voices[v].sep) 4479sy.staves[st].sep=sy.voices[v].sep 4480if(sy.voices[v].maxsep) 4481sy.staves[st].maxsep=sy.voices[v].maxsep} 4482s2=p_voice.clef 4483if(!s2.clef_auto) 4484staff_clef[st].autoclef=false} 4485for(st=0;st<=sy.nstaff;st++) 4486mid[st]=(sy.staves[st].stafflines.length-1)*3 4487for(v=0;v<voice_tb.length;v++){if(!sy.voices[v]||sy.voices[v].second) 4488continue 4489p_voice=voice_tb[v];st=sy.voices[v].st;s2=p_voice.clef 4490if(s2.clef_auto){new_type=set_auto_clef(st,s,staff_clef[st].clef?staff_clef[st].clef.clef_type:'a');new_line=new_type=='t'?2:4}else{new_type=s2.clef_type;new_line=s2.clef_line} 4491if(!staff_clef[st].clef){if(s2.clef_auto){if(s2.type!='a') 4492p_voice.clef=clone(p_voice.clef);p_voice.clef.clef_type=new_type;p_voice.clef.clef_line=new_line} 4493staff_tb[st].clef=staff_clef[st].clef=p_voice.clef 4494continue} 4495if(new_type==staff_clef[st].clef.clef_type&&new_line==staff_clef[st].clef.clef_line) 4496continue 4497g=s.ts_prev 4498while(g&&g.time==s.time&&(g.v!=v||g.st!=st)) 4499g=g.ts_prev 4500if(!g||g.time!=s.time){g=s.ts_next 4501while(g&&(g.v!=v||g.st!=st)) 4502g=g.ts_next 4503if(!g||g.time!=s.time) 4504g=s} 4505if(g.type!=C.CLEF){g=insert_clef(g,new_type,new_line) 4506if(s2.clef_auto) 4507g.clef_auto=true} 4508staff_clef[st].clef=p_voice.clef=g} 4509continue 4510default:s.mid=mid[s.st] 4511continue 4512case C.CLEF:break} 4513if(s.clef_type=='a'){s.clef_type=set_auto_clef(s.st,s.ts_next,staff_clef[s.st].clef.clef_type);s.clef_line=s.clef_type=='t'?2:4} 4514p_voice=s.p_v;p_voice.clef=s 4515if(s.second){unlksym(s) 4516continue} 4517st=s.st 4518if(staff_clef[st].clef){if(s.clef_type==staff_clef[st].clef.clef_type&&s.clef_line==staff_clef[st].clef.clef_line){continue}}else{staff_tb[st].clef=s} 4519staff_clef[st].clef=s} 4520sy=cur_sy 4521for(v=0;v<voice_tb.length;v++){if(!sy.voices[v]) 4522continue 4523s2=voice_tb[v].sym 4524if(!s2||s2.notes[0].pit!=127) 4525continue 4526st=sy.voices[v].st 4527switch(staff_tb[st].clef.clef_type){default:pit=22 4528break 4529case"c":pit=16 4530break 4531case"b":pit=10 4532break} 4533for(s=s2;s;s=s.next) 4534s.notes[0].pit=pit}} 4535var delta_tb={t:0-2*2,c:6-3*2,b:12-4*2,p:0-3*2} 4536var rest_sp=[[18,18],[12,18],[12,12],[0,12],[6,8],[10,10],[6,4],[10,0],[10,4],[10,10]] 4537Abc.prototype.set_pitch=function(last_s){var s,s2,g,st,delta,pitch,note,dur=C.BLEN,m=nstaff+1,staff_delta=new Int16Array(new Array(m*2)),sy=cur_sy 4538for(st=0;st<=nstaff;st++){s=staff_tb[st].clef;staff_delta[st]=delta_tb[s.clef_type]+s.clef_line*2 4539if(s.clefpit) 4540staff_delta[st]+=s.clefpit 4541if(cfmt.sound){if(s.clef_octave&&!s.clef_oct_transp) 4542staff_delta[st]+=s.clef_octave}else{if(s.clef_oct_transp) 4543staff_delta[st]-=s.clef_octave}} 4544for(s=tsfirst;s!=last_s;s=s.ts_next){st=s.st 4545switch(s.type){case C.CLEF:staff_delta[st]=delta_tb[s.clef_type]+ 4546s.clef_line*2 4547if(s.clefpit) 4548staff_delta[st]+=s.clefpit 4549if(cfmt.sound){if(s.clef_octave&&!s.clef_oct_transp) 4550staff_delta[st]+=s.clef_octave}else{if(s.clef_oct_transp) 4551staff_delta[st]-=s.clef_octave} 4552set_yval(s) 4553break 4554case C.GRACE:for(g=s.extra;g;g=g.next){delta=staff_delta[g.st] 4555if(delta&&!s.p_v.ckey.k_drum){for(m=0;m<=g.nhd;m++){note=g.notes[m];note.opit=note.pit 4556note.pit+=delta}} 4557g.ymn=3*(g.notes[0].pit-18)-2;g.ymx=3*(g.notes[g.nhd].pit-18)+2} 4558set_yval(s) 4559break 4560case C.KEY:s.k_y_clef=staff_delta[st] 4561default:set_yval(s) 4562break 4563case C.MREST:if(s.invis) 4564break 4565s.y=12;s.ymx=24+15;s.ymn=-2 4566break 4567case C.REST:if(voice_tb.length==1){s.y=12;s.ymx=24;s.ymn=0 4568break} 4569case C.NOTE:delta=staff_delta[st] 4570if(delta&&!s.p_v.ckey.k_drum){for(m=s.nhd;m>=0;m--){note=s.notes[m] 4571note.opit=note.pit 4572note.pit+=delta}} 4573if(s.type==C.REST){s.y=(((s.notes[0].pit-18)/2)|0)*6;s.ymx=s.y+rest_sp[5-s.nflags][0];s.ymn=s.y-rest_sp[5-s.nflags][1]} 4574if(s.dur<dur) 4575dur=s.dur 4576break}} 4577if(!last_s) 4578smallest_duration=dur} 4579Abc.prototype.set_stem_dir=function(){var t,u,i,st,rvoice,v,v_st,st_v,vobj,v_st_tb,st_v_tb=[],s=tsfirst,sy=cur_sy,nst=sy.nstaff 4580while(s){for(st=0;st<=nst;st++) 4581st_v_tb[st]=[] 4582v_st_tb=[] 4583for(u=s;u;u=u.ts_next){if(u.type==C.BAR) 4584break;if(u.type==C.STAVES){if(u!=s) 4585break 4586sy=s.sy 4587for(st=nst;st<=sy.nstaff;st++) 4588st_v_tb[st]=[] 4589nst=sy.nstaff 4590continue} 4591if((u.type!=C.NOTE&&u.type!=C.REST)||u.invis) 4592continue 4593st=u.st;if(st>nst){var msg="*** fatal set_stem_dir(): bad staff number "+st+" max "+nst;error(2,null,msg);throw new Error(msg)} 4594v=u.v;v_st=v_st_tb[v] 4595if(!v_st){v_st={st1:-1,st2:-1} 4596v_st_tb[v]=v_st} 4597if(v_st.st1<0){v_st.st1=st}else if(v_st.st1!=st){if(st>v_st.st1){if(st>v_st.st2) 4598v_st.st2=st}else{if(v_st.st1>v_st.st2) 4599v_st.st2=v_st.st1;v_st.st1=st}} 4600st_v=st_v_tb[st];rvoice=sy.voices[v].range;for(i=st_v.length;--i>=0;){vobj=st_v[i] 4601if(vobj.v==rvoice) 4602break} 4603if(i<0){vobj={v:rvoice,ymx:0,ymn:24} 4604for(i=0;i<st_v.length;i++){if(rvoice<st_v[i].v){st_v.splice(i,0,vobj) 4605break}} 4606if(i==st_v.length) 4607st_v.push(vobj)} 4608if(u.type!=C.NOTE) 4609continue 4610if(u.ymx>vobj.ymx) 4611vobj.ymx=u.ymx 4612if(u.ymn<vobj.ymn) 4613vobj.ymn=u.ymn 4614if(u.xstem){if(u.ts_prev.st!=st-1||u.ts_prev.type!=C.NOTE){error(1,s,"Bad !xstem!");u.xstem=false}else{u.ts_prev.multi=1;u.multi=1;u.stemless=true}}} 4615for(;s!=u;s=s.ts_next){if(s.multi) 4616continue 4617switch(s.type){default:continue 4618case C.REST:if((s.combine!=undefined&&s.combine<0)||!s.ts_next||s.ts_next.type!=C.REST||s.ts_next.st!=s.st||s.time!=s.ts_next.time||s.dur!=s.ts_next.dur||(s.a_dd&&s.ts_next.a_dd)||(s.a_gch&&s.ts_next.a_gch)||s.invis) 4619break 4620if(s.ts_next.a_dd) 4621s.a_dd=s.ts_next.a_dd 4622if(s.ts_next.a_gch) 4623s.a_gch=s.ts_next.a_gch 4624unlksym(s.ts_next) 4625break 4626case C.NOTE:case C.GRACE:break} 4627st=s.st;v=s.v;v_st=v_st_tb[v];st_v=st_v_tb[st] 4628if(v_st&&v_st.st2>=0){if(st==v_st.st1) 4629s.multi=-1 4630else if(st==v_st.st2) 4631s.multi=1 4632continue} 4633if(st_v.length<=1){if(s.floating) 4634s.multi=st==voice_tb[v].st?-1:1 4635continue} 4636rvoice=sy.voices[v].range 4637for(i=st_v.length;--i>=0;){if(st_v[i].v==rvoice) 4638break} 4639if(i<0) 4640continue 4641if(i==st_v.length-1){s.multi=-1}else{s.multi=1 4642if(i!=0&&i+2==st_v.length){if(st_v[i].ymn-cfmt.stemheight>=st_v[i+1].ymx) 4643s.multi=-1;t=s.ts_next 4644if(s.ts_prev&&s.ts_prev.time==s.time&&s.ts_prev.st==s.st&&s.notes[s.nhd].pit==s.ts_prev.notes[0].pit&&s.beam_st&&s.beam_end&&(!t||t.st!=s.st||t.time!=s.time)) 4645s.multi=-1}}} 4646while(s&&s.type==C.BAR) 4647s=s.ts_next}} 4648function set_rest_offset(){var s,s2,v,end_time,not_alone,v_s,y,ymax,ymin,shift,dots,dx,v_s_tb=[],sy=cur_sy 4649for(s=tsfirst;s;s=s.ts_next){if(s.invis) 4650continue 4651if(s.type==C.STAVES) 4652sy=s.sy 4653if(!s.dur) 4654continue 4655v_s=v_s_tb[s.v] 4656if(!v_s){v_s={} 4657v_s_tb[s.v]=v_s} 4658v_s.s=s;v_s.st=s.st;v_s.end_time=s.time+s.dur 4659if(s.type!=C.REST) 4660continue 4661ymin=-127;ymax=127;not_alone=dots=false 4662for(v=0;v<=v_s_tb.length;v++){v_s=v_s_tb[v] 4663if(!v_s||!v_s.s||v_s.st!=s.st||v==s.v) 4664continue 4665if(v_s.end_time<=s.time) 4666continue 4667not_alone=true;s2=v_s.s 4668if(sy.voices[v].range<sy.voices[s.v].range){if(s2.time==s.time){if(s2.ymn<ymax){ymax=s2.ymn 4669if(s2.dots) 4670dots=true}}else{if(s2.y<ymax) 4671ymax=s2.y}}else{if(s2.time==s.time){if(s2.ymx>ymin){ymin=s2.ymx 4672if(s2.dots) 4673dots=true}}else{if(s2.y>ymin) 4674ymin=s2.y}}} 4675end_time=s.time+s.dur 4676for(s2=s.ts_next;s2;s2=s2.ts_next){if(s2.time>=end_time) 4677break 4678if(s2.st!=s.st||!s2.dur||s2.invis) 4679continue 4680not_alone=true 4681if(sy.voices[s2.v].range<sy.voices[s.v].range){if(s2.time==s.time){if(s2.ymn<ymax){ymax=s2.ymn 4682if(s2.dots) 4683dots=true}}else{if(s2.y<ymax) 4684ymax=s2.y}}else{if(s2.time==s.time){if(s2.ymx>ymin){ymin=s2.ymx 4685if(s2.dots) 4686dots=true}}else{if(s2.y>ymin) 4687ymin=s2.y}}} 4688if(!not_alone){s.y=12;s.ymx=24;s.ymn=0 4689continue} 4690if(ymax==127&&s.y<12){shift=12-s.y 4691s.y+=shift;s.ymx+=shift;s.ymn+=shift} 4692if(ymin==-127&&s.y>12){shift=s.y-12 4693s.y-=shift;s.ymx-=shift;s.ymn-=shift} 4694shift=ymax-s.ymx 4695if(shift<0){shift=Math.ceil(-shift/6)*6 4696if(s.ymn-shift>=ymin){s.y-=shift;s.ymx-=shift;s.ymn-=shift 4697continue} 4698dx=dots?15:10;s.notes[0].shhd=dx;s.xmx=dx 4699continue} 4700shift=ymin-s.ymn 4701if(shift>0){shift=Math.ceil(shift/6)*6 4702if(s.ymx+shift<=ymax){s.y+=shift;s.ymx+=shift;s.ymn+=shift 4703continue} 4704dx=dots?15:10;s.notes[0].shhd=dx;s.xmx=dx 4705continue}}} 4706function new_sym(s,p_v,last_s){s.p_v=p_v 4707s.v=p_v.v 4708s.st=p_v.st 4709s.time=last_s.time 4710if(p_v.last_sym){s.next=p_v.last_sym.next 4711if(s.next) 4712s.next.prev=s;p_v.last_sym.next=s;s.prev=p_v.last_sym} 4713p_v.last_sym=s;lktsym(s,last_s)} 4714function init_music_line(){var p_voice,s,s1,s2,s3,last_s,v,st,shr,shrmx,shl,shlp,p_st,top,nv=voice_tb.length 4715for(v=0;v<nv;v++){if(!cur_sy.voices[v]) 4716continue 4717p_voice=voice_tb[v];p_voice.second=cur_sy.voices[v].second;p_voice.last_sym=p_voice.sym;st=cur_sy.voices[v].st 4718while(st<nstaff&&!cur_sy.st_print[st]) 4719st++;p_voice.st=st 4720if(!p_voice.second){staff_tb[st].key=p_voice.ckey 4721staff_tb[st].meter=p_voice.meter}} 4722s=tsfirst 4723while(s){switch(s.type){case C.CLEF:case C.KEY:case C.METER:switch(s.type){case C.CLEF:staff_tb[s.st].clef=s 4724break 4725case C.KEY:s.p_v.ckey=s 4726break 4727case C.METER:s.p_v.meter=s 4728insert_meter|=1 4729break} 4730unlksym(s) 4731case C.PART:case C.TEMPO:case C.BLOCK:case C.REMARK:s=s.ts_next 4732continue} 4733break} 4734last_s=tsfirst 4735for(v=0;v<nv;v++){p_voice=voice_tb[v] 4736if(!cur_sy.voices[v]||(cur_sy.voices[v].second&&!p_voice.bar_start)) 4737continue 4738st=cur_sy.voices[v].st 4739if(!staff_tb[st]||!staff_tb[st].clef) 4740continue 4741s=clone(staff_tb[st].clef);s.v=v;s.p_v=p_voice;s.st=st;s.time=tsfirst.time;s.prev=null;s.next=p_voice.sym 4742if(s.next) 4743s.next.prev=s;p_voice.sym=p_voice.last_sym=s 4744s.ts_next=last_s;if(last_s) 4745s.ts_prev=last_s.ts_prev 4746else 4747s.ts_prev=null 4748if(!s.ts_prev){tsfirst=s}else{s.ts_prev.ts_next=s 4749delete s.seqst} 4750if(last_s){last_s.ts_prev=s 4751if(last_s.type==C.CLEF) 4752delete last_s.seqst} 4753delete s.clef_small;s.second=cur_sy.voices[v].second 4754if(!cur_sy.st_print[st]) 4755s.invis=true} 4756for(v=0;v<nv;v++){if(!cur_sy.voices[v]||cur_sy.voices[v].second||!cur_sy.st_print[cur_sy.voices[v].st]) 4757continue 4758p_voice=voice_tb[v] 4759s2=p_voice.ckey 4760if(s2.k_sf||s2.k_a_acc){s=clone(s2) 4761new_sym(s,p_voice,last_s) 4762delete s.invis 4763s.k_old_sf=s2.k_sf}} 4764if(insert_meter&1){for(v=0;v<nv;v++){p_voice=voice_tb[v];s2=p_voice.meter 4765if(!cur_sy.voices[v]||cur_sy.voices[v].second||!cur_sy.st_print[cur_sy.voices[v].st]||!s2.a_meter.length) 4766continue 4767s=clone(s2) 4768new_sym(s,p_voice,last_s)} 4769insert_meter&=~1} 4770for(v=0;v<nv;v++){p_voice=voice_tb[v] 4771if(p_voice.sls.length){s={type:C.BAR,fname:last_s.fname,bar_type:"|",dur:0,multi:0,invis:true,sls:p_voice.sls} 4772new_sym(s,p_voice,last_s) 4773p_voice.sls=[]}} 4774for(v=0;v<nv;v++){p_voice=voice_tb[v];s2=p_voice.bar_start;p_voice.bar_start=null 4775if(last_s&&last_s.v==v){for(s3=last_s;s3;s3=s3.ts_next){if(s3.v!=v) 4776break 4777switch(s3.type){case C.PART:case C.TEMPO:continue 4778case C.BAR:p_voice.last_sym=s3 4779last_s=s3.ts_next 4780break} 4781break}} 4782if(!s2) 4783continue 4784if(!cur_sy.voices[v]||!cur_sy.st_print[cur_sy.voices[v].st]) 4785continue 4786if(p_voice.last_sym.type==C.BAR){if(!p_voice.last_sym.rbstop) 4787p_voice.last_sym.rbstart=1}else{new_sym(s2,p_voice,last_s)}} 4788self.set_pitch(last_s);s=tsfirst 4789s.seqst=true 4790shlp=0 4791while(1){s2=s;shl=shrmx=0 4792do{self.set_width(s);shr=s.wl+shlp 4793if(shr>shrmx) 4794shrmx=shr;if(s.wr>shl) 4795shl=s.wr 4796s=s.ts_next}while(s!=last_s&&!s.seqst);s2.shrink=shrmx;s2.space=0 4797if(s==last_s) 4798break 4799shlp=shl} 4800shr=0 4801do{self.set_width(s) 4802if(shr<s.wl) 4803shr=s.wl;s=s.ts_next}while(s&&!s.seqst);last_s.shrink=shl+shr 4804last_s.space=0} 4805function check_end_bar(){var s2,s=tsfirst 4806while(s.ts_next) 4807s=s.ts_next 4808if(s.type!=C.BAR){s2=_bar(s) 4809s2.seqst=true 4810s2.invis=true 4811s2.time=s.time+(s.dur||0) 4812s2.ts_prev=s 4813s.next=s.ts_next=s2}} 4814function set_words(p_voice){var s,s2,nflags,lastnote,res,start_flag=true,pitch=127 4815for(s=p_voice.sym;s;s=s.next){if(s.type==C.NOTE){pitch=s.notes[0].pit 4816break}} 4817for(s=p_voice.sym;s;s=s.next){if(s.a_gch) 4818self.gch_build(s) 4819switch(s.type){case C.MREST:start_flag=true 4820break 4821case C.BAR:s.bar_type=bar_cnv(s.bar_type) 4822if(!s.beam_on) 4823start_flag=true 4824if(!s.next&&s.prev&&!s.invis&&s.prev.head==C.OVALBARS) 4825s.prev.head=C.SQUARE 4826break 4827case C.GRACE:for(s2=s.extra;s2;s2=s2.next) 4828s2.notes.sort(abc2svg.pitcmp) 4829break 4830case C.NOTE:case C.REST:res=identify_note(s,s.dur_orig);s.head=res[0];s.dots=res[1];s.nflags=res[2] 4831if(s.nflags<=-2) 4832s.stemless=true 4833if(s.xstem) 4834s.nflags=0 4835if(s.trem1){if(s.nflags>0) 4836s.nflags+=s.ntrem 4837else 4838s.nflags=s.ntrem} 4839if(s.next&&s.next.trem2) 4840break 4841if(s.trem2){s.prev.trem2=true;s.prev.nflags=--s.nflags;s.prev.head=++s.head 4842if(s.nflags>0){s.nflags+=s.ntrem}else{if(s.nflags<=-2){s.stemless=true;s.prev.stemless=true} 4843s.nflags=s.ntrem} 4844s.prev.nflags=s.nflags 4845break} 4846nflags=s.nflags 4847if(s.ntrem) 4848nflags+=s.ntrem 4849if(s.type==C.REST&&s.beam_end&&!s.beam_on){s.beam_end=false;start_flag=true} 4850if(start_flag||nflags<=0){if(lastnote){lastnote.beam_end=true;lastnote=null} 4851if(nflags<=0){s.beam_st=true;s.beam_end=true}else if(s.type==C.NOTE||s.beam_on){s.beam_st=true;start_flag=false}} 4852if(s.beam_end) 4853start_flag=true 4854if(s.type==C.NOTE||s.beam_on) 4855lastnote=s 4856break} 4857if(s.type==C.NOTE){if(s.nhd) 4858s.notes.sort(abc2svg.pitcmp) 4859pitch=s.notes[0].pit 4860for(s2=s.prev;s2;s2=s2.prev){if(s2.type!=C.REST) 4861break 4862s2.notes[0].pit=pitch}}else{if(!s.notes){s.notes=[] 4863s.notes[0]={} 4864s.nhd=0} 4865s.notes[0].pit=pitch}} 4866if(lastnote) 4867lastnote.beam_end=true} 4868function set_rb(p_voice){var s2,n,s=p_voice.sym 4869while(s){if(s.type!=C.BAR||!s.rbstart||s.norepbra){s=s.next 4870continue} 4871n=0;s2=null 4872for(s=s.next;s;s=s.next){if(s.type!=C.BAR) 4873continue 4874n++ 4875if(s.rbstop) 4876break 4877if(!s.next){s.rbstop=2 4878break} 4879if(n==cfmt.rbmin) 4880s2=s 4881if(n==cfmt.rbmax){if(s2) 4882s=s2;s.rbstop=1 4883break}}}} 4884var delpit=[0,-7,-14,0] 4885function set_global(){var p_voice,v,nv=voice_tb.length,sy=cur_sy,st=sy.nstaff 4886while(1){sy=sy.next 4887if(!sy) 4888break 4889if(sy.nstaff>st) 4890st=sy.nstaff} 4891nstaff=st;check_end_bar() 4892for(v=0;v<nv;v++){p_voice=voice_tb[v];set_words(p_voice) 4893p_voice.ckey=p_voice.key 4894set_rb(p_voice)} 4895if(nv>1){set_float() 4896if(glovar.mrest_p) 4897mrest_expand()} 4898if(glovar.ottava&&cfmt.sound!="play") 4899set_ottava();set_clefs();self.set_pitch(null)} 4900function set_indent(first){var st,v,w,p_voice,p,i,j,font,nv=voice_tb.length,maxw=0 4901for(v=0;v<nv;v++){p_voice=voice_tb[v] 4902if(!cur_sy.voices[v]) 4903continue 4904st=cur_sy.voices[v].st 4905p=((first||p_voice.new_name)&&p_voice.nm)?p_voice.nm:p_voice.snm 4906if(!p) 4907continue 4908if(!font){set_font("voice");font=gene.curfont} 4909i=0 4910while(1){j=p.indexOf("\n",i) 4911if(j<0) 4912w=strwh(p.slice(i)) 4913else 4914w=strwh(p.slice(i,j)) 4915w=w[0] 4916if(w>maxw) 4917maxw=w 4918if(j<0) 4919break 4920i=j+1}} 4921if(font) 4922maxw+=4*cwidf(' ');w=.5 4923for(st=0;st<=cur_sy.nstaff;st++){if(cur_sy.staves[st].flags&(OPEN_BRACE2|OPEN_BRACKET2)){w=12 4924break} 4925if(cur_sy.staves[st].flags&(OPEN_BRACE|OPEN_BRACKET)) 4926w=6} 4927maxw+=w 4928if(first) 4929maxw+=cfmt.indent 4930return maxw} 4931function set_beams(sym){var s,t,g,beam,s_opp,n,m,mid_p,pu,pd,laststem=-1 4932for(s=sym;s;s=s.next){if(s.type!=C.NOTE){if(s.type!=C.GRACE) 4933continue 4934g=s.extra 4935if(g.stem==2){s_opp=s 4936continue} 4937if(!s.stem&&(s.stem=s.multi)==0) 4938s.stem=1 4939for(;g;g=g.next){g.stem=s.stem;g.multi=s.multi} 4940continue} 4941if(!s.stem&&(s.stem=s.multi)==0){mid_p=s.mid/3+18 4942if(beam){s.stem=laststem}else if(s.beam_st&&!s.beam_end){beam=true;n=pu=0 4943for(g=s;g;g=g.next){if(g.type!=C.NOTE){continue} 4944if(g.stem||g.multi){s.stem=g.stem||g.multi 4945break} 4946n+=g.nhd+1 4947for(m=0;m<=g.nhd;m++){if(g.notes[m].pit>=mid_p) 4948pu++} 4949if(g.beam_end) 4950break} 4951if(!s.stem){pu*=2 4952if(pu>n){s.stem=-1}else if(pu<n){s.stem=1}else{pu=s.notes[s.nhd].pit;pd=s.notes[0].pit 4953for(g=s.next;g;g=g.next){if(g.type!=C.NOTE){continue} 4954if(g.notes[g.nhd].pit>pu) 4955pu=g.notes[g.nhd].pit 4956if(g.notes[0].pit<pd) 4957pd=g.notes[0].pit 4958if(g.beam_end) 4959break} 4960if(g.beam_end){if(pu+pd<mid_p*2){s.stem=1}else if(pu+pd>mid_p*2){s.stem=-1}else{if(cfmt.bstemdown) 4961s.stem=-1}}}} 4962if(!s.stem) 4963s.stem=laststem}else{n=(s.notes[s.nhd].pit+s.notes[0].pit)/2 4964if(n==mid_p){for(m=0;m<=s.nhd;m++){if(s.notes[m].pit>=mid_p) 4965break} 4966n=m*2<s.nhd?mid_p-1:mid_p+1} 4967if(n<mid_p) 4968s.stem=1 4969else if(n>mid_p) 4970s.stem=-1 4971else if(cfmt.bstemdown) 4972s.stem=-1 4973else 4974s.stem=laststem}}else{if(s.beam_st&&!s.beam_end) 4975beam=true} 4976if(s.beam_end) 4977beam=false;laststem=s.stem;if(s_opp){for(g=s_opp.extra;g;g=g.next) 4978g.stem=-laststem;s_opp.stem=-laststem;s_opp=null}}} 4979function same_head(s1,s2){var i1,i2,l1,l2,head,i11,i12,i21,i22,sh1,sh2 4980if(s1.shiftunison&&s1.shiftunison>=3) 4981return false 4982if((l1=s1.dur)>=C.BLEN) 4983return false 4984if((l2=s2.dur)>=C.BLEN) 4985return false 4986if(s1.stemless&&s2.stemless) 4987return false 4988if(s1.dots!=s2.dots){if((s1.shiftunison&&(s1.shiftunison&1))||s1.dots*s2.dots!=0) 4989return false} 4990if(s1.stem*s2.stem>0) 4991return false 4992i1=i2=0 4993if(s1.notes[0].pit>s2.notes[0].pit){if(s1.stem<0) 4994return false 4995while(s2.notes[i2].pit!=s1.notes[0].pit){if(++i2>s2.nhd) 4996return false}}else if(s1.notes[0].pit<s2.notes[0].pit){if(s2.stem<0) 4997return false 4998while(s2.notes[0].pit!=s1.notes[i1].pit){if(++i1>s1.nhd) 4999return false}} 5000if(s2.notes[i2].acc!=s1.notes[i1].acc) 5001return false;i11=i1;i21=i2;sh1=s1.notes[i1].shhd;sh2=s2.notes[i2].shhd 5002do{i1++;i2++ 5003if(i1>s1.nhd){break} 5004if(i2>s2.nhd){break} 5005if(s2.notes[i2].acc!=s1.notes[i1].acc) 5006return false 5007if(sh1<s1.notes[i1].shhd) 5008sh1=s1.notes[i1].shhd 5009if(sh2<s2.notes[i2].shhd) 5010sh2=s2.notes[i2].shhd}while(s2.notes[i2].pit==s1.notes[i1].pit) 5011if(i1<=s1.nhd){if(i2<=s2.nhd) 5012return false 5013if(s2.stem>0) 5014return false}else if(i2<=s2.nhd){if(s1.stem>0) 5015return false} 5016i12=i1;i22=i2;head=0 5017if(l1!=l2){if(l1<l2){l1=l2;l2=s1.dur} 5018if(l1<C.BLEN/2){if(s2.dots) 5019head=2 5020else if(s1.dots) 5021head=1}else if(l2<C.BLEN/4){if(s1.shiftunison&&(s1.shiftunison&2)) 5022return false 5023head=s2.dur>=C.BLEN/2?2:1}else{return false}} 5024if(!head) 5025head=s1.p_v.scale<s2.p_v.scale?2:1 5026if(head==1){for(i2=i21;i2<i22;i2++){s2.notes[i2].invis=true 5027delete s2.notes[i2].acc} 5028for(i2=0;i2<=s2.nhd;i2++) 5029s2.notes[i2].shhd+=sh1}else{for(i1=i11;i1<i12;i1++){s1.notes[i1].invis=true 5030delete s1.notes[i1].acc} 5031for(i1=0;i1<=s1.nhd;i1++) 5032s1.notes[i1].shhd+=sh2} 5033return true} 5034function unison_acc(s1,s2,i1,i2){var m,d,acc 5035acc=s2.notes[i2].acc 5036if(!acc){d=w_note[s2.head]*2+s2.xmx+s1.notes[i1].shac+2 5037acc=s1.notes[i1].acc 5038if(typeof acc!="number") 5039d+=2 5040if(s2.dots) 5041d+=6 5042for(m=0;m<=s1.nhd;m++){s1.notes[m].shhd+=d;s1.notes[m].shac-=d} 5043s1.xmx+=d}else{d=w_note[s1.head]*2+s1.xmx+s2.notes[i2].shac+2 5044if(typeof acc!="number") 5045d+=2 5046if(s1.dots) 5047d+=6 5048for(m=0;m<=s2.nhd;m++){s2.notes[m].shhd+=d;s2.notes[m].shac-=d} 5049s2.xmx+=d}} 5050var MAXPIT=48*2 5051function set_left(s){var m,i,j,shift,w_base=w_note[s.head],w=w_base,left=[] 5052for(i=0;i<MAXPIT;i++) 5053left.push(-100) 5054if(s.nflags>-2){if(s.stem>0){w=-w;i=s.notes[0].pit*2;j=(Math.ceil((s.ymx-2)/3)+18)*2}else{i=(Math.ceil((s.ymn+2)/3)+18)*2;j=s.notes[s.nhd].pit*2} 5055if(i<0) 5056i=0 5057if(j>=MAXPIT) 5058j=MAXPIT-1 5059while(i<=j) 5060left[i++]=w} 5061shift=s.notes[s.stem>0?0:s.nhd].shhd;for(m=0;m<=s.nhd;m++){w=-s.notes[m].shhd+w_base+shift;i=s.notes[m].pit*2 5062if(i<0) 5063i=0 5064else if(i>=MAXPIT-1) 5065i=MAXPIT-2 5066if(w>left[i]) 5067left[i]=w 5068if(s.head!=C.SQUARE) 5069w-=1 5070if(w>left[i-1]) 5071left[i-1]=w 5072if(w>left[i+1]) 5073left[i+1]=w} 5074return left} 5075function set_right(s){var m,i,j,k,shift,w_base=w_note[s.head],w=w_base,flags=s.nflags>0&&s.beam_st&&s.beam_end,right=[] 5076for(i=0;i<MAXPIT;i++) 5077right.push(-100) 5078if(s.nflags>-2){if(s.stem<0){w=-w;i=(Math.ceil((s.ymn+2)/3)+18)*2;j=s.notes[s.nhd].pit*2;k=i+4}else{i=s.notes[0].pit*2;j=(Math.ceil((s.ymx-2)/3)+18)*2} 5079if(i<0) 5080i=0 5081if(j>MAXPIT) 5082j=MAXPIT 5083while(i<j) 5084right[i++]=w} 5085if(flags){if(s.stem>0){if(s.xmx==0) 5086i=s.notes[s.nhd].pit*2 5087else 5088i=s.notes[0].pit*2;i+=4 5089if(i<0) 5090i=0 5091for(;i<MAXPIT&&i<=j-4;i++) 5092right[i]=11}else{i=k 5093if(i<0) 5094i=0 5095for(;i<MAXPIT&&i<=s.notes[0].pit*2-4;i++) 5096right[i]=3.5}} 5097shift=s.notes[s.stem>0?0:s.nhd].shhd 5098for(m=0;m<=s.nhd;m++){w=s.notes[m].shhd+w_base-shift;i=s.notes[m].pit*2 5099if(i<0) 5100i=0 5101else if(i>=MAXPIT-1) 5102i=MAXPIT-2 5103if(w>right[i]) 5104right[i]=w 5105if(s.head!=C.SQUARE) 5106w-=1 5107if(w>right[i-1]) 5108right[i-1]=w 5109if(w>right[i+1]) 5110right[i+1]=w} 5111return right} 5112function set_overlap(){var s,s1,s2,s3,i,i1,i2,m,sd,t,dp,d,d2,dr,dr2,dx,left1,right1,left2,right2,right3,pl,pr,sy=cur_sy 5113function v_invert(){s1=s2;s2=s;d=d2;pl=left1;pr=right1;dr2=dr} 5114for(s=tsfirst;s;s=s.ts_next){if(s.type!=C.NOTE||s.invis){if(s.type==C.STAVES) 5115sy=s.sy 5116continue} 5117if(s.xstem&&s.ts_prev.stem<0){for(m=0;m<=s.nhd;m++){s.notes[m].shhd-=7;s.notes[m].shac+=16}} 5118s2=s 5119while(1){s2=s2.ts_next 5120if(!s2) 5121break 5122if(s2.time!=s.time){s2=null 5123break} 5124if(s2.type==C.NOTE&&!s2.invis&&s2.st==s.st) 5125break} 5126if(!s2) 5127continue 5128s1=s 5129if(sy.voices[s1.v].range<sy.voices[s2.v].range) 5130s2.dot_low=true 5131else 5132s1.dot_low=true 5133if(s1.ymn>s2.ymx||s1.ymx<s2.ymn) 5134continue 5135if(same_head(s1,s2)) 5136continue 5137if(!s1.dots&&!s2.dots) 5138if((s1.stem>0&&s2.stem<0&&s1.notes[0].pit==s2.notes[s2.nhd].pit+1)||(s1.stem<0&&s2.stem>0&&s1.notes[s1.nhd].pit+1==s2.notes[0].pit)){if(s1.stem<0){s1=s2;s2=s} 5139d=s1.notes[0].shhd+7 5140for(m=0;m<=s2.nhd;m++) 5141s2.notes[m].shhd+=d 5142s2.xmx+=d 5143s1.xmx=s2.xmx 5144continue} 5145right1=set_right(s1);left2=set_left(s2);s3=s1.ts_prev 5146if(s3&&s3.time==s1.time&&s3.st==s1.st&&s3.type==C.NOTE&&!s3.invis){right3=set_right(s3) 5147for(i=0;i<MAXPIT;i++){if(right3[i]>right1[i]) 5148right1[i]=right3[i]}}else{s3=null} 5149d=-10 5150for(i=0;i<MAXPIT;i++){if(left2[i]+right1[i]>d) 5151d=left2[i]+right1[i]} 5152if(d<-3&&((s2.notes[0].pit&1)||!(s1.dots||s2.dots)||(!(s1.notes[s1.nhd].pit==s2.notes[0].pit+2&&s1.dot_low)&&!(s1.notes[s1.nhd].pit+2==s2.notes[0].pit&&s2.dot_low)))) 5153continue 5154right2=set_right(s2);left1=set_left(s1) 5155if(s3){right3=set_left(s3) 5156for(i=0;i<MAXPIT;i++){if(right3[i]>left1[i]) 5157left1[i]=right3[i]}} 5158d2=dr=dr2=-100 5159for(i=0;i<MAXPIT;i++){if(left1[i]+right2[i]>d2) 5160d2=left1[i]+right2[i] 5161if(right2[i]>dr2) 5162dr2=right2[i] 5163if(right1[i]>dr) 5164dr=right1[i]} 5165t=0;i1=s1.nhd;i2=s2.nhd 5166while(1){dp=s1.notes[i1].pit-s2.notes[i2].pit 5167switch(dp){case 2:if(!(s1.notes[i1].pit&1)) 5168s1.dot_low=false 5169break 5170case 1:if(s1.notes[i1].pit&1) 5171s2.dot_low=true 5172else 5173s1.dot_low=false 5174break 5175case 0:if(s1.notes[i1].acc!=s2.notes[i2].acc&&!s1.notes[i1].acc&&!s2.notes[i2].acc){t=-1 5176break} 5177if(s2.notes[i2].acc){if(!s1.notes[i1].acc) 5178s1.notes[i1].acc=s2.notes[i2].acc 5179s2.notes[i2].acc=0} 5180if(s1.dots&&s2.dots&&(s1.notes[i1].pit&1)) 5181t=1 5182break 5183case-1:if(s1.notes[i1].pit&1) 5184s2.dot_low=false 5185else 5186s1.dot_low=true 5187break 5188case-2:if(!(s1.notes[i1].pit&1)) 5189s2.dot_low=false 5190break} 5191if(t<0) 5192break 5193if(dp>=0){if(--i1<0) 5194break} 5195if(dp<=0){if(--i2<0) 5196break}} 5197if(t<0){unison_acc(s1,s2,i1,i2) 5198continue} 5199sd=0;if(s1.dots){if(s2.dots){if(!t) 5200sd=1}else{v_invert()}}else if(s2.dots){if(d2+dr<d+dr2) 5201sd=1} 5202pl=left2;pr=right2 5203if(!s3&&d2+dr<d+dr2) 5204v_invert() 5205d+=3 5206if(d<0) 5207d=0;m=s1.stem>=0?0:s1.nhd;d+=s1.notes[m].shhd;m=s2.stem>=0?0:s2.nhd;d-=s2.notes[m].shhd 5208if(s1.dots){dx=7.7+s1.xmx+ 52093.5*s1.dots-3.5+ 52103;if(!sd){d2=-100;for(i1=0;i1<=s1.nhd;i1++){i=s1.notes[i1].pit 5211if(!(i&1)){if(!s1.dot_low) 5212i++ 5213else 5214i--} 5215i*=2 5216if(i<1) 5217i=1 5218else if(i>=MAXPIT-1) 5219i=MAXPIT-2 5220if(pl[i]>d2) 5221d2=pl[i] 5222if(pl[i-1]+1>d2) 5223d2=pl[i-1]+1 5224if(pl[i+1]+1>d2) 5225d2=pl[i+1]+1} 5226if(dx+d2+2>d) 5227d=dx+d2+2}else{if(dx<d+dr2+s2.xmx){d2=0 5228for(i1=0;i1<=s1.nhd;i1++){i=s1.notes[i1].pit 5229if(!(i&1)){if(!s1.dot_low) 5230i++ 5231else 5232i--} 5233i*=2 5234if(i<1) 5235i=1 5236else if(i>=MAXPIT-1) 5237i=MAXPIT-2 5238if(pr[i]>d2) 5239d2=pr[i] 5240if(pr[i-1]+1>d2) 5241d2=pr[i-1]=1 5242if(pr[i+1]+1>d2) 5243d2=pr[i+1]+1} 5244if(d2>4.5&&7.7+s1.xmx+2<d+d2+s2.xmx) 5245s2.xmx=d2+3-7.7}}} 5246for(m=s2.nhd;m>=0;m--){s2.notes[m].shhd+=d} 5247s2.xmx+=d 5248if(sd) 5249s1.xmx=s2.xmx}} 5250Abc.prototype.set_stems=function(){var s,s2,g,slen,scale,ymn,ymx,nflags,ymin,ymax,res 5251for(s=tsfirst;s;s=s.ts_next){if(s.type!=C.NOTE){if(s.type!=C.GRACE) 5252continue 5253ymin=ymax=s.mid 5254for(g=s.extra;g;g=g.next){res=identify_note(s,g.dur);g.head=res[0];g.dots=res[1];g.nflags=res[2];slen=GSTEM 5255if(g.nflags>1) 5256slen+=1.2*(g.nflags-1);ymn=3*(g.notes[0].pit-18);ymx=3*(g.notes[g.nhd].pit-18) 5257if(s.stem>=0){g.y=ymn;g.ys=ymx+slen;ymx=Math.round(g.ys)}else{g.y=ymx;g.ys=ymn-slen;ymn=Math.round(g.ys)} 5258ymx+=2;ymn-=2 5259if(ymn<ymin) 5260ymin=ymn 5261else if(ymx>ymax) 5262ymax=ymx;g.ymx=ymx;g.ymn=ymn} 5263s.ymx=ymax;s.ymn=ymin 5264continue} 5265set_head_shift(s);nflags=s.nflags 5266if(s.beam_st&&!s.beam_end){if(s.feathered_beam) 5267nflags=++s.nflags 5268for(s2=s.next;;s2=s2.next){if(s2.type==C.NOTE){if(s.feathered_beam) 5269s2.nflags++ 5270if(s2.beam_end) 5271break}} 5272if(s2.nflags>nflags) 5273nflags=s2.nflags}else if(!s.beam_st&&s.beam_end){for(s2=s.prev;;s2=s2.prev){if(s2.beam_st) 5274break} 5275if(s2.nflags>nflags) 5276nflags=s2.nflags} 5277slen=cfmt.stemheight 5278switch(nflags){case 2:slen+=0;break 5279case 3:slen+=4;break 5280case 4:slen+=8;break 5281case 5:slen+=12;break} 5282if((scale=s.p_v.scale)!=1) 5283slen*=(scale+1)*.5;ymn=3*(s.notes[0].pit-18) 5284if(s.nhd>0){slen-=2;ymx=3*(s.notes[s.nhd].pit-18)}else{ymx=ymn} 5285if(s.ntrem) 5286slen+=2*s.ntrem 5287if(s.stemless){if(s.stem>=0){s.y=ymn;s.ys=ymx}else{s.ys=ymn;s.y=ymx} 5288s.ymx=ymx+4;s.ymn=ymn-4}else if(s.stem>=0){if(s.notes[s.nhd].pit>26&&(nflags<=0||!s.beam_st||!s.beam_end)){slen-=2 5289if(s.notes[s.nhd].pit>28) 5290slen-=2} 5291s.y=ymn 5292if(s.notes[0].tie) 5293ymn-=3;s.ymn=ymn-4;s.ys=ymx+slen 5294if(s.ys<s.mid) 5295s.ys=s.mid;s.ymx=(s.ys+2.5)|0}else{if(s.notes[0].pit<18&&(nflags<=0||!s.beam_st||!s.beam_end)){slen-=2 5296if(s.notes[0].pit<16) 5297slen-=2} 5298s.ys=ymn-slen 5299if(s.ys>s.mid) 5300s.ys=s.mid;s.ymn=(s.ys-2.5)|0;s.y=ymx 5301if(s.notes[s.nhd].tie) 5302ymx+=3;s.ymx=ymx+4}}} 5303function sym_staff_move(st){for(var s=tsfirst;s;s=s.ts_next){if(s.nl) 5304break 5305if(s.st==st&&s.type!=C.CLEF){s.st++;s.invis=true}}} 5306var blocks=[] 5307Abc.prototype.block_gen=function(s){switch(s.subtype){case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"scale":case"staffwidth":blk_flush() 5308self.set_format(s.subtype,s.param) 5309break 5310case"mc_start":multicol={posy:posy,maxy:posy,lmarg:cfmt.leftmargin,rmarg:cfmt.rightmargin} 5311break 5312case"mc_new":if(!multicol){error(1,s,"%%multicol new without start") 5313break} 5314if(posy>multicol.maxy) 5315multicol.maxy=posy 5316cfmt.leftmargin=multicol.lmarg 5317cfmt.rightmargin=multicol.rmarg 5318img.chg=true 5319set_page() 5320posy=multicol.posy 5321break 5322case"mc_end":if(!multicol){error(1,s,"%%multicol new without start") 5323break} 5324if(posy<multicol.maxy) 5325posy=multicol.maxy 5326cfmt.leftmargin=multicol.lmarg 5327cfmt.rightmargin=multicol.rmarg 5328multicol=undefined 5329blk_flush() 5330img.chg=true 5331set_page() 5332break 5333case"ml":blk_flush() 5334user.img_out(s.text) 5335break 5336case"newpage":svg_flush() 5337if(!user.page_format) 5338break 5339if(blkdiv<0) 5340user.img_out('</div>') 5341blkdiv=2 5342break 5343case"sep":set_page();vskip(s.sk1);output+='<path class="stroke"\n\td="M';out_sxsy((img.width-s.l)/2-img.lm,' ',0) 5344output+='h'+s.l.toFixed(1)+'"/>\n';vskip(s.sk2);break 5345case"text":set_font(s.font) 5346write_text(s.text,s.opt) 5347break 5348case"title":write_title(s.text,true) 5349break 5350case"vskip":vskip(s.sk);break}} 5351function set_piece(){var s,last,p_voice,st,v,nv,tmp,non_empty=[],non_empty_gl=[],sy=cur_sy 5352function reset_staff(st){var p_staff=staff_tb[st],sy_staff=sy.staves[st] 5353if(!p_staff) 5354p_staff=staff_tb[st]={} 5355p_staff.y=0;p_staff.stafflines=sy_staff.stafflines;p_staff.staffscale=sy_staff.staffscale;p_staff.ann_top=p_staff.ann_bot=0} 5356function set_brace(){var st,i,empty_fl,n=sy.staves.length 5357for(st=0;st<n;st++){if(!(sy.staves[st].flags&(OPEN_BRACE|OPEN_BRACE2))) 5358continue 5359empty_fl=0;i=st 5360while(st<n){empty_fl|=non_empty[st]?1:2 5361if(sy.staves[st].flags&(CLOSE_BRACE|CLOSE_BRACE2)) 5362break 5363st++} 5364if(empty_fl==3){while(i<=st){non_empty[i]=true;non_empty_gl[i++]=true}}}} 5365function set_top_bot(){var st,p_staff,i,j,l 5366for(st=0;st<=nstaff;st++){p_staff=staff_tb[st] 5367p_staff.hlu=[] 5368p_staff.hld=[] 5369if(!non_empty_gl[st]){p_staff.botbar=p_staff.topbar=0 5370continue} 5371l=p_staff.stafflines.length;p_staff.topbar=6*(l-1) 5372for(i=0;i<l-1;i++){switch(p_staff.stafflines[i]){case'.':case'-':continue} 5373break} 5374p_staff.botline=p_staff.botbar=i*6 5375if(i>=l-2){if(p_staff.stafflines[i]!='.'){p_staff.botbar-=6;p_staff.topbar+=6}else{p_staff.botbar-=12;p_staff.topbar+=12 5376continue}} 5377p_staff.hll=17+i;p_staff.hlmap=new Int8Array(new Array((l-i+1)*2)) 5378for(j=1;i<l;i++,j+=2){switch(p_staff.stafflines[i]){case'|':case'[':p_staff.hlmap[j-1]=1;p_staff.hlmap[j]=1;p_staff.hlmap[j+1]=1 5379break}}}} 5380if(tsfirst.type==C.STAVES){s=tsfirst 5381tsfirst=tsfirst.ts_next 5382tsfirst.ts_prev=null 5383if(s.seqst) 5384tsfirst.seqst=true 5385s.p_v.sym=s.next 5386if(s.next) 5387s.next.prev=null} 5388nstaff=sy.nstaff 5389for(st=0;st<=nstaff;st++) 5390reset_staff(st);for(s=tsfirst;s;s=s.ts_next){if(s.nl) 5391break 5392switch(s.type){case C.STAVES:set_brace();sy.st_print=new Uint8Array(non_empty);sy=s.sy;while(nstaff<sy.nstaff) 5393reset_staff(++nstaff) 5394non_empty=[] 5395continue 5396case C.BLOCK:if(!s.play){blocks.push(s) 5397unlksym(s)} 5398continue} 5399st=s.st 5400if(st>nstaff){switch(s.type){case C.CLEF:staff_tb[st].clef=s 5401break 5402case C.KEY:s.p_v.ckey=s 5403break 5404case C.METER:s.p_v.meter=s 5405break} 5406unlksym(s) 5407continue} 5408if(non_empty[st]) 5409continue 5410switch(s.type){default:continue 5411case C.BAR:if(s.bar_mrep||sy.staves[st].staffnonote>1) 5412break 5413continue 5414case C.GRACE:break 5415case C.NOTE:case C.REST:case C.SPACE:case C.MREST:if(sy.staves[st].staffnonote>1) 5416break 5417if(s.invis) 5418continue 5419if(sy.staves[st].staffnonote||s.type==C.NOTE) 5420break 5421continue} 5422non_empty_gl[st]=non_empty[st]=true} 5423tsnext=s;set_brace() 5424sy.st_print=new Uint8Array(non_empty);set_top_bot() 5425for(st=0;st<nstaff;st++){if(!non_empty_gl[st]) 5426sym_staff_move(st)} 5427if(!non_empty_gl[nstaff]) 5428staff_tb[nstaff].topbar=0;init_music_line();gene.st_print=new Uint8Array(non_empty_gl) 5429if(tsnext){s=tsnext;delete s.nl;last=s.ts_prev;last.ts_next=null;nv=voice_tb.length 5430for(v=0;v<nv;v++){p_voice=voice_tb[v] 5431if(p_voice.sym&&p_voice.sym.time<=tsnext.time){for(s=tsnext.ts_prev;s;s=s.ts_prev){if(s.v==v){p_voice.s_next=s.next;s.next=null;break}} 5432if(s) 5433continue} 5434p_voice.s_next=p_voice.sym;p_voice.sym=null}}} 5435Abc.prototype.set_sym_glue=function(width){var s,g,ll,some_grace,spf,xmin=0,xx=0,x=0,xs=0,xse=0 5436for(s=tsfirst;s;s=s.ts_next){if(s.type==C.GRACE&&!some_grace) 5437some_grace=s 5438if(s.seqst){xmin+=s.shrink 5439if(s.space){if(s.space<s.shrink){xse+=s.shrink;xx+=s.shrink}else{xx+=s.space}}else{xs+=s.shrink}}} 5440if(!xx){realwidth=0 5441return} 5442ll=!tsnext||(tsnext.type==C.BLOCK&&!tsnext.play)||blocks.length 5443if(xmin>=width){if(xmin>width) 5444error(1,s,"Line too much shrunk $1 $2 $3",xmin.toFixed(1),xx.toFixed(1),width.toFixed(1));x=0 5445for(s=tsfirst;s;s=s.ts_next){if(s.seqst) 5446x+=s.shrink;s.x=x} 5447spf_last=0}else if((ll&&xx+xs>width*(1-cfmt.stretchlast))||(!ll&&(xx+xs>width||cfmt.stretchstaff))){if(xx==xse) 5448xx+=5 5449for(var cnt=4;--cnt>=0;){spf=(width-xs-xse)/(xx-xse);xx=0;xse=0;x=0 5450for(s=tsfirst;s;s=s.ts_next){if(s.seqst){if(s.space){if(s.space*spf<=s.shrink){xse+=s.shrink;xx+=s.shrink;x+=s.shrink}else{xx+=s.space;x+=s.space*spf}}else{x+=s.shrink}} 5451s.x=x} 5452if(Math.abs(x-width)<0.1) 5453break} 5454spf_last=spf}else{spf=(width-xs-xse)/xx 5455if(spf_last<spf) 5456spf=spf_last 5457for(s=tsfirst;s;s=s.ts_next){if(s.seqst) 5458x+=s.space*spf<=s.shrink?s.shrink:s.space*spf 5459s.x=x}} 5460realwidth=x 5461for(s=some_grace;s;s=s.ts_next){if(s.type!=C.GRACE) 5462continue 5463if(s.gr_shift) 5464x=s.prev.x+s.prev.wr 5465else 5466x=s.x-s.wl 5467for(g=s.extra;g;g=g.next) 5468g.x+=x}} 5469function set_sym_line(){var p_v,s,v=voice_tb.length 5470while(--v>=0){p_v=voice_tb[v] 5471if(p_v.sym&&p_v.s_prev) 5472p_v.sym.prev=p_v.s_prev 5473s=p_v.s_next 5474p_v.sym=s 5475if(s){if(s.prev) 5476s.prev.next=s 5477p_v.s_prev=s.prev 5478s.prev=null}else{p_v.s_prev=null}}} 5479function set_posx(){posx=img.lm/cfmt.scale} 5480function gen_init(){var s=tsfirst,tim=s.time 5481for(;s;s=s.ts_next){if(s.time!=tim){set_page() 5482return} 5483switch(s.type){case C.NOTE:case C.REST:case C.MREST:case C.SPACE:set_page() 5484return 5485default:continue 5486case C.STAVES:cur_sy=s.sy 5487continue 5488case C.BLOCK:if(s.play) 5489continue 5490self.block_gen(s) 5491break} 5492unlksym(s) 5493if(s.p_v.s_next==s) 5494s.p_v.s_next=s.next} 5495tsfirst=null} 5496Abc.prototype.output_music=function(){var v,lwidth,indent,line_height,ts1st,tslast,p_v,nv=voice_tb.length 5497gen_init() 5498if(!tsfirst) 5499return 5500set_global() 5501if(nv>1) 5502self.set_stem_dir() 5503for(v=0;v<nv;v++) 5504set_beams(voice_tb[v].sym);self.set_stems() 5505if(nv>1){set_rest_offset();set_overlap()} 5506set_acc_shft();set_allsymwidth();indent=set_indent(true) 5507if(cfmt.singleline){v=get_ck_width();lwidth=indent+v[0]+v[1]+get_width(tsfirst,null)[0];img.width=lwidth*cfmt.scale+img.lm+img.rm+2}else{lwidth=get_lwidth();cut_tune(lwidth,indent)} 5508ts1st=tsfirst 5509v=nv 5510while(--v>=0) 5511voice_tb[v].osym=voice_tb[v].sym 5512spf_last=1.2 5513while(1){set_piece();self.set_sym_glue(lwidth-indent) 5514if(realwidth){if(indent) 5515posx+=indent;draw_sym_near();line_height=set_staff();draw_systems(indent);draw_all_sym();delayed_update();vskip(line_height) 5516if(indent){posx-=indent;insert_meter&=~2} 5517while(blocks.length) 5518self.block_gen(blocks.shift())} 5519blk_flush() 5520if(tslast) 5521tslast.ts_next.ts_prev=tslast 5522if(!tsnext) 5523break 5524tsnext.ts_prev.ts_next=tsfirst=tsnext 5525gen_init() 5526if(!tsfirst) 5527break 5528tslast=tsfirst.ts_prev 5529tsfirst.ts_prev=null;set_sym_line();lwidth=get_lwidth() 5530indent=set_indent()} 5531tsfirst=ts1st 5532v=nv 5533while(--v>=0){p_v=voice_tb[v] 5534if(p_v.sym&&p_v.s_prev) 5535p_v.sym.prev=p_v.s_prev 5536p_v.sym=p_v.osym}} 5537function reset_gen(){insert_meter=cfmt.writefields.indexOf('M')>=0?3:2} 5538var a_gch,a_dcn,multicol,maps={} 5539var qplet_tb=new Int8Array([0,1,3,2,3,0,2,0,3,0]),ntb="CDEFGABcdefgab" 5540function set_ref(s){s.fname=parse.fname;s.istart=parse.istart;s.iend=parse.iend} 5541function new_clef(clef_def){var s={type:C.CLEF,clef_line:2,clef_type:"t",v:curvoice.v,p_v:curvoice,time:curvoice.time,dur:0},i=1 5542set_ref(s) 5543switch(clef_def[0]){case'"':i=clef_def.indexOf('"',1);s.clef_name=clef_def.slice(1,i);i++ 5544break 5545case'a':if(clef_def[1]=='u'){s.clef_type="a";s.clef_auto=true;i=4 5546break} 5547i=4 5548case'C':s.clef_type="c";s.clef_line=3 5549break 5550case'b':i=4 5551case'F':s.clef_type="b";s.clef_line=4 5552break 5553case'n':i=4 5554s.invis=true 5555break 5556case't':if(clef_def[1]=='e'){s.clef_type="c";s.clef_line=4 5557break} 5558i=6 5559case'G':break 5560case'p':i=4 5561case'P':s.clef_type="p";s.clef_line=3;curvoice.key.k_sf=0;curvoice.ckey.k_sf=0 5562curvoice.ckey.k_map=abc2svg.keys[7] 5563curvoice.ckey.k_b40=2 5564curvoice.ckey.k_drum=true 5565break 5566default:syntax(1,"Unknown clef '$1'",clef_def) 5567return} 5568if(clef_def[i]>='1'&&clef_def[i]<='9'){s.clef_line=Number(clef_def[i]);i++} 5569if(clef_def[i+1]!='8') 5570return s 5571switch(clef_def[i]){case'^':s.clef_oct_transp=true 5572case'+':s.clef_octave=7 5573if(!s.clef_oct_transp) 5574curvoice.snd_oct=12 5575break 5576case'_':s.clef_oct_transp=true 5577case'-':s.clef_octave=-7 5578if(!s.clef_oct_transp) 5579curvoice.snd_oct=-12 5580break} 5581return s} 5582function get_interval(param,score){var i,val,tmp,note,pit 5583tmp=new scanBuf;tmp.buffer=param 5584pit=[] 5585for(i=0;i<2;i++){note=tmp.buffer[tmp.index]?parse_acc_pit(tmp):null 5586if(!note){if(i!=1||!score){syntax(1,errs.bad_transp) 5587return} 5588pit[i]=242}else{pit[i]=abc2svg.pab40(note.pit,note.acc)}} 5589return pit[1]-pit[0]} 5590function set_linebreak(param){var i,item 5591for(i=0;i<128;i++){if(char_tb[i]=="\n") 5592char_tb[i]=nil} 5593param=param.split(/\s+/) 5594for(i=0;i<param.length;i++){item=param[i] 5595switch(item){case'!':case'$':case'*':case';':case'?':case'@':break 5596case"<none>":continue 5597case"<EOL>":item='\n' 5598break 5599default:syntax(1,"Bad value '$1' in %%linebreak - ignored",item) 5600continue} 5601char_tb[item.charCodeAt(0)]='\n'}} 5602function set_user(parm){var k,c,v,a=parm.match(/(.)[=\s]*(\[I:.+\]|".+"|!.+!)$/) 5603if(!a){syntax(1,'Lack of starting [, ! or " in U: / %%user') 5604return} 5605c=a[1];v=a[2] 5606if(c[0]=='\\'){if(c[1]=='t') 5607c='\t' 5608else if(!c[1]) 5609c=' '} 5610k=c.charCodeAt(0) 5611if(k>=128){syntax(1,errs.not_ascii) 5612return} 5613switch(char_tb[k][0]){case'0':case'd':case'i':case' ':break 5614case'"':case'!':case'[':if(char_tb[k].length>1) 5615break 5616default:syntax(1,"Bad user character '$1'",c) 5617return} 5618switch(v){case"!beambreak!":v=" " 5619break 5620case"!ignore!":v="i" 5621break 5622case"!nil!":case"!none!":v="d" 5623break} 5624char_tb[k]=v} 5625function get_st_lines(param){if(!param) 5626return 5627if(/^[\]\[|.-]+$/.test(param)) 5628return param.replace(/\]/g,'[') 5629var n=parseInt(param) 5630switch(n){case 0:return"..." 5631case 1:return"..|" 5632case 2:return".||" 5633case 3:return".|||"} 5634if(isNaN(n)||n<0||n>16) 5635return 5636return"||||||||||||||||".slice(0,n)} 5637function new_block(subtype){var s={type:C.BLOCK,subtype:subtype,dur:0} 5638if(parse.state==2) 5639goto_tune() 5640if(subtype.slice(0,4)!="midi") 5641curvoice=voice_tb[0] 5642sym_link(s) 5643return s} 5644Abc.prototype.set_vp=function(a){var s,item,pos,val,clefpit 5645while(1){item=a.shift() 5646if(!item) 5647break 5648if(item.slice(-1)=='='&&!a.length){syntax(1,errs.bad_val,item) 5649break} 5650switch(item){case"clef=":s=a.shift() 5651break 5652case"clefpitch=":item=a.shift() 5653if(item){val=ntb.indexOf(item[0]) 5654if(val>=0){switch(item[1]){case"'":val+=7 5655break 5656case',':val-=7 5657if(item[2]==',') 5658val-=7 5659break} 5660clefpit=4-val 5661break}} 5662syntax(1,errs.bad_val,item) 5663break 5664case"octave=":val=parseInt(a.shift()) 5665if(isNaN(val)) 5666syntax(1,errs.bad_val,item) 5667else 5668curvoice.octave=val 5669break 5670case"cue=":curvoice.scale=a.shift()=='on'?.7:1 5671break 5672case"instrument=":item=a.shift() 5673val=item.indexOf('/') 5674if(val<0){val=0 5675curvoice.sndtran=get_interval('c'+item)}else{curvoice.sndtran=get_interval('c'+ 5676item.slice(val+1)) 5677val=get_interval(item.replace('/',''))} 5678curvoice.transp=cfmt.sound?curvoice.sndtran:val 5679break 5680case"map=":curvoice.map=a.shift() 5681break 5682case"name=":case"nm=":curvoice.nm=a.shift() 5683if(curvoice.nm[0]=='"') 5684curvoice.nm=curvoice.nm.slice(1,-1);curvoice.new_name=true 5685break 5686case"stem=":case"pos=":if(item=="pos=") 5687item=a.shift().split(' ') 5688else 5689item=["stm",a.shift()];val=posval[item[1]] 5690if(val==undefined){syntax(1,errs.bad_val,item[0]) 5691break} 5692if(!pos) 5693pos={} 5694pos[item[0]]=val 5695break 5696case"scale=":val=parseFloat(a.shift()) 5697if(isNaN(val)||val<.5||val>2) 5698syntax(1,errs.bad_val,"%%voicescale") 5699else 5700curvoice.scale=val 5701break 5702case"score=":if(cfmt.nedo){syntax(1,errs.notransp) 5703break} 5704item=a.shift() 5705if(cfmt.sound) 5706break 5707curvoice.transp=get_interval(item,true) 5708break 5709case"shift=":if(cfmt.nedo){syntax(1,errs.notransp) 5710break} 5711curvoice.shift=curvoice.sndsh=get_interval(a.shift()) 5712break 5713case"sound=":if(cfmt.nedo){syntax(1,errs.notransp) 5714break} 5715curvoice.sndtran=get_interval(a.shift()) 5716if(cfmt.sound) 5717curvoice.transp=curvoice.sndtran 5718break 5719case"subname=":case"sname=":case"snm=":curvoice.snm=a.shift() 5720if(curvoice.snm[0]=='"') 5721curvoice.snm=curvoice.snm.slice(1,-1);break 5722case"stafflines=":val=get_st_lines(a.shift()) 5723if(val==undefined) 5724syntax(1,"Bad %%stafflines value") 5725else if(curvoice.st!=undefined) 5726par_sy.staves[curvoice.st].stafflines=val 5727else 5728curvoice.stafflines=val 5729break 5730case"staffnonote=":val=parseInt(a.shift()) 5731if(isNaN(val)) 5732syntax(1,"Bad %%staffnonote value") 5733else 5734curvoice.staffnonote=val 5735break 5736case"staffscale=":val=parseFloat(a.shift()) 5737if(isNaN(val)||val<.3||val>2) 5738syntax(1,"Bad %%staffscale value") 5739else 5740curvoice.staffscale=val 5741break 5742case"transpose=":if(cfmt.nedo){syntax(1,errs.notransp) 5743break} 5744val=get_transp(a.shift()) 5745if(val==undefined){syntax(1,errs.bad_transp)}else{curvoice.sndtran=val 5746if(cfmt.sound) 5747curvoice.transp=val} 5748break 5749default:switch(item.slice(0,4)){case"treb":case"bass":case"alto":case"teno":case"perc":s=item 5750break 5751default:if("GFC".indexOf(item[0])>=0) 5752s=item 5753else if(item.slice(-1)=='=') 5754a.shift() 5755break} 5756break}} 5757if(pos){curvoice.pos=clone(curvoice.pos) 5758for(item in pos) 5759if(pos.hasOwnProperty(item)) 5760curvoice.pos[item]=pos[item]} 5761if(s){s=new_clef(s) 5762if(s){if(clefpit) 5763s.clefpit=clefpit 5764get_clef(s)}}} 5765function set_kv_parm(a){if(!curvoice.init){curvoice.init=true 5766if(info.V){if(info.V['*']) 5767a=info.V['*'].concat(a) 5768if(info.V[curvoice.id]) 5769a=info.V[curvoice.id].concat(a)}} 5770if(a.length) 5771self.set_vp(a)} 5772function memo_kv_parm(vid,a){if(!a.length) 5773return 5774if(!info.V) 5775info.V={} 5776if(info.V[vid]) 5777Array.prototype.push.apply(info.V[vid],a) 5778else 5779info.V[vid]=a} 5780function new_key(param){var i,clef,key_end,c,tmp,exp,sf="FCGDAEB".indexOf(param[0])-1,mode=0,s={type:C.KEY,dur:0} 5781function set_k_acc(s,sf){var i,j,n,nacc,p_acc,accs=[],pits=[] 5782if(sf>0){for(nacc=0;nacc<sf;nacc++){accs[nacc]=1;pits[nacc]=[26,23,27,24,21,25,22][nacc]}}else{for(nacc=0;nacc<-sf;nacc++){accs[nacc]=-1;pits[nacc]=[22,25,21,24,20,23,26][nacc]}} 5783n=s.k_a_acc.length 5784for(i=0;i<n;i++){p_acc=s.k_a_acc[i] 5785for(j=0;j<nacc;j++){if(pits[j]==p_acc.pit){accs[j]=p_acc.acc 5786break}} 5787if(j==nacc){accs[j]=p_acc.acc;pits[j]=p_acc.pit 5788nacc++}} 5789for(i=0;i<nacc;i++){p_acc=s.k_a_acc[i] 5790if(!p_acc) 5791p_acc=s.k_a_acc[i]={} 5792p_acc.acc=accs[i];p_acc.pit=pits[i]}} 5793set_ref(s);i=1 5794if(sf<-1){switch(param[0]){case'H':if(param[1].toLowerCase()!='p'){syntax(1,"Unknown bagpipe-like key") 5795key_end=true 5796break} 5797s.k_bagpipe=param[1];sf=param[1]=='P'?0:2;i++ 5798if(!cfmt.temper) 5799cfmt.temper=new Float32Array([11.62,12.55,2.37,2.37,3.49,0,2.37,2.37,3.49,4.41,5.53,0,3.49,4.41,5.53,7.35,7.35,4.41,5.53,7.35,7.35,8.19,0,7.35,7.35,8.19,9.39,10.51,0,8.19,9.39,10.51,11.62,12.55,0,10.51,11.62,12.55,2.37,2.37]) 5800break 5801case'P':syntax(1,"K:P is deprecated");sf=0;s.k_drum=true;key_end=true 5802break 5803case'n':if(param.indexOf("none")==0){sf=0;s.k_none=true;i=4 5804break} 5805default:s.k_map=[] 5806s.k_mode=0 5807return[s,info_split(param)]}} 5808if(!key_end){switch(param[i]){case'#':sf+=7;i++;break 5809case'b':sf-=7;i++;break} 5810param=param.slice(i).trim() 5811switch(param.slice(0,3).toLowerCase()){default:if(param[0]!='m'||(param[1]!=' '&¶m[1]!='\t'&¶m[1]!='\n')){key_end=true 5812break} 5813case"aeo":case"m":case"min":sf-=3;mode=5 5814break 5815case"dor":sf-=2;mode=1 5816break 5817case"ion":case"maj":break 5818case"loc":sf-=5;mode=6 5819break 5820case"lyd":sf+=1;mode=3 5821break 5822case"mix":sf-=1;mode=4 5823break 5824case"phr":sf-=4;mode=2 5825break} 5826if(!key_end) 5827param=param.replace(/\w+\s*/,'') 5828if(param.indexOf("exp ")==0){param=param.replace(/\w+\s*/,'') 5829if(!param) 5830syntax(1,"No accidental after 'exp'");exp=true} 5831c=param[0] 5832if(c=='^'||c=='_'||c=='='){s.k_a_acc=[];tmp=new scanBuf;tmp.buffer=param 5833do{var note=parse_acc_pit(tmp) 5834if(!note) 5835break 5836s.k_a_acc.push(note);c=param[tmp.index] 5837while(c==' ') 5838c=param[++tmp.index]}while(c=='^'||c=='_'||c=='=');if(!exp) 5839set_k_acc(s,sf) 5840param=param.slice(tmp.index)}else if(exp&¶m.indexOf("none")==0){sf=0 5841param=param.replace(/\w+\s*/,'')}} 5842s.k_sf=sf;if(s.k_a_acc){s.k_map=[] 5843i=s.k_a_acc.length 5844while(--i>=0){note=s.k_a_acc[i] 5845s.k_map[(note.pit+19)%7]=note.acc}}else{s.k_map=abc2svg.keys[sf+7]} 5846s.k_mode=mode 5847s.k_b40=[1,24,7,30,13,36,19,2,25,8,31,14,37,20,3][sf+7] 5848return[s,info_split(param)]} 5849function new_meter(p){var s={type:C.METER,dur:0,a_meter:[]},meter={},val,v,m1=0,m2,i=0,j,wmeasure,in_parenth;set_ref(s) 5850if(p.indexOf("none")==0){i=4;wmeasure=1}else{wmeasure=0 5851while(i<p.length){if(p[i]=='=') 5852break 5853switch(p[i]){case'C':meter.top=p[i++] 5854if(!m1){m1=4;m2=4} 5855break 5856case'c':case'o':meter.top=p[i++] 5857if(!m1){if(p[i-1]=='c'){m1=2;m2=4}else{m1=3;m2=4} 5858switch(p[i]){case'|':m2/=2 5859break 5860case'.':m1*=3;m2*=2 5861break}} 5862break 5863case'.':case'|':m1=0;meter.top=p[i++] 5864break 5865case'(':if(p[i+1]=='('){in_parenth=true;meter.top=p[i++];s.a_meter.push(meter);meter={}} 5866j=i+1 5867while(j<p.length){if(p[j]==')'||p[j]=='/') 5868break 5869j++} 5870if(p[j]==')'&&p[j+1]=='/'){i++ 5871continue} 5872case')':in_parenth=p[i]=='(';meter.top=p[i++];s.a_meter.push(meter);meter={} 5873continue 5874default:if(p[i]<='0'||p[i]>'9'){syntax(1,"Bad char '$1' in M:",p[i]) 5875return} 5876m2=2;meter.top=p[i++] 5877for(;;){while(p[i]>='0'&&p[i]<='9') 5878meter.top+=p[i++] 5879if(p[i]==')'){if(p[i+1]!='/') 5880break 5881i++} 5882if(p[i]=='/'){i++;if(p[i]<='0'||p[i]>'9'){syntax(1,"Bad char '$1' in M:",p[i]) 5883return} 5884meter.bot=p[i++] 5885while(p[i]>='0'&&p[i]<='9') 5886meter.bot+=p[i++] 5887break} 5888if(p[i]!=' '&&p[i]!='+') 5889break 5890if(i>=p.length||p[i+1]=='(') 5891break 5892meter.top+=p[i++]} 5893m1=parseInt(meter.top) 5894break} 5895if(!in_parenth){if(meter.bot) 5896m2=parseInt(meter.bot);wmeasure+=m1*C.BLEN/m2} 5897s.a_meter.push(meter);meter={} 5898while(p[i]==' ') 5899i++ 5900if(p[i]=='+'){meter.top=p[i++];s.a_meter.push(meter);meter={}}}} 5901if(p[i]=='='){val=p.substring(++i).match(/^(\d+)\/(\d+)$/) 5902if(!val){syntax(1,"Bad duration '$1' in M:",p.substring(i)) 5903return} 5904wmeasure=C.BLEN*val[1]/val[2]} 5905s.wmeasure=wmeasure 5906if(cfmt.writefields.indexOf('M')<0) 5907s.a_meter=[] 5908if(parse.state!=3){info.M=p;glovar.meter=s 5909if(parse.state>=1){if(!glovar.ulen){if(wmeasure<=1||wmeasure>=C.BLEN*3/4) 5910glovar.ulen=C.BLEN/8 5911else 5912glovar.ulen=C.BLEN/16} 5913for(v=0;v<voice_tb.length;v++){voice_tb[v].meter=s;voice_tb[v].wmeasure=wmeasure}}}else{curvoice.wmeasure=wmeasure 5914if(is_voice_sig()){curvoice.meter=s;reset_gen()}else{sym_link(s)}}} 5915function new_tempo(text){var i,c,d,nd,txt=text,s={type:C.TEMPO,dur:0} 5916function get_nd(p){var n,d,nd=p.match(/(\d+)\/(\d+)/) 5917if(nd){d=Number(nd[2]) 5918if(d&&!isNaN(d)&&!(d&(d-1))){n=Number(nd[1]) 5919if(!isNaN(n)) 5920return C.BLEN*n/d}} 5921syntax(1,"Invalid note duration $1",c)} 5922set_ref(s) 5923if(cfmt.writefields.indexOf('Q')<0) 5924s.invis=true 5925if(text[0]=='"'){c=text.match(/"([^"]*)"/) 5926if(!c){syntax(1,"Unterminated string in Q:") 5927return} 5928s.tempo_str1=c[1] 5929text=text.slice(c[0].length).replace(/^\s+/,'')} 5930if(text.slice(-1)=='"'){i=text.indexOf('"') 5931s.tempo_str2=text.slice(i+1,-1) 5932text=text.slice(0,i).replace(/\s+$/,'')} 5933i=text.indexOf('=') 5934if(i>0){d=text.slice(0,i).split(/\s+/) 5935text=text.slice(i+1).replace(/^\s+/,'') 5936while(1){c=d.shift() 5937if(!c) 5938break 5939nd=get_nd(c) 5940if(!nd) 5941return 5942if(!s.tempo_notes) 5943s.tempo_notes=[] 5944s.tempo_notes.push(nd)} 5945if(text.slice(0,4)=="ca. "){s.tempo_ca='ca. ' 5946text=text.slice(4)} 5947i=text.indexOf('/') 5948if(i>0){nd=get_nd(text) 5949if(!nd) 5950return 5951s.new_beat=nd}else{s.tempo=Number(text) 5952if(!s.tempo||isNaN(s.tempo)){syntax(1,"Bad tempo value") 5953return}}} 5954if(parse.state!=3){if(parse.state==1){info.Q=txt 5955glovar.tempo=s 5956return} 5957goto_tune()} 5958sym_link(s) 5959if(glovar.tempo&&curvoice.time==0) 5960glovar.tempo.invis=true} 5961function do_info(info_type,text){var s,d1,d2,a,vid 5962if(curvoice&&curvoice.ignore&&info_type!='V') 5963return 5964switch(info_type){case'I':self.do_pscom(text) 5965break 5966case'L':if(parse.state==2) 5967goto_tune();a=text.match(/^1\/(\d+)(=(\d+)\/(\d+))?$/) 5968if(a){d1=Number(a[1]) 5969if(!d1||(d1&(d1-1))!=0) 5970break 5971d1=C.BLEN/d1 5972if(a[2]){d2=Number(a[4]) 5973d2=d2?Number(a[3])/d2*C.BLEN:0}else{d2=d1}}else if(text=="auto"){d1=d2=-1} 5974if(!d2){syntax(1,"Bad L: value") 5975break} 5976if(parse.state<2){glovar.ulen=d1}else{curvoice.ulen=d1;curvoice.dur_fact=d2/d1} 5977break 5978case'M':new_meter(text) 5979break 5980case'U':set_user(text) 5981break 5982case'P':if(parse.state==0) 5983break 5984if(parse.state==1){info.P=text 5985break} 5986if(parse.state==2) 5987goto_tune() 5988s={type:C.PART,text:text,dur:0} 5989if(cfmt.writefields.indexOf(info_type)<0) 5990s.invis=true 5991sym_link(s) 5992break 5993case'Q':if(parse.state==0) 5994break 5995new_tempo(text) 5996break 5997case'V':get_voice(text) 5998if(parse.state==3) 5999curvoice.ignore=!par_sy.voices[curvoice.v] 6000break 6001case'K':if(!parse.state) 6002break 6003get_key(text) 6004break 6005case'N':case'R':if(!info[info_type]) 6006info[info_type]=text 6007else 6008info[info_type]+='\n'+text 6009break 6010case'r':if(!user.keep_remark||parse.state!=3) 6011break 6012s={type:C.REMARK,text:text,dur:0} 6013sym_link(s) 6014break 6015default:syntax(0,"'$1:' line ignored",info_type) 6016break}} 6017function adjust_dur(s){var s2,time,auto_time,i,fac;s2=curvoice.last_sym 6018if(!s2) 6019return;if(s2.type==C.MREST||s2.type==C.BAR) 6020return 6021while(s2.type!=C.BAR&&s2.prev) 6022s2=s2.prev;time=s2.time;auto_time=curvoice.time-time 6023fac=curvoice.wmeasure/auto_time 6024if(time==0){while(s2&&!s2.dur) 6025s2=s2.next 6026if(s2&&s2.type==C.REST&&s2.invis){time+=s2.dur*fac 6027if(s2.prev) 6028s2.prev.next=s2.next 6029else 6030curvoice.sym=s2.next 6031if(s2.next) 6032s2.next.prev=s2.prev;s2=s2.next}} 6033if(curvoice.wmeasure==auto_time) 6034return 6035for(;s2;s2=s2.next){s2.time=time 6036if(!s2.dur||s2.grace) 6037continue 6038s2.dur*=fac;s2.dur_orig*=fac;time+=s2.dur 6039if(s2.type!=C.NOTE&&s2.type!=C.REST) 6040continue 6041for(i=0;i<=s2.nhd;i++) 6042s2.notes[i].dur*=fac} 6043curvoice.time=s.time=time} 6044function new_bar(dotted){var s2,c,bar_type,line=parse.line,s={type:C.BAR,fname:parse.fname,istart:parse.bol+line.index,dur:0,multi:0} 6045if(dotted) 6046s.bar_dotted=true 6047if(vover&&vover.bar) 6048get_vover('|') 6049if(glovar.new_nbar){s.bar_num=glovar.new_nbar;glovar.new_nbar=0} 6050bar_type=line.char() 6051while(1){c=line.next_char() 6052switch(c){case'|':case'[':case']':case':':bar_type+=c 6053continue} 6054break} 6055if(bar_type[0]==':'){if(bar_type.length==1){bar_type='|';s.bar_dotted=true}else{s.rbstop=2 6056if(curvoice.tie_s) 6057curvoice.tie_s.tie_s=s}} 6058if(a_gch) 6059csan_add(s) 6060if(a_dcn){deco_cnv(a_dcn,s);a_dcn=null} 6061if(parse.ottava.length){s2=s 6062if(curvoice.cst!=curvoice.st){s2={type:C.SPACE,fname:parse.fname,istart:parse.bol+line.index,dur:0,multi:0,invis:true,width:1} 6063sym_link(s2)} 6064s2.ottava=parse.ottava 6065parse.ottava=[]} 6066if(bar_type.slice(-1)=='['&&!(/[0-9" ]/.test(c))){bar_type=bar_type.slice(0,-1);line.index--;c='['} 6067if(bar_type.slice(-1)==':') 6068s.rbstop=2 6069if(c>'0'&&c<='9'){s.text=c 6070while(1){c=line.next_char() 6071if("0123456789,.-".indexOf(c)<0) 6072break 6073s.text+=c} 6074s.rbstop=2;s.rbstart=2}else if(c=='"'&&bar_type.slice(-1)=='['){s.text="" 6075while(1){c=line.next_char() 6076if(!c){syntax(1,"No end of repeat string") 6077return} 6078if(c=='"'){line.index++ 6079break} 6080s.text+=c} 6081s.rbstop=2;s.rbstart=2} 6082if(bar_type[0]==']'){s.rbstop=2 6083if(bar_type.length!=1) 6084bar_type=bar_type.slice(1) 6085else 6086s.invis=true} 6087s.iend=parse.bol+line.index 6088if(s.rbstart&&curvoice.norepbra&&!curvoice.second) 6089s.norepbra=true 6090if(s.text){if(bar_type.slice(-1)=='['&&bar_type!='[') 6091bar_type=bar_type.slice(0,-1) 6092if(s.text[0]=='1'){if(curvoice.tie_s) 6093curvoice.tie_s_rep=curvoice.tie_s 6094if(curvoice.acc_tie) 6095curvoice.acc_tie_rep=curvoice.acc_tie.slice() 6096else if(curvoice.acc_tie_rep) 6097curvoice.acc_tie_rep=null}else{if(curvoice.tie_s_rep){curvoice.tie_s=clone(curvoice.tie_s_rep) 6098curvoice.tie_s.notes=clone(curvoice.tie_s.notes) 6099for(var m=0;m<=curvoice.tie_s.nhd;m++){curvoice.tie_s.notes[m]=clone(curvoice.tie_s.notes[m]) 6100curvoice.tie_s.notes[m].s=curvoice.tie_s}} 6101if(curvoice.acc_tie_rep) 6102curvoice.acc_tie=curvoice.acc_tie_rep.slice()}} 6103if(curvoice.ulen<0) 6104adjust_dur(s);if((bar_type=="["||bar_type=="|:")&&!curvoice.eoln){s2=curvoice.last_sym 6105if(s2&&s2.time==curvoice.time){if(s2&&s2.type==C.BAR){if(bar_type=="["&&!s2.text&&(curvoice.st==0||(par_sy.staves[curvoice.st-1].flags&STOP_BAR)||s.norepbra)){if(s.text) 6106s2.text=s.text 6107if(s.a_gch) 6108s2.a_gch=s.a_gch 6109if(s.norepbra) 6110s2.norepbra=s.norepbra 6111if(s.rbstart) 6112s2.rbstart=s.rbstart 6113if(s.rbstop) 6114s2.rbstop=s.rbstop 6115return} 6116if(s2.st==curvoice.st&&bar_type=="|:"){if(s2.bar_type==":|"){s2.bar_type="::";s2.rbstop=2 6117return} 6118if(s2.bar_type=="||"){s2.bar_type="||:";s2.rbstop=2 6119return}}}}} 6120switch(bar_type){case"[":s.rbstop=2 6121case"[]":case"[|]":s.invis=true;bar_type="[]" 6122break 6123case":|:":case":||:":bar_type="::" 6124break 6125case"||":if(!cfmt.rbdbstop) 6126break 6127case"[|":case"|]":s.rbstop=2 6128break} 6129s.bar_type=bar_type 6130if(!curvoice.lyric_restart) 6131curvoice.lyric_restart=s 6132if(!curvoice.sym_restart) 6133curvoice.sym_restart=s 6134sym_link(s);s.st=curvoice.st 6135if(s.rbstart&&!curvoice.norepbra&&curvoice.st>0&&!(par_sy.staves[curvoice.st-1].flags&STOP_BAR)){s2={type:C.BAR,fname:s.fname,istart:s.istart,iend:s.iend,bar_type:"[",multi:0,invis:true,text:s.text,rbstart:2} 6136sym_link(s2);s2.st=curvoice.st 6137delete s.text;s.rbstart=0} 6138if(!s.bar_dotted&&!s.invis) 6139curvoice.acc=[]} 6140function parse_staves(p){var v,vid,vids={},a_vf=[],err=false,flags=0,brace=0,bracket=0,parenth=0,flags_st=0,e,a=p.match(/[^[\]|{}()*+\s]+|[^\s]/g) 6141if(!a){syntax(1,errs.bad_val,"%%score") 6142return} 6143while(1){e=a.shift() 6144if(!e) 6145break 6146switch(e){case'[':if(parenth||brace+bracket>=2){syntax(1,errs.misplaced,'[');err=true 6147break} 6148flags|=brace+bracket==0?OPEN_BRACKET:OPEN_BRACKET2;bracket++;flags_st<<=8;flags_st|=OPEN_BRACKET 6149break 6150case'{':if(parenth||brace||bracket>=2){syntax(1,errs.misplaced,'{');err=true 6151break} 6152flags|=!bracket?OPEN_BRACE:OPEN_BRACE2;brace++;flags_st<<=8;flags_st|=OPEN_BRACE 6153break 6154case'(':if(parenth){syntax(1,errs.misplaced,'(');err=true 6155break} 6156flags|=OPEN_PARENTH;parenth++;flags_st<<=8;flags_st|=OPEN_PARENTH 6157break 6158case'*':if(brace&&!parenth&&!(flags&(OPEN_BRACE|OPEN_BRACE2))) 6159flags|=FL_VOICE 6160break 6161case'+':flags|=MASTER_VOICE 6162break 6163case']':case'}':case')':syntax(1,"Bad voice ID in %%score");err=true 6164break 6165default:vid=e 6166while(1){e=a.shift() 6167if(!e) 6168break 6169switch(e){case']':if(!(flags_st&OPEN_BRACKET)){syntax(1,errs.misplaced,']');err=true 6170break} 6171bracket--;flags|=brace+bracket==0?CLOSE_BRACKET:CLOSE_BRACKET2;flags_st>>=8 6172continue 6173case'}':if(!(flags_st&OPEN_BRACE)){syntax(1,errs.misplaced,'}');err=true 6174break} 6175brace--;flags|=!bracket?CLOSE_BRACE:CLOSE_BRACE2;flags&=~FL_VOICE;flags_st>>=8 6176continue 6177case')':if(!(flags_st&OPEN_PARENTH)){syntax(1,errs.misplaced,')');err=true 6178break} 6179parenth--;flags|=CLOSE_PARENTH;flags_st>>=8 6180continue 6181case'|':flags|=STOP_BAR 6182continue} 6183break} 6184if(vids[vid]){syntax(1,"Double voice in %%score")}else{vids[vid]=true 6185a_vf.push([vid,flags])} 6186flags=0 6187if(!e) 6188break 6189a.unshift(e) 6190break}} 6191if(flags_st!=0){syntax(1,"'}', ')' or ']' missing in %%score");err=true} 6192if(err||!a_vf.length) 6193return 6194return a_vf} 6195function info_split(text){if(!text) 6196return[] 6197var a=text.match(/[^\s"=]+=?|"[^"]+"/g) 6198if(!a){syntax(1,"Unterminated string") 6199return[]} 6200return a} 6201var reg_dur=/(\d*)(\/*)(\d*)/g 6202function parse_dur(line){var res,num,den;reg_dur.lastIndex=line.index;res=reg_dur.exec(line.buffer) 6203if(!res[0]) 6204return[1,1];num=res[1]||1;den=res[3]||1 6205if(!res[3]) 6206den*=1<<res[2].length;line.index=reg_dur.lastIndex 6207return[num,den]} 6208function parse_acc_pit(line){var note,acc,pit,d,nd,c=line.char() 6209switch(c){case'^':c=line.next_char() 6210if(c=='^'){acc=2;c=line.next_char()}else{acc=1} 6211break 6212case'=':acc=3;c=line.next_char() 6213break 6214case'_':c=line.next_char() 6215if(c=='_'){acc=-2;c=line.next_char()}else{acc=-1} 6216break} 6217if(acc==1||acc==-1){if((c>='1'&&c<='9')||c=='/'){nd=parse_dur(line);if(acc<0) 6218nd[0]=-nd[0] 6219if(cfmt.nedo&&nd[1]==1){nd[0]*=12 6220nd[1]*=cfmt.nedo} 6221acc=nd 6222c=line.char()}} 6223pit=ntb.indexOf(c)+16;c=line.next_char() 6224if(pit<16){syntax(1,"'$1' is not a note",line.buffer[line.index-1]) 6225return} 6226while(c=="'"){pit+=7;c=line.next_char()} 6227while(c==','){pit-=7;c=line.next_char()} 6228note={pit:pit,shhd:0,shac:0} 6229if(acc) 6230note.acc=acc 6231return note} 6232function set_map(note,acc){var pit=note.pit,nn=not2abc(pit,acc),map=maps[curvoice.map] 6233if(!map[nn]){nn='o'+nn.replace(/[',]+/,'') 6234if(!map[nn]){nn='k'+ntb[(pit+75- 6235curvoice.ckey.k_sf*11)%7] 6236if(!map[nn]){nn='all' 6237if(!map[nn]) 6238return}}} 6239note.map=map=map[nn] 6240if(map[1]){note.pit=pit=map[1].pit 6241note.acc=map[1].acc 6242if(!note.acc&&curvoice.acc[pit+19]) 6243note.acc=3 6244curvoice.acc[pit+19]=note.acc==3?0:note.acc} 6245if(map[2]) 6246note.color=map[2] 6247nn=map[3] 6248if(nn) 6249note.midi=pit2mid(nn.pit+19,nn.acc)} 6250function parse_basic_note(line,ulen){var nd,note=parse_acc_pit(line) 6251if(!note) 6252return 6253if(line.char()=='0'){parse.stemless=true;line.index++} 6254nd=parse_dur(line);note.dur=ulen*nd[0]/nd[1] 6255return note} 6256function parse_vpos(){var line=parse.line,ty=0 6257if(line.buffer[line.index-1]=='.'&&!a_dcn) 6258ty=C.SL_DOTTED 6259switch(line.next_char()){case"'":line.index++ 6260return ty+C.SL_ABOVE 6261case",":line.index++ 6262return ty+C.SL_BELOW} 6263return ty+C.SL_AUTO} 6264function slur_add(enote,e_is_note){var i,s,sl,snote,s_is_note 6265for(i=curvoice.sls.length;--i>=0;){sl=curvoice.sls[i] 6266snote=sl.note 6267s_is_note=sl.is_note 6268delete sl.is_note 6269if(snote.s!=enote.s){sl.note=enote 6270if(e_is_note) 6271sl.is_note=e_is_note 6272s=s_is_note?snote:snote.s 6273if(!s.sls) 6274s.sls=[];s.sls.push(sl) 6275curvoice.sls.splice(i,1) 6276if(s_is_note) 6277snote.s.sl1=true 6278if(sl.grace) 6279sl.grace.sl1=true 6280if(enote.s.grace) 6281enote.s.sl2=true 6282return}} 6283if(enote.grace){error(1,enote.s,errs.bad_slur_end) 6284return} 6285for(s=enote.s.prev;s;s=s.prev){if(s.type==C.BAR&&s.bar_type[0]==':'&&s.text){if(!s.sls) 6286s.sls=[];s.sls.push({note:enote,ty:C.SL_AUTO}) 6287if(e_is_note) 6288s.sls[s.sls.length-1].is_note=e_is_note 6289return}} 6290syntax(1,"End of slur without start")} 6291function pit2mid(pit,acc){var p=[0,2,4,5,7,9,11][pit%7],o=((pit/7)|0)*12,p0,p1,s,b40 6292if(curvoice.snd_oct) 6293o+=curvoice.snd_oct 6294if(acc==3) 6295acc=0 6296if(acc){if(typeof acc!="number"){s=acc[0]/acc[1] 6297if(acc[1]==100) 6298return p+o+s}else{s=acc}}else{if(cfmt.temper) 6299return cfmt.temper[abc2svg.p_b40[pit%7]]+o 6300return p+o} 6301if(!cfmt.nedo){if(!cfmt.temper){p+=o+s 6302return p}}else{if(typeof acc=="number"){b40=abc2svg.p_b40[pit%7]+acc 6303return cfmt.temper[b40]+o} 6304if(acc[1]==cfmt.nedo){b40=abc2svg.p_b40[pit%7] 6305return cfmt.temper[b40]+o+s}} 6306p0=cfmt.temper[abc2svg.p_b40[pit%7]] 6307if(s>0){p1=cfmt.temper[(abc2svg.p_b40[pit%7]+1)%40] 6308if(p1<p0) 6309p1+=12}else{p1=cfmt.temper[(abc2svg.p_b40[pit%7]+39)%40] 6310if(p1>p0) 6311p1-=12 6312s=-s} 6313return p0+o+(p1-p0)*s} 6314Abc.prototype.new_note=function(grace,sls){var note,s,in_chord,c,dcn,type,tie_s,acc_tie,i,n,s2,nd,res,num,dur,apit,sl1=[],line=parse.line,a_dcn_sav=a_dcn 6315function do_ties(s,tie_s){var m,note,mid 6316for(m=0;m<=s.nhd;m++){note=s.notes[m] 6317mid=note.midi 6318if(tie_s.type!=C.GRACE){for(i=0;i<=tie_s.nhd;i++){if(!tie_s.notes[i].tie_ty) 6319continue 6320if(tie_s.notes[i].midi==mid){tie_s.notes[i].tie_n=note 6321note.s=s 6322tie_s.tie_s=s 6323break}}}else{for(s2=tie_s.extra;s2;s2=s2.next){if(!s2.notes[0].tie_ty) 6324continue 6325if(s2.notes[0].midi==mid){s2.tie_s=s 6326s2.notes[0].tie_n=note 6327note.s=s 6328s2.notes[0].s=s2 6329tie_s.tie_s=s 6330break}}} 6331s.ti2=tie_s}} 6332a_dcn=null;parse.stemless=false;s={type:C.NOTE,fname:parse.fname,stem:0,multi:0,nhd:0,xmx:0} 6333s.istart=parse.bol+line.index 6334if(curvoice.color) 6335s.color=curvoice.color 6336if(curvoice.tie_s){tie_s=curvoice.tie_s 6337curvoice.tie_s=null} 6338if(grace){s.grace=true}else{if(a_gch) 6339csan_add(s) 6340if(parse.repeat_n){s.repeat_n=parse.repeat_n;s.repeat_k=parse.repeat_k;parse.repeat_n=0}} 6341c=line.char() 6342switch(c){case'X':s.invis=true 6343case'Z':s.type=C.MREST;c=line.next_char() 6344s.nmes=(c>'0'&&c<='9')?line.get_int():1;s.dur=curvoice.wmeasure*s.nmes 6345if(curvoice.second){curvoice.time+=s.dur 6346return} 6347if(s.nmes==1){s.type=C.REST;s.dur_orig=s.dur;s.notes=[{pit:18,dur:s.dur}]}else{glovar.mrest_p=true} 6348break 6349case'y':s.type=C.SPACE;s.invis=true;s.dur=0;c=line.next_char() 6350if(c>='0'&&c<='9') 6351s.width=line.get_int() 6352else 6353s.width=10 6354if(tie_s){curvoice.tie_s=tie_s 6355tie_s=null} 6356break 6357case'x':s.invis=true 6358case'z':s.type=C.REST;line.index++;nd=parse_dur(line);s.dur_orig=((curvoice.ulen<0)?C.BLEN:curvoice.ulen)*nd[0]/nd[1];s.dur=s.dur_orig*curvoice.dur_fact;s.notes=[{pit:18,dur:s.dur_orig}] 6359break 6360case'[':in_chord=true;c=line.next_char() 6361default:if(curvoice.acc_tie){acc_tie=curvoice.acc_tie 6362curvoice.acc_tie=null} 6363s.notes=[] 6364while(1){if(in_chord){while(1){if(!c) 6365break 6366i=c.charCodeAt(0);if(i>=128){syntax(1,errs.not_ascii) 6367return} 6368type=char_tb[i] 6369switch(type[0]){case'(':sl1.push(parse_vpos());c=line.char() 6370continue 6371case'!':if(!a_dcn) 6372a_dcn=[] 6373if(type.length>1){a_dcn.push(type.slice(1,-1))}else{dcn="" 6374while(1){c=line.next_char() 6375if(!c){syntax(1,"No end of decoration") 6376return} 6377if(c=='!') 6378break 6379dcn+=c} 6380a_dcn.push(dcn)} 6381c=line.next_char() 6382continue} 6383break}} 6384note=parse_basic_note(line,s.grace?C.BLEN/4:curvoice.ulen<0?C.BLEN:curvoice.ulen) 6385if(!note) 6386return 6387if(curvoice.octave) 6388note.pit+=curvoice.octave*7 6389apit=note.pit+19 6390i=note.acc 6391if(i){curvoice.acc[apit]=i}else{i=curvoice.acc[apit] 6392if(!i&&acc_tie) 6393i=acc_tie[apit] 6394if(!i) 6395i=curvoice.ckey.k_map[apit%7]||0} 6396note.midi=pit2mid(apit,i) 6397if(curvoice.ckey.k_sndtran) 6398note.midi+=abc2svg.b40m(curvoice.ckey.k_sndtran+ 6399122)-36 6400if(curvoice.map&&maps[curvoice.map]) 6401set_map(note,i) 6402if(sl1.length){while(1){i=sl1.shift() 6403if(!i) 6404break 6405curvoice.sls.push({is_note:true,note:note,ty:i})} 6406note.s=s} 6407if(a_dcn){note.a_dcn=a_dcn;a_dcn=null} 6408s.notes.push(note) 6409if(!in_chord) 6410break 6411c=line.char() 6412while(1){switch(c){case')':note.s=s 6413slur_add(note,true) 6414c=line.next_char() 6415continue 6416case'-':note.tie_ty=parse_vpos() 6417note.s=s 6418curvoice.tie_s=s 6419if(curvoice.acc[apit]||(acc_tie&&acc_tie[apit])){if(!curvoice.acc_tie) 6420curvoice.acc_tie=[] 6421curvoice.acc_tie[apit]=curvoice.acc[apit]||acc_tie[apit]} 6422c=line.char() 6423continue 6424case'.':c=line.next_char() 6425switch(c){case'-':case'(':continue} 6426syntax(1,"Misplaced dot") 6427break} 6428break} 6429if(c==']'){line.index++;nd=parse_dur(line);s.nhd=s.notes.length-1 6430for(i=0;i<=s.nhd;i++){note=s.notes[i];note.dur=note.dur*nd[0]/nd[1]} 6431break}} 6432if(sls.length){while(1){i=sls.shift() 6433if(!i) 6434break 6435s.notes[0].s=s 6436curvoice.sls.push({note:s.notes[0],ty:i}) 6437if(grace) 6438curvoice.sls[curvoice.sls.length-1].grace=grace}} 6439s.dur_orig=s.notes[0].dur;s.dur=s.notes[0].dur*curvoice.dur_fact} 6440if(s.grace&&s.type!=C.NOTE){syntax(1,errs.bad_grace) 6441return} 6442if(tie_s&&s.type!=C.NOTE){syntax(1,"Bad tie") 6443tie_s=null} 6444if(s.notes){if(!grace){switch(curvoice.pos.stm){case C.SL_ABOVE:s.stem=1;break 6445case C.SL_BELOW:s.stem=-1;break 6446case C.SL_HIDDEN:s.stemless=true;break} 6447num=curvoice.brk_rhythm 6448if(num){curvoice.brk_rhythm=0;s2=curvoice.last_note 6449if(num>0){n=num*2-1;s.dur=s.dur*n/num;s.dur_orig=s.dur_orig*n/num 6450for(i=0;i<=s.nhd;i++) 6451s.notes[i].dur=s.notes[i].dur*n/num;s2.dur/=num;s2.dur_orig/=num 6452for(i=0;i<=s2.nhd;i++) 6453s2.notes[i].dur/=num}else{num=-num;n=num*2-1;s.dur/=num;s.dur_orig/=num 6454for(i=0;i<=s.nhd;i++) 6455s.notes[i].dur/=num;s2.dur=s2.dur*n/num;s2.dur_orig=s2.dur_orig*n/num 6456for(i=0;i<=s2.nhd;i++) 6457s2.notes[i].dur=s2.notes[i].dur*n/num} 6458curvoice.time=s2.time+s2.dur;for(s2=s2.next;s2;s2=s2.next) 6459s2.time=curvoice.time}}else{var div=curvoice.ckey.k_bagpipe?8:4 6460for(i=0;i<=s.nhd;i++) 6461s.notes[i].dur/=div;s.dur/=div;s.dur_orig/=div 6462if(grace.stem) 6463s.stem=grace.stem} 6464curvoice.last_note=s 6465c=line.char() 6466while(1){switch(c){case'-':var ty=parse_vpos() 6467for(i=0;i<=s.nhd;i++){s.notes[i].tie_ty=ty 6468s.notes[i].s=s} 6469if(grace) 6470grace.tie_s=curvoice.tie_s=grace 6471else 6472curvoice.tie_s=s 6473for(i=0;i<=s.nhd;i++){note=s.notes[i] 6474apit=note.pit+19 6475if(curvoice.acc[apit]||(acc_tie&&acc_tie[apit])){if(!curvoice.acc_tie) 6476curvoice.acc_tie=[] 6477curvoice.acc_tie[apit]=curvoice.acc[apit]||acc_tie[apit]}} 6478c=line.char() 6479continue 6480case')':s.notes[0].s=s 6481slur_add(s.notes[0]) 6482c=line.next_char() 6483continue 6484case'.':if(line.buffer[line.index+1]!='-') 6485break 6486c=line.next_char() 6487continue} 6488break} 6489if(tie_s) 6490do_ties(s,tie_s)} 6491sym_link(s) 6492if(cfmt.shiftunison) 6493s.shiftunison=cfmt.shiftunison 6494if(!grace){if(!curvoice.lyric_restart) 6495curvoice.lyric_restart=s 6496if(!curvoice.sym_restart) 6497curvoice.sym_restart=s} 6498if(a_dcn_sav) 6499deco_cnv(a_dcn_sav,s,s.prev) 6500if(parse.ottava.length){if(grace) 6501grace.ottava=parse.ottava 6502else 6503s.ottava=parse.ottava 6504parse.ottava=[]} 6505if(parse.stemless) 6506s.stemless=true 6507s.iend=parse.bol+line.index 6508return s} 6509function tp_adj(s,fact){var tim=s.time 6510curvoice.time=tim+(curvoice.time-tim)*fact 6511while(1){s.in_tuplet=true 6512if(!s.grace){s.time=tim 6513if(s.dur){s.dur*=fact 6514tim+=s.dur}} 6515if(!s.next){if(s.tpe) 6516s.tpe++ 6517else 6518s.tpe=1 6519break} 6520s=s.next}} 6521var nil="0",char_tb=[nil,nil,nil,nil,nil,nil,nil,nil,nil," ","\n",nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil," ","!",'"',"i","\n",nil,"&",nil,"(",")","i",nil,nil,"-","!dot!",nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,nil,"|","i","<","n","<","i","i","n","n","n","n","n","n","n","!fermata!","d","d","d","!emphasis!","!lowermordent!","d","!coda!","!uppermordent!","d","d","!segno!","!trill!","d","d","d","n","d","n","[","\\","|","n","n","i","n","n","n","n","n","n","n","d","d","d","d","d","d","d","d","d","d","d","d","d","!upbow!","!downbow!","d","n","n","n","{","|","}","!gmark!",nil,],ottava={"8va(":1,"8va)":0,"15ma(":2,"15ma)":0,"8vb(":-1,"8vb)":0,"15mb(":-2,"15mb)":0} 6522function parse_music_line(){var grace,last_note_sav,a_dcn_sav,no_eol,s,tps,tp=[],tpn=-1,sls=[],line=parse.line 6523function check_mac(m){var i,j,b 6524for(i=1,j=line.index+1;i<m.length;i++,j++){if(m[i]==line.buffer[j]) 6525continue 6526if(m[i]!='n') 6527return 6528b=ntb.indexOf(line.buffer[j]) 6529if(b<0) 6530return 6531while(line.buffer[j+1]=="'"){b+=7;j++} 6532while(line.buffer[j+1]==','){b-=7;j++}} 6533line.index=j 6534return b} 6535function n2n(n){var c=ntb[n] 6536while(n<0){n+=7;c+=','} 6537while(n>14){n-=7;c+="'"} 6538return c} 6539function expand(m,b){var c,i,r="",n=m.length 6540for(i=0;i<n;i++){c=m[i] 6541if(c>='h'&&c<='z'){r+=n2n(b+c.charCodeAt(0)-'n'.charCodeAt(0))}else{r+=c}} 6542return r} 6543function parse_mac(k,m,b){var te,ti,curv,s,line_sav=line,istart_sav=parse.istart;parse.line=line=new scanBuf;parse.istart+=line_sav.index;if(cfmt.writefields.indexOf('m')<0){line.buffer=k.replace('n',n2n(b)) 6544s=curvoice.last_sym 6545ti=curvoice.time 6546parse_seq(true) 6547if(!s) 6548s=curvoice.sym 6549for(s=s.next;s;s=s.next) 6550s.noplay=true 6551te=curvoice.time 6552curv=curvoice 6553curvoice=clone_voice(curv.id+'-p') 6554if(!par_sy.voices[curvoice.v]){curvoice.second=true 6555par_sy.voices[curvoice.v]={st:curv.st,second:true,range:curvoice.v}} 6556curvoice.time=ti 6557s=curvoice.last_sym 6558parse.line=line=new scanBuf 6559parse.istart+=line_sav.index 6560line.buffer=b?expand(m,b):m 6561parse_seq(true) 6562if(curvoice.time!=te) 6563syntax(1,"Bad length of the macro sequence") 6564if(!s) 6565s=curvoice.sym 6566for(;s;s=s.next) 6567s.invis=s.play=true 6568curvoice=curv}else{line.buffer=b?expand(m,b):m;parse_seq(true)} 6569parse.line=line=line_sav 6570parse.istart=istart_sav} 6571function parse_seq(in_mac){var c,idx,type,k,s,dcn,i,n,text,note 6572while(1){c=line.char() 6573if(!c) 6574break 6575if(curvoice.ignore){while(1){if(c=='['&&line.buffer[line.index+1]=='V'&&line.buffer[line.index+2]==':') 6576break 6577c=line.next_char() 6578if(!c) 6579return}} 6580if(c=='.'){switch(line.buffer[line.index+1]){case'(':case'-':case'|':c=line.next_char() 6581break}} 6582if(!in_mac&&maci[c]){n=0 6583for(k in mac){if(!mac.hasOwnProperty(k)||k[0]!=c) 6584continue 6585if(k.indexOf('n')<0){if(line.buffer.indexOf(k,line.index) 6586!=line.index) 6587continue 6588line.index+=k.length}else{n=check_mac(k) 6589if(!n) 6590continue} 6591parse_mac(k,mac[k],n) 6592n=1 6593break} 6594if(n) 6595continue} 6596idx=c.charCodeAt(0) 6597if(idx>=128){syntax(1,errs.not_ascii) 6598line.index++ 6599break} 6600type=char_tb[idx] 6601switch(type[0]){case' ':s=curvoice.last_note 6602if(s){s.beam_end=true 6603if(grace) 6604grace.gr_shift=true} 6605break 6606case'\n':if(cfmt.barsperstaff) 6607break 6608if(par_sy.voices[curvoice.v]&&par_sy.voices[curvoice.v].range==0) 6609curvoice.eoln=true 6610break 6611case'&':if(grace){syntax(1,errs.bad_grace) 6612break} 6613c=line.next_char() 6614if(c==')'){get_vover(')') 6615break} 6616get_vover('&') 6617continue 6618case'(':c=line.next_char() 6619if(c>'0'&&c<='9'){if(grace){syntax(1,errs.bad_grace) 6620break} 6621var pplet=line.get_int(),qplet=qplet_tb[pplet],rplet=pplet,c=line.char() 6622if(c==':'){c=line.next_char() 6623if(c>'0'&&c<='9'){qplet=line.get_int();c=line.char()} 6624if(c==':'){c=line.next_char() 6625if(c>'0'&&c<='9'){rplet=line.get_int();c=line.char()}else{syntax(1,"Invalid 'r' in tuplet") 6626continue}}} 6627if(qplet==0||qplet==undefined) 6628qplet=(curvoice.wmeasure%9)==0?3:2;if(tpn<0) 6629tpn=tp.length 6630tp.push({p:pplet,q:qplet,r:rplet,ro:rplet,f:cfmt.tuplets}) 6631continue} 6632if(c=='&'){if(grace){syntax(1,errs.bad_grace) 6633break} 6634get_vover('(') 6635break} 6636line.index--;sls.push(parse_vpos()) 6637continue 6638case')':s=curvoice.last_sym 6639if(s){switch(s.type){case C.SPACE:if(!s.notes){s.notes=[] 6640s.notes[0]={}} 6641case C.NOTE:case C.REST:break 6642case C.GRACE:for(s=s.extra;s.next;s=s.next);break 6643default:s=null 6644break}} 6645if(!s){syntax(1,errs.bad_char,c) 6646break} 6647s.notes[0].s=s 6648slur_add(s.notes[0]) 6649break 6650case'!':if(!a_dcn) 6651a_dcn=[] 6652if(type.length>1){dcn=type.slice(1,-1)}else{dcn="";i=line.index 6653while(1){c=line.next_char() 6654if(!c) 6655break 6656if(c=='!') 6657break 6658dcn+=c} 6659if(!c){line.index=i;syntax(1,"No end of decoration") 6660break}} 6661if(ottava[dcn]!=undefined){glovar.ottava=true;parse.ottava.push(ottava[dcn])}else{a_dcn.push(dcn)} 6662break 6663case'"':if(grace){syntax(1,errs.bad_grace) 6664break} 6665parse_gchord(type) 6666break 6667case'[':if(type.length>1){self.do_pscom(type.slice(3,-1)) 6668break} 6669var c_next=line.buffer[line.index+1] 6670if('|[]: "'.indexOf(c_next)>=0||(c_next>='1'&&c_next<='9')){if(grace){syntax(1,errs.bar_grace) 6671break} 6672new_bar() 6673continue} 6674if(line.buffer[line.index+2]==':'){if(grace){syntax(1,errs.bad_grace) 6675break} 6676i=line.buffer.indexOf(']',line.index+1) 6677if(i<0){syntax(1,"Lack of ']'") 6678break} 6679text=line.buffer.slice(line.index+3,i).trim() 6680parse.istart=parse.bol+line.index;parse.iend=parse.bol+ ++i;line.index=0;do_info(c_next,text);line.index=i 6681continue} 6682case'n':s=self.new_note(grace,sls) 6683if(!s) 6684continue 6685if(grace||!s.notes) 6686continue 6687if(tpn>=0){s.tp=tp.slice(tpn) 6688tpn=-1 6689if(tps) 6690s.tp[0].s=tps 6691tps=s}else if(!tps){continue} 6692k=tp[tp.length-1] 6693if(--k.r>0) 6694continue 6695while(1){tp_adj(tps,k.q/k.p) 6696i=k.ro 6697if(k.s) 6698tps=k.s 6699tp.pop() 6700if(!tp.length){tps=null 6701break} 6702k=tp[tp.length-1] 6703k.r-=i 6704if(k.r>0) 6705break} 6706continue 6707case'<':if(!curvoice.last_note){syntax(1,"No note before '<'") 6708break} 6709if(grace){syntax(1,"Cannot have a broken rhythm in grace notes") 6710break} 6711n=c=='<'?1:-1 6712while(c=='<'||c=='>'){n*=2;c=line.next_char()} 6713curvoice.brk_rhythm=n 6714continue 6715case'i':break 6716case'{':if(grace){syntax(1,"'{' in grace note") 6717break} 6718last_note_sav=curvoice.last_note;curvoice.last_note=null;a_dcn_sav=a_dcn;a_dcn=undefined;grace={type:C.GRACE,fname:parse.fname,istart:parse.bol+line.index,dur:0,multi:0} 6719switch(curvoice.pos.gst){case C.SL_ABOVE:grace.stem=1;break 6720case C.SL_BELOW:grace.stem=-1;break 6721case C.SL_HIDDEN:grace.stem=2;break} 6722sym_link(grace);c=line.next_char() 6723if(c=='/'){grace.sappo=true 6724break} 6725continue 6726case'|':if(grace){syntax(1,errs.bar_grace) 6727break} 6728new_bar(line.buffer[line.index-1]=='.') 6729continue 6730case'}':s=curvoice.last_note 6731if(!grace||!s){syntax(1,errs.bad_char,c) 6732break} 6733if(a_dcn) 6734syntax(1,"Decoration ignored");grace.extra=grace.next;grace.extra.prev=null;grace.next=null;curvoice.last_sym=grace;grace=null 6735if(!s.prev&&!curvoice.ckey.k_bagpipe){for(i=0;i<=s.nhd;i++) 6736s.notes[i].dur*=2;s.dur*=2;s.dur_orig*=2} 6737curvoice.last_note=last_note_sav;a_dcn=a_dcn_sav 6738break 6739case"\\":if(!line.buffer[line.index+1]){no_eol=true 6740break} 6741default:syntax(1,errs.bad_char,c) 6742break} 6743line.index++}} 6744if(parse.state!=3){if(parse.state!=2) 6745return 6746goto_tune()} 6747if(parse.tp){tp=parse.tp 6748tpn=parse.tpn 6749tps=parse.tps 6750parse.tp=null} 6751parse_seq() 6752if(tp.length){parse.tp=tp 6753parse.tps=tps 6754parse.tpn=tpn} 6755if(sls.length) 6756syntax(1,"Start of slur without note") 6757if(grace){syntax(1,"No end of grace note sequence");curvoice.last_sym=grace.prev;curvoice.last_note=last_note_sav 6758if(grace.prev) 6759grace.prev.next=null} 6760if(cfmt.breakoneoln&&curvoice.last_note) 6761curvoice.last_note.beam_end=true 6762if(no_eol||cfmt.barsperstaff) 6763return 6764if(char_tb['\n'.charCodeAt(0)]=='\n'&&par_sy.voices[curvoice.v]&&par_sy.voices[curvoice.v].range==0) 6765curvoice.eoln=true} 6766var sheet 6767var add_fstyle=typeof document!="undefined"?function(s){var e 6768if(!sheet){if(abc2svg.sheet){sheet=abc2svg.sheet 6769e=sheet.cssRules.length 6770while(--e>=0) 6771sheet.deleteRule(e)}else{e=document.createElement('style') 6772document.head.appendChild(e) 6773abc2svg.sheet=sheet=e.sheet}} 6774s=s.match(/[^{]+{[^}]+}/g) 6775while(1){e=s.shift() 6776if(!e) 6777break 6778sheet.insertRule(e,sheet.cssRules.length)}}:function(s){font_style+="\n"+s} 6779var 6780sw_tb=new Float32Array([.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.250,.333,.408,.500,.500,.833,.778,.333,.333,.333,.500,.564,.250,.564,.250,.278,.500,.500,.500,.500,.500,.500,.500,.500,.500,.500,.278,.278,.564,.564,.564,.444,.921,.722,.667,.667,.722,.611,.556,.722,.722,.333,.389,.722,.611,.889,.722,.722,.556,.722,.667,.556,.611,.722,.722,.944,.722,.722,.611,.333,.278,.333,.469,.500,.333,.444,.500,.444,.500,.444,.333,.500,.500,.278,.278,.500,.278,.778,.500,.500,.500,.500,.333,.389,.278,.500,.500,.722,.500,.500,.444,.480,.200,.480,.541,.500]),ssw_tb=new Float32Array([.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.000,.278,.278,.355,.556,.556,.889,.667,.191,.333,.333,.389,.584,.278,.333,.278,.278,.556,.556,.556,.556,.556,.556,.556,.556,.556,.556,.278,.278,.584,.584,.584,.556,1.015,.667,.667,.722,.722,.667,.611,.778,.722,.278,.500,.667,.556,.833,.722,.778,.667,.778,.722,.667,.611,.722,.667,.944,.667,.667,.611,.278,.278,.278,.469,.556,.333,.556,.556,.500,.556,.556,.278,.556,.556,.222,.222,.500,.222,.833,.556,.556,.556,.556,.333,.500,.278,.556,.500,.722,.500,.500,.500,.334,.260,.334,.584,.512]),cw_tb=sw_tb 6781function cwid(c){var i=c.charCodeAt(0) 6782if(i>=0x80){if(i>=0x300&&i<0x370) 6783return 0;i=0x61} 6784return cw_tb[i]} 6785function cwidf(c){return cwid(c)*gene.curfont.swfac} 6786var strwh=typeof document!="undefined"?(function(){var el=abc2svg.eltxt 6787if(!el){abc2svg.eltxt=el=document.createElement('text') 6788el.style.position='absolute';el.style.top='-1000px';el.style.padding='0';document.body.appendChild(el)} 6789return function(str){if(str.wh) 6790return str.wh 6791var c,font=gene.curfont,h=font.size,w=0,n=str.length,i0=0,i=0 6792el.className=font_class(font) 6793el.style.lineHeight=1 6794if(typeof str=="object"){el.innerHTML=str 6795str.wh=[el.clientWidth,el.clientHeight] 6796return str.wh} 6797str=str.replace(/<|>|&[^&]*?;|&| /g,function(c){switch(c){case'<':return"<" 6798case'>':return">" 6799case'&':return"&" 6800case" ":return' '} 6801return c}) 6802while(1){i=str.indexOf('$',i) 6803if(i<0) 6804break 6805c=str[i+1] 6806if(c=='0'){font=gene.deffont}else if(c>='1'&&c<='9'){font=get_font("u"+c)}else{i++ 6807continue} 6808el.innerHTML=str.slice(i0,i);w+=el.clientWidth 6809if(font.size>h) 6810h=font.size;el.style.font=style_font(font).slice(5);i+=2;i0=i} 6811el.innerHTML=str.slice(i0);w+=el.clientWidth;gene.curfont=font 6812return[w,h]}})():function(str){var font=gene.curfont,swfac=font.swfac,h=font.size,w=0,i,j,c,n=str.length 6813for(i=0;i<n;i++){c=str[i] 6814switch(c){case'$':c=str[i+1] 6815if(c=='0'){font=gene.deffont}else if(c>='1'&&c<='9'){font=get_font("u"+c)}else{c='$' 6816break} 6817i++;swfac=font.swfac 6818if(font.size>h) 6819h=font.size 6820continue 6821case'&':j=str.indexOf(';',i) 6822if(j>0&&j-i<10){i=j;c='a'} 6823break} 6824w+=cwid(c)*swfac} 6825gene.curfont=font 6826return[w,h]} 6827function str2svg(str){if(typeof str=="object") 6828return str 6829var o,n_font,wh,o_font=gene.curfont,c_font=o_font 6830function tspan(nf,of){var cl 6831if(nf.class&&nf.name==of.name&&nf.size==of.size&&nf.weight==of.weight&&nf.style==of.style) 6832cl=nf.class 6833else 6834cl=font_class(nf) 6835return'<tspan\n\tclass="'+cl+'">'} 6836o=str.replace(/<|>|&[^&]*?;|&| |\$./g,function(c){switch(c){case'<':return"<" 6837case'>':return">" 6838case'&':return"&" 6839case' ':return' ' 6840default:if(c[0]!='$') 6841break 6842if(c[1]=='0') 6843n_font=gene.deffont 6844else if(c[1]>='1'&&c[1]<='9') 6845n_font=get_font("u"+c[1]) 6846else 6847break 6848c='' 6849if(n_font==c_font) 6850return c 6851if(c_font!=o_font) 6852c="</tspan>" 6853c_font=n_font 6854if(c_font==o_font) 6855return c 6856return c+tspan(c_font,o_font)} 6857return c}) 6858if(c_font!=o_font){o+="</tspan>" 6859gene.curfont=c_font} 6860o=new String(o) 6861if(typeof document!="undefined") 6862strwh(o) 6863else 6864o.wh=strwh(str) 6865return o} 6866function set_font(xxx){if(typeof xxx=="string") 6867xxx=get_font(xxx) 6868cw_tb=xxx.name.slice(0,4)=='sans'?ssw_tb:sw_tb 6869gene.curfont=gene.deffont=xxx} 6870function out_str(str){output+=str2svg(str)} 6871function xy_str(x,y,str,action,w,wh){if(!wh) 6872wh=str.wh||strwh(str) 6873output+='<text class="'+font_class(gene.curfont) 6874if(action!='j'&&str.length>5&&gene.curfont.wadj) 6875output+='" lengthAdjust="'+gene.curfont.wadj+'" textLength="'+wh[0].toFixed(1);output+='" x="';out_sxsy(x,'" y="',y+wh[1]*.2) 6876switch(action){case'c':x-=wh[0]/2;output+='" text-anchor="middle">' 6877break 6878case'j':output+='" textLength="'+w.toFixed(1)+'">' 6879break 6880case'r':x-=wh[0];output+='" text-anchor="end">' 6881break 6882default:output+='">' 6883break} 6884out_str(str);output+="</text>\n"} 6885function trim_title(title,is_subtitle){var i 6886if(cfmt.titletrim){i=title.lastIndexOf(", ") 6887if(i<0||title[i+2]<'A'||title[i+2]>'Z'){i=0}else if(cfmt.titletrim==true){if(i<title.length-7||title.indexOf(' ',i+3)>=0) 6888i=0}else{if(i<title.length-cfmt.titletrim-2) 6889i=0} 6890if(i) 6891title=title.slice(i+2).trim()+' '+title.slice(0,i)} 6892if(!is_subtitle&&cfmt.writefields.indexOf('X')>=0) 6893title=info.X+'. '+title 6894if(cfmt.titlecaps) 6895return title.toUpperCase() 6896return title} 6897function get_lwidth(){return(img.width-img.lm-img.rm 6898-2) 6899/ cfmt.scale} 6900function write_title(title,is_subtitle){var h,wh 6901if(!title) 6902return 6903set_page();title=trim_title(title,is_subtitle) 6904if(is_subtitle){set_font("subtitle");h=cfmt.subtitlespace}else{set_font("title");h=cfmt.titlespace} 6905wh=strwh(title) 6906wh[1]+=gene.curfont.pad*2 6907vskip(wh[1]+h+gene.curfont.pad) 6908h=gene.curfont.pad 6909if(cfmt.titleleft) 6910xy_str(0,h,title,null,null,wh) 6911else 6912xy_str(get_lwidth()/2,h,title,"c",null,wh)} 6913function put_inf2r(x,y,str1,str2,action){if(!str1){if(!str2) 6914return 6915str1=str2;str2=null} 6916if(!str2) 6917xy_str(x,y,str1,action) 6918else 6919xy_str(x,y,str1+' ('+str2+')',action)} 6920function write_text(text,action){if(action=='s') 6921return 6922set_page();var wh,font,o,strlw=get_lwidth(),sz=gene.curfont.size,lineskip=sz*cfmt.lineskipfac,parskip=sz*cfmt.parskipfac,i,j,x,words,w,k,ww,str;switch(action){default:font=gene.curfont 6923switch(action){case'c':x=strlw/2;break 6924case'r':x=strlw-font.pad;break 6925default:x=font.pad;break} 6926j=0 6927while(1){i=text.indexOf('\n',j) 6928if(i<0){str=str2svg(text.slice(j)) 6929vskip(str.wh[1]*cfmt.lineskipfac+font.pad*2) 6930xy_str(x,font.pad,str,action) 6931break} 6932if(i==j){vskip(parskip);blk_flush() 6933use_font(gene.curfont) 6934while(text[i+1]=='\n'){vskip(lineskip);i++} 6935if(i==text.length) 6936break}else{str=str2svg(text.slice(j,i)) 6937vskip(str.wh[1]*cfmt.lineskipfac+font.pad*2) 6938xy_str(x,font.pad,str,action)} 6939j=i+1} 6940vskip(parskip);blk_flush() 6941break 6942case'f':case'j':j=0 6943while(1){i=text.indexOf('\n\n',j) 6944if(i<0) 6945words=text.slice(j) 6946else 6947words=text.slice(j,i);words=words.split(/\s+/);w=k=0 6948font=gene.curfont 6949for(j=0;j<words.length;j++){ww=strwh(words[j])[0];w+=ww 6950if(w>=strlw){str=str2svg(words.slice(k,j).join(' ')) 6951vskip(str.wh[1]*cfmt.lineskipfac) 6952xy_str(0,0,str,action,strlw) 6953k=j;w=ww} 6954w+=cwidf(' ')} 6955if(w!=0){str=str2svg(words.slice(k).join(' ')) 6956vskip(str.wh[1]*cfmt.lineskipfac) 6957xy_str(0,0,str)} 6958vskip(parskip);blk_flush() 6959if(i<0) 6960break 6961while(text[i+2]=='\n'){vskip(lineskip);i++} 6962if(i==text.length) 6963break 6964use_font(gene.curfont);j=i+2} 6965break}} 6966function put_words(words){var p,i,j,nw,w,lw,x1,x2,i1,i2,do_flush,maxn=0,n=1 6967function put_wline(p,x){var i=0,j,k 6968if(p[i]=='$'&&p[i+1]>='0'&&p[i+1]<='9') 6969i+=2;k=0;j=i 6970if((p[i]>='0'&&p[i]<='9')||p[i+1]=='.'){while(i<p.length){i++ 6971if(p[i]==' '||p[i-1]==':'||p[i-1]=='.') 6972break} 6973k=i 6974while(p[i]==' ') 6975i++} 6976if(k!=0) 6977xy_str(x,0,p.slice(j,k),'r') 6978if(i<p.length) 6979xy_str(x+5,0,p.slice(i),'l')} 6980set_font("words") 6981vskip(cfmt.wordsspace) 6982svg_flush() 6983words=words.split('\n') 6984nw=words.length 6985for(i=0;i<nw;i++){p=words[i] 6986if(!p){while(i+1<nw&&!words[i+1]) 6987i++ 6988n++}else if(p.length>maxn){maxn=p.length 6989i1=i}} 6990w=get_lwidth()/2 6991lw=strwh(words[i1])[0] 6992i1=i2=0 6993if(lw<w){j=n>>1 6994for(i=0;i<nw;i++){p=words[i] 6995if(!p){if(--j<=0) 6996i1=i 6997while(i+1<nw&&!words[i+1]) 6998i++ 6999if(j<=0){i2=i+1 7000break}}} 7001n>>=1} 7002if(i2){x1=(w-lw)/2+10 7003x2=x1+w}else{x2=w-lw/2+10} 7004do_flush=true 7005for(i=0;i<i1||i2<nw;i++,i2++){vskip(cfmt.lineskipfac*gene.curfont.size) 7006if(i<i1){p=words[i] 7007if(p) 7008put_wline(p,x1) 7009else 7010use_font(gene.curfont)} 7011if(i2<nw){p=words[i2] 7012if(p){put_wline(p,x2)}else{if(--n==0){if(i<i1){n++}else if(i2<nw-1){x2=w-lw/2+10 7013svg_flush()}}}} 7014if(!words[i+1]&&!words[i2+1]){if(do_flush){svg_flush() 7015do_flush=false}}else{do_flush=true}}} 7016function put_history(){var i,j,c,str,font,h,w,wh,head,names=cfmt.infoname.split("\n"),n=names.length 7017for(i=0;i<n;i++){c=names[i][0] 7018if(cfmt.writefields.indexOf(c)<0) 7019continue 7020str=info[c] 7021if(!str) 7022continue 7023if(!font){font=true;set_font("history");vskip(cfmt.textspace);h=gene.curfont.size*cfmt.lineskipfac} 7024head=names[i].slice(2) 7025if(head[0]=='"') 7026head=head.slice(1,-1);vskip(h);wh=strwh(head);xy_str(0,0,head,null,null,wh);w=wh[0];str=str.split('\n');xy_str(w,0,str[0]) 7027for(j=1;j<str.length;j++){vskip(h);xy_str(w,0,str[j])} 7028vskip(h*.3);use_font(gene.curfont)}} 7029var info_font_init={A:"info",C:"composer",O:"composer",P:"parts",Q:"tempo",R:"info",T:"title",X:"title"} 7030function write_headform(lwidth){var c,font,font_name,align,x,y,sz,info_val={},info_font=clone(info_font_init),info_sz={A:cfmt.infospace,C:cfmt.composerspace,O:cfmt.composerspace,R:cfmt.infospace},info_nb={} 7031var fmt="",p=cfmt.titleformat,j=0,i=0 7032while(1){while(p[i]==' ') 7033i++ 7034c=p[i++] 7035if(!c) 7036break 7037if(c<'A'||c>'Z'){switch(c){case'+':align='+' 7038c=p[i++] 7039break 7040case',':fmt+='\n' 7041default:continue 7042case'<':align='l' 7043c=p[i++] 7044break 7045case'>':align='r' 7046c=p[i++] 7047break}}else{switch(p[i]){case'-':align='l' 7048i++ 7049break 7050case'1':align='r' 7051i++ 7052break 7053case'0':i++ 7054default:align='c' 7055break}} 7056if(!info_val[c]){if(!info[c]) 7057continue 7058info_val[c]=info[c].split('\n');info_nb[c]=1}else{info_nb[c]++} 7059fmt+=align+c} 7060fmt+='\n' 7061var ya={l:cfmt.titlespace,c:cfmt.titlespace,r:cfmt.titlespace},xa={l:0,c:lwidth*.5,r:lwidth},yb={},str;p=fmt;i=0 7062while(1){yb.l=yb.c=yb.r=y=0;j=i 7063while(1){align=p[j++] 7064if(align=='\n') 7065break 7066c=p[j++] 7067if(align=='+'||yb[align]) 7068continue 7069str=info_val[c] 7070if(!str) 7071continue 7072font_name=info_font[c] 7073if(!font_name) 7074font_name="history";font=get_font(font_name);sz=font.size*1.1 7075if(info_sz[c]) 7076sz+=info_sz[c] 7077if(y<sz) 7078y=sz;yb[align]=sz} 7079ya.l+=y-yb.l;ya.c+=y-yb.c;ya.r+=y-yb.r 7080while(1){align=p[i++] 7081if(align=='\n') 7082break 7083c=p[i++] 7084if(!info_val[c].length) 7085continue 7086str=info_val[c].shift() 7087if(p[i]=='+'){info_nb[c]--;i++ 7088c=p[i++];if(info_val[c].length){if(str) 7089str+=' '+info_val[c].shift() 7090else 7091str=' '+info_val[c].shift()}} 7092font_name=info_font[c] 7093if(!font_name) 7094font_name="history";font=get_font(font_name);sz=font.size*1.1 7095if(info_sz[c]) 7096sz+=info_sz[c];set_font(font);x=xa[align];y=ya[align]+sz 7097if(c=='Q'){self.set_width(glovar.tempo) 7098if(!glovar.tempo.invis){if(align!='l'){tempo_build(glovar.tempo) 7099w=glovar.tempo.tempo_wh[0] 7100if(align=='c') 7101w*=.5;x-=w} 7102writempo(glovar.tempo,x,-y)}}else if(str){if(c=='T') 7103str=trim_title(str,info_font.T[0]=='s') 7104xy_str(x,-y,str,align)} 7105if(c=='T'){font_name=info_font.T="subtitle";info_sz.T=cfmt.subtitlespace} 7106if(info_nb[c]<=1){if(c=='T'){font=get_font(font_name);sz=font.size*1.1 7107if(info_sz[c]) 7108sz+=info_sz[c];set_font(font)} 7109while(info_val[c].length>0){y+=sz;str=info_val[c].shift();xy_str(x,-y,str,align)}} 7110info_nb[c]--;ya[align]=y} 7111if(ya.c>ya.l) 7112ya.l=ya.c 7113if(ya.r>ya.l) 7114ya.l=ya.r 7115if(i>=p.length) 7116break 7117ya.c=ya.r=ya.l} 7118vskip(ya.l)} 7119function write_heading(){var i,j,area,composer,origin,rhythm,down1,down2,lwidth=get_lwidth() 7120vskip(cfmt.topspace) 7121if(cfmt.titleformat){write_headform(lwidth);vskip(cfmt.musicspace) 7122return} 7123if(info.T&&cfmt.writefields.indexOf('T')>=0){i=0 7124while(1){j=info.T.indexOf("\n",i) 7125if(j<0){write_title(info.T.substring(i),i!=0) 7126break} 7127write_title(info.T.slice(i,j),i!=0);i=j+1}} 7128down1=down2=0 7129if(parse.ckey.k_bagpipe&&!cfmt.infoline&&cfmt.writefields.indexOf('R')>=0) 7130rhythm=info.R 7131if(rhythm){set_font("composer");xy_str(0,-cfmt.composerspace,rhythm);down1=cfmt.composerspace} 7132area=info.A 7133if(cfmt.writefields.indexOf('C')>=0) 7134composer=info.C 7135if(cfmt.writefields.indexOf('O')>=0) 7136origin=info.O 7137if(composer||origin||cfmt.infoline){var xcomp,align;set_font("composer");vskip(cfmt.composerspace) 7138if(cfmt.aligncomposer<0){xcomp=0;align=' '}else if(cfmt.aligncomposer==0){xcomp=lwidth*.5;align='c'}else{xcomp=lwidth;align='r'} 7139down2=down1 7140if(composer||origin){if(cfmt.aligncomposer>=0&&down1!=down2) 7141vskip(down1-down2);i=0 7142while(1){vskip(gene.curfont.size) 7143if(composer) 7144j=composer.indexOf("\n",i) 7145else 7146j=-1 7147if(j<0){put_inf2r(xcomp,0,composer?composer.substring(i):null,origin,align) 7148break} 7149xy_str(xcomp,0,composer.slice(i,j),align);down1+=gene.curfont.size;i=j+1} 7150if(down2>down1) 7151vskip(down2-down1)} 7152rhythm=rhythm?null:info.R 7153if((rhythm||area)&&cfmt.infoline){set_font("info");vskip(gene.curfont.size+cfmt.infospace);put_inf2r(lwidth,0,rhythm,area,'r');down1+=gene.curfont.size+cfmt.infospace}}else{down2=cfmt.composerspace} 7154if(info.P&&cfmt.writefields.indexOf('P')>=0){set_font("parts");down1=cfmt.partsspace+gene.curfont.size-down1 7155if(down1>0) 7156down2+=down1 7157if(down2>.01) 7158vskip(down2);xy_str(0,0,info.P);down2=0} 7159vskip(down2+cfmt.musicspace)} 7160var output="",style='\ 7161\n.stroke{stroke:currentColor;fill:none}\ 7162\n.bW{stroke:currentColor;fill:none;stroke-width:1}\ 7163\n.bthW{stroke:currentColor;fill:none;stroke-width:3}\ 7164\n.slW{stroke:currentColor;fill:none;stroke-width:.7}\ 7165\n.slthW{stroke:currentColor;fill:none;stroke-width:1.5}\ 7166\n.sW{stroke:currentColor;fill:none;stroke-width:.7}\ 7167\n.box{outline: 1px solid black;outline-offset: 1px}',font_style='',posx=cfmt.leftmargin/cfmt.scale,posy=0,img={width:cfmt.pagewidth,lm:cfmt.leftmargin,rm:cfmt.rightmargin},defined_glyph={},defs='',fulldefs='',stv_g={scale:1,dy:0,st:-1,v:-1,g:0},blkdiv=0 7168var tgls={"mtr ":{x:0,y:0,c:"\u0020"},brace:{x:0,y:0,c:"\ue000"},lphr:{x:0,y:24,c:"\ue030"},mphr:{x:0,y:24,c:"\ue038"},sphr:{x:0,y:27,c:"\ue039"},rdots:{x:-1,y:0,c:"\ue043"},dsgn:{x:-4,y:-4,c:"\ue045"},dcap:{x:-4,y:-4,c:"\ue046"},sgno:{x:-6,y:0,c:"\ue047"},coda:{x:-12,y:-6,c:"\ue048"},tclef:{x:-8,y:0,c:"\ue050"},cclef:{x:-8,y:0,c:"\ue05c"},bclef:{x:-8,y:0,c:"\ue062"},pclef:{x:-6,y:0,c:"\ue069"},spclef:{x:-6,y:0,c:"\ue069"},stclef:{x:-8,y:0,c:"\ue07a"},scclef:{x:-8,y:0,c:"\ue07b"},sbclef:{x:-7,y:0,c:"\ue07c"},oct:{x:0,y:2,c:"\ue07d"},mtr0:{x:0,y:0,c:"\ue080"},mtr1:{x:0,y:0,c:"\ue081"},mtr2:{x:0,y:0,c:"\ue082"},mtr3:{x:0,y:0,c:"\ue083"},mtr4:{x:0,y:0,c:"\ue084"},mtr5:{x:0,y:0,c:"\ue085"},mtr6:{x:0,y:0,c:"\ue086"},mtr7:{x:0,y:0,c:"\ue087"},mtr8:{x:0,y:0,c:"\ue088"},mtr9:{x:0,y:0,c:"\ue089"},mtrC:{x:0,y:0,c:"\ue08a"},"mtr+":{x:0,y:0,c:"\ue08c"},"mtr(":{x:0,y:0,c:"\ue094"},"mtr)":{x:0,y:0,c:"\ue095"},HDD:{x:-7,y:0,c:"\ue0a0"},breve:{x:-7,y:0,c:"\ue0a1"},HD:{x:-5.2,y:0,c:"\ue0a2"},Hd:{x:-3.8,y:0,c:"\ue0a3"},hd:{x:-3.7,y:0,c:"\ue0a4"},ghd:{x:2,y:0,c:"\ue0a4",sc:.66},pshhd:{x:-3.7,y:0,c:"\ue0a9"},pfthd:{x:-3.7,y:0,c:"\ue0b3"},x:{x:-3.7,y:0,c:"\ue0a9"},"circle-x":{x:-3.7,y:0,c:"\ue0b3"},srep:{x:-5,y:0,c:"\ue101"},"dot+":{x:-5,y:0,sc:.7,c:"\ue101"},diamond:{x:-4,y:0,c:"\ue1b9"},triangle:{x:-4,y:0,c:"\ue1bb"},dot:{x:-1,y:0,c:"\ue1e7"},flu1:{x:-.3,y:0,c:"\ue240"},fld1:{x:-.3,y:0,c:"\ue241"},flu2:{x:-.3,y:0,c:"\ue242"},fld2:{x:-.3,y:0,c:"\ue243"},flu3:{x:-.3,y:3.5,c:"\ue244"},fld3:{x:-.3,y:-4,c:"\ue245"},flu4:{x:-.3,y:8,c:"\ue246"},fld4:{x:-.3,y:-9,c:"\ue247"},flu5:{x:-.3,y:12.5,c:"\ue248"},fld5:{x:-.3,y:-14,c:"\ue249"},"acc-1":{x:-1,y:0,c:"\ue260"},"cacc-1":{x:-18,y:0,c:"\ue26a\ue260\ue26b"},"sacc-1":{x:-1,y:0,sc:.7,c:"\ue260"},acc3:{x:-1,y:0,c:"\ue261"},"cacc3":{x:-18,y:0,c:"\ue26a\ue261\ue26b"},sacc3:{x:-1,y:0,sc:.7,c:"\ue261"},acc1:{x:-2,y:0,c:"\ue262"},"cacc1":{x:-18,y:0,c:"\ue26a\ue262\ue26b"},sacc1:{x:-2,y:0,sc:.7,c:"\ue262"},acc2:{x:-3,y:0,c:"\ue263"},"acc-2":{x:-3,y:0,c:"\ue264"},"acc-1_2":{x:-2,y:0,c:"\ue280"},"acc-3_2":{x:-3,y:0,c:"\ue281"},acc1_2:{x:-1,y:0,c:"\ue282"},acc3_2:{x:-3,y:0,c:"\ue283"},accent:{x:-3,y:0,c:"\ue4a0"},stc:{x:-1,y:-2,c:"\ue4a2"},emb:{x:-4,y:-2,c:"\ue4a4"},wedge:{x:-1,y:0,c:"\ue4a8"},marcato:{x:-3,y:0,c:"\ue4ac"},hld:{x:-7,y:0,c:"\ue4c0"},brth:{x:0,y:0,c:"\ue4ce"},r00:{x:-1.5,y:0,c:"\ue4e1"},r0:{x:-1.5,y:0,c:"\ue4e2"},r1:{x:-3.5,y:-6,c:"\ue4e3"},r2:{x:-3.2,y:0,c:"\ue4e4"},r4:{x:-3,y:0,c:"\ue4e5"},r8:{x:-3,y:0,c:"\ue4e6"},r16:{x:-4,y:0,c:"\ue4e7"},r32:{x:-4,y:0,c:"\ue4e8"},r64:{x:-4,y:0,c:"\ue4e9"},r128:{x:-4,y:0,c:"\ue4ea"},mrest:{x:-10,y:0,c:"\ue4ee"},mrep:{x:-6,y:0,c:"\ue500"},mrep2:{x:-9,y:0,c:"\ue501"},p:{x:-4,y:-6,c:"\ue520"},f:{x:-4,y:-6,c:"\ue522"},pppp:{x:-4,y:-6,c:"\ue529"},ppp:{x:-4,y:-6,c:"\ue52a"},pp:{x:-4,y:-6,c:"\ue52b"},mp:{x:-4,y:-6,c:"\ue52c"},mf:{x:-4,y:-6,c:"\ue52d"},ff:{x:-4,y:-6,c:"\ue52f"},fff:{x:-4,y:-6,c:"\ue530"},ffff:{x:-4,y:-6,c:"\ue531"},sfz:{x:-4,y:-6,c:"\ue539"},trl:{x:-4,y:-4,c:"\ue566"},turn:{x:-5,y:-4,c:"\ue567"},turnx:{x:-5,y:-4,c:"\ue569"},umrd:{x:-7,y:-2,c:"\ue56c"},lmrd:{x:-7,y:-2,c:"\ue56d"},dplus:{x:-4,y:10,c:"\ue582"},sld:{x:-8,y:12,c:"\ue5d0"},grm:{x:-2,y:0,c:"\ue5e2"},dnb:{x:-4,y:0,c:"\ue610"},upb:{x:-3,y:0,c:"\ue612"},opend:{x:-2,y:0,c:"\ue614"},roll:{x:0,y:0,c:"\ue618"},thumb:{x:0,y:0,c:"\ue624"},snap:{x:-2,y:0,c:"\ue630"},ped:{x:-10,y:0,c:"\ue650"},pedoff:{x:-5,y:0,c:"\ue655"},mtro:{x:0,y:0,c:"\ue911"},mtrc:{x:0,y:0,c:"\ue915"},"mtr.":{x:0,y:0,c:"\ue920"},"mtr|":{x:0,y:0,c:"\ue925"},longa:{x:-4.7,y:0,c:"\ue95d"},custos:{x:-4,y:3,c:"\uea02"},ltr:{x:2,y:6,c:"\ueaa4"}} 7169var glyphs={} 7170function m_gl(s){return s.replace(/[Cco]\||[co]\.|./g,function(e){var m=tgls["mtr"+e] 7171return m.c})} 7172function def_use(gl){var i,j,g 7173if(defined_glyph[gl]) 7174return 7175defined_glyph[gl]=true;g=glyphs[gl] 7176if(!g){error(1,null,"Unknown glyph: '$1'",gl) 7177return} 7178j=0 7179while(1){i=g.indexOf('xlink:href="#',j) 7180if(i<0) 7181break 7182i+=13;j=g.indexOf('"',i);def_use(g.slice(i,j))} 7183defs+='\n'+g} 7184function defs_add(text){var i,j,gl,tag,is,ie=0 7185text=text.replace(/<!--.*?-->/g,'') 7186while(1){is=text.indexOf('<',ie);if(is<0) 7187break 7188i=text.indexOf('id="',is) 7189if(i<0) 7190break 7191i+=4;j=text.indexOf('"',i);if(j<0) 7192break 7193gl=text.slice(i,j);ie=text.indexOf('>',j);if(ie<0) 7194break 7195if(text[ie-1]=='/'){ie++}else{i=text.indexOf(' ',is);if(i<0) 7196break 7197tag=text.slice(is+1,i);ie=text.indexOf('</'+tag+'>',ie) 7198if(ie<0) 7199break 7200ie+=3+tag.length} 7201if(text.substr(is,7)=='<filter') 7202fulldefs+=text.slice(is,ie)+'\n' 7203else 7204glyphs[gl]=text.slice(is,ie)}} 7205function set_g(){if(stv_g.started){stv_g.started=false;glout() 7206output+="</g>\n"} 7207if(stv_g.scale==1&&!stv_g.color) 7208return 7209glout() 7210output+='<g ' 7211if(stv_g.scale!=1){if(stv_g.st<0) 7212output+=voice_tb[stv_g.v].scale_str 7213else if(stv_g.v<0) 7214output+=staff_tb[stv_g.st].scale_str 7215else 7216output+='transform="translate(0,'+ 7217(posy-stv_g.dy).toFixed(1)+') scale('+stv_g.scale.toFixed(2)+')"'} 7218if(stv_g.color){if(stv_g.scale!=1) 7219output+=' ';output+='color="'+stv_g.color+'" fill="'+stv_g.color+'"'} 7220output+=">\n";stv_g.started=true} 7221function set_color(color){if(color==stv_g.color) 7222return undefined 7223var old_color=stv_g.color;stv_g.color=color;set_g() 7224return old_color} 7225function set_sscale(st){var new_scale,dy 7226if(st!=stv_g.st&&stv_g.scale!=1) 7227stv_g.scale=0;new_scale=st>=0?staff_tb[st].staffscale:1 7228if(st>=0&&new_scale!=1) 7229dy=staff_tb[st].y 7230else 7231dy=posy 7232if(new_scale==stv_g.scale&&dy==stv_g.dy) 7233return 7234stv_g.scale=new_scale;stv_g.dy=dy;stv_g.st=st;stv_g.v=-1;set_g()} 7235function set_scale(s){var new_dy,new_scale=s.p_v.scale 7236if(new_scale==1){set_sscale(s.st) 7237return} 7238new_dy=posy 7239if(staff_tb[s.st].staffscale!=1){new_scale*=staff_tb[s.st].staffscale;new_dy=staff_tb[s.st].y} 7240if(new_scale==stv_g.scale&&stv_g.dy==posy) 7241return 7242stv_g.scale=new_scale;stv_g.dy=new_dy;stv_g.st=staff_tb[s.st].staffscale==1?-1:s.st;stv_g.v=s.v;set_g()} 7243function set_dscale(st,no_scale){if(output){if(stv_g.st<0){staff_tb[0].output+=output}else if(stv_g.scale==1){staff_tb[stv_g.st].output+=output}else{staff_tb[stv_g.st].sc_out+=output} 7244output=""} 7245if(st<0) 7246stv_g.scale=1 7247else 7248stv_g.scale=no_scale?1:staff_tb[st].staffscale;stv_g.st=st;stv_g.dy=0} 7249function delayed_update(){var st,new_out,text 7250for(st=0;st<=nstaff;st++){if(staff_tb[st].sc_out){output+='<g '+staff_tb[st].scale_str+'>\n'+ 7251staff_tb[st].sc_out+'</g>\n';staff_tb[st].sc_out=""} 7252if(!staff_tb[st].output) 7253continue 7254output+='<g transform="translate(0,'+ 7255(-staff_tb[st].y).toFixed(1)+')">\n'+ 7256staff_tb[st].output+'</g>\n';staff_tb[st].output=""}} 7257function anno_out(s,t,f){if(s.istart==undefined) 7258return 7259var type=s.type,h=s.ymx-s.ymn+4,wl=s.wl||2,wr=s.wr||2 7260if(s.grace) 7261type=C.GRACE 7262f(t||abc2svg.sym_name[type],s.istart,s.iend,s.x-wl-2,staff_tb[s.st].y+s.ymn+h-2,wl+wr+4,h,s)} 7263function a_start(s,t){anno_out(s,t,user.anno_start)} 7264function a_stop(s,t){anno_out(s,t,user.anno_stop)} 7265function empty_function(){} 7266var anno_start=user.anno_start?a_start:empty_function,anno_stop=user.anno_stop?a_stop:empty_function 7267function anno_put(){var s 7268while(1){s=anno_a.shift() 7269if(!s) 7270break 7271switch(s.type){case C.CLEF:case C.METER:case C.KEY:case C.REST:if(s.type!=C.REST||s.rep_nb){set_sscale(s.st) 7272break} 7273case C.GRACE:case C.NOTE:case C.MREST:set_scale(s) 7274break} 7275anno_stop(s)}} 7276function out_XYAB(str,x,y,a,b){x=sx(x);y=sy(y);output+=str.replace(/X|Y|A|B|F|G/g,function(c){switch(c){case'X':return x.toFixed(1) 7277case'Y':return y.toFixed(1) 7278case'A':return a 7279case'B':return b 7280case'F':return a.toFixed(1) 7281default:return b.toFixed(1)}})} 7282function g_open(x,y,rot,sx,sy){glout() 7283out_XYAB('<g transform="translate(X,Y',x,y);if(rot) 7284output+=') rotate('+rot.toFixed(2) 7285if(sx){if(sy) 7286output+=') scale('+sx.toFixed(2)+', '+sy.toFixed(2) 7287else 7288output+=') scale('+sx.toFixed(2)} 7289output+=')">\n';stv_g.g++} 7290function g_close(){glout() 7291stv_g.g--;output+='</g>\n'} 7292Abc.prototype.out_svg=function(str){output+=str} 7293function sx(x){if(stv_g.g) 7294return x 7295return(x+posx)/stv_g.scale} 7296Abc.prototype.sx=sx 7297function sy(y){if(stv_g.g) 7298return-y 7299if(stv_g.scale==1) 7300return posy-y 7301if(stv_g.v>=0) 7302return(stv_g.dy-y)/voice_tb[stv_g.v].scale 7303return stv_g.dy-y} 7304Abc.prototype.sy=sy;Abc.prototype.sh=function(h){if(stv_g.st<0) 7305return h/stv_g.scale 7306return h} 7307Abc.prototype.ax=function(x){return x+posx} 7308Abc.prototype.ay=function(y){if(stv_g.st<0) 7309return posy-y 7310return posy+(stv_g.dy-y)*stv_g.scale-stv_g.dy} 7311Abc.prototype.ah=function(h){if(stv_g.st<0) 7312return h 7313return h*stv_g.scale} 7314function out_sxsy(x,sep,y){x=sx(x);y=sy(y);output+=x.toFixed(1)+sep+y.toFixed(1)} 7315Abc.prototype.out_sxsy=out_sxsy 7316function xypath(x,y,fill){if(fill) 7317out_XYAB('<path d="mX Y',x,y) 7318else 7319out_XYAB('<path class="stroke" d="mX Y',x,y)} 7320Abc.prototype.xypath=xypath 7321var gla=[[],[],"",[],[],[]] 7322function glout(){var e,v=[] 7323if(gla[0].length){while(1){e=gla[0].shift() 7324if(e==undefined) 7325break 7326v.push(e.toFixed(1))} 7327output+='<text x="'+v.join(',') 7328v=[] 7329while(1){e=gla[1].shift() 7330if(e==undefined) 7331break 7332v.push(e.toFixed(1))} 7333output+='"\ny="'+v.join(',') 7334output+='"\n>'+gla[2]+'</text>\n' 7335gla[2]=""} 7336if(!gla[3].length) 7337return 7338output+='<path class="sW" d="' 7339while(1){e=gla[3].shift() 7340if(e==undefined) 7341break 7342output+='M'+e.toFixed(1)+' '+gla[3].shift().toFixed(1)+'v'+gla[3].shift().toFixed(1)} 7343output+='"/>\n'} 7344function xygl(x,y,gl){if(glyphs[gl]){def_use(gl) 7345out_XYAB('<use x="X" y="Y" xlink:href="#A"/>\n',x,y,gl)}else{var tgl=tgls[gl] 7346if(tgl){x+=tgl.x*stv_g.scale;y-=tgl.y 7347if(tgl.sc){out_XYAB('<text transform="translate(X,Y) scale(A)">B</text>\n',x,y,tgl.sc,tgl.c)}else{gla[0].push(sx(x)) 7348gla[1].push(sy(y)) 7349gla[2]+=tgl.c}}else{error(1,null,'no definition of $1',gl)}}} 7350function out_acciac(x,y,dx,dy,up){if(up){x-=1;y+=4}else{x-=5;y-=4} 7351out_XYAB('<path class="stroke" d="mX YlF G"/>\n',x,y,dx,-dy)} 7352function out_brace(x,y,h){x+=posx-6;y=posy-y;h/=24;output+='<text transform="translate('+ 7353x.toFixed(1)+','+y.toFixed(1)+') scale(2.5,'+h.toFixed(2)+')">'+tgls.brace.c+'</text>\n'} 7354function out_bracket(x,y,h){x+=posx-5;y=posy-y-3;h+=2;output+='<path d="m'+x.toFixed(1)+' '+y.toFixed(1)+'\n\ 7355 c10.5 1 12 -4.5 12 -3.5c0 1 -3.5 5.5 -8.5 5.5\n\ 7356 v'+h.toFixed(1)+'\n\ 7357 c5 0 8.5 4.5 8.5 5.5c0 1 -1.5 -4.5 -12 -3.5"/>\n'} 7358function out_hyph(x,y,w){var n,a_y,d=25+((w/20)|0)*3 7359if(w>15.) 7360n=((w-15)/d)|0 7361else 7362n=0;x+=(w-d*n-5)/2;out_XYAB('<path class="stroke" stroke-width="1.2"\n\ 7363 stroke-dasharray="5,A"\n\ 7364 d="mX YhB"/>\n',x,y+6,Math.round((d-5)/stv_g.scale),d*n+5)} 7365function out_stem(x,y,h,grace,nflags,straight){var dx=grace?GSTEM_XOFF:3.5,slen=-h 7366if(h<0) 7367dx=-dx;x+=dx*stv_g.scale 7368if(stv_g.v>=0) 7369slen/=voice_tb[stv_g.v].scale;gla[3].push(sx(x)) 7370gla[3].push(sy(y)) 7371gla[3].push(slen) 7372if(!nflags) 7373return 7374y+=h 7375if(h>0){if(!straight){if(!grace){xygl(x,y,"flu"+nflags) 7376return}else{output+='<path d="' 7377if(nflags==1){out_XYAB('MX Yc0.6 3.4 5.6 3.8 3 10\n\ 7378 1.2 -4.4 -1.4 -7 -3 -7\n',x,y)}else{while(--nflags>=0){out_XYAB('MX Yc1 3.2 5.6 2.8 3.2 8\n\ 7379 1.4 -4.8 -2.4 -5.4 -3.2 -5.2\n',x,y);y-=3.5}}}}else{output+='<path d="' 7380if(!grace){while(--nflags>=0){out_XYAB('MX Yl7 3.2 0 3.2 -7 -3.2z\n',x,y);y-=5.4}}else{while(--nflags>=0){out_XYAB('MX Yl3 1.5 0 2 -3 -1.5z\n',x,y);y-=3}}}}else{if(!straight){if(!grace){xygl(x,y,"fld"+nflags) 7381return}else{output+='<path d="' 7382if(nflags==1){out_XYAB('MX Yc0.6 -3.4 5.6 -3.8 3 -10\n\ 7383 1.2 4.4 -1.4 7 -3 7\n',x,y)}else{while(--nflags>=0){out_XYAB('MX Yc1 -3.2 5.6 -2.8 3.2 -8\n\ 7384 1.4 4.8 -2.4 5.4 -3.2 5.2\n',x,y);y+=3.5}}}}else{output+='<path d="' 7385if(!grace){while(--nflags>=0){out_XYAB('MX Yl7 -3.2 0 -3.2 -7 3.2z\n',x,y);y+=5.4}}}} 7386output+='"/>\n'} 7387function out_trem(x,y,ntrem){out_XYAB('<path d="mX Y\n\t',x-4.5,y) 7388while(1){output+='l9 -3v3l-9 3z' 7389if(--ntrem<=0) 7390break 7391output+='m0 5.4'} 7392output+='"/>\n'} 7393function out_tubr(x,y,dx,dy,up){var h=up?-3:3;y+=h;dx/=stv_g.scale;output+='<path class="stroke" d="m';out_sxsy(x,' ',y);output+='v'+h.toFixed(1)+'l'+dx.toFixed(1)+' '+(-dy).toFixed(1)+'v'+(-h).toFixed()+'"/>\n'} 7394function out_tubrn(x,y,dx,dy,up,str){var sw=str.length*10,h=up?-3:3;set_font("tuplet") 7395xy_str(x+dx/2,y+dy/2-gene.curfont.size*.5+2,str,'c') 7396dx/=stv_g.scale 7397if(!up) 7398y+=6;output+='<path class="stroke" d="m';out_sxsy(x,' ',y);output+='v'+h.toFixed(1)+'m'+dx.toFixed(1)+' '+(-dy).toFixed(1)+'v'+(-h).toFixed(1)+'"/>\n'+'<path class="stroke" stroke-dasharray="'+ 7399((dx-sw)/2).toFixed(1)+' '+sw.toFixed(1)+'" d="m';out_sxsy(x,' ',y-h);output+='l'+dx.toFixed(1)+' '+(-dy).toFixed(1)+'"/>\n'} 7400function out_wln(x,y,w){out_XYAB('<path class="stroke" stroke-width="0.8" d="mX YhF"/>\n',x,y+3,w)} 7401var deco_str_style={crdc:{dx:0,dy:5,style:'font:italic 14px serif'},dacs:{dx:0,dy:3,style:'font:16px serif',anchor:' text-anchor="middle"'},fng:{dx:0,dy:1,style:'font-family:Bookman; font-size:8px',anchor:' text-anchor="middle"'},pf:{dx:0,dy:5,style:'font:italic bold 16px serif'},'@':{dx:0,dy:5,style:'font: 12px sans-serif'}} 7402function out_deco_str(x,y,name,str){var a,f,a_deco=deco_str_style[name] 7403if(!a_deco){xygl(x,y,name) 7404return} 7405x+=a_deco.dx;y+=a_deco.dy;if(!a_deco.def){style+="\n."+name+" {"+a_deco.style+"}";a_deco.def=true} 7406out_XYAB('<text x="X" y="Y" class="A"B>',x,y,name,a_deco.anchor||"");set_font("annotation");out_str(str);output+='</text>\n'} 7407function out_arp(x,y,val){g_open(x,y,270);x=0;val=Math.ceil(val/6) 7408while(--val>=0){xygl(x,6,"ltr");x+=6} 7409g_close()} 7410function out_cresc(x,y,val,defl){x+=val;val=-val;out_XYAB('<path class="stroke"\n\ 7411 d="mX YlA ',x,y+5,val) 7412if(defl.nost) 7413output+='-2.2m0 -3.6l'+(-val).toFixed(1)+' -2.2"/>\n' 7414else 7415output+='-4l'+(-val).toFixed(1)+' -4"/>\n'} 7416function out_dim(x,y,val,defl){out_XYAB('<path class="stroke"\n\ 7417 d="mX YlA ',x,y+5,val) 7418if(defl.noen) 7419output+='-2.2m0 -3.6l'+(-val).toFixed(1)+' -2.2"/>\n' 7420else 7421output+='-4l'+(-val).toFixed(1)+' -4"/>\n'} 7422function out_ltr(x,y,val){y+=4;val=Math.ceil(val/6) 7423while(--val>=0){xygl(x,y,"ltr");x+=6}} 7424Abc.prototype.out_lped=function(x,y,val,defl){y+=4;if(!defl.nost) 7425xygl(x,y,"ped");if(!defl.noen) 7426xygl(x+val+6,y,"pedoff")} 7427function out_8va(x,y,val,defl){if(!defl.nost){out_XYAB('<text x="X" y="Y" \ 7428style="font:italic bold 12px serif">8\ 7429<tspan dy="-4" style="font-size:10px">va</tspan></text>\n',x-8,y);x+=12;val-=12}else{val-=5} 7430y+=6;out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',x,y,val) 7431if(!defl.noen) 7432out_XYAB('<path class="stroke" d="mX Yv6"/>\n',x+val,y)} 7433function out_8vb(x,y,val,defl){if(!defl.nost){out_XYAB('<text x="X" y="Y" \ 7434style="font:italic bold 12px serif">8\ 7435<tspan dy="-4" style="font-size:10px">vb</tspan></text>\n',x-8,y);x+=4;val-=4}else{val-=5} 7436out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',x,y,val) 7437if(!defl.noen) 7438out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',x+val,y)} 7439function out_15ma(x,y,val,defl){if(!defl.nost){out_XYAB('<text x="X" y="Y" \ 7440style="font:italic bold 12px serif">15\ 7441<tspan dy="-4" style="font-size:10px">ma</tspan></text>\n',x-10,y);x+=20;val-=20}else{val-=5} 7442y+=6;out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',x,y,val) 7443if(!defl.noen) 7444out_XYAB('<path class="stroke" d="mX Yv6"/>\n',x+val,y)} 7445function out_15mb(x,y,val,defl){if(!defl.nost){out_XYAB('<text x="X" y="Y" \ 7446style="font:italic bold 12px serif">15\ 7447<tspan dy="-4" style="font-size:10px">mb</tspan></text>\n',x-10,y);x+=7;val-=7}else{val-=5} 7448out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhF"/>\n',x,y,val) 7449if(!defl.noen) 7450out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',x+val,y)} 7451var deco_val_tb={arp:out_arp,cresc:out_cresc,dim:out_dim,ltr:out_ltr,lped:function(x,y,val,defl){self.out_lped(x,y,val,defl)},"8va":out_8va,"8vb":out_8vb,"15ma":out_15ma,"15mb":out_15mb} 7452function out_deco_val(x,y,name,val,defl){if(deco_val_tb[name]) 7453deco_val_tb[name](x,y,val,defl) 7454else 7455error(1,null,"No function for decoration '$1'",name)} 7456function out_glisq(x2,y2,de){var de1=de.start,x1=de1.x,y1=de1.y+staff_tb[de1.st].y,ar=Math.atan2(y1-y2,x2-x1),a=ar/Math.PI*180,len=(x2-x1)/Math.cos(ar);g_open(x1,y1,a);x1=de1.s.dots?13+de1.s.xmx:8;len=(len-x1-6)/6|0 7457if(len<1) 7458len=1 7459while(--len>=0){xygl(x1,0,"ltr");x1+=6} 7460g_close()} 7461function out_gliss(x2,y2,de){var de1=de.start,x1=de1.x,y1=de1.y+staff_tb[de1.st].y,ar=-Math.atan2(y2-y1,x2-x1),a=ar/Math.PI*180,len=(x2-x1)/Math.cos(ar);g_open(x1,y1,a);x1=de1.s.dots?13+de1.s.xmx:8;len-=x1+8;xypath(x1,0);output+='h'+len.toFixed(1)+'" stroke-width="1"/>\n';g_close()} 7462var deco_l_tb={glisq:out_glisq,gliss:out_gliss} 7463function out_deco_long(x,y,de){var name=de.dd.glyph 7464if(deco_l_tb[name]) 7465deco_l_tb[name](x,y,de) 7466else 7467error(1,null,"No function for decoration '$1'",name)} 7468function tempo_note(s,dur){var p,elts=identify_note(s,dur) 7469switch(elts[0]){case C.OVAL:p="\ueca2" 7470break 7471case C.EMPTY:p="\ueca3" 7472break 7473default:switch(elts[2]){case 2:p="\ueca9" 7474break 7475case 1:p="\ueca7" 7476break 7477default:p="\ueca5" 7478break} 7479break} 7480if(elts[1]) 7481p+='<tspan dx=".1em">\uecb7</tspan>' 7482return p} 7483function tempo_build(s){var i,j,bx,p,wh,dy,w=0,str=[] 7484if(s.tempo_str) 7485return 7486if(!cfmt.musicfont.used) 7487get_font("music") 7488set_font("tempo") 7489if(s.tempo_str1){str.push(s.tempo_str1) 7490w+=strwh(s.tempo_str1)[0]} 7491if(s.tempo_notes){dy=' dy="-.05em"' 7492for(i=0;i<s.tempo_notes.length;i++){p=tempo_note(s,s.tempo_notes[i]) 7493str.push('<tspan\nclass="'+ 7494font_class(cfmt.musicfont)+'" style="font-size:'+ 7495(gene.curfont.size*1.3).toFixed(1)+'px"'+ 7496dy+'>'+ 7497p+'</tspan>') 7498j=p.length>1?2:1 7499w+=j*gene.curfont.swfac 7500dy=''} 7501str.push('<tspan dy=".065em">=</tspan>') 7502w+=cwidf('=') 7503if(s.tempo_ca){str.push(s.tempo_ca) 7504w+=strwh(s.tempo_ca)[0] 7505j=s.tempo_ca.length+1} 7506if(s.tempo){str.push(s.tempo) 7507w+=strwh(s.tempo.toString())[0]}else{p=tempo_note(s,s.new_beat) 7508str.push('<tspan\nclass="'+ 7509font_class(cfmt.musicfont)+'" style="font-size:'+ 7510(gene.curfont.size*1.3).toFixed(1)+'px" dy="-.05em">'+ 7511p+'</tspan>') 7512j=p.length>1?2:1 7513w+=j*gene.curfont.swfac 7514dy='y'}} 7515if(s.tempo_str2){if(dy) 7516str.push('<tspan\n\tdy=".065em">'+ 7517s.tempo_str2+'</tspan>') 7518else 7519str.push(s.tempo_str2) 7520w+=strwh(s.tempo_str2)[0]} 7521s.tempo_str=str.join(' ') 7522w+=cwidf(' ')*(str.length-1) 7523s.tempo_wh=[w,13.0] 7524if(dy) 7525s.tempo_dy=dy} 7526function writempo(s,x,y){var bx 7527set_font("tempo") 7528if(gene.curfont.box){gene.curfont.box=false 7529bx=x} 7530output+='<text class="'+font_class(gene.curfont)+'" x="' 7531out_sxsy(x,'" y="',y+gene.curfont.size*.2) 7532output+='">'+s.tempo_str+'</text>\n' 7533if(bx){gene.curfont.box=true 7534bh=gene.curfont.size+4;output+='<rect class="stroke" x="' 7535out_sxsy(bx-2,'" y="',y+bh-1) 7536output+='" width="'+(s.tempo_wh[0]+2).toFixed(1)+'" height="'+bh.toFixed(1)+'"/>\n'} 7537s.invis=true} 7538function vskip(h){posy+=h} 7539function svg_flush(){if(multicol||!output||!user.img_out||posy==0) 7540return 7541var i,font,head='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n\ 7542 xmlns:xlink="http://www.w3.org/1999/xlink"\n\ 7543 color="',g='' 7544glout() 7545if(cfmt.fgcolor) 7546head+=cfmt.fgcolor+'" fill="'+cfmt.fgcolor+'"' 7547else 7548head+='black"';head+=' stroke-width=".7"' 7549if(cfmt.bgcolor) 7550head+=' style="background-color: '+cfmt.bgcolor+'"';font=get_font("music") 7551head+=' class="'+font_class(font)+' tune'+tunes.length+'"\n' 7552posy*=cfmt.scale 7553if(user.imagesize){head+=user.imagesize+' viewBox="0 0 '+img.width.toFixed(0)+' '+ 7554posy.toFixed(0)+'">\n'}else{head+=' width="'+img.width.toFixed(0)+'px" height="'+posy.toFixed(0)+'px">\n'} 7555head+=fulldefs 7556if(style||font_style) 7557head+='<style>\n.'+ 7558font_class(font)+' text,tspan{fill:currentColor}'+ 7559font_style+style+'\n</style>\n' 7560if(defs) 7561head+='<defs>'+defs+'\n</defs>\n' 7562if(cfmt.scale!=1){head+='<g class="g" transform="scale('+ 7563cfmt.scale.toFixed(2)+')">\n';g='</g>\n'} 7564if(psvg) 7565psvg.ps_flush(true);if(blkdiv>0){user.img_out(blkdiv==1?'<div class="nobrk">':'<div class="nobrk newpage">') 7566blkdiv=-1} 7567user.img_out(head+output+g+"</svg>");output="" 7568font_style='' 7569if(cfmt.fullsvg&&typeof document=="undefined"){defined_glyph={} 7570for(i=0;i<font_tb.length;i++) 7571font_tb[i].used=false}else{style='';fulldefs=''} 7572defs='';posy=0} 7573function blk_flush(){svg_flush() 7574if(blkdiv<0&&(!parse.state||cfmt.splittune)){user.img_out('</div>') 7575blkdiv=0}} 7576Abc.prototype.blk_flush=blk_flush 7577var par_sy,cur_sy,voice_tb,curvoice,staves_found,vover,tsfirst 7578function voice_filter(){var opt 7579function vfilt(opts,opt){var i,sel=new RegExp(opt) 7580if(sel.test(curvoice.id)||sel.test(curvoice.nm)){for(i=0;i<opts.length;i++) 7581self.do_pscom(opts[i])}} 7582if(parse.voice_opts) 7583for(opt in parse.voice_opts){if(parse.voice_opts.hasOwnProperty(opt)) 7584vfilt(parse.voice_opts[opt],opt)} 7585if(parse.tune_v_opts) 7586for(opt in parse.tune_v_opts){if(parse.tune_v_opts.hasOwnProperty(opt)) 7587vfilt(parse.tune_v_opts[opt],opt)}} 7588function sym_link(s){if(!s.fname) 7589set_ref(s) 7590parse.last_sym=s;s.prev=curvoice.last_sym 7591if(curvoice.last_sym) 7592curvoice.last_sym.next=s 7593else 7594curvoice.sym=s;curvoice.last_sym=s 7595s.v=curvoice.v;s.p_v=curvoice;s.st=curvoice.cst;s.time=curvoice.time 7596if(s.dur&&!s.grace) 7597curvoice.time+=s.dur;s.pos=curvoice.pos 7598if(curvoice.second) 7599s.second=true 7600if(curvoice.floating) 7601s.floating=true 7602if(curvoice.eoln){s.soln=true 7603curvoice.eoln=false}} 7604function sym_add(p_voice,type){var s={type:type,dur:0},s2,p_voice2=curvoice;curvoice=p_voice;sym_link(s);curvoice=p_voice2;s2=s.prev 7605if(!s2) 7606s2=s.next 7607if(s2){s.fname=s2.fname;s.istart=s2.istart;s.iend=s2.iend} 7608return s} 7609var w_tb=new Uint8Array([4,1,8,0,3,5,6,9,9,0,9,3,0,7,0,0,0,0]) 7610function sort_all(){var s,s2,p_voice,v,time,w,wmin,ir,multi,prev,nb,ir2,v2,fl,new_sy,nv=voice_tb.length,vtb=[],vn=[],sy=cur_sy 7611for(v=0;v<nv;v++) 7612vtb.push(voice_tb[v].sym) 7613ir2=nv 7614multi=-1 7615for(v=0;v<nv;v++){if(!sy.voices[v]) 7616continue 7617ir=sy.voices[v].range 7618if(ir<ir2) 7619ir2=ir 7620vn[ir]=v 7621multi++} 7622v=vn[ir2] 7623tsfirst=prev=vtb[v] 7624if(!tsfirst) 7625return 7626vtb[v]=tsfirst.next 7627prev.seqst=true 7628fl=!w_tb[prev.type]||tsfirst.type==tsfirst.next 7629while(1){if(new_sy&&fl){sy=new_sy;new_sy=null;multi=-1;vn=[] 7630for(v=0;v<nv;v++){if(!sy.voices[v]) 7631continue 7632ir=sy.voices[v].range 7633vn[ir]=v;multi++}} 7634wmin=time=1000000 7635for(ir=0;ir<nv;ir++){v=vn[ir] 7636if(v==undefined) 7637break 7638s=vtb[v] 7639if(!s||s.time>time) 7640continue 7641w=w_tb[s.type] 7642if(s.time<time){time=s.time;wmin=w}else if(w<wmin){wmin=w}} 7643if(wmin>127) 7644break 7645for(ir=0;ir<nv;ir++){v=vn[ir] 7646if(v==undefined) 7647break 7648s=vtb[v] 7649if(!s||s.time!=time||w_tb[s.type]!=wmin) 7650continue 7651if(s.type==C.STAVES){new_sy=s.sy;for(ir2=0;ir2<nv;ir2++){if(vn[ir2]==undefined) 7652break} 7653for(v2=0;v2<nv;v2++){if(!new_sy.voices[v2]||sy.voices[v2]) 7654continue 7655vn[ir2++]=v2}} 7656if(fl){fl=0;s.seqst=true} 7657s.ts_prev=prev 7658prev.ts_next=s 7659prev=s 7660vtb[v]=s.next} 7661fl=wmin}} 7662function voice_adj(sys_chg){var p_voice,s,s2,v 7663function set_feathered_beam(s1){var s,s2,t,d,b,i,a,d=s1.dur,n=1 7664for(s=s1;s;s=s.next){if(s.beam_end||!s.next) 7665break 7666n++} 7667if(n<=1){delete s1.feathered_beam 7668return} 7669s2=s;b=d/2;a=d/(n-1);t=s1.time 7670if(s1.feathered_beam>0){for(s=s1,i=n-1;s!=s2;s=s.next,i--){d=((a*i)|0)+b;s.dur=d;s.time=t;t+=d}}else{for(s=s1,i=0;s!=s2;s=s.next,i++){d=((a*i)|0)+b;s.dur=d;s.time=t;t+=d}} 7671s.dur=s.time+s.dur-t;s.time=t} 7672if(curvoice&&curvoice.clone){parse.istart=parse.eol 7673do_cloning()} 7674s=glovar.tempo 7675if(s&&staves_found<=0){v=par_sy.top_voice;p_voice=voice_tb[v];if(p_voice.sym&&p_voice.sym.type!=C.TEMPO&&(!p_voice.sym.next||p_voice.sym.next.type!=C.TEMPO)){s=clone(s);s.v=v;s.p_v=p_voice;s.st=p_voice.st;s.time=0;s.prev=p_voice.sym 7676s.next=p_voice.sym.next 7677if(s.next) 7678s.next.prev=s 7679p_voice.sym.next=s}} 7680for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 7681if(!sys_chg){delete p_voice.eoln 7682while(1){var sl=p_voice.sls.shift() 7683if(!sl) 7684break 7685s=sl.note.s 7686for(s2=s.next;s2;s2=s2.next){if(s2.bar_type&&s2.bar_type[0]==':') 7687break} 7688if(s2){if(!s.sls) 7689s.sls=[] 7690s.sls.push({ty:sl.ty,note:{s:s2}})}else{syntax(1,"Lack of ending slur(s)")}}} 7691for(s=p_voice.sym;s;s=s.next){if(s.time>=staves_found) 7692break} 7693for(;s;s=s.next){switch(s.type){case C.GRACE:if(s.next&&s.next.type==C.BAR) 7694s.time-- 7695if(!cfmt.graceword) 7696continue 7697for(s2=s.next;s2;s2=s2.next){switch(s2.type){case C.SPACE:continue 7698case C.NOTE:if(!s2.a_ly) 7699break 7700s.a_ly=s2.a_ly;s2.a_ly=null 7701break} 7702break} 7703continue 7704case C.MREST:if(s.next&&s.next.type!=C.BAR){syntax(1,"Lack of bar after multi-measure rest") 7705s2=clone(s) 7706s2.type=C.BAR 7707s2.bar_type='|' 7708s2.dur=0 7709s2.time=s.next.time 7710s2.prev=s 7711s2.next=s.next 7712s2.next.prev=s2 7713s.next=s2} 7714continue} 7715if(s.feathered_beam) 7716set_feathered_beam(s)}}} 7717function new_syst(init){var st,v,sy_new={voices:[],staves:[],top_voice:0} 7718if(init){cur_sy=par_sy=sy_new 7719return} 7720for(v=0;v<voice_tb.length;v++){if(par_sy.voices[v]){st=par_sy.voices[v].st 7721var sy_staff=par_sy.staves[st],p_voice=voice_tb[v] 7722sy_staff.staffnonote=p_voice.staffnonote 7723if(p_voice.staffscale) 7724sy_staff.staffscale=p_voice.staffscale}} 7725for(st=0;st<par_sy.staves.length;st++){sy_new.staves[st]=clone(par_sy.staves[st]);sy_new.staves[st].flags=0} 7726par_sy.next=sy_new;par_sy=sy_new} 7727Abc.prototype.set_bar_num=function(){var s,s2,tim,rep_tim,k,n,bar_num=gene.nbar,bar_tim=0,ptim=0,wmeasure=voice_tb[cur_sy.top_voice].meter.wmeasure 7728for(s=tsfirst;;s=s.ts_next){if(!s) 7729return 7730switch(s.type){case C.METER:wmeasure=s.wmeasure 7731case C.CLEF:case C.KEY:case C.STBRK:continue 7732case C.BAR:if(s.bar_num) 7733bar_num=s.bar_num 7734break} 7735break} 7736for(s2=s.ts_next;s2;s2=s2.ts_next){if(s2.type==C.BAR&&s2.time){if(s2.time<wmeasure){s=s2 7737bar_tim=s.time} 7738break}} 7739for(;s;s=s.ts_next){if(!s.seqst) 7740continue 7741switch(s.type){case C.METER:bar_num+=(s.time-bar_tim)/wmeasure 7742bar_tim=s.time 7743wmeasure=s.wmeasure 7744break 7745case C.BAR:if(s.invis) 7746break 7747tim=s.time 7748if(s.bar_num){bar_num=s.bar_num 7749ptim=bar_tim=tim 7750continue} 7751if(wmeasure==1){if(s.bar_dotted) 7752continue 7753if(s.text){if(!cfmt.contbarnb){if(s.text[0]=='1') 7754rep_tim=bar_num 7755else 7756bar_num=rep_tim}} 7757s.bar_num=++bar_num 7758continue} 7759n=bar_num+(tim-bar_tim)/wmeasure 7760k=n-(n|0) 7761if(cfmt.checkbars&&((k&&!s.bar_dotted&&s.next)||(tim>ptim+wmeasure&&s.prev.type!=C.MREST))) 7762error(0,s,"Bad measure duration") 7763if(tim>ptim+wmeasure){n|=0 7764k=0 7765bar_tim=tim 7766bar_num=n} 7767if(s.text){if(s.text[0]=='1'){if(cfmt.contbarnb) 7768rep_tim=bar_tim+k*wmeasure 7769else 7770rep_tim=tim 7771if(!k) 7772s.bar_num=n}else{if(cfmt.contbarnb) 7773bar_tim=rep_tim 7774else 7775bar_tim+=tim-rep_tim 7776n=bar_num+(tim-bar_tim)/wmeasure 7777if(n==(n|0)) 7778s.bar_num=n}}else{if(k) 7779n-=k 7780s.bar_num=n} 7781if(!k) 7782ptim=tim 7783break}}} 7784function not2abc(pit,acc){var i,nn='' 7785if(acc&&acc!=3){if(typeof acc=="number"){nn=['__','_','','^','^^'][acc+2]}else{i=acc[0] 7786if(i>0){nn+='^'}else{nn+='_' 7787i=-i} 7788nn+=i+'/'+acc[1]}} 7789nn+=ntb[(pit+75)%7] 7790for(i=pit;i>=21;i-=7) 7791nn+="'" 7792for(i=pit;i<14;i+=7) 7793nn+="," 7794return nn} 7795function get_map(text){if(!text) 7796return 7797var i,note,notes,map,tmp,ns,ty='',a=text.split(/\s+/) 7798if(a.length<3){syntax(1,not_enough_p) 7799return} 7800ns=a[1] 7801if(ns[0]=='*'||ns.indexOf("all")==0){ns='all'}else{if(ns.indexOf("octave,")==0||ns.indexOf("key,")==0){ty=ns[0] 7802ns=ns.split(',')[1] 7803ns=ns.replace(/[,']+/,'').toUpperCase() 7804if(ns.indexOf("key,")==0) 7805ns=ns.replace(/[=^_]+/,'')} 7806tmp=new scanBuf 7807tmp.buffer=ns 7808note=parse_acc_pit(tmp) 7809if(!note){syntax(1,"Bad note in %%map") 7810return} 7811ns=ty+not2abc(note.pit,note.acc)} 7812notes=maps[a[0]] 7813if(!notes) 7814maps[a[0]]=notes={} 7815map=notes[ns] 7816if(!map) 7817notes[ns]=map=[] 7818a.shift() 7819a.shift() 7820if(!a.length) 7821return 7822a=info_split(a.join(' ')) 7823i=0 7824if(a[0].indexOf('=')<0){if(a[0][0]!='*'){tmp=new scanBuf;tmp.buffer=a[0];map[1]=parse_acc_pit(tmp)} 7825if(!a[1]) 7826return 7827i++ 7828if(a[1].indexOf('=')<0){map[0]=a[1].split(',') 7829i++}} 7830for(;i<a.length;i++){switch(a[i]){case"heads=":if(!a[++i]){syntax(1,not_enough_p) 7831break} 7832map[0]=a[i].split(',') 7833break 7834case"print=":case"play=":if(!a[++i]){syntax(1,not_enough_p) 7835break} 7836tmp=new scanBuf;tmp.buffer=a[i];note=parse_acc_pit(tmp) 7837if(a[i-1][1]=='r') 7838map[1]=note 7839else 7840map[3]=note 7841break 7842case"color=":if(!a[++i]){syntax(1,not_enough_p) 7843break} 7844map[2]=a[i] 7845break}}} 7846function set_transp(){var s,transp,sndtran 7847if(curvoice.ckey.k_bagpipe||curvoice.ckey.k_drum) 7848return 7849if(cfmt.transp&&curvoice.shift) 7850syntax(0,"Mix of old and new transposition syntaxes");if(cfmt.transp!=undefined||curvoice.transp!=undefined||curvoice.shift!=undefined) 7851transp=(cfmt.transp||0)+ 7852(curvoice.transp||0)+ 7853(curvoice.shift||0) 7854if(curvoice.sndtran!=undefined||curvoice.sndsh!=undefined) 7855sndtran=(curvoice.sndtran||0)+ 7856(curvoice.sndsh||0) 7857if(transp==undefined){if(sndtran==undefined) 7858return}else{curvoice.vtransp=transp} 7859if(is_voice_sig()){curvoice.key=s=clone(curvoice.okey)}else{s=curvoice.last_sym 7860while(1){if(s.type==C.KEY) 7861break 7862s=s.prev 7863if(!s){s=curvoice.key 7864break}}} 7865if(transp!=undefined) 7866s.k_transp=transp 7867if(sndtran!=undefined) 7868s.k_sndtran=sndtran 7869curvoice.ckey=clone(s) 7870if(curvoice.key.k_none) 7871s.k_sf=0} 7872function note_transp(s,sk,note){var ak,an,d,b40,n=note.pit,a=note.acc 7873if(!a&&sk.k_a_acc) 7874a=sk.k_map[(n+19)%7] 7875b40=abc2svg.pab40(n,a)+sk.k_transp 7876note.pit=abc2svg.b40p(b40) 7877if(!a){if(!sk.k_a_acc&&!sk.k_none) 7878return} 7879an=abc2svg.b40a(b40) 7880if(a){if(sk.k_a_acc){ak=sk.k_map[(note.pit+19)%7] 7881if(ak==an) 7882an=0} 7883if(!an) 7884an=3}else if(sk.k_none){if(acc_same_pitch(s,note.pit)) 7885return}else if(sk.k_a_acc){if(acc_same_pitch(s,note.pit)) 7886return 7887ak=sk.k_map[(note.pit+19)%7] 7888if(ak) 7889an=3}else{return} 7890note.acc=an} 7891function pit_adj(){var i,p_v,s,sk,g,nv=voice_tb.length 7892while(--nv>=0){p_v=voice_tb[nv] 7893if(p_v.vtransp==undefined) 7894continue 7895if(p_v.key.k_transp){sk=p_v.key 7896key_transp(sk)}else{sk=null} 7897s=p_v.sym 7898while(s){if(!sk){for(;s;s=s.next){if(s.type==C.KEY&&s.k_transp) 7899break}} 7900for(;s;s=s.next){switch(s.type){case C.GRACE:for(g=s.extra;g;g=g.next){for(i=0;i<=g.nhd;i++) 7901note_transp(g,sk,g.notes[i])} 7902continue 7903case C.NOTE:for(i=0;i<=s.nhd;i++) 7904note_transp(s,sk,s.notes[i]) 7905continue 7906case C.KEY:if(sk) 7907s.k_sf=sk.k_sf 7908key_transp(s) 7909if(!s.k_transp) 7910break 7911sk=s 7912default:continue} 7913break} 7914sk=null}}} 7915function get_transp(param){if(param[0]=='0') 7916return 0 7917if("123456789-+".indexOf(param[0])>=0){var val=parseInt(param) 7918if(isNaN(val)||val<-36||val>36){syntax(1,errs.bad_transp) 7919return} 7920val+=36 7921return(((val/12)|0)-3)*40+ 7922(param.slice(-1)=='b'?abc2svg.ifb40:abc2svg.isb40)[val%12]}} 7923Abc.prototype.do_pscom=function(text){var h1,val,s,cmd,param,n,k,b 7924cmd=text.match(/(\w|-)+/) 7925if(!cmd) 7926return 7927cmd=cmd[0];if(curvoice&&curvoice.ignore){switch(cmd){case"staves":case"score":break 7928default:return}} 7929param=text.replace(cmd,'').trim() 7930if(param.slice(-5)==' lock'){fmt_lock[cmd]=true;param=param.slice(0,-5).trim()}else if(fmt_lock[cmd]){return} 7931if(cmd.slice(0,5)=="title"&&parse.state==2) 7932goto_tune() 7933switch(cmd){case"center":set_font("text") 7934if(parse.state>=2){s=new_block("text");s.text=param 7935s.opt='c' 7936s.font=gene.curfont 7937return} 7938write_text(param,'c') 7939return 7940case"clef":if(parse.state>=2){if(parse.state==2) 7941goto_tune();s=new_clef(param) 7942if(s) 7943get_clef(s)} 7944return 7945case"deco":deco_add(param) 7946return 7947case"linebreak":set_linebreak(param) 7948return 7949case"map":get_map(param) 7950return 7951case"maxsysstaffsep":if(parse.state==3){val=get_unit(param) 7952if(isNaN(val)){syntax(1,errs.bad_val,"%%maxsysstaffsep") 7953return} 7954par_sy.voices[curvoice.v].maxsep=val 7955return} 7956break 7957case"multicol":if(parse.state>=2){if(parse.state==2) 7958goto_tune() 7959curvoice=voice_tb[0] 7960s=new_block("mc_"+param) 7961break} 7962switch(param){case"start":multicol={maxy:0,lmarg:cfmt.leftmargin,rmarg:cfmt.rightmargin} 7963break 7964case"new":if(!multicol){syntax(1,"%%multicol new without start") 7965break} 7966if(posy>multicol.maxy) 7967multicol.maxy=posy;cfmt.leftmargin=multicol.lmarg;cfmt.rightmargin=multicol.rmarg;img.chg=true;set_page();posy=0 7968break 7969case"end":if(!multicol){syntax(1,"%%multicol end without start") 7970break} 7971if(posy<multicol.maxy) 7972posy=multicol.maxy;cfmt.leftmargin=multicol.lmarg;cfmt.rightmargin=multicol.rmarg;multicol=undefined;blk_flush();img.chg=true;set_page() 7973break 7974default:syntax(1,"Unknown keyword '$1' in %%multicol",param) 7975break} 7976return 7977case"ottava":if(parse.state!=3){if(parse.state!=2) 7978return 7979goto_tune()} 7980n=parseInt(param) 7981if(isNaN(n)||n<-2||n>2){syntax(1,errs.bad_val,"%%ottava") 7982return} 7983glovar.ottava=true;parse.ottava.push(n) 7984return 7985case"repbra":if(parse.state>=2){if(parse.state==2) 7986goto_tune();curvoice.norepbra=!get_bool(param)} 7987return 7988case"repeat":if(parse.state!=3) 7989return 7990if(!curvoice.last_sym){syntax(1,"%%repeat cannot start a tune") 7991return} 7992if(!param.length){n=1;k=1}else{b=param.split(/\s+/);n=parseInt(b[0]);k=parseInt(b[1]) 7993if(isNaN(n)||n<1||(curvoice.last_sym.type==C.BAR&&n>2)){syntax(1,"Incorrect 1st value in %%repeat") 7994return} 7995if(isNaN(k)){k=1}else{if(k<1){syntax(1,"Incorrect 2nd value in %%repeat") 7996return}}} 7997parse.repeat_n=curvoice.last_sym.type==C.BAR?n:-n;parse.repeat_k=k 7998return 7999case"sep":var h2,len,values,lwidth;set_page();lwidth=img.width-img.lm-img.rm;h1=h2=len=0 8000if(param){values=param.split(/\s+/);h1=get_unit(values[0]) 8001if(values[1]){h2=get_unit(values[1]) 8002if(values[2]) 8003len=get_unit(values[2])} 8004if(isNaN(h1)||isNaN(h2)||isNaN(len)){syntax(1,errs.bad_val,"%%sep") 8005return}} 8006if(h1<1) 8007h1=14 8008if(h2<1) 8009h2=h1 8010if(len<1) 8011len=90 8012if(parse.state>=2){s=new_block(cmd);s.x=(lwidth-len)/2/cfmt.scale;s.l=len/cfmt.scale;s.sk1=h1;s.sk2=h2 8013return} 8014vskip(h1);output+='<path class="stroke"\n\td="M';out_sxsy((lwidth-len)/2/cfmt.scale,' ',0);output+='h'+(len/cfmt.scale).toFixed(1)+'"/>\n';vskip(h2);blk_flush() 8015return 8016case"setbarnb":val=parseInt(param) 8017if(isNaN(val)||val<1){syntax(1,"Bad %%setbarnb value") 8018break} 8019if(parse.state==2) 8020goto_tune() 8021glovar.new_nbar=val 8022return 8023case"staff":if(parse.state!=3){if(parse.state!=2) 8024return 8025goto_tune()} 8026val=parseInt(param) 8027if(isNaN(val)){syntax(1,"Bad %%staff value '$1'",param) 8028return} 8029var st 8030if(param[0]=='+'||param[0]=='-') 8031st=curvoice.cst+val 8032else 8033st=val-1 8034if(st<0||st>nstaff){syntax(1,"Bad %%staff number $1 (cur $2, max $3)",st,curvoice.cst,nstaff) 8035return} 8036delete curvoice.floating;curvoice.cst=st 8037return 8038case"staffbreak":if(parse.state!=3){if(parse.state!=2) 8039return 8040goto_tune()} 8041s={type:C.STBRK,dur:0} 8042if(param.slice(-1)=='f'){s.stbrk_forced=true 8043param=param.replace(/\sf$/,'')} 8044if(param){val=get_unit(param) 8045if(isNaN(val)){syntax(1,errs.bad_val,"%%staffbreak") 8046return} 8047s.xmx=val}else{s.xmx=14} 8048sym_link(s) 8049return 8050case"stafflines":case"staffscale":case"staffnonote":set_v_param(cmd,param) 8051return 8052case"staves":case"score":if(parse.state==0) 8053return 8054if(parse.scores&&parse.scores.length>0){text=parse.scores.shift();cmd=text.match(/([^\s]+)\s*(.*)/);get_staves(cmd[1],cmd[2])}else{get_staves(cmd,param)} 8055return 8056case"sysstaffsep":if(parse.state==3){val=get_unit(param) 8057if(isNaN(val)){syntax(1,errs.bad_val,"%%sysstaffsep") 8058return} 8059par_sy.voices[curvoice.v].sep=val 8060return} 8061break 8062case"text":set_font("text") 8063if(parse.state>=2){s=new_block(cmd);s.text=param 8064s.opt=cfmt.textoption 8065s.font=gene.curfont 8066return} 8067write_text(param,cfmt.textoption) 8068return 8069case"transpose":if(cfmt.sound) 8070return 8071val=get_transp(param) 8072if(val==undefined){val=get_interval(param) 8073if(val==undefined){syntax(1,errs.bad_transp) 8074return}} 8075switch(parse.state){case 0:cfmt.transp=0 8076case 1:case 2:cfmt.transp=(cfmt.transp||0)+val 8077return} 8078for(s=curvoice.last_sym;s;s=s.prev){switch(s.type){case C.NOTE:s=clone(curvoice.okey);s.k_old_sf=curvoice.ckey.k_sf;sym_link(s) 8079break 8080case C.KEY:break 8081default:continue} 8082break} 8083curvoice.transp=val 8084set_transp() 8085return 8086case"tune":return 8087case"user":set_user(param) 8088return 8089case"voicecolor":if(parse.state!=3){if(parse.state!=2) 8090return 8091goto_tune()} 8092curvoice.color=param 8093return 8094case"vskip":val=get_unit(param) 8095if(isNaN(val)){syntax(1,errs.bad_val,"%%vskip") 8096return} 8097if(val<0){syntax(1,"%%vskip cannot be negative") 8098return} 8099if(parse.state>=2){s=new_block(cmd);s.sk=val 8100return} 8101vskip(val);return 8102case"newpage":case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"printmargin":case"scale":case"staffwidth":if(parse.state>=2){s=new_block(cmd);s.param=param 8103return} 8104if(cmd=="newpage"){blk_flush() 8105if(user.page_format) 8106blkdiv=2 8107return} 8108break} 8109self.set_format(cmd,param)} 8110Abc.prototype.do_begin_end=function(type,opt,text){var i,j,action,s 8111switch(type){case"js":js_inject(text) 8112break 8113case"ml":if(parse.state>=2){s=new_block(type);s.text=text}else{blk_flush() 8114if(user.img_out) 8115user.img_out(text)} 8116break 8117case"svg":j=0 8118while(1){i=text.indexOf('<style',j) 8119if(i<0) 8120break 8121i=text.indexOf('>',i) 8122j=text.indexOf('</style>',i) 8123if(j<0){syntax(1,"No </style> in %%beginsvg sequence") 8124break} 8125style+=text.slice(i+1,j).replace(/\s+$/,'')} 8126j=0 8127while(1){i=text.indexOf('<defs>\n',j) 8128if(i<0) 8129break 8130j=text.indexOf('</defs>',i) 8131if(j<0){syntax(1,"No </defs> in %%beginsvg sequence") 8132break} 8133defs_add(text.slice(i+6,j))} 8134break 8135case"text":action=get_textopt(opt);if(!action) 8136action=cfmt.textoption 8137set_font("text") 8138if(parse.state>=2){s=new_block(type);s.text=text 8139s.opt=action 8140s.font=gene.curfont 8141break} 8142write_text(text,action) 8143break}} 8144function generate(in_mc){var s,v,p_voice;if(parse.tp){syntax(1,"No end of tuplet") 8145s=parse.tps 8146if(s) 8147delete s.tp 8148delete parse.tp} 8149if(vover){syntax(1,"No end of voice overlay");get_vover(vover.bar?'|':')')} 8150if(!voice_tb.length) 8151return 8152voice_adj();sort_all() 8153if(!tsfirst) 8154return 8155self.set_bar_num() 8156pit_adj() 8157if(info.P) 8158tsfirst.parts=info.P 8159if(user.get_abcmodel) 8160user.get_abcmodel(tsfirst,voice_tb,abc2svg.sym_name,info) 8161if(user.img_out) 8162self.output_music() 8163if(tsfirst) 8164tunes.push([tsfirst,voice_tb,info,cfmt]) 8165if(!in_mc) 8166return 8167voice_tb=Object.create(voice_tb) 8168for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v];p_voice.time=0;p_voice.sym=p_voice.last_sym=null;delete p_voice.have_ly;p_voice.sls=[];p_voice.hy_st=0;delete p_voice.bar_start} 8169staves_found=0} 8170function key_transp(sk){if(sk.k_a_acc||sk.k_none) 8171return 8172var d,k_b40=sk.k_b40,n_b40=(k_b40+200+sk.k_transp)%40 8173d=abc2svg.b40k[n_b40]-n_b40 8174if(d){if(sk.k_transp>0) 8175sk.k_transp+=d 8176else 8177sk.k_transp-=d 8178n_b40+=d} 8179sk.k_b40=n_b40 8180var sf=abc2svg.b40sf[n_b40] 8181sk.k_old_sf=sk.k_sf 8182sk.k_sf=sf 8183sk.k_map=abc2svg.keys[sf+7]} 8184function acc_same_pitch(s,pit){var i,time=s.time 8185for(s=s.prev;s;s=s.prev){switch(s.type){case C.BAR:if(s.time<time) 8186return 8187while(1){s=s.prev 8188if(!s) 8189return 8190if(s.type==C.NOTE){if(s.time+s.dur==time) 8191break 8192return} 8193if(s.time<time) 8194return} 8195for(i=0;i<=s.nhd;i++){if(s.notes[i].pit==pit&&s.notes[i].tie_ty) 8196return s.notes[i].acc} 8197return 8198case C.NOTE:for(i=0;i<=s.nhd;i++){if(s.notes[i].pit==pit) 8199return s.notes[i].acc} 8200break}} 8201return} 8202function get_staves(cmd,parm){var s,p_voice,p_voice2,i,flags,v,vid,st,range,a_vf=parse_staves(parm) 8203if(!a_vf) 8204return 8205if(voice_tb.length) 8206voice_adj(true);var maxtime=0,no_sym=true 8207for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 8208if(p_voice.time>maxtime) 8209maxtime=p_voice.time 8210if(p_voice.sym) 8211no_sym=false} 8212if(no_sym||(maxtime==0&&staves_found<0)){par_sy.staves=[] 8213par_sy.voices=[]}else{for(v=0;v<par_sy.voices.length;v++){if(par_sy.voices[v]){curvoice=voice_tb[v] 8214break}} 8215curvoice.time=maxtime;s={type:C.STAVES,dur:0} 8216sym_link(s);par_sy.nstaff=nstaff;new_syst();s.sy=par_sy} 8217staves_found=maxtime 8218for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 8219delete p_voice.second 8220delete p_voice.ignore 8221delete p_voice.floating} 8222range=0 8223for(i=0;i<a_vf.length;i++){vid=a_vf[i][0];p_voice=new_voice(vid);p_voice.time=maxtime;v=p_voice.v 8224a_vf[i][0]=p_voice;while(1){par_sy.voices[v]={} 8225par_sy.voices[v].range=range++ 8226p_voice=p_voice.voice_down 8227if(!p_voice) 8228break 8229v=p_voice.v}} 8230par_sy.top_voice=a_vf[0][0].v 8231if(cmd[1]=='t'){for(i=0;i<a_vf.length;i++){flags=a_vf[i][1] 8232if(!(flags&(OPEN_BRACE|OPEN_BRACE2))) 8233continue 8234if((flags&(OPEN_BRACE|CLOSE_BRACE))==(OPEN_BRACE|CLOSE_BRACE)||(flags&(OPEN_BRACE2|CLOSE_BRACE2))==(OPEN_BRACE2|CLOSE_BRACE2)) 8235continue 8236if(a_vf[i+1][1]!=0) 8237continue 8238if((flags&OPEN_PARENTH)||(a_vf[i+2][1]&OPEN_PARENTH)) 8239continue 8240if(a_vf[i+2][1]&(CLOSE_BRACE|CLOSE_BRACE2)){a_vf[i+1][1]|=FL_VOICE}else if(a_vf[i+2][1]==0&&(a_vf[i+3][1]&(CLOSE_BRACE|CLOSE_BRACE2))){a_vf[i][1]|=OPEN_PARENTH;a_vf[i+1][1]|=CLOSE_PARENTH;a_vf[i+2][1]|=OPEN_PARENTH;a_vf[i+3][1]|=CLOSE_PARENTH}}} 8241st=-1 8242for(i=0;i<a_vf.length;i++){flags=a_vf[i][1] 8243if((flags&(OPEN_PARENTH|CLOSE_PARENTH))==(OPEN_PARENTH|CLOSE_PARENTH)){flags&=~(OPEN_PARENTH|CLOSE_PARENTH);a_vf[i][1]=flags} 8244p_voice=a_vf[i][0] 8245if(flags&FL_VOICE){p_voice.floating=true;p_voice.second=true}else{st++;if(!par_sy.staves[st]){par_sy.staves[st]={stafflines:p_voice.stafflines||"|||||",staffscale:1}} 8246par_sy.staves[st].flags=0} 8247v=p_voice.v;p_voice.st=p_voice.cst=par_sy.voices[v].st=st;par_sy.staves[st].flags|=flags 8248if(flags&OPEN_PARENTH){p_voice2=p_voice 8249while(i<a_vf.length-1){p_voice=a_vf[++i][0];v=p_voice.v 8250if(a_vf[i][1]&MASTER_VOICE){p_voice2.second=true 8251p_voice2=p_voice}else{p_voice.second=true} 8252p_voice.st=p_voice.cst=par_sy.voices[v].st=st 8253if(a_vf[i][1]&CLOSE_PARENTH) 8254break} 8255par_sy.staves[st].flags|=a_vf[i][1]}} 8256if(st<0) 8257st=0 8258par_sy.nstaff=nstaff=st 8259if(cmd[1]=='c'){for(st=0;st<nstaff;st++) 8260par_sy.staves[st].flags^=STOP_BAR} 8261for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 8262if(!par_sy.voices[v]) 8263continue 8264p_voice2=p_voice.voice_down 8265while(p_voice2){i=p_voice2.v 8266p_voice2.st=p_voice2.cst=par_sy.voices[i].st=st 8267p_voice2=p_voice2.voice_down} 8268par_sy.voices[v].second=p_voice.second;st=p_voice.st 8269if(st>0&&!p_voice.norepbra&&!(par_sy.staves[st-1].flags&STOP_BAR)) 8270p_voice.norepbra=true} 8271curvoice=parse.state>=2?voice_tb[par_sy.top_voice]:null} 8272function clone_voice(id){var v,p_voice 8273for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v] 8274if(p_voice.id==id) 8275return p_voice} 8276p_voice=clone(curvoice);p_voice.v=voice_tb.length;p_voice.id=id;p_voice.sym=p_voice.last_sym=null;p_voice.key=clone(curvoice.key) 8277p_voice.sls=[] 8278delete p_voice.nm 8279delete p_voice.snm 8280delete p_voice.new_name 8281delete p_voice.lyric_restart 8282delete p_voice.lyric_cont 8283delete p_voice.ly_a_h;delete p_voice.sym_restart 8284delete p_voice.sym_cont 8285delete p_voice.have_ly 8286delete p_voice.tie_s 8287voice_tb.push(p_voice) 8288return p_voice} 8289function get_vover(type){var p_voice2,p_voice3,range,s,time,v,v2,v3,line=parse.line 8290if(type=='|'||type==')'){if(!curvoice.last_note){syntax(1,errs.nonote_vo) 8291return} 8292curvoice.last_note.beam_end=true 8293if(!vover){syntax(1,"Erroneous end of voice overlay") 8294return} 8295if(curvoice.time!=vover.p_voice.time){syntax(1,"Wrong duration in voice overlay");if(curvoice.time>vover.p_voice.time) 8296vover.p_voice.time=curvoice.time} 8297curvoice.acc=[] 8298curvoice=vover.p_voice;vover=null 8299return} 8300if(type=='('){if(vover){syntax(1,"Voice overlay already started") 8301return} 8302vover={p_voice:curvoice,time:curvoice.time} 8303return} 8304if(!curvoice.last_note){syntax(1,errs.nonote_vo) 8305return} 8306curvoice.last_note.beam_end=true;p_voice2=curvoice.voice_down 8307if(!p_voice2){p_voice2=clone_voice(curvoice.id+'o');curvoice.voice_down=p_voice2;p_voice2.time=0;p_voice2.second=true;v2=p_voice2.v;par_sy.voices[v2]={st:curvoice.st,second:true} 8308range=par_sy.voices[curvoice.v].range 8309for(v=0;v<par_sy.voices.length;v++){if(par_sy.voices[v]&&par_sy.voices[v].range>range) 8310par_sy.voices[v].range++} 8311par_sy.voices[v2].range=range+1} 8312p_voice2.ulen=curvoice.ulen 8313p_voice2.dur_fact=curvoice.dur_fact 8314p_voice2.acc=[] 8315if(!vover){vover={bar:true,p_voice:curvoice} 8316time=p_voice2.time 8317for(s=curvoice.last_sym;;s=s.prev){if(s.type==C.BAR||s.time<=time) 8318break} 8319vover.time=s.time}else{if(curvoice!=vover.p_voice&&curvoice.time!=vover.p_voice.time){syntax(1,"Wrong duration in voice overlay") 8320if(curvoice.time>vover.p_voice.time) 8321vover.p_voice.time=curvoice.time}} 8322p_voice2.time=vover.time;curvoice=p_voice2 8323if(vover.bar){sym_link({type:C.BAR,bar_type:type,dur:0,multi:0})}} 8324function is_voice_sig(){var s 8325if(curvoice.time!=0) 8326return false 8327for(s=curvoice.last_sym;s;s=s.prev) 8328if(w_tb[s.type]!=0) 8329return false 8330return true} 8331function get_clef(s){if(is_voice_sig()){curvoice.clef=s 8332return} 8333sym_link(s);s.clef_small=true 8334var s2=s.prev 8335if(s2&&s2.type==C.BAR&&s2.bar_type[0]!=':'){s.next=s2 8336s.prev=s2.prev 8337if(s.prev) 8338s.prev.next=s 8339s2.prev=s 8340s2.next=null 8341curvoice.last_sym=s2 8342if(s.soln){delete s.soln 8343curvoice.eoln=true}}} 8344function get_key(parm){var v,p_voice,s,transp,sndtran,a=new_key(parm),s_key=a[0];a=a[1] 8345switch(parse.state){case 1:if(s_key.k_sf==undefined&&!s_key.k_a_acc){s_key.k_sf=0;s_key.k_none=true 8346s_key.k_map=abc2svg.keys[7]} 8347for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v];p_voice.key=clone(s_key);p_voice.okey=clone(s_key);p_voice.ckey=clone(s_key)} 8348parse.ckey=s_key 8349if(a.length) 8350memo_kv_parm('*',a) 8351if(!glovar.ulen) 8352glovar.ulen=C.BLEN/8;parse.state=2;return 8353case 2:goto_tune(true) 8354break} 8355if(a.length) 8356set_kv_parm(a) 8357if(!curvoice.ckey.k_bagpipe&&!curvoice.ckey.k_drum&&(cfmt.transp!=undefined||curvoice.transp!=undefined||curvoice.shift!=undefined)) 8358transp=(cfmt.transp||0)+ 8359(curvoice.transp||0)+ 8360(curvoice.shift||0) 8361if(curvoice.sndtran!=undefined||curvoice.sndsh!=undefined) 8362sndtran=(curvoice.sndtran||0)+ 8363(curvoice.sndsh||0) 8364if(s_key.k_sf==undefined){if(!s_key.k_a_acc&&transp==undefined){if(sndtran==undefined) 8365return 8366s_key.k_play=true} 8367s_key.k_sf=curvoice.okey.k_sf} 8368curvoice.okey=clone(s_key) 8369if(transp!=undefined){curvoice.vtransp=transp;s_key.k_transp=transp} 8370if(sndtran!=undefined) 8371s_key.k_sndtran=sndtran 8372s_key.k_old_sf=curvoice.ckey.k_sf;if(!s_key.k_b40) 8373s_key.k_b40=curvoice.ckey.k_b40 8374curvoice.ckey=s_key 8375if(is_voice_sig()){curvoice.key=clone(s_key) 8376if(s_key.k_none) 8377curvoice.key.k_sf=0}else{sym_link(s_key)}} 8378function new_voice(id){var p_voice,v,p_v_sav,n=voice_tb.length 8379if(n==1&&voice_tb[0].default){delete voice_tb[0].default 8380if(voice_tb[0].time==0){p_voice=voice_tb[0];p_voice.id=id 8381if(cfmt.transp&&parse.state>=2){p_v_sav=curvoice;curvoice=p_voice;set_transp();curvoice=p_v_sav} 8382return p_voice}} 8383for(v=0;v<n;v++){p_voice=voice_tb[v] 8384if(p_voice.id==id) 8385return p_voice} 8386p_voice={v:v,id:id,time:0,new:true,pos:{dyn:0,gch:0,gst:0,orn:0,stm:0,voc:0,vol:0},scale:1,ulen:glovar.ulen,dur_fact:1,key:clone(parse.ckey),ckey:clone(parse.ckey),okey:clone(parse.ckey),meter:clone(glovar.meter),wmeasure:glovar.meter.wmeasure,staffnonote:1,clef:{type:C.CLEF,clef_auto:true,clef_type:"a",time:0},acc:[],sls:[],hy_st:0} 8387voice_tb.push(p_voice);return p_voice} 8388function init_tune(){nstaff=-1;voice_tb=[];curvoice=null;new_syst(true);staves_found=-1;gene={} 8389a_de=[]} 8390function do_cloning(){var i,clone=curvoice.clone,vs=clone.vs,a=clone.a,bol=clone.bol,eol=parse.istart,parse_sav=parse,file=parse.file 8391delete curvoice.clone 8392if(file[eol-1]=='[') 8393eol-- 8394include++;for(i=0;i<vs.length;i++){parse=Object.create(parse_sav) 8395parse.line=Object.create(parse_sav.line) 8396get_voice(vs[i],a) 8397tosvg(parse.fname,file,bol,eol)} 8398include-- 8399parse=parse_sav} 8400function get_voice(parm){var v,vs,a=info_split(parm),vid=a.shift() 8401if(!vid) 8402return 8403if(curvoice&&curvoice.clone) 8404do_cloning() 8405if(vid.indexOf(',')>0) 8406vs=vid.split(',') 8407else 8408vs=[vid] 8409if(parse.state<2){while(1){vid=vs.shift() 8410if(!vid) 8411break 8412if(a.length) 8413memo_kv_parm(vid,a) 8414if(vid!='*'&&parse.state==1) 8415curvoice=new_voice(vid)} 8416return} 8417if(vid=='*'){syntax(1,"Cannot have V:* in tune body") 8418return} 8419curvoice=new_voice(vs[0]) 8420if(vs.length>1){vs.shift() 8421curvoice.clone={vs:vs,a:a,bol:parse.iend} 8422if(parse.file[curvoice.clone.bol-1]!=']') 8423curvoice.clone.bol++} 8424set_kv_parm(a) 8425if(parse.state==2) 8426goto_tune();set_transp();v=curvoice.v 8427if(curvoice.new){delete curvoice.new 8428if(staves_found<0){curvoice.st=curvoice.cst=++nstaff;par_sy.nstaff=nstaff;par_sy.voices[v]={st:nstaff,range:v} 8429par_sy.staves[nstaff]={stafflines:curvoice.stafflines||"|||||",staffscale:1}}} 8430if(!curvoice.filtered&&par_sy.voices[v]&&(parse.voice_opts||parse.tune_v_opts)){curvoice.filtered=true;voice_filter()}} 8431function goto_tune(is_K){var v,p_voice,s={type:C.STAVES,dur:0,sy:par_sy} 8432set_page();write_heading();reset_gen();if(glovar.new_nbar){gene.nbar=glovar.new_nbar 8433glovar.new_nbar=0}else{gene.nbar=1} 8434parse.state=3;if(!voice_tb.length){get_voice("1");curvoice.clef.istart=curvoice.key.istart;curvoice.clef.iend=curvoice.key.iend;curvoice.default=true}else if(!curvoice){curvoice=voice_tb[staves_found<0?0:par_sy.top_voice]} 8435if(!curvoice.init&&!is_K){set_kv_parm([]) 8436set_transp()} 8437for(v=0;v<voice_tb.length;v++){p_voice=voice_tb[v];p_voice.ulen=glovar.ulen 8438if(p_voice.ckey.k_bagpipe&&!p_voice.pos.stm){p_voice.pos=clone(p_voice.pos);p_voice.pos.stm=C.SL_BELOW}} 8439if(staves_found<0){nstaff=voice_tb.length-1 8440for(v=0;v<=nstaff;v++){p_voice=voice_tb[v];delete p_voice.new;p_voice.st=p_voice.cst=v;par_sy.voices[v]={st:v,range:v} 8441par_sy.staves[v]={stafflines:p_voice.stafflines||"|||||",staffscale:1}} 8442par_sy.nstaff=nstaff} 8443p_voice=curvoice;curvoice=voice_tb[par_sy.top_voice];sym_link(s) 8444curvoice=p_voice} 8445function get_sym(p,cont){var s,c,i,j,d 8446if(curvoice.ignore) 8447return 8448if(cont){s=curvoice.sym_cont 8449if(!s){syntax(1,"+: symbol line without music") 8450return}}else{if(curvoice.sym_restart){curvoice.sym_start=s=curvoice.sym_restart;curvoice.sym_restart=null}else{s=curvoice.sym_start} 8451if(!s) 8452s=curvoice.sym 8453if(!s){syntax(1,"s: without music") 8454return}} 8455i=0 8456while(1){while(p[i]==' '||p[i]=='\t') 8457i++;c=p[i] 8458if(!c) 8459break 8460switch(c){case'|':while(s&&s.type!=C.BAR) 8461s=s.next 8462if(!s){syntax(1,"Not enough measure bars for symbol line") 8463return} 8464s=s.next;i++ 8465continue 8466case'!':case'"':j=++i 8467i=p.indexOf(c,j) 8468if(i<0){syntax(1,c=='!'?"No end of decoration":"No end of guitar chord");i=p.length 8469continue} 8470d=p.slice(j-1,i+1) 8471break 8472case'*':break 8473default:d=c.charCodeAt(0) 8474if(d<128){d=char_tb[d] 8475if(d.length>1&&(d[0]=='!'||d[0]=='"')){c=d[0] 8476break}} 8477syntax(1,errs.bad_char,c) 8478break} 8479while(s&&(s.type!=C.NOTE||s.grace)) 8480s=s.next 8481if(!s){syntax(1,"Too many elements in symbol line") 8482return} 8483switch(c){default:break 8484case'!':deco_cnv([d.slice(1,-1)],s,s.prev) 8485break 8486case'"':parse_gchord(d) 8487if(a_gch) 8488csan_add(s) 8489break} 8490s=s.next;i++} 8491curvoice.lyric_cont=s} 8492function get_lyrics(text,cont){var s,word,p,i,j,ly,dfnt 8493if(curvoice.ignore) 8494return 8495if(curvoice.pos.voc!=C.SL_HIDDEN) 8496curvoice.have_ly=true 8497if(cont){s=curvoice.lyric_cont 8498if(!s){syntax(1,"+: lyric without music") 8499return}}else{set_font("vocal") 8500if(curvoice.lyric_restart){curvoice.lyric_start=s=curvoice.lyric_restart;curvoice.lyric_restart=null;curvoice.lyric_line=0}else{curvoice.lyric_line++;s=curvoice.lyric_start} 8501if(!s) 8502s=curvoice.sym 8503if(!s){syntax(1,"w: without music") 8504return}} 8505dfnt=gene.curfont 8506p=text;i=0 8507while(1){while(p[i]==' '||p[i]=='\t') 8508i++ 8509if(!p[i]) 8510break 8511j=parse.istart+i+2 8512switch(p[i]){case'|':while(s&&s.type!=C.BAR) 8513s=s.next 8514if(!s){syntax(1,"Not enough measure bars for lyric line") 8515return} 8516s=s.next;i++ 8517continue 8518case'-':word="-\n" 8519break 8520case'_':word="_\n" 8521break 8522case'*':word="" 8523break 8524default:if(p[i]=='\\'&&i==p.length-1){curvoice.lyric_cont=s 8525return} 8526word="";while(1){if(!p[i]) 8527break 8528switch(p[i]){case'_':case'*':case'|':i-- 8529case' ':case'\t':break 8530case'~':word+=' ';i++ 8531continue 8532case'-':word+="\n" 8533break 8534case'\\':word+=p[++i];i++ 8535continue 8536default:word+=p[i++] 8537continue} 8538break} 8539break} 8540while(s&&(s.type!=C.NOTE||s.grace)) 8541s=s.next 8542if(!s){syntax(1,"Too many words in lyric line") 8543return} 8544if(word&&s.pos.voc!=C.SL_HIDDEN){if(word.match(/^\$\d/)){gene.curfont=word[1]=='0'?dfnt:get_font("u"+word[1]) 8545word=word.slice(2)} 8546ly={t:word,font:gene.curfont,wh:strwh(word),istart:j,iend:j+word.length} 8547if(!s.a_ly) 8548s.a_ly=[] 8549s.a_ly[curvoice.lyric_line]=ly} 8550s=s.next;i++} 8551curvoice.lyric_cont=s} 8552function ly_width(s,wlw){var ly,sz,swfac,align,xx,w,i,j,k,shift,p,a_ly=s.a_ly;align=0 8553for(i=0;i<a_ly.length;i++){ly=a_ly[i] 8554if(!ly) 8555continue 8556p=ly.t;if(p=="-\n"||p=="_\n"){ly.shift=0 8557continue} 8558w=ly.wh[0];swfac=ly.font.swfac;xx=w+2*cwid(' ')*swfac 8559if(s.type==C.GRACE){shift=s.wl}else if((p[0]>='0'&&p[0]<='9'&&p.length>2)||p[1]==':'||p[0]=='('||p[0]==')'){if(p[0]=='('){sz=cwid('(')*swfac}else{j=p.indexOf(' ');set_font(ly.font) 8560if(j>0) 8561sz=strwh(p.slice(0,j))[0] 8562else 8563sz=w*.2} 8564shift=(w-sz+2*cwid(' ')*swfac)*.4 8565if(shift>20) 8566shift=20;shift+=sz 8567if(ly.t[0]>='0'&&ly.t[0]<='9'){if(shift>align) 8568align=shift}}else{shift=xx*.4 8569if(shift>20) 8570shift=20} 8571ly.shift=shift 8572if(wlw<shift) 8573wlw=shift;xx-=shift;shift=2*cwid(' ')*swfac 8574for(k=s.next;k;k=k.next){switch(k.type){case C.NOTE:case C.REST:if(!k.a_ly||!k.a_ly[i]) 8575xx-=9 8576else if(k.a_ly[i].t=="-\n"||k.a_ly[i].t=="_\n") 8577xx-=shift 8578else 8579break 8580if(xx<=0) 8581break 8582continue 8583case C.CLEF:case C.METER:case C.KEY:xx-=10 8584continue 8585default:xx-=5 8586break} 8587break} 8588if(xx>s.wr) 8589s.wr=xx} 8590if(align>0){for(i=0;i<a_ly.length;i++){ly=a_ly[i] 8591if(ly&&ly.t[0]>='0'&&ly.t[0]<='9') 8592ly.shift=align}} 8593return wlw} 8594function draw_lyric_line(p_voice,j,y){var p,lastx,w,s,s2,ly,lyl,hyflag,lflag,x0,font,shift 8595if(p_voice.hy_st&(1<<j)){hyflag=true;p_voice.hy_st&=~(1<<j)} 8596for(s=p_voice.sym;;s=s.next) 8597if(s.type!=C.CLEF&&s.type!=C.KEY&&s.type!=C.METER) 8598break 8599lastx=s.prev?s.prev.x:tsfirst.x;x0=0 8600for(;s;s=s.next){if(s.a_ly) 8601ly=s.a_ly[j] 8602else 8603ly=null 8604if(!ly){switch(s.type){case C.REST:case C.MREST:if(lflag){out_wln(lastx+3,y,x0-lastx);lflag=false;lastx=s.x+s.wr}} 8605continue} 8606if(ly.font!=gene.curfont) 8607gene.curfont=font=ly.font;p=ly.t;w=ly.wh[0];shift=ly.shift 8608if(hyflag){if(p=="_\n"){p="-\n"}else if(p!="-\n"){out_hyph(lastx,y,s.x-shift-lastx);hyflag=false;lastx=s.x+s.wr}} 8609if(lflag&&p!="_\n"){out_wln(lastx+3,y,x0-lastx+3);lflag=false;lastx=s.x+s.wr} 8610if(p=="-\n"||p=="_\n"){if(x0==0&&lastx>s.x-18) 8611lastx=s.x-18 8612if(p[0]=='-') 8613hyflag=true 8614else 8615lflag=true;x0=s.x-shift 8616continue} 8617x0=s.x-shift;if(p.slice(-1)=='\n'){p=p.slice(0,-1);hyflag=true} 8618if(user.anno_start||user.anno_stop){s2={st:s.st,istart:ly.istart,iend:ly.iend,x:x0,y:y,ymn:y,ymx:y+gene.curfont.size,wl:0,wr:w} 8619anno_start(s2,'lyrics')} 8620xy_str(x0,y,p,null,null,ly.wh);anno_stop(s2,'lyrics') 8621lastx=x0+w} 8622if(hyflag){hyflag=false;x0=realwidth-10 8623if(x0<lastx+10) 8624x0=lastx+10;out_hyph(lastx,y,x0-lastx) 8625if(cfmt.hyphencont) 8626p_voice.hy_st|=(1<<j)} 8627for(p_voice.s_next;s;s=s.next){if(s.type==C.NOTE){if(!s.a_ly) 8628break 8629ly=s.a_ly[j] 8630if(ly&&ly.t=="_\n"){lflag=true;x0=realwidth-15 8631if(x0<lastx+12) 8632x0=lastx+12} 8633break}} 8634if(lflag){out_wln(lastx+3,y,x0-lastx+3);lflag=false}} 8635function draw_lyrics(p_voice,nly,a_h,y,incr){var j,top,sc=staff_tb[p_voice.st].staffscale;set_font("vocal") 8636if(incr>0){if(y>-cfmt.vocalspace) 8637y=-cfmt.vocalspace;y*=sc 8638for(j=0;j<nly;j++){y-=a_h[j]*1.1;draw_lyric_line(p_voice,j,y)} 8639return(y-a_h[j-1]/6)/sc} 8640top=staff_tb[p_voice.st].topbar+cfmt.vocalspace 8641if(y<top) 8642y=top;y*=sc 8643for(j=nly;--j>=0;){draw_lyric_line(p_voice,j,y);y+=a_h[j]*1.1} 8644return y/sc} 8645function draw_all_lyrics(){var p_voice,s,v,nly,i,x,y,w,a_ly,ly,lyst_tb=new Array(nstaff+1),nv=voice_tb.length,h_tb=new Array(nv),nly_tb=new Array(nv),above_tb=new Array(nv),rv_tb=new Array(nv),top=0,bot=0,st=-1 8646for(v=0;v<nv;v++){p_voice=voice_tb[v] 8647if(!p_voice.sym) 8648continue 8649if(p_voice.st!=st){top=0;bot=0;st=p_voice.st} 8650nly=0 8651if(p_voice.have_ly){if(!h_tb[v]) 8652h_tb[v]=[] 8653for(s=p_voice.sym;s;s=s.next){a_ly=s.a_ly 8654if(!a_ly) 8655continue 8656x=s.x;w=10 8657for(i=0;i<a_ly.length;i++){ly=a_ly[i] 8658if(ly){x-=ly.shift;w=ly.wh[0] 8659break}} 8660y=y_get(p_voice.st,1,x,w) 8661if(top<y) 8662top=y;y=y_get(p_voice.st,0,x,w) 8663if(bot>y) 8664bot=y 8665while(nly<a_ly.length) 8666h_tb[v][nly++]=0 8667for(i=0;i<a_ly.length;i++){ly=a_ly[i] 8668if(!ly) 8669continue 8670if(!h_tb[v][i]||ly.font.size>h_tb[v][i]) 8671h_tb[v][i]=ly.font.size}}}else{y=y_get(p_voice.st,1,0,realwidth) 8672if(top<y) 8673top=y;y=y_get(p_voice.st,0,0,realwidth) 8674if(bot>y) 8675bot=y} 8676if(!lyst_tb[st]) 8677lyst_tb[st]={} 8678lyst_tb[st].top=top;lyst_tb[st].bot=bot;nly_tb[v]=nly 8679if(nly==0) 8680continue 8681if(p_voice.pos.voc) 8682above_tb[v]=p_voice.pos.voc==C.SL_ABOVE 8683else if(voice_tb[v+1]&&voice_tb[v+1].st==st&&voice_tb[v+1].have_ly) 8684above_tb[v]=true 8685else 8686above_tb[v]=false 8687if(above_tb[v]) 8688lyst_tb[st].a=true 8689else 8690lyst_tb[st].b=true} 8691i=0 8692for(v=0;v<nv;v++){p_voice=voice_tb[v] 8693if(!p_voice.sym) 8694continue 8695if(!p_voice.have_ly) 8696continue 8697if(above_tb[v]){rv_tb[i++]=v 8698continue} 8699st=p_voice.st;set_dscale(st,true) 8700if(nly_tb[v]>0) 8701lyst_tb[st].bot=draw_lyrics(p_voice,nly_tb[v],h_tb[v],lyst_tb[st].bot,1)} 8702while(--i>=0){v=rv_tb[i];p_voice=voice_tb[v];st=p_voice.st;set_dscale(st,true);lyst_tb[st].top=draw_lyrics(p_voice,nly_tb[v],h_tb[v],lyst_tb[st].top,-1)} 8703for(v=0;v<nv;v++){p_voice=voice_tb[v] 8704if(!p_voice.sym) 8705continue 8706st=p_voice.st;if(lyst_tb[st].a){top=lyst_tb[st].top+2 8707for(s=p_voice.sym.next;s;s=s.next){if(s.a_ly){y_set(st,1,s.x-2,10,top)}}} 8708if(lyst_tb[st].b){bot=lyst_tb[st].bot-2 8709if(nly_tb[p_voice.v]>0){for(s=p_voice.sym.next;s;s=s.next){if(s.a_ly){y_set(st,0,s.x-2,10,bot)}}}else{y_set(st,0,0,realwidth,bot)}}}} 8710function parse_gchord(type){var c,text,gch,x_abs,y_abs,type,i,j,istart,iend,ann_font=get_font("annotation"),h_ann=ann_font.size,line=parse.line 8711function get_float(){var txt='' 8712while(1){c=text[i++] 8713if("1234567890.-".indexOf(c)<0) 8714return parseFloat(txt) 8715txt+=c}} 8716istart=parse.bol+line.index 8717if(type.length>1){text=type.slice(1,-1);iend=istart+1}else{i=++line.index 8718while(1){j=line.buffer.indexOf('"',i) 8719if(j<0){syntax(1,"No end of guitar chord") 8720return} 8721if(line.buffer[j-1]!='\\') 8722break 8723i=j+1} 8724text=cnv_escape(line.buffer.slice(line.index,j)) 8725line.index=j 8726iend=parse.bol+line.index+1} 8727if(ann_font.pad) 8728h_ann+=ann_font.pad 8729i=0;type='g' 8730while(1){c=text[i] 8731if(!c) 8732break 8733gch={text:"",istart:istart,iend:iend,font:ann_font} 8734switch(c){case'@':type=c;i++;x_abs=get_float() 8735if(c!=','){syntax(1,"',' lacking in annotation '@x,y'");y_abs=0}else{y_abs=get_float() 8736if(c!=' ') 8737i--} 8738gch.x=x_abs;gch.y=y_abs-h_ann/2 8739break 8740case'^':case'_':case'<':case'>':i++;type=c 8741break 8742default:switch(type){case'g':gch.font=get_font("gchord") 8743break 8744case'@':gch.x=x_abs;y_abs-=h_ann;gch.y=y_abs-h_ann/2 8745break} 8746break} 8747gch.type=type 8748while(1){c=text[i] 8749if(!c) 8750break 8751switch(c){case'\\':c=text[++i] 8752if(!c||c=='n') 8753break 8754gch.text+='\\' 8755default:gch.text+=c;i++ 8756continue 8757case'&':while(1){gch.text+=c;c=text[++i] 8758switch(c){default:continue 8759case';':case undefined:case'\\':break} 8760break} 8761if(c==';'){i++;gch.text+=c 8762continue} 8763break 8764case';':break} 8765i++ 8766break} 8767gch.otext=gch.text 8768if(!a_gch) 8769a_gch=[] 8770a_gch.push(gch)}} 8771var note_names="CDEFGAB",acc_name=["bb","b","","#","##"] 8772function gch_tr1(p,transp){var i,o,n,a,ip,b40,csa=p.split('/') 8773for(i=0;i<csa.length;i++){p=csa[i];o=p.search(/[A-G]/) 8774if(o<0) 8775continue 8776ip=o+1 8777a=0 8778while(p[ip]=='#'||p[ip]=='\u266f'){a++;ip++} 8779while(p[ip]=='b'||p[ip]=='\u266d'){a--;ip++} 8780n=note_names.indexOf(p[o])+16 8781b40=(abc2svg.pab40(n,a)+transp+200)%40 8782b40=abc2svg.b40k[b40] 8783csa[i]=p.slice(0,o)+ 8784note_names[abc2svg.b40_p[b40]]+ 8785acc_name[abc2svg.b40_a[b40]+2]+ 8786p.slice(ip)} 8787return csa.join('/')} 8788function gch_transp(s){var gch,i=s.a_gch.length 8789while(--i>=0){gch=s.a_gch[i] 8790if(gch.type=='g') 8791gch.text=gch_tr1(gch.text,curvoice.vtransp)}} 8792function csan_add(s){s.a_gch=a_gch;a_gch=null 8793if(curvoice.vtransp) 8794gch_transp(s)} 8795Abc.prototype.gch_build=function(s){var gch,wh,xspc,ix,y_above=0,y_below=0,y_left=0,y_right=0,GCHPRE=.4;for(ix=0;ix<s.a_gch.length;ix++){gch=s.a_gch[ix] 8796if(gch.type=='g'){gch.text=gch.text.replace(/##|#|=|bb|b| /g,function(x){switch(x){case'##':return"𝄪" 8797case'#':return"\u266f" 8798case'=':return"\u266e" 8799case'b':return"\u266d" 8800case' ':return' '} 8801return"𝄫"})}else{if(gch.type=='@'&&!user.anno_start&&!user.anno_stop){set_font(gch.font) 8802gch.text=str2svg(gch.text) 8803gch.text.wh=[0,0] 8804continue}} 8805set_font(gch.font);gch.text=str2svg(gch.text) 8806wh=gch.text.wh 8807wh[1]+=gch.font.pad*2 8808switch(gch.type){case'@':break 8809case'^':xspc=wh[0]*GCHPRE 8810if(xspc>8) 8811xspc=8;gch.x=-xspc;break 8812case'_':xspc=wh[0]*GCHPRE 8813if(xspc>8) 8814xspc=8;gch.x=-xspc;break 8815case'<':gch.x=-(wh[0]+6);y_left-=wh[1];gch.y=y_left+wh[1]/2 8816break 8817case'>':gch.x=6;y_right-=wh[1];gch.y=y_right+wh[1]/2 8818break 8819default:xspc=wh[0]*GCHPRE 8820if(xspc>8) 8821xspc=8;gch.x=-xspc;break}} 8822y_left/=2;y_right/=2 8823for(ix=0;ix<s.a_gch.length;ix++){gch=s.a_gch[ix] 8824switch(gch.type){case'<':gch.y-=y_left 8825break 8826case'>':gch.y-=y_right 8827break}}} 8828Abc.prototype.draw_gchord=function(i,s,x,y){var y2,an=s.a_gch[i],h=an.font.size,pad=an.font.pad,w=an.text.wh[0]+pad*2 8829switch(an.type){case'_':y-=h+pad 8830y_set(s.st,0,x,w,y-pad) 8831break 8832case'^':y=y_get(s.st,1,x,w) 8833y+=pad 8834y_set(s.st,1,x,w,y+h+pad) 8835break 8836case'<':case'>':if(an.type=='<'){if(s.notes[0].acc) 8837x-=s.notes[0].shac 8838x-=pad}else{if(s.xmx) 8839x+=s.xmx 8840if(s.dots) 8841x+=1.5+3.5*s.dots 8842x+=pad} 8843y+=(s.type==C.NOTE?(((s.notes[s.nhd].pit+s.notes[0].pit)>>1)- 884418)*3:12) 8845-h/2 8846break 8847default:if(y>=0){y+=pad 8848y_set(s.st,1,x,w,y+h+pad)}else{y-=h+pad 8849y_set(s.st,0,x,w,y-pad)} 8850break 8851case'@':y+=(s.type==C.NOTE?(((s.notes[s.nhd].pit+s.notes[0].pit)>>1)- 885218)*3:12) 8853+h*.2 8854if(y>0){y2=y+h*.8 8855if(y2>staff_tb[s.st].ann_top) 8856staff_tb[s.st].ann_top=y2}else{y2=y 8857if(y2<staff_tb[s.st].ann_bot) 8858staff_tb[s.st].ann_bot=y2} 8859break} 8860use_font(an.font) 8861set_font(an.font) 8862set_dscale(s.st) 8863if(user.anno_start) 8864user.anno_start("annot",an.istart,an.iend,x-2,y+h+2,w+4,h+4,s) 8865xy_str(x,y,an.text) 8866if(user.anno_stop) 8867user.anno_stop("annot",an.istart,an.iend,x-2,y+h+2,w+4,h+4,s)} 8868function draw_all_chsy(){var s,san1,an,i,y,w,pos=curvoice.pos.gch==C.SL_BELOW?-1:1,n_an=0,minmax=new Array(nstaff+1) 8869if(curvoice.pos.gch==C.SL_HIDDEN) 8870pos=0 8871function set_an_yu(j){var an,i,s,x,y,w 8872for(s=san1;s;s=s.ts_next){an=s.a_gch 8873if(!an) 8874continue 8875i=an.length-j-1 8876an=an[i] 8877if(!an) 8878continue 8879if((an.type=='g'&&pos>0)||an.type=='^'){x=s.x+an.x 8880w=an.text.wh[0] 8881if(w&&x+w>realwidth) 8882x=realwidth-w 8883y=y_get(s.st,1,x,w) 8884if(an.type=='g'&&y<minmax[s.st].yup) 8885y=minmax[s.st].yup}else if((an.type=='g'&&pos<=0)||an.type=='_'){continue}else{x=s.x+an.x 8886y=an.y} 8887self.draw_gchord(i,s,x,y)}} 8888function set_an_yl(i){var an,x,y,w 8889for(var s=san1;s;s=s.ts_next){an=s.a_gch 8890if(!an) 8891continue 8892an=an[i] 8893if(!an||!((an.type=='g'&&pos<0)||an.type=='_')) 8894continue 8895x=s.x+an.x 8896w=an.text.wh[0] 8897if(w&&x+w>realwidth) 8898x=realwidth-w 8899y=y_get(s.st,0,x,w) 8900if(an.type=='g'&&y>minmax[s.st].ydn) 8901y=minmax[s.st].ydn 8902self.draw_gchord(i,s,x,y)}} 8903for(i=0;i<=nstaff;i++) 8904minmax[i]={ydn:staff_tb[i].botbar-3,yup:staff_tb[i].topbar+4} 8905for(s=tsfirst;s;s=s.ts_next){an=s.a_gch 8906if(!an) 8907continue 8908if(!san1) 8909san1=s 8910i=an.length 8911if(i>n_an) 8912n_an=i 8913while(--i>=0){if(an[i].type=='g'){an=an[i] 8914w=an.text.wh[0] 8915if(pos>0){y=y_get(s.st,true,s.x,w) 8916if(y>minmax[s.st].yup) 8917minmax[s.st].yup=y}else if(pos<0){y=y_get(s.st,false,s.x,w) 8918if(y<minmax[s.st].ydn) 8919minmax[s.st].ydn=y} 8920break}}} 8921if(!san1) 8922return 8923set_dscale(-1) 8924for(i=0;i<n_an;i++){set_an_yu(i) 8925set_an_yl(i)}} 8926init_tune() 8927Abc.prototype.a_de=function(){return a_de} 8928Abc.prototype.add_style=function(s){style+=s};Abc.prototype.cfmt=function(){return cfmt};Abc.prototype.clone=clone;Abc.prototype.deco_cnv=deco_cnv;Abc.prototype.defs_add=defs_add 8929Abc.prototype.draw_meter=draw_meter 8930Abc.prototype.draw_note=draw_note;Abc.prototype.errs=errs;Abc.prototype.font_class=font_class;Abc.prototype.gch_tr1=gch_tr1;Abc.prototype.get_bool=get_bool;Abc.prototype.get_cur_sy=function(){return cur_sy};Abc.prototype.get_curvoice=function(){return curvoice};Abc.prototype.get_delta_tb=function(){return delta_tb};Abc.prototype.get_decos=function(){return decos};Abc.prototype.get_font=get_font;Abc.prototype.get_font_style=function(){return font_style};Abc.prototype.get_glyphs=function(){return glyphs};Abc.prototype.get_img=function(){return img};Abc.prototype.get_maps=function(){return maps};Abc.prototype.get_multi=function(){return multicol};Abc.prototype.get_newpage=function(){if(block.newpage){block.newpage=false;return true}};Abc.prototype.get_posy=function(){var t=posy;posy=0;return t};Abc.prototype.get_staff_tb=function(){return staff_tb};Abc.prototype.get_top_v=function(){return par_sy.top_voice};Abc.prototype.get_tsfirst=function(){return tsfirst};Abc.prototype.get_unit=get_unit;Abc.prototype.get_voice_tb=function(){return voice_tb};Abc.prototype.glout=glout 8931Abc.prototype.goto_tune=goto_tune;Abc.prototype.info=function(){return info};Abc.prototype.new_block=new_block;Abc.prototype.out_arp=out_arp;Abc.prototype.out_deco_str=out_deco_str;Abc.prototype.out_deco_val=out_deco_val;Abc.prototype.out_ltr=out_ltr;Abc.prototype.param_set_font=param_set_font;Abc.prototype.parse=parse;Abc.prototype.psdeco=empty_function;Abc.prototype.psxygl=empty_function;Abc.prototype.set_cur_sy=function(sy){cur_sy=sy};Abc.prototype.set_dscale=set_dscale;Abc.prototype.set_font=set_font;Abc.prototype.set_a_gch=function(s,a){a_gch=a;csan_add(s)} 8932Abc.prototype.set_hl=set_hl 8933Abc.prototype.set_pagef=function(){blkdiv=1} 8934Abc.prototype.set_scale=set_scale;Abc.prototype.set_tsfirst=function(s){tsfirst=s};Abc.prototype.set_v_param=set_v_param;Abc.prototype.strwh=strwh;Abc.prototype.stv_g=function(){return stv_g};Abc.prototype.svg_flush=svg_flush;Abc.prototype.syntax=syntax;Abc.prototype.tunes=tunes 8935Abc.prototype.unlksym=unlksym;Abc.prototype.use_font=use_font;Abc.prototype.vskip=vskip 8936Abc.prototype.xy_str=xy_str;Abc.prototype.xygl=xygl;var hook_init 8937function set_hooks(){var h=abc2svg.modules.hooks,gh=abc2svg.modules.g_hooks 8938function set_hs(hs){for(var k=0;k<hs.length;k++) 8939hs[k](self)} 8940if(hook_init){if(h.length){set_hs(h);gh.push.apply(gh,h);abc2svg.modules.hooks=[]}}else{if(h.length){gh.push.apply(gh,h);abc2svg.modules.hooks=[]} 8941set_hs(gh);hook_init=true}}} 8942var Abc=abc2svg.Abc 8943if(typeof module=='object'&&typeof exports=='object'){exports.abc2svg=abc2svg;exports.Abc=Abc} 8944if(!abc2svg.loadjs){abc2svg.loadjs=function(fn,onsuccess,onerror){if(onerror) 8945onerror()}} 8946abc2svg.modules={ambitus:{},begingrid:{fn:'grid3'},beginps:{fn:'psvg'},break:{},capo:{},chordnames:{},clip:{},clairnote:{fn:'clair'},voicecombine:{fn:'combine'},diagram:{fn:'diag'},equalbars:{},gamelan:{},grid:{},grid2:{},jazzchord:{},jianpu:{},mdnn:{},MIDI:{},pageheight:{fn:'page'},pedline:{},percmap:{fn:'perc'},soloffs:{},sth:{},strtab:{},temperament:{fn:'temper'},nreq:0,hooks:[],g_hooks:[],load:function(file,relay,errmsg){function get_errmsg(){if(typeof user=='object'&&user.errmsg) 8947return user.errmsg 8948if(typeof abc2svg.printErr=='function') 8949return abc2svg.printErr 8950if(typeof alert=='function') 8951return function(m){alert(m)} 8952if(typeof console=='object') 8953return console.log 8954return function(){}} 8955function load_end(){if(--abc2svg.modules.nreq==0) 8956abc2svg.modules.cbf()} 8957function load_ko(fn){abc2svg.modules.errmsg('Error loading the module '+fn) 8958load_end()} 8959var m,i,fn,nreq_i=this.nreq,ls=file.match(/(^|\n)(%%|I:).+?\b/g) 8960if(!ls) 8961return true 8962this.cbf=relay||function(){} 8963this.errmsg=errmsg||get_errmsg() 8964for(i=0;i<ls.length;i++){fn=ls[i].replace(/\n?(%%|I:)/,'') 8965m=abc2svg.modules[fn] 8966if(!m||m.loaded) 8967continue 8968m.loaded=true 8969if(m.fn) 8970fn=m.fn 8971this.nreq++ 8972abc2svg.loadjs(fn+"-1.js",load_end,function(){load_ko(fn)})} 8973return this.nreq==nreq_i}} 8974abc2svg.version="1.20.16-6c1ff8e813";abc2svg.vdate="2021-01-06" 8975