Lines Matching defs:B
8 function external_eval(param){return eval(param)}function isQuoted(e){return e.q}function quote(e){return e.q=!0,e}function unquote(e){return delete e.q,e}function Symbol(e){return this.nm=e,this}function isSymbol(e){return e&&e.constructor===Symbol}function symbolName(e){return e.nm}function isArray(e){return e&&e.constructor===Array}function inDs(e,t){for(var n=e.length-1;0<=n;--n)if("undefined"!=typeof e[n][t])return e[n];return!1}function member(e,t){return 0<=t.indexOf(e)}function PsParser(){function t(t){e.L=t,e.N=t.length,e.I=0,e.D=0}function n(){return e.I<e.N&&e.L[e.I]}function r(){return e.I<e.N&&e.L[e.I++]}function i(){while(e.I<e.N&&member(e.L[e.I]," \n"))e.I++}function s(){while("%"==n()){while(n()&&"\n"!=n())r();i()}}function o(){r();var e=[],t=1;while(0<t&&n()){var i=r();switch(i){case"(":t++;break;case")":t--,t<=0&&(i=!1);break;case"\\":i=r();switch(i){case"(":break;case")":break;case"\\":break;case"n":i="\n";break;case"r":i="\r";break;case"t":i=" ";break;default:i=!1}}i!==!1&&e.push(i)}return e.join("")}function u(){var e=r();if(member(e,"()<>/% \n"))throw new Error("Symbol expected, got "+e);var t=member(e,"+-0123456789."),i="."==e,s=[e];while(n()&&!member(n(),"()<>[]{}/% \n"))e=r(),s.push(e),t&&!member(e,"0123456789")&&(!i&&"."==e?i=!0:t=!1);return s=s.join(""),1==s.length&&member(s,"+-.")&&(t=!1),t?i?parseFloat(s):parseInt(s,10):new Symbol(s)}function a(){i();switch(n()){case!1:return undefined;case"%":return s();case"[":return new Symbol(r());case"]":return new Symbol(r());case"{":return e.D++,new Symbol(r());case"}":return e.D--,new Symbol(r());case"/":r();var t=u();return quote(t);case"(":return o();case"<":r();if("<"!=n())throw new Error("Encoded strings not implemented yet");return r(),new Symbol("<<");case">":r();if(">"!=n())throw new Error("Unexpected >");return r(),new Symbol(">>");default:return u()}}var e=this;return PsParser.prototype.init=t,PsParser.prototype.peek=n,PsParser.prototype.token=a,this}function Ps0(e,t,n){function r(i,s){if(isSymbol(i)&&!isQuoted(i)){var o=symbolName(i),u=inDs(t,o);if(!u)throw new Error("bind error '"+o+"'");n.push([!1,u[o]])}else if(s&&isArray(i)&&isQuoted(i)){if(0<i.length){var a=i[0],f=quote(i.slice(1));0<f.length&&n.push([!1,f]),r(a,!1)}}else"function"==typeof i?i():e.push(i)}function i(){var t=e.pop();r(t,!1)}function s(){var t=n.pop(),i=t.shift(),s=t.pop();for(var o=0;o<t.length;o++)e.push(t[o]);r(s,!0)}function u(t){o.init(t);while(o.peek()){var r=o.token();if(r||r===0){e.push(r);if(o.D<=0||isSymbol(r)&&(member(symbolName(r),"[]{}")||"<<"==symbolName(r)||">>"==symbolName(r))){i();while(0<n.length)s()}}}return e}var o=new PsParser;return Ps0.prototype.run=r,Ps0.prototype.exec=i,Ps0.prototype.step=s,Ps0.prototype.parse=u,this}function Wps(e){function f(e){if(isSymbol(e)&&!isQuoted(e))return e;if(isArray(e)&&isQuoted(e)){var t=e.length,n=[];for(var r=0;r<t;r++){var i=e[r],s=f(i);isArray(i)?n=n.concat(isQuoted(i)?quote([s]):[s]):n=n.concat(s)}return quote(n)}return e}function l(){var e=arguments;if(e.length)for(var t=0;t<e.length;t++)o.parse(e[t]);else o.parse(e);return n}var t=e,n=[],r={},i=[r],s=[],o=new Ps0(n,i,s);r["true"]=function(){n.push(!0)},r["false"]=function(){n.push(!1)},r["null"]=function(){n.push(null)},r.sub=function(){var e=n.pop();n.push(n.pop()-e)},r.mul=function(){n.push(n.pop()*n.pop())},r.div=function(){var e=n.pop();n.push(n.pop()/e)},r.mod=function(){var e=n.pop();n.push(n.pop()%e)};var u={};r.mark=function(){n.push(u)},r.counttomark=function(){var e=0;for(var t=n.length-1;0<=t;t--){if(u===n[t])return n.push(e);e++}throw new Error("Mark not found")},r["<<"]=r.mark,r[">>"]=function(){var e={};while(0<n.length){var t=n.pop();if(u===t)return n.push(e);e[n.pop()]=t}throw new Error("Mark not found")},r.exch=function(){var e=n.pop(),t=n.pop();n.push(e),n.push(t)},r.clear=function(){n.length=0},r.pop=function(){n.pop()},r.index=function(){n.push(n[n.length-2-n.pop()])},r.roll=function(){var e=n.pop(),t=n.pop(),r=[],i=[];e<0&&(e=t+e);for(var s=0;s<t;s++)s<e?r.unshift(n.pop()):i.unshift(n.pop());for(s=0;s<e;s++)n.push(r.shift());for(s=0;s<t-e;s++)n.push(i.shift())},r.copy=function(){var e=n.pop();if("object"==typeof e){var t=n.pop();for(var r in t)e[r]=t[r];n.push(e)}else{var t=n.length-e;for(var r=0;r<e;r++)n.push(n[t+r])}},r.length=function(){n.push(n.pop().length)},r.astore=function(){var e=n.pop(),t=e.length;for(var r=t-1;0<=r;r--)e[r]=n.pop();n.push(e)},r.array=function(){n.push(new Array(n.pop()))},r.eq=function(){var e=n.pop(),t=n.pop();n.push(t==e)},r.lt=function(){var e=n.pop(),t=n.pop();n.push(t<e)},r.ifelse=function(){var e=n.pop(),t=n.pop(),r=n.pop();s.push([!1,r===!0?t:e])},r.and=function(){var e=n.pop(),t=n.pop();if(!0===e||!1===e){n.push(e==1&&t===!0);return}n.push(e&t)},r.repeat=function c(){var e=n.pop(),t=n.pop();1<t&&s.push([!0,t-1,e,c]),0<t&&s.push([!1,e])},r["for"]=function h(){var e=n.pop(),t=n.pop(),r=n.pop(),i=n.pop();r<0?(t<=i+r&&s.push([!0,i+r,r,t,e,h]),t<=i&&s.push([!1,i,e])):(i+r<=t&&s.push([!0,i+r,r,t,e,h]),i<=t&&s.push([!1,i,e]))},r.exec=function(){s.push([!1,n.pop()])},r.cvx=function(){var e=n.pop();isSymbol(e)&&isQuoted(e)?n.push(unquote(e)):isArray(e)&&!isQuoted(e)?n.push(quote(e)):n.push(e)},r.dict=function(){n.pop(),n.push({})},r.get=function(){var e=n.pop(),t=n.pop();isSymbol(e)?n.push(t[symbolName(e)]):n.push(t[e])},r.getinterval=function(){var e=n.pop(),t=n.pop()+e,r=n.pop(),i=[];while(--e>=0)i.push(r[t++]);n.push(i)},r.put=function(){var e=n.pop(),t=n.pop(),r=n.pop();isSymbol(t)?r[symbolName(t)]=e:r[t]=e},r.begin=function(){i.push(n.pop())},r.end=function(){i.pop()},r.currentdict=function(){n.push(i[i.length-1])},r.where=function(){var e=symbolName(n.pop()),t=inDs(i,e);t?(n.push(t),n.push(!0)):n.push(!1)},r.save=function(){var e=i.slice();for(var t=0;t<e.length;t++){var r=e[t],s={};for(var o in r)s[o]=r[o];e[t]=s}n.push(e)},r.restore=function(){var e=n.pop();while(0<i.length)i.pop();while(0<e.length)i.unshift(e.pop())},r.type=function(){var e=n.pop(),t;if(null===e)t="nulltype";else if(!0===e||!1===e)t="booleantype";else if(u===e)t="marktype";else if("string"==typeof e)t="stringtype";else if(isSymbol(e))t=isQuoted(e)?"nametype":"operatortype";else if("function"==typeof e)t="operatortype";else if(isArray(e))t="arraytype";else if("object"==typeof e)t="dicttype";else{if(1*e!=e)throw new Error("Undefined type '"+e+"'");t=e%1==0?"integertype":"realtype"}n.push(t)};var a=!0;return r[".strictBind"]=function(){a=!0===n.pop()},r.bind=function(){n.push(f(n.pop()))},r["="]=function(){var e=n.pop();alert(e&&e.nm||e)},r["=="]=function(){alert(n.pop())},r.stack=function(){alert(n)},r.pstack=function(){alert(n)},r[".call"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=[];for(var s=0;s<e;s++)i.unshift(n.pop());if(!r[t])throw new Error(".call: "+t+" undef");n.push(r[t].apply(r,i))},r[".call0"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=[];for(var s=0;s<e;s++)i.unshift(n.pop());if(!r[t])throw new Error(".call0: "+t+" undef");r[t].apply(r,i)},r[".svg"]=function(){n.push(t)},r[".math"]=function(){n.push(Math)},r[".date"]=function(){n.push(new Date)},r[".window"]=function(){n.push(window)},r[".callback"]=function(){var e=n.pop();n.push(function(){o.run(e,!0);while(0<s.length)o.step()})},r[".minv"]=function(){var e=n.pop(),t=e[0],r=e[1],i=e[2],s=e[3],o=e[4],u=e[5];n.push([s,r,i,t,i*u-s*o,r*o-t*u])},r[".mmul"]=function(){var e=n.pop(),t=n.pop(),r=t[0],i=t[1],s=t[2],o=t[3],u=t[4],a=t[5],f=e[0],l=e[1],c=e[2],h=e[3],p=e[4],d=e[5];n.push([r*f+i*c,r*l+i*h,s*f+o*c,s*l+o*h,u*f+a*c+p,u*l+a*h+d])},r[".xy"]=function(){var e=n.pop(),t=n.pop(),r=n.pop();n.push(e[0]*r+e[2]*t+e[4]),n.push(e[1]*r+e[3]*t+e[5])},r[".rgb"]=function(){var e=n.pop(),t=n.pop(),r=n.pop();n.push("rgb("+r+","+t+","+e+")")},r[".rgba"]=function(){var e=n.pop(),t=n.pop(),r=n.pop(),i=n.pop();n.push("rgba("+i+","+r+","+t+","+e+")")},Wps.prototype.parse=l,this}function Psvg(e){function d(){return w(0),[o.xoffs-o.xorig,o.yoffs-o.yorig]}function v(){s=!1,w(0),t+="<g";if(o.xscale!=1||o.yscale!=1||o.rotate){t+=' transform="';if(o.xscale!=1||o.yscale!=1)o.xscale==o.yscale?t+="scale("+o.xscale.toFixed(3)+")":t+="scale("+o.xscale.toFixed(3)+","+o.yscale.toFixed(3)+")";if(o.rotate){if(o.xoffs||o.yoffs){var e,n=o.xoffs,r=o.yoffs,u=o.sin,l=o.cos;e=n*l-r*u,r=n*u+r*l,t+=" translate("+e.toFixed(2)+","+r.toFixed(2)+")",a=o.xoffs,f=o.yoffs,o.xoffs=0,o.yoffs=0}t+=" rotate("+o.rotate.toFixed(2)+")"}t+='"'}g(!1),o.rgb&&(t+=' style="color:'+o.rgb+'"'),t+=">\n",i=1}function m(e){var t,n=new e.constructor;for(t in e)e.hasOwnProperty(t)&&(n[t]=e[t]);return n}function g(e){var n=o.font_n;if(!n)return;var r="",i=n.indexOf("Italic"),s=100,u=n.indexOf("Oblique"),a=n.indexOf("Bold"),f=0;a>0&&(r=' font-weight="bold"',s=a,f=2);if(i>0||u>0)i>0&&(r+=' font-style="italic"',i<s&&(s=i),f|=4),u>0&&(r+=' font-style="oblique"',u<s&&(s=u),f=8);s!=100&&(n[s-1]=="-"&&s--,n=n.slice(0,s)),e&&(!(f&2)&&c.indexOf("Bold")>=0&&(r+=' font-weight="normal"'),!(f&12)&&(c.indexOf("Italic")>=0||c.indexOf("Oblique")>=0)&&(r+=' font-style="normal"')),t+=' font-family="'+n+'"'+r+' font-size="'+o.font_s+'"'}function y(){if(p)return;w(1),o.px=o.cx,o.py=o.cy,p='<path d="m'+(o.xoffs+o.cx).toFixed(2)+" "+(o.yoffs-o.cy).toFixed(2)+"\n"}function b(){t+=p,p=""}function w(e){i==2&&(t+="</text>\n",i=1),e==0?i&&(i=0,t+="</g>\n",o.rotate&&(o.xoffs=a,o.yoffs=f,a=0,f=0)):s&&v()}function E(e){return e.length*o.font_s*.5}function S(e,t,n,r,i,s){var u,a,f,l;r>=360&&(r-=360),i>=360&&(i-=360),u=e+n*Math.cos(r*Math.PI/180),a=t+n*Math.sin(r*Math.PI/180),o.cx!=undefined?p?(u!=o.cx||a!=o.cy?p+="l":p+="m",p+=(u-o.cx).toFixed(2)+" "+(-(a-o.cy)).toFixed(2)):(o.cx=u,o.cy=a,y()):(p&&(p=""),o.cx=u,o.cy=a,y()),r==i?(i=180-r,f=e+n*Math.cos(i*Math.PI/180),l=t+n*Math.sin(i*Math.PI/180),p+="a"+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(f-u).toFixed(2)+" "+(a-l).toFixed(2)+" "+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(u-f).toFixed(2)+" "+(l-a).toFixed(2)+"\n",o.cx=u,o.cy=a):(f=e+n*Math.cos(i*Math.PI/180),l=t+n*Math.sin(i*Math.PI/180),p+="a"+n.toFixed(2)+" "+n.toFixed(2)+" 0 0 "+(s?"1 ":"0 ")+(f-u).toFixed(2)+" "+(a-l).toFixed(2)+"\n",o.cx=f,o.cy=l)}function x(e,t){y(),e==0?p+=" v"+(-t).toFixed(2)+"\n":t==0?p+=" h"+e.toFixed(2)+"\n":p+=" l"+e.toFixed(2)+" "+(-t).toFixed(2)+"\n",o.cx+=e,o.cy+=t}function T(e){e&&w(0);if(!t)return;n.out_svg(t),t=""}function N(e,t,i,s){return o.xorig=o.xoffs=n.sx(0),o.yorig=o.yoffs=n.sy(0),o.cx=0,o.cy=0,r.parse(s+(t/n.stv_g().scale).toFixed(2)+" "+i.toFixed(2)+" "+e),T(!0),!0}var t="",n=e,r=new Wps(this),i=0,s,o={cx:0,cy:0,xoffs:0,yoffs:0,xscale:1,yscale:1,rotate:0,sin:0,cos:1,linewidth:.7,dash:""},u=[],a=0,f=0,l="",c="",h=0,p;Psvg.prototype.strw=E,Psvg.prototype.arc=S,Psvg.prototype.arcn=function(e,t,n,r,i){S(e,t,n,r,i,!0)},Psvg.prototype.closepath=function(){p&&o.cx&&x(o.px-o.cx,o.py-o.cy)},Psvg.prototype.cx=function(){return o.cx},Psvg.prototype.cy=function(){return o.cy},Psvg.prototype.curveto=function(e,t,n,r,i,s){y(),p+=" C"+(o.xoffs+e).toFixed(2)+" "+(o.yoffs-t).toFixed(2)+" "+(o.xoffs+n).toFixed(2)+" "+(o.yoffs-r).toFixed(2)+" "+(o.xoffs+i).toFixed(2)+" "+(o.yoffs-s).toFixed(2)+"\n",o.cx=i,o.cy=s},Psvg.prototype.eofill=function(){b(),t+='" fill-rule="evenodd" fill="currentColor"/>\n'},Psvg.prototype.fill=function(){b(),t+='" fill="currentColor"/>\n'},Psvg.prototype.gsave=function(){u.push(m(o))},Psvg.prototype.grestore=function(){o=u.pop(),s=!0},Psvg.prototype.lineto=function(e,t){y(),e==o.cx?p+=" v"+(o.cy-t).toFixed(2)+"\n":t==o.cy?p+=" h"+(e-o.cx).toFixed(2)+"\n":p+=" l"+(e-o.cx).toFixed(2)+" "+(o.cy-t).toFixed(2)+"\n",o.cx=e,o.cy=t},Psvg.prototype.moveto=function(e,n){o.cx=e,o.cy=n,p?p+=" M"+(o.xoffs+o.cx).toFixed(2)+" "+(o.yoffs-o.cy).toFixed(2)+"\n":i==2&&(t+="</text>\n",i=1)},Psvg.prototype.newpath=function(){o.cx=o.cy=undefined},Psvg.prototype.rcurveto=function(e,t,n,r,i,s){y(),p+=" c"+e.toFixed(2)+" "+(-t).toFixed(2)+" "+n.toFixed(2)+" "+(-r).toFixed(2)+" "+i.toFixed(2)+" "+(-s).toFixed(2)+"\n",o.cx+=i,o.cy+=s},Psvg.prototype.rlineto=x,Psvg.prototype.rmoveto=function(e,n){p?p+=" m"+e.toFixed(2)+" "+(-n).toFixed(2)+"\n":i==2&&(t+="</text>\n",i=1),o.cx+=e,o.cy+=n},Psvg.prototype.rotate=function(e){w(0);var t,n=o.xoffs,r=o.yoffs,i=o.sin,u=o.cos;t=n*u-r*i,r=n*i+r*u,o.xoffs=t/o.xscale,o.yoffs=r/o.yscale,n=o.cx,r=o.cy,t=n*u-r*i,r=-n*i+r*u,o.cx=t/o.xscale,o.cy=r/o.yscale,e=360-e,o.rotate+=e,o.rotate>180?o.rotate-=360:o.rotate<=-180&&(o.rotate+=360),e=o.rotate*Math.PI/180,o.sin=i=Math.sin(e),o.cos=u=Math.cos(e),t=o.cx,o.cx=(t*u+o.cy*i)*o.xscale,o.cy=(-t*i+o.cy*u)*o.yscale,t=o.xoffs,o.xoffs=(t*u+o.yoffs*i)*o.xscale,o.yoffs=(-t*i+o.yoffs*u)*o.yscale,s=!0},Psvg.prototype.scale=function(e,t){o.xoffs/=e,o.yoffs/=t,o.cx/=e,o.cy/=t,o.xscale*=e,o.yscale*=t,s=!0},Psvg.prototype.selectfont=function(e,t){e=e.nm;if(h!=t||e!=l)o.font_n_old=o.font_n,o.font_n=e,o.font_s=t,s=!0},Psvg.prototype.setdash=function(e,t){var n=e.length,r;if(n==0){o.dash="";return}o.dash=' stroke-dashoffset="'+t+'" stroke-dasharray="',r=0;for(;;){o.dash+=e[r];if(--n==0)break;o.dash+=" "}o.dash+='"'},Psvg.prototype.setlinewidth=function(e){o.linewidth=e},Psvg.prototype.setrgbcolor=function(e,t,n){var r=16777216+(Math.floor(e*255)<<16)+(Math.floor(t*255)<<8)+Math.floor(n*255);r=r.toString(16),r=r.replace("1","#"),r!=o.rgb&&(o.rgb=r,s=!0)},Psvg.prototype.show=function(e){var n,r,u;s&&(i==2?n=!0:v()),r=o.cx,u=o.cy,n?(t+="<tspan\n ",g(!0),t+=">"):i!=2&&(t+='<text x="'+(r+o.xoffs).toFixed(2)+'" y="'+(o.yoffs-u).toFixed(2)+'">',i=2),t+=e.replace(/<|>|&| /g,function(e){switch(e){case"<":return"<";case">":return">";case"&":return"&";case" ":return" "}}),n&&(t+="</tspan>"),o.cx=r+E(e)},Psvg.prototype.stroke=function(){b(),o.linewidth!=.7&&(t+='" stroke-width="'+o.linewidth.toFixed(2)),t+='" stroke="currentColor" fill="none"'+o.dash+"/>\n"},Psvg.prototype.translate=function(e,t){o.xoffs+=e,o.yoffs-=t,o.cx-=e,o.cy-=t},Psvg.prototype.arp=function(e,t,r){var i=d();T(),n.out_arp((t+i[0])*n.stv_g().scale,r-i[1],e)},Psvg.prototype.ltr=function(e,t,r){var i=d();T(),n.out_ltr((t+i[0])*n.stv_g().scale,r-i[1],e)},Psvg.prototype.xygl=function(e,t,r){var i=d();T(),n.xygl((e+i[0])*n.stv_g().scale,t-i[1],r)},Psvg.prototype.xygls=function(e,t,r,i){var s=d();T(),n.out_deco_str((t+s[0])*n.stv_g().scale,r-s[1],i,e)},Psvg.prototype.xyglv=function(e,t,r,i){var s=d();T(),n.out_deco_val((t+s[0])*n.stv_g().scale,r-s[1],i,e)},Psvg.prototype.y0=function(e){var t=n.get_staff_tb();return e+t[0].y},Psvg.prototype.y1=function(e){var t=n.get_staff_tb();return e+t[1].y},Psvg.prototype.ps_flush=T,Psvg.prototype.ps_eval=function(e){r.parse(e),T()},Psvg.prototype.psdeco=function(e,t,i,s){var o,u,a,f,l=r.parse("/"+e+" where"),c=l.pop(),h=n.get_staff_tb();return c?(f=0,s.defl.nost&&(f=1),s.defl.noen&&(f|=2),s.s.stem>=0&&(f|=4),l.pop(),a="/defl "+f+" def ",s.lden&&(a+=t.toFixed(2)+" "+i.toFixed(2)+" ",u=s.start,t=u.x,i=u.y+h[u.st].y,t>s.x-20&&(t=s.x-20)),o=s.dd,s.has_val?a+=s.val+" ":o.str&&(a+="("+o.str+") ",i+=o.h*.2),N(e,t,i,a)):!1},Psvg.prototype.psxygl=function(e,t,n){var i=r.parse("/"+n+" where"),s=i.pop();return s?(i.pop(),N(n,e,t,"dlw ")):!1},Psvg.prototype.svgcall=function(e,t,r,i,s){var o=d();T(),e((t+o[0])*n.stv_g().scale,r-o[1],i,s)},r.parse("currentdict/systemdict currentdict put\nsystemdict/{/mark cvx put\nsystemdict/[/mark cvx put\nsystemdict/]\n/counttomark cvx\n/array cvx\n/astore cvx\n/exch cvx\n/pop cvx\n5 array astore cvx put\nsystemdict/}/] cvx/cvx cvx 2 array astore cvx put\nsystemdict/def{currentdict 2 index 2 index put pop pop}put\n\n/maxlength 1000 def % TODO\n/.bdef{bind def}bind def\n/.xdef{exch def}.bdef\n/dup{0 index}.bdef\n/load{dup where pop exch get}.bdef\n/.ldef{load def}.bdef\n/if{{}ifelse}.bdef\n/cleartomark{array pop}.bdef\n/known{exch begin where{currentdict eq}{false}if end}.bdef\n/store{1 index where{3 1 roll put}{def}ifelse}.bdef\n/not{{false}{true}ifelse}.bdef\n%/.logand{{{true}{false}ifelse}{pop false}ifelse}.bdef\n%/and/.logand .ldef % TODO numeric and\n/.logor{{pop true}{{true}{false}ifelse}ifelse}.bdef\n/or/.logor .ldef % TODO numeric or\n/ne{eq not}.bdef\n/ge{lt not}.bdef\n/le{1 index 1 index eq 3 1 roll lt or}.bdef\n/gt{le not}.bdef\n/.repeat{1 1 4 2 roll for}.bdef\n\n%% math\n\n/floor{.math(floor)1 .call}.bdef\n\n/neg{0 exch sub}.bdef\n/add{neg sub}.bdef\n/idiv{div floor}.bdef\n\n/.pi{.math(PI)get}.bdef\n\n/abs{.math(abs)1 .call}.bdef\n%/.acos{.math(acos)1 .call}.bdef\n%/.asin{.math(asin)1 .call}.bdef\n/atan{.math(atan2)2 .call 180 mul .pi div}.bdef\n%/.atan2{.math(atan2)2 .call}.bdef\n%/ceiling{.math(ceil)1 .call}.bdef\n/cos{.pi mul 180 div .math(cos)1 .call}.bdef\n%/.exp{.math(exp)1 .call}.bdef\n%/log{.math(log)1 .call}.bdef\n%/.max{.math(max)2 .call}.bdef\n%/.min{.math(min)2 .call}.bdef\n%/.pow{.math(pow)2 .call}.bdef\n%/.random{.math(random)0 .call}.bdef\n%/rand{.random}.bdef % TODO follow spec\n%/round{.math(round)1 .call}.bdef\n%/sin{.math(sin)1 .call}.bdef\n%/sqrt{.math(sqrt)1 .call}.bdef\n%/.tan{.math(tan)1 .call}.bdef\n%/truncate{.math(truncate)1 .call}.bdef % TODO Math.truncate does not exist!\n\n% graphic\n/arc{.svg(arc)5 .call0}.bdef\n/arcn{.svg(arcn)5 .call0}.bdef\n/closepath{.svg(closepath)0 .call}.bdef\n/currentpoint{.svg(cx)0 .call .svg(cy)0 .call}.bdef\n/curveto{.svg(curveto)6 .call0}.bdef\n/eofill{.svg(eofill)0 .call0}.bdef\n/fill{.svg(fill)0 .call0}.bdef\n/grestore{.svg(grestore)0 .call0}.bdef\n/gsave{.svg(gsave)0 .call0}.bdef\n/lineto{.svg(lineto)2 .call0}.bdef\n/moveto{.svg(moveto)2 .call0}.bdef\n/newpath{.svg(newpath)0 .call0}.bdef\n/rcurveto{.svg(rcurveto)6 .call0}.bdef\n/rlineto{.svg(rlineto)2 .call0}.bdef\n/rmoveto{.svg(rmoveto)2 .call0}.bdef\n/rotate{.svg(rotate)1 .call0}.bdef\n/scale{.svg(scale)2 .call0}.bdef\n/selectfont{.svg(selectfont)2 .call0}.bdef\n/setdash{.svg(setdash)2 .call0}.bdef\n/setlinewidth{.svg(setlinewidth)1 .call0}.bdef\n/setrgbcolor{.svg(setrgbcolor)3 .call0}.bdef\n/show{.svg(show)1 .call0}.bdef\n/stroke{.svg(stroke)0 .call0}.bdef\n/stringwidth{.svg(strw)1 .call 1}.bdef %fixme: height KO\n/translate{.svg(translate)2 .call0}.bdef\n\n/setgray{255 mul dup dup setrgbcolor}.bdef\n% abcm2ps syms.c\n/!{bind def}bind def\n/T/translate load def\n/M/moveto load def\n/RM/rmoveto load def\n/L/lineto load def\n/RL/rlineto load def\n/C/curveto load def\n/RC/rcurveto load def\n/SLW/setlinewidth load def\n/defl 0 def\n/dlw{0.7 SLW}!\n/xymove{/x 2 index def/y 1 index def M}!\n/showc{dup stringwidth pop .5 mul neg 0 RM show}!\n%\n% abcm2ps internal glyphs\n/arp{.svg(arp)3 .call0}.bdef\n/ltr{.svg(ltr)3 .call0}.bdef\n/ft0{(acc-1).svg(xygl)3 .call0}.bdef\n/nt0{(acc3).svg(xygl)3 .call0}.bdef\n/sh0{(acc1).svg(xygl)3 .call0}.bdef\n/dsh0{(acc2).svg(xygl)3 .call0}.bdef\n/trl{(trl).svg(xygl)3 .call0}.bdef\n/lmrd{(lmrd).svg(xygl)3 .call0}.bdef\n/turn{(turn).svg(xygl)3 .call0}.bdef\n/umrd{(umrd).svg(xygl)3 .call0}.bdef\n/y0{.svg(y0)1 .call}.bdef\n/y1{.svg(y1)1 .call}.bdef\n")}var abc=null,$ABC_UI=function(){"use strict";function $(e,t,n){return e.indexOf(t)!==-1?"":t+" "+n+"\n"}function J(e,t){e=e||{};if(e.zoom===undefined||e.zoom===null)e.zoom=1;if(e.pagewidth===undefined||e.pagewidth===null)e.pagewidth=p;var r=q+" s"+n+"\n";return n++,r+=$(t,"%%pagewidth",e.pagewidth.toString()+"cm"),r+=$(t,"%%staffwidth",e.pagewidth.toString()+"cm"),r+=$(t,"%%scale",e.zoom.toString()),r+=$(t,"%%topmargin","0px"),r+=$(t,"%%botmargin","0px"),r+=$(t,"%%leftmargin","16px"),r+=$(t,"%%rightmargin","8px"),r+=$(t,"%%topspace","0px"),r+=$(t,"%%musicspace","0px"),r+=$(t,"%%vocalspace","0px"),r+=$(t,"%%staffsep","0px"),r+=$(t,"%%sysstaffsep",".7cm"),r+=$(t,"%%vocalfont Time","13"),r}function K(e,t){var n=e.nextSibling.nextSibling;n!==null&&n.nodeName==="#text"&&(n=e.nextSibling.nextSibling);if(n!==null&&n!==undefined&&n.nodeName&&n.nodeName==="DIV"&&n.classList&&n.classList.contains(t))return n;n=e.cloneNode(!0);var r=n.classList;while(r.length>0)r.remove(r.item(0));return n.classList.add(t),e&&e.nextSibling&&e.nextSibling.nodeName=="#text"&&(e=e.nextSibling),e.parentNode.insertBefore(n,e.nextSibling),n}function Q(e,t){var n="",r={read_file:null,errmsg:function(e,t,n){},img_out:function(e){n+=e},page_format:!1},i=J(t,e)+X+V;abc=new Abc(r);try{abc.tosvg("edit",i),abc.tosvg("score.abc",e)}catch(s){var o="%c "+s.message+"\nabc2svg tosvg bug - stack:\n"+s.stack;console.log(o,"color: red;")}return n}function G(e,t){const n={beam:!0,slur:!0,tuplet:!0,deco:!0};var r="",i={read_file:null,errmsg:function(e,t,n){},img_out:function(e){r+=e},anno_start:null,anno_stop:function(e,r,i,s,o,u,a){if(n[e])return;isNaN(u)||(abc.out_svg('<rect class="'+C+" "+t.idScore+" "+r+'" x="'),abc.out_sxsy(s,'" y="',o),abc.out_svg('" width="'+u.toFixed(2)+'" height="'+a.toFixed(2)+'"/>\n'))}},s=J(t,e)+X+V;abc=new Abc(i);try{abc.tosvg("edit",s),abc.tosvg("follower.abc",e)}catch(o){var u="%c "+o.message+"\nabc2svg tosvg bug - stack:\n"+o.stack;console.log(u,"color: red;")}return r}function Y(e,t){if(t===undefined)return;var n=document.getElementById(e);if(n===undefined||n===null)return null;var r=t.indexOf(B,0)===-1,i={errmsg:function(e,t,n){console.log("%c "+e,"color: red;")},get_abcmodel:function(t,i,s,f){var l=i.length;for(var c=0;c<l;c++){var h=i[c],p=h.instr||0;h.midictl&&(h.midictl[32]&&(p+=h.midictl[32]*128),h.midictl[0]&&(p+=h.midictl[0]*128*128),p=128),u.indexOf(p)===-1&&(u.push(p),o=!1)}var d=0;if(r&&l>1){var v=!0;for(c=0;c<l;c++){var m=$ABC_UTIL.remapVoiceName(i[c],a);if($ABC_UTIL.isActiveVoice(m)){d++,v||n.appendChild(document.createElement("br")),v=!1;var g=document.createElement("input");g.type="checkbox",g.id=e+"_V"+c,g.classList.add(A),g.checked=!0,n.appendChild(g);var y=document.createElement("label");y.classList.add(N),y.appendChild(document.createTextNode(" "+m)),n.appendChild(y)}}}n.hidden=d<2}},s=I+"\n"+X;try{abc=new Abc(i),abc.tosvg("player",s),abc.tosvg("audio.abc",t)}catch(f){var l="%c "+f.message+"\nabc2svg tosvg bug - stack:\n"+f.stack;console.log(l,"color: red;")}}function Z(e,n,o){function ot(e){var t=st;e!==undefined&&(t=$ABC_UTIL.updateTempo(st,e));var n={events:$ABC_EVENTS.render(t,g,X),id:v};ut&&(ut.value=JSON.stringify(n));var r={idScore:v,zoom:o.scale,pagewidth:u};rt.innerHTML=$ABC_UTIL.svgMerge(Q(t,r),G(t,r))}if(e===undefined||e===null)return null;var u=parseFloat(e.classList[1]);isNaN(u)&&(u=p);var f=parseFloat(e.classList[2]);isNaN(f)||(o.scale=f),o=o||{};var l=n.indexOf(j,0)===-1&&n.indexOf(F,0)===-1;o.bPlayer===undefined&&(o.bPlayer=l),o.width===undefined&&(o.width=h),o.scale===undefined&&(o.scale=d),o.bHideTempo===undefined&&(o.bHideTempo=!0),o.lang===undefined&&(o.lang=a);var c=O+t,v=M+t,m=_+t,g=D+t,y=P+t;t++;var N=$ABC_UTIL.buildTempoSlider(n,m),C=K(e,b),H='<table id="'+c+'">',B='<div id="'+v+'"></div>';if(o.bPlayer){var I=n.indexOf(R,0)!==-1,q=n.indexOf(U,0)!==-1,z=n.indexOf(W,0)!==-1,V=!(I||q||z),$='<button id="'+y+'" class="'+k+'" value="80"></button>',J='<button id="'+m+'" class="'+w+'"></button>',Z='<div id="'+g+'" class="'+T+'"></div>',et="<div>"+N.html+"</div>";V?C.innerHTML=H+"<tr>"+'<td valign="center">'+"<table>"+'<tr><td align="center">'+$+J+et+"</td></tr>"+"<tr><td>"+Z+"</td></tr>"+"</table>"+"</td>"+"<td>"+B+"</td>"+"</tr><table>":z?C.innerHTML=H+"<tr>"+"<td>"+B+"</td>"+'<td valign="center">'+"<table>"+'<tr><td align="center">'+$+J+et+"</td></tr>"+"<tr><td>"+Z+"</td></tr>"+"</table>"+"</td>"+"</tr><table>":I?C.innerHTML=H+"<tr>"+'<td align="center">'+"<table>"+'<tr valign="center">'+'<td align="center">'+$+J+et+"</td>"+'<td width="10px"></td>'+"<td>"+Z+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"<tr><td>"+B+"</td></tr>"+"<table>":q&&(C.innerHTML=H+"<tr><td>"+B+"</td></tr>"+"<tr>"+'<td align="center">'+"<table>"+'<tr valign="center">'+'<td align="center">'+$+J+et+"</td>"+'<td width="10px"></td>'+"<td>"+Z+"</td>"+"</tr>"+"</table>"+"</td>"+"</tr>"+"<table>")}else C.innerHTML=H+"<tr><td>"+B+"</td></tr><table>";var tt=document.getElementById(c),nt=document.getElementById(m),rt=document.getElementById(v),it=document.getElementById(y),st=$ABC_UTIL.normalize(n,o);if(o.bPlayer){var ut=document.getElementById(m);Y(g,st);var at=N.selection;it.value=at,ot(at);var ft="."+L,lt=tt.querySelectorAll(ft);for(var ct=0,ht=lt.length;ct<ht;ct++)lt[ct].addEventListener("click",function(){var e="."+m+"."+L+"."+E,t=parseInt(this.classList[2]),n=it?it.value:undefined;if(t==n)return;nt.classList.contains(S)&&($EVENT_PLAYER.stop(),nt.classList.toggle(S)),tt.querySelector(e).classList.toggle(E),this.classList.toggle(E),it&&(it.value=t),ot(t)});ft="."+A;var pt=tt.querySelectorAll(ft);for(ct=0,ht=pt.length;ct<ht;ct++)pt[ct].addEventListener("change",function(){nt.classList.contains(S)&&($EVENT_PLAYER.stop(),nt.classList.toggle(S));var e=it?it.value:undefined;e==="undefined"&&(e=undefined),ot(e)});r?ut.classList.contains(x)||ut.classList.add(x):ut.hidden=!r,ut.addEventListener("click",function(){if(this.classList.contains(x)){$EVENT_PLAYER.stop(),this.classList.toggle(S);if(this.classList.contains(S)){var e=document.querySelectorAll("."+w);for(var t=0,n=e.length;t<n;t++)e[t].classList.contains(S)&&e[t]!=ut&&e[t].classList.toggle(S);if(s!==null){var r=document.getElementsByClassName(s);for(t=0,n=r.length;t<n;t++)r[t].style.setProperty("fill-opacity",0)}i=ut;var o=JSON.parse(ut.value);s=o.id,$EVENT_PLAYER.play(0,1e6,o.events)}}})}else{var dt={idScore:v,zoom:o.scale,pagewidth:u};rt.innerHTML=$ABC_UTIL.svgMerge(Q(st,dt),G(st,dt))}}function et(e,t,n){n===undefined&&(n=!1),t=t||!1,e=e||c;var r="div."+y;n||(r+="."+v);var i=e[0]=="m",s=-1,o,u,a="";if(t===!0){var f=i?m:g;s=f;var l=r+"."+f,h=document.querySelectorAll(l);h.forEach(function(e){var t=K(e,b);t.hidden=!0}),f=i?g:m;var p=r+"."+f,d=document.querySelectorAll(p);d.forEach(function(e){var t=K(e,b);t.hidden=!1})}var w=document.querySelectorAll(r);for(o=0,u=w.length;o<u;o++){a="";var E="",S=w[o];if(s===-1||s!==-1&&!S.classList.contains(s)){var x=S.childNodes.length===0?"":S.childNodes[0].nodeValue,T=1,N=e,C=S.classList.contains(v);x.trim()===""?E=external_eval(S.id):S.id!==""?(T=parseFloat(x),isNaN(T)?(T=1,x.indexOf("\n")==-1?(x.charAt(0)!=="<"&&(N=x,C=!0,x.indexOf("m")!=-1?N="m"+x.replace("m",""):x.indexOf("M")==-1&&(N="M"+x)),E=external_eval(S.id)):E=x):E=external_eval(S.id)):E=x;var k={scale:T};C&&(k.transpose=N),Z(S,a+E,k)}}}function tt(e){var t=e||{};t.lang&&(a=t.lang),t.instruments&&t.instruments.length>0&&(u=t.instruments),et(t.tonality,t.bMajorOrMinor,!0),u.length===0&&!o&&u.push(0),u.length>0&&nt(u)}function nt(e){var t=e.length;$EVENT_PLAYER.init(e,function(){$EVENT_PLAYER.stop(),i.classList.contains(S)&&i.classList.toggle(S)},function(e,t){var n=document.getElementsByClassName(s+" "+e);if(n!==undefined&&n.length>0){var r=t?.2:0;n[0].style.setProperty("fill-opacity",r)}},function(e){t--;if(t===0){r=!0;var n=document.querySelectorAll("."+w);for(var i=0,s=n.length;i<s;i++)n[i].classList.toggle(x),n[i].hidden=!1}},function(e){console.warn("Failure loading Soundfont instrument "+e)})}var e={},t=0,n=0,r=!1,i=null,s="",o=!0,u=[],a="en";const f="C",l="M",c=l+f,h=600,p=16,d=1,v="transposable",m="major",g="minor",y="abc-source",b="abc-render",w="abc-player",E="selected",S="playing",x="ready",T="abc-voices",N="abc-voice",C="abc-follow",k="abc-hidden",L="abc-dot",A="check-voice",O="abc-container",M=b,_=w,D=T,P="abc-tempo",H="%%voicecombine",B="%%player_no_voice",j="%%no_player",F="%%player_off",I="%%play",q="%%fullsvg",R="%%player_top",U="%%player_bottom",z="%%player_left",W="%%player_right",X="%%deco red 10 @ 0 0 0\n%%deco blue 10 @ 0 0 0\n%%deco green 10 @ 0 0 0\n%%deco brown 10 @ 0 0 0\n%%deco orange 10 @ 0 0 0\n%%deco yellow 10 @ 0 0 0\n%%deco gray 10 @ 0 0 0\n%%deco cyan 10 @ 0 0 0\n%%deco coral 10 @ 0 0 0\n%%deco gold 10 @ 0 0 0\n%%deco khaki 10 @ 0 0 0\n%%deco indigo 10 @ 0 0 0\n%%deco lime 10 @ 0 0 0\n%%deco navy 10 @ 0 0 0\n%%deco orchid 10 @ 0 0 0\n%%deco pink 10 @ 0 0 0\n%%deco peru 10 @ 0 0 0\n%%deco plum 10 @ 0 0 0\n%%deco purple 10 @ 0 0 0\n%%deco tan 10 @ 0 0 0\n%%deco teal 10 @ 0 0 0\n%%deco o>( 1 arrow_orange 0 0 0\n%%deco o>) 1 arrow_orange 0 0 0\n%%deco r>( 1 arrow_red 0 0 0\n%%deco r>) 1 arrow_red 0 0 0\n%%deco g>( 1 arrow_green 0 0 0\n%%deco g>) 1 arrow_green 0 0 0\n%%deco b>( 1 arrow_blue 0 0 0\n%%deco b>) 1 arrow_blue 0 0 0\n%%deco n>( 1 arrow_black 0 0 0\n%%deco n>) 1 arrow_black 0 0 0\n%%deco ->( 1 arrow_gray 0 0 0\n%%deco ->) 1 arrow_gray 0 0 0\n",V='%%beginsvg\n<defs>\n <marker id="arrow_orange" fill="orange" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_red" fill="red" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_blue" fill="blue" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_green" fill="green" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_gray" fill="gray" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <marker id="arrow_black" fill="black" markerWidth="6" markerHeight="6" refX="6" refY="3" orient="auto"><path d="M1,1 L1,5 L6,3 L1,1"/></marker>\n <path id="x_notehead" d="m-3 -3l6 6m0 -6l-6 6" class="stroke" style="stroke-width:1.2"/>\n <path id="xcircle_notehead" d="m-3 -3 l6 6 m0 -6 l-6 6 M 0, 0 m -4, 0 a 4,4 0 1,0 8,0 a 4,4 0 1,0 -8,0" class="stroke" style="stroke-width:1.2"></path>\n <path id="triangle_notehead" d="M0 -5 L-4 4 H4 Z"/>\n <path id="square_notehead" d="M0 -4 L-4 0 L0 4 L4 0Z"/>\n</defs>\n%%endsvg\n%%beginjs\nvar dsx=12,dex=14;\nuser.arrow_red = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_red");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_red); color: red"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_green = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_green");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_green); color: green"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_blue = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_blue");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_blue); color: blue"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_orange = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_orange");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_orange); color: orange"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_gray = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_gray");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_gray); color: gray"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\nuser.arrow_black = function (x, y, de) {\n var de1 = de.start;\n def_use("arrow_black");\n abc.xypath(de1.s.x + dsx, de1.y + staff_tb[de1.st].y);\n var s = \'" stroke-width="1.5" style="marker-end: url(#arrow_black); color: black"/>\';\n abc.out_svg("L" + abc.sx(de.s.x - dex).toFixed(2) + " " + abc.sy(de.y + staff_tb[de.st].y).toFixed(2) + s);\n}\n%%endjs\n';return e.init=function(e){tt(e)},e.updateTonality=function(e,t){et(e,t)},e.buildScore=function(e,t,n){return Z(e,t,n)},e}(),$ABC_UTIL=function(){"use strict";function N(e){var t=!0;e.bEditors===!1&&(t=!1);var n=document.querySelectorAll(s);for(var i=0,o=n.length;i<o;i++){var u=n[i],a=u.innerHTML;a=a.replace(/>/g,">");var f=I(a),l="";if(t){var c="?abc=",h=T.encode(f),p=encodeURI(m+c+h),d=encodeURI(g+c+h),y=B(a,{bStandard:!0,bKeepSpace:!0}),b=T.encode(y),w=encodeURI(v+c+b);l+="See in editors <a href='"+w+"' target='_blank'>abc2svg</a>, "+"<a href='"+p+"' target='_blank'>abc-ui</a>, "+"<a href='"+d+"' target='_blank'>dev.music</a>."}var E=u.classList.contains(r);E&&(f=k(f,e),l+="<pre class='abc-text'>"+f+"</pre>");var S=document.createElement("div");S.innerHTML=l;var x=u.parentNode;x.insertBefore(S,u)}}function C(e,t,n,r){r=r||{};var i=e,s;return t.forEach(function(e){r.bMacro?e="%%"+e:r.bDeco&&(e="!"+e+"!"),s='<span class="'+n+'">'+e+"</span>",e=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),i=i.replace(new RegExp(e,"g"),s)}),i}function k(e,t){t=t||{};var n=e,r;if(t.bMacro){var i={bMacro:!0};n=C(n,y,"abc-macro",i),n=C(n,b,"abc-ui-macro",i),w.forEach(function(e){e="%%"+e;var t=n.indexOf(e);if(t!==-1){var r=n.indexOf("\n",t),i=n.substring(0,t),s=n.substring(t,r),o='<span class="abc-ui-macro">'+s+"</span>",u=n.substring(r,n.length);n=i+o+u}})}if(t.bDeco){var s={bDeco:!0};n=C(n,E,"abc-deco",s),n=C(n,S,"color-deco",s),n=C(n,x,"arrow-deco",s)}return n}function L(e,t,n,r){if(r!=undefined)return r+e[0];if(t===!0)return"="+e[0];if(n===!0)return e[0];var i=e;return e.indexOf("#")!==-1?i="^"+e[0]:e.indexOf("b")!==-1&&(i="_"+e[0]),i}function A(e,t){var n=t.substring(1,t.length),r=L(n);if(r==="C")return e;if(r.indexOf("B")!==-1||r.indexOf("A")!==-1)r+=",";var i=e,s=0,o;for(;;){s=i.indexOf("K:",s+1);if(s===-1)break;o=i.indexOf("\n",s+1);var u=i.substring(s,o),a=u+" shift=C"+r+"\n";if(o===-1)break;i=i.substring(0,s)+a+i.substring(o+1,i.length)}return i}function O(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].replace(/^\s+|\s+$/gm,"");s=s.replace(/\s+/g," "),s=s.replace(/^\t+|\t+$/gm,""),s!==""&&(t+=s+"\n")}return t}function M(e,t){t=t||"en";var n="",r="",i="",s="",u="",a="",f="",h="",d="",v="",m="",g="",y="",b="";return e.indexOf("+name")!==-1?(f=' name="'+p[t].soprano+'" sname="'+p[t].sopranoShort+'"',d=' name="'+p[t].alto+'" sname="'+p[t].altoShort+'"',m=' name="'+p[t].tenor+'" sname="'+p[t].tenorShort+'"',y=' name="'+p[t].bass+'" sname="'+p[t].bassShort+'"'):e.indexOf("+shortname")!==-1&&(f=' name="'+p[t].sopranoShort+'" sname="'+p[t].sopranoShort+'"',d=' name="'+p[t].altoShort+'" sname="'+p[t].altoShort+'"',m=' name="'+p[t].tenorShort+'" sname="'+p[t].tenorShort+'"',y=' name="'+p[t].bassShort+'" sname="'+p[t].bassShort+'"'),e.indexOf("T")!==-1?(a="clef=C1",h="clef=C3",v="clef=C4",g="clef=F4"):e.indexOf("G")!==-1?(a=l,h=l,v="clef=treble_8",g=c):(a=l,h=l,v="clef=C",g=c),e.indexOf("D")!==-1&&(s="V:D "+a+"\n",r+="D "),e.indexOf("C")!==-1&&(u="V:C "+a+"\n",r+="C "),e.indexOf("N")!==-1&&(b="V:N "+g+"\n",i+=" N"),n+=s+u+"V:S "+a+f+"\n"+"V:A "+h+d+"\n"+"V:T "+v+m+"\n"+"V:B "+g+y+"\n"+b+o+"[("+r+"S) | A | T | (B"+i+")]\n",n}function _(e){var t=e.indexOf("D")!==-1,n=e.indexOf("C")!==-1,r=e.indexOf("N")!==-1,i=e.indexOf("2+2")!==-1||e.indexOf("4")!==-1,s=e.indexOf("3+1")!==-1,u=e.indexOf("4+1")!==-1,a=e.indexOf("3+2")!==-1,f=e.indexOf("2+3")!==-1,h=e.indexOf("3+3")!==-1,p=e.indexOf("4+2")!==-1,d=e.indexOf("5+1")!==-1,v="",m="",g="";return t&&(v+="V:D "+l+"\n",m+="D "),n&&(v+="V:C "+l+"\n",m+="C "),r&&(v+="V:N "+c+"\n",g+=" N"),h?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+c+"\nV:5 "+c+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3)|(4 5 6"+g+")}\n":d?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+l+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3 4 5)|(6"+g+")}\n":p?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+c+"\nV:6 "+c+"\n"+o+" {("+m+"1 2 3 4)|(5 6"+g+")}\n":u?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+l+"\nV:5 "+c+"\n"+o+" {("+m+"1 2 3 4)|(5"+g+")}\n":a?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+l+"\nV:4 "+c+"\nV:5 "+c+"\n"+o+" {("+m+"1 2 3)|(4 5"+g+")}\n":f?v+="V:1 "+l+"\nV:2 "+l+"\nV:3 "+c+"\nV:4 "+c+"\nV:5 "+c+"\n"+o+" {("+m+"1 2)|(3 4 5"+g+")}\n":i?v+="V:S "+l+"\nV:A "+l+"\nV:T "+c+"\nV:B "+c+"\n"+o+" {("+m+"S A)|(T B"+g+")}\n":s?v+="V:S "+l+"\nV:A "+l+"\nV:T "+l+"\nV:B "+c+"\n"+o+" {("+m+"S A T)|(B"+g+")}\n":v+="V:KG "+l+"\nV:KF "+c+"\n"+o+" {("+m+"KG)|(KF"+g+")}\n",v}function D(e,t){var n,r,i,s=e.indexOf(a,0);if(s!==-1){n=e.indexOf("\n",s+1);if(n!==-1)return r=e.substring(s,n),i=_(r,t),e.indexOf("K:")===-1&&(i+="K:C\n"),e=e.substring(0,s)+i+e.substring(n+1,e.length),e}s=e.indexOf(f,0);if(s!==-1){n=e.indexOf("\n",s+1);if(n!==-1)return r=e.substring(s,n),i=M(r,t),e.indexOf("K:")===-1&&(i+="K:C\n"),e=e.substring(0,s)+i+e.substring(n+1,e.length),e}return e}function P(e){var t=undefined,n=[],r=e.indexOf(u,0);if(r!==-1){var i=e.indexOf("\n",r+1);if(i!==-1){r=e.indexOf("{",r+1)+1,i=e.indexOf("}",r);var s=e.substring(r,i);s=s.replace(/\s/g,"");var o=!1,a;r=0;do i=s.indexOf(",",r),i!==-1?a=s.substring(r,i):(a=s.substring(r,s.length),o=!0),a.trim(),a.indexOf("*")!==-1&&(t=a.replace(/\*/g,""),a=t),n.push(a),r=i+1;while(!o)}}return t===undefined&&(t=n[0]),{tempos:n,selection:t}}function H(e,t){var n=P(e);if(n.selection===undefined)return{html:"",selection:undefined};var r=n.tempos,i=parseInt(r[0]),s=parseInt(r[r.length-1]),o=4,u=9,a=(u-o)/(s-i),f=o-a*i,l='<div class=" + class_abc_tempo + ">';for(var c=0,h=r.length;c<h;c++){var p=parseInt(r[c]),d=Math.round(a*p+f),v=" dot"+d,m=r[c]===n.selection?" selected":"";l+='<span class="'+t+" abc-dot "+r[c]+m+v+'"></span>'}return l+="</div>",{html:l,selection:n.selection}}function B(e,t){t=t||{};var n=!1;t.bKeepSpace!==undefined&&t.bKeepSpace===!0&&(n=!0);var r=n?I(e):O(e),i=-1,s=-1;r.indexOf("X:")!==-1&&(i=r.indexOf("X:",0),i!==-1&&(s=r.indexOf("\n",i+1),s!==-1&&(r=r.substring(0,i)+r.substring(s+1,r.length))));var o="";t.bHideTempo!==undefined&&(t.bHideTempo===!0?(i=r.indexOf("Q:",0),i!==-1&&(o="%%writefields Q 0\n")):t.bHideTempo===!1&&(o="%%writefields Q 1\n"));var u=o+"X:1\n";r.indexOf("L:")===-1&&(u+="L:1/1\n"),r=u+D(r,t.lang),r.indexOf("K:")===-1&&(i=r.indexOf("\n",r.indexOf("L:"))+1,r=r.substring(0,i)+"K:C\n"+r.substring(i,r.length)),t.transpose&&(r=A(r,t.transpose));if(t.bStandard===!0){r=r.replace(/%%MIDI program 128/g,"%%MIDI channel 10"),r=r.replace(/%%no_player\n/g,""),r=r.replace(/%%player_no_voice\n/g,"");var a=S.concat(x);a.forEach(function(e){e="!"+e+"!";var t=" ".repeat(e.length);e=e.replace(/[.*+?^${}()|[\]\\]/g,"\\$&"),r=r.replace(new RegExp(e,"g"),t)})}return q(r)}function j(e,t){var n=e,r="Q:1/4="+t+"\n",i=e.indexOf("X:1\n");return i!==-1&&(i+=4,n=e.substring(0,i)+r+e.substring(i,e.length)),n}function F(e,t){var n=e,r=e.indexOf(t);if(r!==-1){var i=e.indexOf("\n",r+1);if(i!==-1)return n=e.substring(0,r)+e.substring(i+1,e.length),F(n,t)}return n}function I(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].trim();s!==""&&(t+=s+"\n")}return q(t)}function q(e){var t=e.lastIndexOf("\n"),n=e.length;return t===n-1?e.substring(0,t):e}function R(e){var t="",n=e.split("\n");for(var r=0,i=n.length;r<i;r++){var s=n[r].trim();s=s.replace(/\s+/g," "),s!==""&&(t+=s+"\n")}return t}function U(e){var t=document.createElement("div");t.innerHTML=e;var n=t.querySelectorAll("style, defs, path, text, use");for(var r=0,i=n.length;r<i;r++){var s=n[r];s.parentNode.removeChild(s)}return R(t.innerHTML)}function z(e,t){var n=e.split(h),r=t.split(h),i=n.length,s=r.length;if(i!==s)return e;var o="";for(var u=0,a=i;u<a;u++){var f=n[u],l=U(r[u]),c=l.indexOf('<g class="music"');o+=f+l.substring(c,l.length)+h}return o}var e={};const t="abc-tempo",n="abc-source",r="view-source",i="view-editor",s="div."+n+"."+r+", div."+n+"."+i,o="%%score",u="%%tempo",a="%%piano",f="%%chorus",l="clef=treble",c="clef=bass",h="</svg>",p={en:{soprano:"Soprano",sopranoShort:"S",alto:"Alto",altoShort:"A",tenor:"Tenor",tenorShort:"T",bass:"Bass",bassShort:"B",KG:"G key",KGShort:"GK",KF:"F key",KFShort:"FG"},fr:{soprano:"Soprano",sopranoShort:"S",alto:"Alto",altoShort:"A",tenor:"Ténor",tenorShort:"T",bass:"Basse",bassShort:"B",KG:"Clé de sol",KGShort:"Sol",KF:"Clé de fa",KFShort:"Fa"}};var d="en";const v="../../../../editors/abc2svg/index.html",m="../../../../editors/abc_ui/index.html",g="http://dev.music.free.fr/editors/abc_ui/index.html",y=["scores","score","staves","keywarn","timewarn","stemheight","bstemdown","flatbeams","slurheight","squarebreve","voicecombine","singleline","dblrepbar","graceslurs","gracespace","graceword","stafflines","cancelkey","ambitus","straightflags","MIDI","voicemap","diagram","chordnames","measurenb","measurebox ","setbarnb","contbarnb","equalbars","barsperstaff","break","stretchlast","stretchstaff","leftmargin","pagewidth","soloffs","musicspace","shiftunison","textoption","begintext","endtext","center","infoline","aligncomposer","composerfont","composerspace","hyphencont","text","clef","pos","map","sth"],b=["no_player","player_off","player_no_voice","tempo"],w=["piano","chorus"],E=["beambr1","beambr2","ped","ped-up","ped(","ped)","1","2","3","4","5","/","//","///","-(","-)","roll","snap","thumb","open","+","0","breath","shortphrase","mediumphrase","longphrase","tenuto","wedge","accent","^","upbow","downbow","emphasis","marcato","arpeggio","mordent","uppermordent","lowermordent","trill","pralltriller","trill(","trill)","diminuendo(","diminuendo)","crescendo(","crescendo)","fermata","invertedfermata","D.C.","coda","D.S.","segno","fine","turn","turnx","invertedturn","invertedturnx","mf","f","ff","fff","ffff","mp","p","pp","ppp","pppp","8va(","8va)","8vb(","8vb)"],S=["red","blue","green","brown","orange","yellow","gray","cyan","coral","gold","khaki","indigo","lime","navy","orchid","pink","peru","plum","purple","tan","teal"],x=["o>(","o>)","b>(","b>)","g>(","g>)","r>(","r>)","n>(","n>)",">(",">)"];var T={_keyStr:"ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=",_utf8_encode:function(e){e=e.replace(/\r\n/g,"\n");for(var t="",n=0;n<e.length;n++){var r=e.charCodeAt(n);r<128?t+=String.fromCharCode(r):r>127&&r<2048?(t+=String.fromCharCode(r>>6|192),t+=String.fromCharCode(63&r|128)):(t+=String.fromCharCode(r>>12|224),t+=String.fromCharCode(r>>6&63|128),t+=String.fromCharCode(63&r|128))}return t},encode:function(e){var t,n,r,i,s,o,u,a="",f=0;for(e=T._utf8_encode(e);f<e.length;)i=(t=e.charCodeAt(f++))>>2,s=(3&t)<<4|(n=e.charCodeAt(f++))>>4,o=(15&n)<<2|(r=e.charCodeAt(f++))>>6,u=63&r,isNaN(n)?o=u=64:isNaN(r)&&(u=64),a=a+this._keyStr.charAt(i)+this._keyStr.charAt(s)+this._keyStr.charAt(o)+this._keyStr.charAt(u);return a}};return e.remapVoiceName=function(e,t){t=t||"en";const n={KG:p[t].KG,KF:p[t].KF,S:p[t].soprano,A:p[t].alto,T:p[t].tenor,B:p[t].bass};var r=e.id.toUpperCase();return e.nm?n[e.nm]?n[e.nm]:e.nm:n[r]?n[r]:e.id},e.isActiveVoice=function(e){const t=["D","C","N"];return t.indexOf(e.toUpperCase())===-1},e.updateTempo=function(e,t){return j(e,t)},e.buildTempoSlider=function(e,t){return H(e,t)},e.normalize=function(e,t){return B(e,t)},e.addHtmlVievers=function(e){return N(e)},e.remove=function(e,t){return F(e,t)},e.svgMerge=function(e,t){return z(e,t)},e}(),$ABC_EVENTS=function(){"use strict";function u(e){o&&console.log("$ABC_EVENTS."+e)}function a(){u("init"),t=null,n=0,r=0,i=0,s=0}function f(e,n,o){function L(e){const t=e.v;for(var n=0;n<10;n++)m[t].set(v,n*7);g[t].set(m[t])}function A(e){v=[0,0,0,0,0,0,0];switch(e.k_sf){case 7:v[6]=1;case 6:v[2]=1;case 5:v[5]=1;case 4:v[1]=1;case 3:v[4]=1;case 2:v[0]=1;case 1:v[3]=1;break;case-7:v[3]=-1;case-6:v[0]=-1;case-5:v[4]=-1;case-4:v[1]=-1;case-3:v[5]=-1;case-2:v[2]=-1;case-1:v[6]=-1}L(e)}function O(){for(var e=0;e<a;e++){var t=n[e].clef;y[e]=!t.clef_octave||t.clef_oct_transp?0:t.clef_octave;var r=n[e],i=r.instr||0;r.midictl&&(r.midictl[32]&&(i+=r.midictl[32]*128),r.midictl[0]&&(i+=r.midictl[0]*128*128)),b[e]=i,m[e]=new Float32Array(70),g[e]=new Float32Array(70),r.key.v=e,A(r.key)}}function M(e,t){var n=e.notes[t],r=n.pit+19-7,i=n.acc;y[e.v]&&(r+=y[e.v]),i?(i==3?i=0:n.micro_n&&(console.log("micro tone not supported"),i=(i<0?-n.micro_n:n.micro_n)/n.micro_d*2),d[r]=i):i=d[r];var s=r/7|0;return r=h[r%7]+i,r>=12?(r-=12,s++):r<0&&(r+=12,s--),c[r]+l[s]}function _(t){if(t.v!=w)return null;var n;if(t.bar_type[0]===":"){u("_handle_bar with ':|' or ':]'"),t.bar_type="|"+t.bar_type.slice(1),N=t,C||(C=t);if(T){t=T;for(n=0;n<a;n++)g[n].set(S[n]),y[n]=E[n];r=x}else t=e,O();return s=t.time,t}if(!t.invis)for(n=0;n<a;n++)g[n].set(m[n]);if(t.bar_type[t.bar_type.length-1]==":"){u("_handle_bar with '|:'"),T=t,C=null;for(n=0;n<a;n++)S||(S=[]),S[n]||(S[n]=new Float32Array(70)),S[n].set(g[n]),E||(E=[]),E[n]=y[n];x=r}else t.text&&t.text[0]=="1"&&(u("_handle_bar with 1st time repeat"),C=t);return null}function D(e,t,n){u("_do_tie");var i,s,o,a=e.time+e.dur,f=e.notes[t],l=f.pit;for(o=e.next;;o=o.next){if(!o||o.time!=a)return n;if(o==C){var c=o.v;o=N.ts_next;while(o&&o.v!==c)e=e.ts_next;if(!e)return n;a=o.time}if(o.time!=a)return n;if(o.type==abc2svg.C.NOTE)break}s=o.notes.length;for(i=0;i<s;i++){f=o.notes[i];if(f.pit==l)return n+=o.dur/r,f.ti2=!0,f.ti1?D(o,i,n):n}return n}function P(e,n,r){for(var i=0;i<=e.nhd;i++){var s=e.notes[i];if(s.ti2)continue;var a=!0;o&&(a=o.indexOf(e.v)===-1);if(a){s=M(e,i);var f=e.istart,l=e.notes[i].ti1?D(e,i,r):r,c=b[e.v];t.push([f,n,c,s,l]),u("add event: index="+f+", time="+n+", instrument="+c+", note='"+s+"', duration="+l)}}}function H(e){u("_gen_grace");var t=e.next;if(e.time==0&&s===0){var n=0;if(e.sappo)n=abc2svg.C.BLEN/16;else if(!t||t.type!=abc2svg.C.NOTE)n=k/2;s-=n}var o,a,l,c;if(e.sappo)c=f/16;else if((!t||t.type!=abc2svg.C.NOTE)&&e.prev&&e.prev.type==abc2svg.C.NOTE)c=e.prev.dur/2;else{t.ts_prev.ts_next=t.ts_next,t.ts_next.ts_prev=t.ts_prev;for(var h=t.ts_next;h;h=h.ts_next)if(h.time!=t.time){t.ts_next=h,t.ts_prev=h.ts_prev,t.ts_prev.ts_next=t,h.ts_prev=t;break}t.dots?t.dots==1?c=t.dur/3:c=t.dur*2/7:c=t.dur/2,t.time+=c,t.dur-=c}a=0;for(o=e.extra;o;o=o.next)o.type==abc2svg.C.NOTE&&a++;c/=a*r,l=i;for(o=e.extra;o;o=o.next){if(o.type!=abc2svg.C.NOTE)continue;P(o,l,c),l+=c}}const a=n.length,f=1536,l="012345678",c=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],h=[0,2,4,5,7,9,11];var p=e,d,v=[],m=[],g=[],y=[],b=[],w=null,E=null,S=null,x=null,T=null,N=null,C=null,k=null;O(),t?p.time<s&&(s=p.time):(t=[],s=i=0,r=f/4*80/60);while(p){if(p.tempo){var B=0;for(var j=0,F=p.tempo_notes.length;j<F;j++)B+=p.tempo_notes[j];r=B*p.tempo/60}var I=p.time-s;I>0&&(i+=I/r,s=p.time),p==C&&(p=N,s=p.time),d=g[p.v];switch(p.type){case abc2svg.C.BAR:var q=_(p);q!==null&&(p=q);break;case abc2svg.C.CLEF:y[p.v]=!p.clef_octave||p.clef_oct_transp?0:p.clef_octave;break;case abc2svg.C.GRACE:H(p);break;case abc2svg.C.KEY:A(p);break;case abc2svg.C.REST:case abc2svg.C.NOTE:k=p.dur;var R=p.next;if(R&&R.type===abc2svg.C.GRACE){I=0;if(R.sappo)I=abc2svg.C.BLEN/16;else if(!R.next||R.next.type!==abc2svg.C.NOTE)I=k/2;R.time-=I,k-=I}k/=r,p.type==abc2svg.C.NOTE?P(p,i,k):t.push([p.istart,i,-1,0,k]);break;case abc2svg.C.STAVES:w=p.sy.top_voice}p=p.ts_next}}function l(e,n,r){if(e===undefined)return;var i="",s={errmsg:function(e,t,n){console.log("%c "+e,"color: red;")},get_abcmodel:function(e,t){const r=t.length;if(r!==1)for(var s=0;s<r;s++){var o=n+"_V"+s,a=document.getElementById(o);if(a===undefined||a!==null&&a.checked===!1)i+=s+" "}u("voice_no_play="+i),f(e,t,i)}},o=$ABC_UTIL.remove(e,"%%voicecombine");a();var l="%%play\n"+r;try{abc=new Abc(s),abc.tosvg("play",l),abc.tosvg("follower.abc",o)}catch(c){var h="%c "+c.message+"\nabc2svg tosvg bug - stack:\n"+c.stack;console.log(h,"color: red;")}return t}var e={},t=null,n=0,r=0,i=0,s=0;const o=!1;return e.render=function(e,t,n){return u("render"),l(e,t,n)},e}(),$EVENT_PLAYER=function(){"use strict";function p(e){c&&console.log("$EVENT_PLAYER."+e)}function d(e,t,r){n[e]&&(p("_playNote("+e+", '"+t+"', "+r+")"),n[e].play(t,l,{duration:r}))}function v(){var e,n,c,p;if(u===0){r&&r();return}c=s[o++];if(!c||c[0]>u){r&&r();return}n=c[1]-a;for(;;){var m=c[2],g=c[3],y=c[4];d(m,g,y);if(i){var b=c[0],w=(c[1]+f-t.currentTime)*h,E=w+y*h;setTimeout(i,w,b,!0),setTimeout(i,E,b,!1)}p=s[o];if(!p){e=n+y;break}c=p,e=c[1]-a;if(e!=n)break;o++}l+=e-n,setTimeout(v,(l-t.currentTime-1)*h)}function m(e,n,i){p("_play("+e+", "+n+")"),s=i;if(!s||!s.length){r&&r();return}o=0,u=n,a=0;while(s[o]&&o<e&&e!=0)a=s[o][1],o++;s[o]&&(l=t.currentTime+s[o][1]-a),f=t.currentTime+.05,v()}function g(){return p("_stop() at index="+o),u=0,a=0,o}function y(e,s,o,u,a){r=s,i=o;if("AudioContext"in window)console.log("%cSound being generated with window.AudioContext.","color: green;"),t=new window.AudioContext;else{if(!("webkitAudioContext"in window)){alert("Web Audio API is not available!\nCan't generate sound!");return}console.log("%cSound being generated with window.webkitAudioContext.","color: green;"),t=new window.webkitAudioContext}if(t===null&&a){a("Web Audio API is not available!");return}$SF_PLAYER.init(t,e,function(e){n[e.index]=e,u&&u(e)},function(e){a&&a(e)})}var e={},t=null,n={},r=null,i=null,s=null,o=0,u=0,a=0,f=0,l=0;const c=!1,h=1e3;return e.init=function(e,t,n,r,i){p("init"),y(e,t,n,r,i)},e.play=function(e,t,n){p("play"),m(e,t,n)},e.stop=function(){return p("stop"),g()},e.playNote=function(e,t,n){p("playNote"),d(e,t,n)},e}();if(typeof MIDI=="undefined")var MIDI={};typeof MIDI.Soundfont=="undefined"&&(MIDI.Soundfont={});var $SF_PLAYER=function(){"use strict";function i(e,n){t&&console.log("$SF_PLAYER."+e)}function s(e,t){n&&console.log("$SF_PLAYER - "+e,t)}function o(e,t,n,r){i("_load");var s=null;l(t)?s=c:w(t)?s=E:h(t)?s=p:y(t)?s=b:u(t)&&(s=a);var o=n||{};return s?s(e,t,o):r?Promise.resolve(r):Promise.reject("Source not valid ("+t+")")}function a(e,t,n){i("_loadMidiJSFile");var r=g(n.from,t);return o(e,o.fetch(r,"text").then(f),n)}function f(e){i("_midiJsToJson");var t=e.indexOf("MIDI.Soundfont.");if(t<0)throw Error("Invalid MIDI.js Soundfont format");t=e.indexOf("=",t)+2;var n=e.lastIndexOf(",");return JSON.parse(e.slice(t,n)+"}")}function l(e){return e instanceof ArrayBuffer}function c(e,t,n){return i("_loadArrayBuffer"),new Promise(function(n,r){e.decodeAudioData(t,function(e){n(e)},function(){r("Can't decode audio data ("+t.slice(0,30)+"...)")})})}function h(e){return e&&typeof e=="object"}function p(e,t,n){i("_loadObjectData");var r="",s={},u=Object.keys(t).map(function(i){if(n.only&&n.only.indexOf(i)===-1)return null;r+=i+", ";var u=t[i];return o(e,u,n,u).then(function(e){s[i]=e})});return Promise.all(u).then(function(){return i(r),s})}function d(e){return e>64&&e<91?e-65:e>96&&e<123?e-71:e>47&&e<58?e+4:e===43?62:e===47?63:0}function v(e,t){var n=e.replace(/[^A-Za-z0-9\+\/]/g,""),r=n.length,i=t?Math.ceil((r*3+1>>2)/t)*t:r*3+1>>2,s=new Uint8Array(i);for(var o,u,a=0,f=0,l=0;l<r;l++){u=l&3,a|=d(n.charCodeAt(l))<<18-6*u;if(u===3||r-l===1){for(o=0;o<3&&f<i;o++,f++)s[f]=a>>>(16>>>o&24)&255;a=0}}return s}function m(e){return function(t){return typeof t=="string"&&e.test(t)}}function g(e,t){return typeof e=="string"?e+t:typeof e=="function"?e(t):t}function b(e,t,n){i("_loadBase64Audio");var r=t.indexOf(",");return o(e,v(t.slice(r+1)).buffer,n)}function w(e){return e&&typeof e.then=="function"}function E(e,t,n){return i("_loadPromise"),t.then(function(t){return o(e,t,n)})}function S(e){i("ADSR");var t=e.createGain(),n=t._voltage=N(e),r=C(n),s=C(n),o=C(n);return t._startAmount=C(s),t._endAmount=C(o),t._multiplier=C(r),t._multiplier.connect(t),t._startAmount.connect(t),t._endAmount.connect(t),t.value=r.gain,t.startValue=s.gain,t.endValue=o.gain,t.startValue.value=0,t.endValue.value=0,Object.defineProperties(t,x),t}function N(e){i("getVoltage");var t=e.createBufferSource(),n=e.createBuffer(1,2,e.sampleRate);return n.getChannelData(0).set(T),t.buffer=n,t.loop=!0,t}function C(e){i("scale");var t=e.context.createGain();return e.connect(t),t}function k(e){return Math.log(e+1)/Math.log(100)}function L(e,t,n,r,i){var s=t-e,o=r-n,u=i-n,a=u/o,f=e+a*s;return f<=e&&(f=e),f>=t&&(f=t),f}function M(e,t,n){function f(t,n){return n.id=i++,s[n.id]=n,n.source.onended=function(){var t=e.currentTime;n.source.disconnect(),n.env.disconnect(),n.disconnect(),a.emit("ended",t,n.id,n)},n.id}function l(t,n,r){var i=e.createGain();return i.gain.value=0,i.connect(o),i.env=P(e,r,u),i.env.connect(i.gain),i.source=e.createBufferSource(),i.source.buffer=n,i.source.connect(i),i.source.loop=r.loop||u.loop,i.source.playbackRate.value=H(r.cents||u.cents),i.source.loopStart=r.loopStart||u.loopStart,i.source.loopEnd=r.loopEnd||u.loopEnd,i.stop=function(n){var r=n||e.currentTime;a.emit("stop",r,t);var s=i.env.stop(r);i.source.stop(s)},i}var r=!1,i=0,s={},o=e.createGain(),u=Object.assign({},O,n),a={context:e,out:o,opts:u};return t instanceof AudioBuffer?a.buffer=t:a.buffers=t,a.start=function(t,n,i){if(a.buffer&&t!==null)return a.start(null,t,n);var s=t?a.buffers[t]:a.buffer;if(!s){console.warn("Buffer "+t+" not found.");return}if(!r){console.warn("SamplePlayer not connected to any node.");return}var o=i||A;n=Math.max(e.currentTime,n||0),a.emit("start",n,t,o);var u=l(t,s,o);return u.id=f(t,u),u.env.start(n),u.source.start(n),a.emit("started",n,u.id,u),o.duration&&u.stop(n+o.duration),u},a.play=function(e,t,n){return a.start(e,t,n)},a.stop=function(e,t){var n;return t=t||Object.keys(s),t.map(function(t){return n=s[t],n?(n.stop(e),n.id):null})},a.connect=function(e){return r=!0,o.connect(e),a},a.emit=function(e,t,n,r){a.onevent&&a.onevent(e,t,n,r);var i=a["on"+e];i&&i(t,n,r)},a}function _(e){return typeof e=="number"}function P(e,t,n){i("envelope");var r=S(e),s=t.adsr||n.adsr;return D.forEach(function(e,i){s?r[e]=s[i]:r[e]=t[e]||n[e]}),r.value.value=_(t.gain)?t.gain:_(n.gain)?n.gain:1,r}function H(e){return e?Math.pow(2,e/1200):1}function B(e){return/\.js(\?.*)?$/i.test(e)}function j(e,t,n){return n=n==="ogg"?n:"mp3",t=t==="FluidR3_GM"?t:"MusyngKite","https://gleitz.github.io/midi-js-soundfonts/"+t+"/"+e+"-"+n+".js"}function F(e){return r.indexOf(e)}function I(e,t,n){var r=n||{};s("_initInstrument",t);if(MIDI.Soundfont[t])return s("Already loaded, decode Soundfont ",t),o(e,MIDI.Soundfont[t],{only:r.only||r.notes}).then(function(n){var i=M(e,n,r).connect(e.destination);return i.name=t,i.index=F(t),i});var i=r.isSoundfontURL||B,u=r.nameToUrl||j,a=i(t)?t:u(t,r.soundfont,r.format);return o(e,a,{only:r.only||r.notes}).then(function(n){s("Load and decode ",a);var i=M(e,n,r).connect(e.destination);return i.url=a,i.name=t,i.index=F(t),i})}function q(e){function t(e){var t=[];for(var n=0,r=e.length;n<r;n++){var i=-1;typeof e[n]=="number"?i=e[n]:typeof e[n]=="string"&&(i=F(e[n])),i<=128&&i!=-1&&t.push(i)}return t}function n(e){return e.sort().filter(function(e,t,n){return!t||e!=n[t-1]})}return n(t(e))}var e={};const t=!1,n=!1,r=["acoustic_grand_piano","bright_acoustic_piano","electric_grand_piano","honky-tonk_piano","electric_piano_1","electric_piano_2","harpsichord","clavinet","celesta","glockenspiel","music_box","vibraphone","marimba","xylophone","tubular_bells","dulcimer","drawbar_organ","percussive_organ","rock_organ","church_organ","reed_organ","accordion","harmonica","tango_accordion","acoustic_guitar_nylon","acoustic_guitar_steel","electric_guitar_jazz","electric_guitar_clean","electric_guitar_muted","overdriven_guitar","distortion_guitar","guitar_harmonics","acoustic_bass","electric_bass_finger","electric_bass_pick","fretless_bass","slap_bass_1","slap_bass_2","synth_bass_1","synth_bass_2","violin","viola","cello","contrabass","tremolo_strings","pizzicato_strings","orchestral_harp","timpani","string_ensemble_1","string_ensemble_2","synth_strings_1","synth_strings_2","choir_aahs","voice_oohs","synth_choir","orchestra_hit","trumpet","trombone","tuba","muted_trumpet","french_horn","brass_section","synth_brass_1","synth_brass_2","soprano_sax","alto_sax","tenor_sax","baritone_sax","oboe","english_horn","bassoon","clarinet","piccolo","flute","recorder","pan_flute","blown_bottle","shakuhachi","whistle","ocarina","lead_1_square","lead_2_sawtooth","lead_3_calliope","lead_4_chiff","lead_5_charang","lead_6_voice","lead_7_fifths","lead_8_bass__lead","pad_1_new_age","pad_2_warm","pad_3_polysynth","pad_4_choir","pad_5_bowed","pad_6_metallic","pad_7_halo","pad_8_sweep","fx_1_rain","fx_2_soundtrack","fx_3_crystal","fx_4_atmosphere","fx_5_brightness","fx_6_goblins","fx_7_echoes","fx_8_sci-fi","sitar","banjo","shamisen","koto","kalimba","bagpipe","fiddle","shanai","tinkle_bell","agogo","steel_drums","woodblock","taiko_drum","melodic_tom","synth_drum","reverse_cymbal","guitar_fret_noise","breath_noise","seashore","bird_tweet","telephone_ring","helicopter","applause","gunshot","percussion"];o.fetch=function(e,t){return i("_load.fetch"),new Promise(function(n,r){var i=new XMLHttpRequest;t&&(i.responseType=t),i.open("GET",e),i.onload=function(){i.status===200?n(i.response):r(Error(i.statusText))},i.onerror=function(){r(Error("Network Error"))},i.send()})};var u=m(/\.js(\?.*)?$/i),y=m(/^data:audio/),x={attack:{value:0,writable:!0},decay:{value:0,writable:!0},sustain:{value:1,writable:!0},release:{value:0,writable:!0},getReleaseDuration:{value:function(){return this.release}},start:{value:function(e){i("start");var t=this._multiplier.gain,n=this._startAmount.gain,r=this._endAmount.gain;this._voltage.start(e),this._decayFrom=this._decayFrom=e+this.attack,this._startedAt=e;var s=this.sustain;t.cancelScheduledValues(e),n.cancelScheduledValues(e),r.cancelScheduledValues(e),r.setValueAtTime(0,e),this.attack?(t.setValueAtTime(0,e),t.linearRampToValueAtTime(1,e+this.attack),n.setValueAtTime(1,e),n.linearRampToValueAtTime(0,e+this.attack)):(t.setValueAtTime(1,e),n.setValueAtTime(0,e)),this.decay&&t.setTargetAtTime(s,this._decayFrom,k(this.decay))}},stop:{value:function(e,t){i("stop"),t&&(e-=this.release);var n=e+this.release;if(this.release){var r=this._multiplier.gain,s=this._startAmount.gain,o=this._endAmount.gain;r.cancelScheduledValues(e),s.cancelScheduledValues(e),o.cancelScheduledValues(e);var u=k(this.release);if(this.attack&&e<this._decayFrom){var a=L(0,1,this._startedAt,this._decayFrom,e);r.linearRampToValueAtTime(a,e),s.linearRampToValueAtTime(1-a,e),s.setTargetAtTime(0,e,u)}o.setTargetAtTime(1,e,u),r.setTargetAtTime(0,e,u)}return this._voltage.stop(n),n}},onended:{get:function(){return this._voltage.onended},set:function(e){this._voltage.onended=e}}},T=new Float32Array([1,1]),A={},O={gain:1,attack:.01,decay:.1,sustain:.9,release:.3,loop:!1,cents:0,loopStart:0,loopEnd:0},D=["attack","decay","sustain","release"];return e.init=function(e,t,n,i,o){if(typeof u=="undefined")var u={};typeof u.Soundfont=="undefined"&&(u.Soundfont={}),t=q(t);var a=t.length;s(a,"instrument(s) to initialize.");for(var f=0;f<a;f++){var l=t[f],c=r[l];s("#"+l,c),I(e,c).then(function(e){console.log('%cSoundfont instrument "'+e.name+'" loaded. (MIDI program '+e.index+")","color: green;"),n&&n(e)},function(e){i&&i(e)})}},e}();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:1,SL_BELOW:2,SL_AUTO:3,SL_HIDDEN:4,SL_DOTTED:8},Abc:function(user){"use strict";function clone(e,t){if(!e)return e;var n=new e.constructor;for(var r in e)e.hasOwnProperty(r)&&(t&&typeof e[r]=="object"?n[r]=clone(e[r],t-1):n[r]=e[r]);return n}function errbld(e,t,n,r){var i,s,o,u,a;if(user.errbld){switch(e){case 0:e="warn";break;case 1:e="error";break;default:e="fatal"}user.errbld(e,t,n,r);return}if(r!=undefined&&r>=0){i=o=0;for(;;){s=parse.file.indexOf("\n",i);if(s<0||s>r)break;o++,i=s+1}u=r-i}a="",n&&(a=n,o&&(a+=":"+(o+1)+":"+(u+1)),a+=" ");switch(e){case 0:a+="Warning: ";break;case 1:a+="Error: ";break;default:a+="Internal bug: "}user.errmsg(a+t,o,u)}function error(e,t,n,r,i,s,o){var u,a,f,l;user.textrans&&(l=user.textrans[n],l&&(n=l)),arguments.length>3&&(n=n.replace(/\$./g,function(e){switch(e){case"$1":return r;case"$2":return i;case"$3":return s;default:return o}})),t&&t.fname?errbld(e,n,t.fname,t.istart):errbld(e,n)}function scanBuf(){this.index=0,scanBuf.prototype.char=function(){return this.buffer[this.index]},scanBuf.prototype.next_char=function(){return this.buffer[++this.index]},scanBuf.prototype.get_int=function(){var e=0,t=this.buffer[this.index];while(t>="0"&&t<="9")e=e*10+Number(t),t=this.next_char();return e}}function syntax(e,t,n,r,i,s){var o={fname:parse.fname,istart:parse.istart+parse.line.index};error(e,o,t,n,r,i,s)}function js_inject(js){/eval *\(|Function|setTimeout|setInterval/.test(js)?syntax(1,"Unsecure code"):eval('"use strict"\n'+js)}function y_get(e,t,n,r){var i,s=staff_tb[e],o=n/realwidth*YSTEP|0,u=(n+r)/realwidth*YSTEP|0;o<0&&(o=0),u>=YSTEP&&(u=YSTEP-1,o>u&&(o=u));if(t){i=s.top[o++];while(o<=u)i<s.top[o]&&(i=s.top[o]),o++}else{i=s.bot[o++];while(o<=u)i>s.bot[o]&&(i=s.bot[o]),o++}return i}function y_set(e,t,n,r,i){var s=staff_tb[e],o=n/realwidth*YSTEP|0,u=(n+r)/realwidth*YSTEP|0;o<0&&(o=0),u>=YSTEP&&(u=YSTEP-1,o>u&&(o=u));if(t)while(o<=u)s.top[o]<i&&(s.top[o]=i),o++;else while(o<=u)s.bot[o]>i&&(s.bot[o]=i),o++}function up_p(e,t){switch(t){case C.SL_ABOVE:return!0;case C.SL_BELOW:return!1}return e.multi&&e.multi!=0?e.multi>0:e.p_v.have_ly?e.pos.voc!=C.SL_ABOVE:!1}function d_arp(e){var t,n,r,i=e.s,s=e.dd,o=5;if(i.type==C.NOTE)for(t=0;t<=i.nhd;t++){if(i.notes[t].acc)r=5+i.notes[t].shac;else{r=6-i.notes[t].shhd;switch(i.head){case C.SQUARE:r+=3.5;break;case C.OVALBARS:case C.OVAL:r+=2}}r>o&&(o=r)}n=3*(i.notes[i.nhd].pit-i.notes[0].pit)+4,t=s.h,n<t&&(n=t),e.has_val=!0,e.val=n,e.x-=o,e.y=3*(i.notes[0].pit-18)-3}function d_cresc(e){if(e.ldst)return;var t,n,r,i,s,o,u,a,f=e.s,l=e.start,c,h;t=l.s,s=t.x+3,a=l.ix,a>0&&(c=a_de[a-1]),e.st=f.st,e.lden=!1,e.has_val=!0,i=up_p(f,f.pos.dyn),i&&(e.up=!0),c&&c.s==t&&(e.up&&!c.up||!e.up&&c.up)&&(r=c.dd,f_staff[r.func]&&(u=c.x+c.val+4,u>s&&(s=u))),e.defl.noen?(o=e.x-s,o<20&&(s=e.x-20-3,o=20)):(u=f.x,h=a_de[e.ix+1],h&&h.s==t&&(e.up&&!h.up||!e.up&&h.up)&&(r=h.dd,f_staff[r.func]&&(u-=5)),o=u-s-4,o<20&&(s-=(20-o)*.5,o=20)),e.val=o,e.x=s,e.y=y_get(e.st,i,s,o),i||(n=e.dd,e.y-=n.h)}function d_near(e){var t,n,r=e.s,i=e.dd;if(i.str)return;r.multi?n=r.multi>0:n=r.stem<0,n?t=r.ymx|0:t=r.ymn-i.h|0,t>-6&&t<24&&(n&&(t+=3),t=((t+6)/6|0)*6-6),n?r.ymx=t+i.h:r.ymn=t,e.y=t,r.type==C.NOTE&&(e.x+=r.notes[r.stem>=0?0:r.nhd].shhd),i.name[0]=="d"&&r.nflags>=-1&&(n?r.stem>0&&(e.x+=3.5):r.stem<0&&(e.x-=3.5))}function d_pf(e){var t,n,r,i,s=e.s,o=e.dd,u;e.val=o.wl+o.wr,i=up_p(s,s.pos.vol),i&&(e.up=!0),r=s.x-o.wl,e.ix>0&&(u=a_de[e.ix-1],u.s==s&&(e.up&&!u.up||!e.up&&u.up)&&(t=u.dd,f_staff[t.func]&&(n=u.x+u.val+4,n>r&&(r=n)))),e.x=r,e.y=y_get(s.st,i,r,e.val),i||(e.y-=o.h)}function d_slide(e){var t,n,r=e.s,i=r.notes[0].pit,s=5;for(t=0;t<=r.nhd;t++){if(r.notes[t].acc)n=4+r.notes[t].shac;else{n=5-r.notes[t].shhd;switch(r.head){case C.SQUARE:n+=3.5;break;case C.OVALBARS:case C.OVAL:n+=2}}r.notes[t].pit<=i+3&&n>s&&(s=n)}e.x-=s,e.y=3*(i-18)}function d_trill(e){if(e.ldst)return;var t,n,r,i,s,o=e.s,u=o.st,a=e.start.s,f=a.x;e.prev&&(f=e.prev.x+10,r=e.prev.y),e.st=u;if(e.dd.func!=4)switch(e.dd.glyph){case"8va":case"15ma":n=1;break;default:n=o.multi>=0}e.defl.noen?(i=e.x-f,i<20&&(f=e.x-20-3,i=20)):(i=o.x-f-6,o.type==C.NOTE&&(i-=6),i<20&&(f-=(20-i)*.5,i=20)),t=e.dd,r||(r=y_get(u,n,f,i)),n?(s=staff_tb[a.st].topbar+2,r<s&&(r=s)):(r-=t.h,s=staff_tb[a.st].botbar-2,r>s&&(r=s)),e.lden=!1,e.has_val=!0,e.val=i,e.x=f,e.y=r,n&&(r+=t.h),y_set(u,n,f,i,r),n?a.ymx=o.ymx=r:a.ymn=o.ymn=r}function d_upstaff(e){if(e.ldst)return;if(e.start){d_trill(e);return}var t,n,r,i=e.s,s=e.dd,o=i.x,u=s.wl+s.wr,a=staff_tb[i.st].topbar+2,f=staff_tb[i.st].botbar-2;i.nhd&&(o+=i.notes[i.stem>=0?0:i.nhd].shhd),n=-1;if(s.func==4)n=0;else if(i.pos)switch(i.pos.orn){case C.SL_ABOVE:n=1;break;case C.SL_BELOW:n=0}switch(s.glyph){case"accent":case"roll":!n||n<0&&(i.multi<0||!i.multi&&i.stem>0)?(t=y_get(i.st,!1,i.x-s.wl,u)-2,t>f&&(t=f),t-=s.h,y_set(i.st,!1,i.x,0,t),r=!0,i.ymn=t):(t=y_get(i.st,!0,i.x-s.wl,u)+2,t<a&&(t=a),y_set(i.st,!0,i.x-s.wl,u,t+s.h),i.ymx=t+s.h);break;case"brth":case"lphr":case"mphr":case"sphr":t=a+1,s.glyph=="brth"&&t<i.ymx&&(t=i.ymx);for(i=i.ts_next;i;i=i.ts_next)if(i.seqst)break;o+=((i?i.x:realwidth)-o)*.45;break;default:s.name.indexOf("invert")==0&&(r=!0),s.name!="invertedfermata"&&(n>0||n<0&&i.multi>=0)?(t=y_get(i.st,!0,i.x-s.wl,u)+2,t<a&&(t=a),y_set(i.st,!0,i.x-s.wl,u,t+s.h),i.ymx=t+s.h):(t=y_get(i.st,!1,i.x-s.wl,u)-2,t>f&&(t=f),t-=s.h,y_set(i.st,!1,i.x-s.wl,u,t),s.name=="fermata"&&(r=!0),i.ymn=t)}r&&(t+=s.h,e.inv=!0),e.x=o,e.y=t}function deco_add(e){var t=e.match(/(\S*)\s+(.*)/);decos[t[1]]=t[2]}function deco_def(e){var t,n,r,i,s,o,u,a,f=decos[e];if(!f){cfmt.decoerr&&error(1,null,"Unknown decoration '$1'",e);return}t=f.match(/(\d+)\s+(.+?)\s+([0-9.]+)\s+([0-9.]+)\s+([0-9.]+)/);if(!t){error(1,null,"Invalid decoration '$1'",e);return}var l=Number(t[1]),c=parseFloat(t[3]),h=parseFloat(t[4]),p=parseFloat(t[5]);if(isNaN(l)){error(1,null,"%%deco: bad C function value '$1'",t[1]);return}if((l<0||l>10)&&(l<32||l>41)){error(1,null,"%%deco: bad C function index '$1'",l);return}if(c<0||h<0||p<0){error(1,null,"%%deco: cannot have a negative value '$1'",f);return}if(c>50||h>80||p>80){error(1,null,"%%deco: abnormal h/wl/wr value '$1'",f);return}n=dd_tb[e],n||(n={name:e},dd_tb[e]=n),n.func=n.name.indexOf("head-")==0?9:l,n.glyph=t[2],n.h=c,n.wl=h,n.wr=p,a=f.replace(t[0],"").trim(),a&&(a[0]=='"'&&(a=a.slice(1,-1)),n.str=a),n.func==6&&n.str==undefined&&(n.str=n.name),s=n.name.slice(-1);if(s=="("||s==")"&&n.name.indexOf("(")<0){i=n.name.slice(0,-1)+(s=="("?")":"("),r=dd_tb[i];if(r)s=="("?(n.dd_en=r,r.dd_st=n):(n.dd_st=r,r.dd_en=n);else{r=deco_def(i);if(!r)return}}return n}function deco_cnv(e,t,n){var r,i,s,o,u,a=e.length;for(r=0;r<a;r++){o=e[r],s=dd_tb[o];if(!s){s=deco_def(o);if(!s)continue}switch(s.func){case 0:if(t.type==C.BAR&&s.name=="dot"){t.bar_dotted=!0;break};case 1:case 2:if(!t.notes){error(1,t,errs.must_note_rest,s.name);continue}break;case 8:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}u=t.notes[t.nhd],u.a_dcn||(u.a_dcn=[]),u.a_dcn.push(s.name);continue;case 9:if(!t.notes){error(1,t,errs.must_note_rest,s.name);continue}for(i=0;i<=t.nhd;i++)u=t.notes[i],u.a_dcn||(u.a_dcn=[]),u.a_dcn.push(s.name);continue;default:break;case 10:if(t.notes)for(i=0;i<=t.nhd;i++)t.notes[i].color=s.name;else t.color=s.name;continue;case 32:t.invis=!0;continue;case 33:if(t.type!=C.BAR){error(1,t,"!beamon! must be on a bar");continue}t.beam_on=!0;continue;case 34:if(t.type!=C.NOTE||!n||n.type!=C.NOTE||t.nflags!=n.nflags){error(1,t,"!$1! must be on the last of a couple of notes",s.name);continue}t.trem2=!0,t.beam_end=!0,n.trem2=!0,n.beam_st=!0,t.ntrem=n.ntrem=Number(s.name[4]),n.nflags=--t.nflags,n.head=++t.head,t.nflags>0?t.nflags+=t.ntrem:(t.nflags<=-2&&(t.stemless=!0,n.stemless=!0),t.nflags=t.ntrem),n.nflags=t.nflags;for(i=0;i<=t.nhd;i++)t.notes[i].dur*=2;for(i=0;i<=n.nhd;i++)n.notes[i].dur*=2;continue;case 35:if(t.type!=C.NOTE){error(1,t,"!xstem! must be on a note");continue}t.xstem=!0,t.nflags=0;continue;case 36:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}s.name[6]=="1"?t.beam_br1=!0:t.beam_br2=!0;continue;case 37:t.rbstop=1;continue;case 38:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}t.trem1=!0,t.ntrem=s.name.length,t.nflags>0?t.nflags+=t.ntrem:t.nflags=t.ntrem;continue;case 39:if(t.type!=C.NOTE){error(1,t,errs.must_note,s.name);continue}t.feathered_beam=s.name[5]=="a"?1:-1;continue;case 40:t.stemless=!0;continue;case 41:t.rbstop=2;continue}t.a_dd||(t.a_dd=[]),t.a_dd.push(s)}}function deco_update(e,t){var n,r,i=a_de.length;for(n=0;n<i;n++)r=a_de[n],r.s==e&&(r.x+=t)}function deco_width(e){var t,n,r=0,i=e.a_dd,s=i.length;for(n=0;n<s;n++){t=i[n];switch(t.func){case 1:r<7&&(r=7);break;case 2:r<14&&(r=14);break;case 3:switch(t.glyph){case"brth":case"lphr":case"mphr":case"sphr":e.wr<20&&(e.wr=20)}}}return r!=0&&e.prev&&e.prev.type==C.BAR&&(r-=3),r}function draw_all_deco(){if(a_de.length==0)return;var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v=[],m=[];if(!cfmt.dynalign){o=nstaff,a=staff_tb[o].y;while(--o>=0)f=staff_tb[o].y,m[o]=(a+24+f)*.5,a=f}for(;;){e=a_de.shift();if(!e)break;n=e.dd;if(!n)continue;if(n.dd_en)continue;r=e.s,s=n.glyph,h=s.indexOf("/"),h>0&&(r.stem>=0?s=s.slice(0,h):s=s.slice(h+1)),f_staff[n.func]?set_sscale(r.st):set_scale(r),o=e.st;if(!staff_tb[o].topbar)continue;u=e.x,a=e.y+staff_tb[o].y;if(e.m!=undefined)i=r.notes[e.m],u+=i.shhd*stv_g.scale;else if(f_staff[n.func]&&!cfmt.dynalign&&(e.up&&o>0||!e.up&&o<nstaff)){e.up?l=m[--o]:l=m[o++],l-=n.h*.5;if(e.up&&a<l||!e.up&&a>l){f=y_get(o,!e.up,e.x,e.val)+staff_tb[o].y,e.up&&(f-=n.h);if(e.up&&f>l||!e.up&&f<l)a=l}}c=user[s];if(c&&typeof c=="function"){c(u,a,e);continue}if(self.psdeco(s,u,a,e))continue;anno_start(r,"deco"),e.inv&&(g_open(u,a,0,1,-1),u=a=0),e.has_val?(n.func!=2||stv_g.st<0?out_deco_val(u,a,s,e.val/stv_g.scale,e.defl):out_deco_val(u,a,s,e.val,e.defl),e.defl.noen&&v.push(e.start)):n.str!=undefined&&n.str!="sfz"?(p=n.str,p[0]=="@"&&(d=p.match(/^@([0-9.-]+),([0-9.-]+);?/),u+=Number(d[1]),a+=Number(d[2]),p=p.replace(d[0],"")),out_deco_str(u,a,s,p)):e.lden?out_deco_long(u,a,e):xygl(u,a,s),stv_g.g&&g_close(),anno_stop(r,"deco")}a_de=v}function draw_deco_near(){function n(e){var t,n,r=e.x-e.wl,i=a_de.length;for(t=0;t<i;t++)n=a_de[t],n.ix=t,n.s.x=n.x=r,n.defl.nost=!0}function r(e){var t,n,r,i,s,o,u=e.a_dd.length;for(n=0;n<u;n++){t=e.a_dd[n];switch(t.func){default:i=0;break;case 3:case 4:case 5:if(ottava[t.name]){o=t.name.slice(0,-1)+e.st.toString();if(od[o]){if(t.name[t.name.length-1]=="("){od[o]++;continue}od[o]--;if(e.v+1!=od[o]>>8||!od[o])continue;od[o]&=255}else t.name[t.name.length-1]=="("&&(od[o]=1+(e.v+1<<8))}i=e.pos.orn;break;case 6:i=e.pos.vol;break;case 7:i=e.pos.dyn}if(i==C.SL_HIDDEN)continue;s={s:e,dd:t,st:e.st,ix:a_de.length,defl:{},x:e.x,y:e.y},a_de.push(s),t.dd_en?s.ldst=!0:t.dd_st&&(s.lden=!0,s.defl.nost=!0);if(!f_near[t.func])continue;func_tb[t.func](s)}}function i(e,t){var n,r,i,s,o,u,a,f=e.notes[t],l=f.a_dcn.length;for(o=0;o<l;o++){u=f.a_dcn[o],a=dd_tb[u];if(!a){a=deco_def(u);if(!a)continue}switch(a.func){case 0:case 1:case 3:case 4:case 8:break;default:error(1,null,"Cannot have !$1! on a head",a.name);continue;case 9:f.invis=!0;break;case 10:f.color=a.name;continue;case 32:f.invis=!0;continue;case 40:e.stemless=!0;continue}i={s:e,dd:a,st:e.st,m:t,ix:0,defl:{},x:e.x,y:3*(f.pit-18)},a_de.push(i),a.dd_en?i.ldst=!0:a.dd_st&&(i.lden=!0,i.defl.nost=!0)}}function s(e){var t;e.a_dd&&r(e);if(e.notes)for(t=0;t<e.notes.length;t++)e.notes[t].a_dcn&&i(e,t)}function o(){var e,t,n,r,i,s,o,u,a,f=a_de.length;for(e=0;e<f;e++){n=a_de[e];if(!n.ldst)continue;i=n.dd,s=i.dd_en,u=n.s,o=u.v;for(t=e+1;t<f;t++){r=a_de[t];if(!r.start&&r.dd==s&&r.s.v==o)break}if(t==f){a=u.st;for(t=e+1;t<f;t++){r=a_de[t];if(!r.start&&r.dd==s&&r.s.st==a)break}}t==f&&(r={s:n.s,st:n.st,dd:s,ix:a_de.length-1,x:realwidth-6,y:n.s.y,lden:!0,defl:{noen:!0}},r.x<u.x+10&&(r.x=u.x+10),n.m!=undefined&&(r.m=n.m),a_de.push(r)),r.start=n,r.defl.nost=n.defl.nost,i.name=="trill("&&e>0&&a_de[e-1].dd.name=="trill"&&(r.prev=a_de[e-1])}for(e=0;e<f;e++){r=a_de[e];if(!r.lden||r.start)continue;u=r.s,n={s:prev_scut(u),st:r.st,dd:r.dd.dd_st,ix:a_de.length-1,y:u.y,ldst:!0},n.x=n.s.x,r.m!=undefined&&(n.m=r.m),a_de.push(n),r.start=n}}var e,t;for(e=tsfirst;e;e=e.ts_next){switch(e.type){case C.CLEF:case C.KEY:case C.METER:continue}break}a_de.length!=0&&n(e);for(;e;e=e.ts_next){switch(e.type){case C.BAR:case C.MREST:case C.NOTE:case C.REST:case C.SPACE:break;case C.GRACE:for(t=e.extra;t;t=t.next)s(t);default:continue}s(e)}o()}function draw_deco_note(){var e,t,n,r,i=a_de.length;for(e=0;e<i;e++)t=a_de[e],n=t.dd,r=n.func,f_note[r]&&t.m==undefined&&func_tb[r](t)}function draw_deco_staff(){function g(e){var t,n,i,s,o,u,a,f,l;i=staff_tb[e.st].topbar+25;for(t=e.sym;t;t=t.next){if(t.type!=C.BAR)continue;if(!t.rbstart||t.norepbra)continue;if(!t.next)break;l||(l=t,set_font("repeat")),n=t;for(;;){if(!t.next)break;t=t.next;if(t.rbstop)break}s=y_get(e.st,!0,n.x,t.x-n.x),i<s&&(i=s),n.text&&(f=strwh(n.text),s=y_get(e.st,!0,n.x+4,f[0]),s+=f[1],i<s&&(i=s)),t.rbstart&&(t=t.prev)}t=l;if(!t)return;set_dscale(e.st,!0),s=i*staff_tb[e.st].staffscale;for(;t;t=t.next){if(!t.rbstart||t.norepbra)continue;n=t;for(;;){if(!t.next)break;t=t.next;if(t.rbstop)break}if(n==t)break;r=n.x,t.type!=C.BAR?a=t.rbstop?0:t.x-realwidth+4:t.bar_type.length>1&&t.bar_type!="[]"||t.bar_type=="]"?n.st>0&&!(cur_sy.staves[n.st-1].flags&STOP_BAR)?a=t.wl:t.bar_type.slice(-1)==":"?a=12:t.bar_type[0]!=":"?a=0:a=8:a=t.rbstop?0:8,a=t.x-r-a,!t.next&&!t.rbstop&&!e.bar_start&&(e.bar_start=clone(t),e.bar_start.type=C.BAR,e.bar_start.bar_type="[",delete e.bar_start.text,e.bar_start.rbstart=1,delete e.bar_start.a_gch),n.text&&xy_str(r+4,s-gene.curfont.size-3,n.text),xypath(r,s),n.rbstart==2&&(output+="m0 20v-20"),output+="h"+a.toFixed(2),t.rbstop==2&&(output+="v20"),output+='"/>\n',y_set(n.st,!0,r,a,i+2),t.rbstart&&(t=t.prev)}}var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v=new Array(nstaff),m=a_de.length;for(o=0;o<=nstaff;o++)v[o]={ymin:0,ymax:0};for(o=0;o<m;o++){a=a_de[o],f=a.dd;if(!f)continue;if(!f_staff[f.func]||a.m!=undefined)continue;func_tb[f.func](a);if(f.dd_en)continue;cfmt.dynalign&&(a.up?a.y>v[a.st].ymax&&(v[a.st].ymax=a.y):a.y<v[a.st].ymin&&(v[a.st].ymin=a.y))}for(o=0;o<m;o++){a=a_de[o],f=a.dd;if(!f)continue;if(f.dd_en||!f_staff[f.func])continue;cfmt.dynalign?(a.up?i=v[a.st].ymax:i=v[a.st].ymin,a.y=i):i=a.y,a.up&&(i+=f.h),y_set(a.st,a.up,a.x,a.val,i)}for(o=0;o<=nstaff;o++)v[o]={ymin:0,ymax:24};for(e=tsfirst;e;e=e.ts_next){if(!e.a_gch)continue;t||(t=e),c=null;for(h=0;h<e.a_gch.length;h++){l=e.a_gch[h];if(l.type!="g")continue;c=l;if(l.y<0)break}c&&(s=c.w,c.y>=0?(i=y_get(e.st,!0,e.x,s),i>v[e.st].ymax&&(v[e.st].ymax=i)):(i=y_get(e.st,!1,e.x,s),i<v[e.st].ymin&&(v[e.st].ymin=i)))}if(t){for(o=0;o<=nstaff;o++)d=staff_tb[o].botbar,v[o].ymin>d-4&&(v[o].ymin=d-4),p=staff_tb[o].topbar,v[o].ymax<p+4&&(v[o].ymax=p+4);set_dscale(-1);for(e=t;e;e=e.ts_next){if(!e.a_gch)continue;self.draw_gchord(e,v[e.st].ymin,v[e.st].ymax)}}for(u=0;u<voice_tb.length;u++){n=voice_tb[u];if(n.second||!n.sym)continue;g(n)}}function draw_measnb(){var e,t,n,r,i,s,o,u,a=cur_sy;for(t=0;t<=nstaff;t++)if(a.st_print[t])break;if(t>nstaff)return;set_dscale(t),staff_tb[t].staffscale!=1&&(u=get_font("measure").size,param_set_font("measurefont","* "+(u/staff_tb[t].staffscale).toString())),set_font("measure"),e=tsfirst,n=gene.nbar;if(n>1)if(cfmt.measurenb==0)o=!0,i=y_get(t,!0,0,20),i<staff_tb[t].topbar+14&&(i=staff_tb[t].topbar+14),cfmt.measurebox?xy_str_b(0,i,n.toString()):xy_str(0,i,n.toString()),y_set(t,!0,0,20,i+gene.curfont.size+2);else if(n%cfmt.measurenb==0){for(;;e=e.ts_next){switch(e.type){case C.METER:case C.CLEF:case C.KEY:case C.STBRK:continue}break}while(e.st!=t)e=e.ts_next;if(e.type!=C.BAR||!e.bar_num)e.prev&&e.prev.type!=C.CLEF&&(e=e.prev),r=e.x-e.wl,o=!0,s=cwid("0")*gene.curfont.swfac,n>=10&&(s*=n>=100?3:2),cfmt.measurebox&&(s+=4),i=y_get(t,!0,r,s),i<staff_tb[t].topbar+6&&(i=staff_tb[t].topbar+6),i+=2,cfmt.measurebox?(xy_str_b(r,i,n.toString()),i+=2,s+=3):xy_str(r,i,n.toString()),i+=gene.curfont.size,y_set(t,!0,r,s,i),e.ymx=i}for(;e;e=e.ts_next){switch(e.type){case C.STAVES:a=e.sy;for(t=0;t<nstaff;t++)if(a.st_print[t])break;set_sscale(t);continue;default:continue;case C.BAR:if(!e.bar_num)continue}n=e.bar_num;if(cfmt.measurenb==0||n%cfmt.measurenb!=0||!e.next)continue;o||(o=!0),s=cwid("0")*gene.curfont.swfac,n>=10&&(s*=n>=100?3:2),cfmt.measurebox&&(s+=4),r=e.x-s*.4,i=y_get(t,!0,r,s),i<staff_tb[t].topbar+6&&(i=staff_tb[t].topbar+6),e.next.type==C.NOTE&&(e.next.stem>0?i<e.next.ys-gene.curfont.size&&(i=e.next.ys-gene.curfont.size):i<e.next.y&&(i=e.next.y)),i+=2,cfmt.measurebox?(xy_str_b(r,i,n.toString()),i+=2,s+=3):xy_str(r,i,n.toString()),i+=gene.curfont.size,y_set(t,!0,r,s,i),e.ymx=i}gene.nbar=n,u&¶m_set_font("measurefont","* "+u.toString())}function draw_notempo(e,t,n,r,i){var s,o,u,a=identify_note(e,r),f=a[0],l=a[1],c=a[2];out_XYAB('<g transform="translate(X,Y) scale(F)">\n',t+4,n+5,i);switch(f){case C.OVAL:o="HD";break;case C.EMPTY:o="Hd";break;default:o="hd"}xygl(-posx,posy,o),s=4;if(l){u=9,c>0&&(u+=4);switch(f){case C.SQUARE:u+=3;break;case C.OVALBARS:case C.OVAL:u+=2;break;case C.EMPTY:u+=1}s=u*l,u-=posx;while(--l>=0)xygl(u,posy,"dot"),u+=3.5}return r<C.BLEN&&(c<=0?out_stem(-posx,posy,21):(out_stem(-posx,posy,21,!1,c),s<6&&(s=6))),output+="</g>\n",(s+15)*i}function tempo_width(e){var t=0;return set_font("tempo"),e.tempo_str1&&(t=strwh(e.tempo_str1)[0]),e.tempo_ca&&(t+=strwh(e.tempo_ca)[0]),e.tempo_notes&&(t+=10*e.tempo_notes.length+6+cwid(" ")*gene.curfont.swfac*6+10),e.tempo_str2&&(t+=strwh(e.tempo_str2)[0]),t}function write_tempo(e,t,n){var r,i,s=.6*gene.curfont.size/15;set_font("tempo"),e.tempo_str1&&(xy_str(t,n,e.tempo_str1),t+=strwh(e.tempo_str1)[0]+3);if(e.tempo_notes){for(r=0;r<e.tempo_notes.length;r++)t+=draw_notempo(e,t,n,e.tempo_notes[r],s);xy_str(t,n,"="),t+=strwh("= ")[0],e.tempo_ca&&(xy_str(t,n,e.tempo_ca),t+=strwh(e.tempo_ca)[0]),e.tempo?(xy_str(t,n,e.tempo.toString()),i=cwid("0")*gene.curfont.swfac,t+=i+5,e.tempo>=10&&(t+=i,e.tempo>=100&&(t+=i))):t+=draw_notempo(e,t,n,e.new_beat,s)}e.tempo_str2&&xy_str(t,n,e.tempo_str2),e.del=!0}function draw_partempo(e,t){var n,r,i,s,o,u,a=0,f=0,l=staff_tb[e].topbar+8,c=0,h=1,p=0;for(n=tsfirst;n;n=n.ts_next){if(n.type!=C.TEMPO||n.del)continue;i||(i=n),o=tempo_width(n),n.time==0&&n.x>40&&(n.x=40),u=y_get(e,!0,n.x-16,o),u>l&&(l=u),p>=n.x-16&&!(c&h>>1)&&(c|=h),h<<=1,p=n.x-16+o}if(i){set_sscale(-1),set_font("tempo"),f=gene.curfont.size+2+2,u=2-f,s=u-f,c!=0&&(f*=2),t<l+f&&(a=l+f-t);for(n=i;n;n=n.ts_next){if(n.type!=C.TEMPO||n.del)continue;if(user.anno_start||user.anno_stop)n.wl=16,n.wr=30,n.ymn=c&1?s:u,n.ymx=n.ymn+14,anno_start(n);write_tempo(n,n.x-16,c&1?s:u),anno_stop(n),c>>=1}}l=staff_tb[e].topbar+8;for(n=tsfirst;n;n=n.ts_next){if(n.type!=C.PART)continue;r||(r=n,set_font("parts"),s=gene.curfont.size+2+2),o=strwh(n.text)[0],u=y_get(e,!0,n.x-10,o+3),l<u&&(l=u)}if(r){set_sscale(-1),t<l+s+f&&(a=l+s+f-t);for(n=r;n;n=n.ts_next){if(n.type!=C.PART)continue;n.x-=10;if(user.anno_start||user.anno_stop)o=strwh(n.text)[0],n.wl=0,n.wr=o,n.ymn=-f-s,n.ymx=n.ymn+s,anno_start(n);cfmt.partsbox?xy_str_b(n.x,2-f-s,n.text):xy_str(n.x,2-f-s,n.text),anno_stop(n)}}return a}function b_pos(e,t,n,r){function l(e){var t=Math.round((e+12)/6)*6-12;return t-e}var i,s,o,u,a=e?3.5:BEAM_SHIFT,f=e?1.8:BEAM_DEPTH;if(t>0){s=r-(n-1)*a-f;if(s>26)return 0;i=r}else{i=r+(n-1)*a+f;if(i<-2)return 0;s=r}return o=l(i-BEAM_OFFSET),u=l(s+BEAM_OFFSET),o*o>u*u?u:o}function sym_dup(e){var t,n,r=clone(e);r.invis=!0,delete r.text,delete r.a_gch,delete r.a_ly,delete r.a_dd,r.notes=clone(e.notes);for(t=0;t<=r.nhd;t++)n=r.notes[t]=clone(e.notes[t]),delete n.a_dcn;return r}function calculate_beam(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T;t.beam_st||(n=sym_dup(t),lkvsym(n,t),lktsym(n,t),n.x-=12,n.x>t.prev.x+12&&(n.x=t.prev.x+12),n.beam_st=!0,delete n.beam_end,n.tmp=!0,delete n.slur_start,delete n.slur_end,t=n),s=o=0,f=l=!1,u=t.st,a=t.v,E=t.grace?GSTEM_XOFF:3.5;for(r=t;;r=r.next){if(r.type==C.NOTE){r.nflags>o&&(o=r.nflags),s++,r.st!=u&&(f=!0),r.stem!=t.stem&&(l=!0),!x&&!r.invis&&(!r.stemless||r.trem2)&&(x=!0);if(r.beam_end)break}if(!r.next){for(;;r=r.prev)if(r.type==C.NOTE)break;n=sym_dup(r),n.next=r.next,n.next&&(n.next.prev=n),r.next=n,n.prev=r,n.ts_next=r.ts_next,n.ts_next&&(n.ts_next.ts_prev=n),r.ts_next=n,n.ts_prev=r,delete n.beam_st,n.beam_end=!0,n.tmp=!0,delete n.slur_start,delete n.slur_end,n.x+=12,n.x<realwidth-12&&(n.x=realwidth-12),r=n,s++;break}}if(!x)return!1;e.s2=r;if(staff_tb[u].y==0){if(f)return!1}else if(!f)return e.s1=t,e.a=(t.ys-r.ys)/(t.xs-r.xs),e.b=t.ys-t.xs*e.a+staff_tb[u].y,e.nflags=o,!0;w=t,y=100,b=0;for(n=t;;n=n.next){if(n.type!=C.NOTE)continue;(S=n.p_v.scale)==1&&(S=staff_tb[n.st].staffscale),n.stem>=0?(c=E+n.notes[0].shhd,n.notes[n.nhd].pit>b&&(b=n.notes[n.nhd].pit,w=n)):(c=-E+n.notes[n.nhd].shhd,n.notes[0].pit<y&&(y=n.notes[0].pit,w=n)),n.xs=n.x+c*S;if(n==r)break}cfmt.flatbeams?d=0:!l&&s>=3&&w!=t&&w!=r&&(d=0),h=t.ys+staff_tb[u].y,d==undefined&&(d=(r.ys+staff_tb[r.st].y-h)/(r.xs-t.xs)),d!=0&&(d>0?d=BEAM_SLOPE*d/(BEAM_SLOPE+d):d=BEAM_SLOPE*d/(BEAM_SLOPE-d)),v=(h+r.ys+staff_tb[r.st].y)/2-d*(r.xs+t.xs)/2,g=0,n=t;if(l)p=((t.grace?3.5:BEAM_SHIFT)*(o-1)+BEAM_DEPTH)*.5,t.stem!=r.stem&&t.nflags<r.nflags?v+=p*r.stem:v+=p*t.stem;else if(!t.grace){var N=BEAM_DEPTH+BEAM_SHIFT*(o-1);while(n.ts_prev&&n.ts_prev.type==C.NOTE&&n.ts_prev.time==n.time&&n.ts_prev.x>t.xs)n=n.ts_prev;for(;n&&n.time<=r.time;n=n.ts_next){if(n.type!=C.NOTE||n.invis||n.st!=u&&n.v!=a)continue;c=n.v==a?n.xs:n.x,p=d*c+v-staff_tb[n.st].y;if(n.v==a)m=min_tb[n.nhd==0?0:1][n.nflags],n.stem>0?(n.notes[n.nhd].pit>26&&(m-=2,n.notes[n.nhd].pit>28&&(m-=2)),m-=p-3*(n.notes[n.nhd].pit-18)):(n.notes[0].pit<18&&(m-=2,n.notes[0].pit<16&&(m-=2)),m-=3*(n.notes[0].pit-18)-p),m+=BEAM_DEPTH+BEAM_SHIFT*(n.nflags-1);else{if(t.stem>0)if(n.stem>0){if(n.ymn>p+4||n.ymx<p-N-2)continue;n.v>a?m=n.ymx-p:m=n.ymn+8-p}else m=n.ymx-p;else if(n.stem<0){if(n.ymx<p-4||n.ymn>p-N-2)continue;n.v<a?m=p-n.ymn:m=p-n.ymx+8}else m=p-n.ymn;m+=2+N}m>g&&(g=m)}}else for(;;n=n.next){p=d*n.xs+v-staff_tb[n.st].y,m=GSTEM-2,n.stem>0?m-=p-3*(n.notes[n.nhd].pit-18):m+=p-3*(n.notes[0].pit-18),m+=3*(n.nflags-1),m>g&&(g=m);if(n==r)break}g>0&&(v+=t.stem*g);if(!f&&!l)for(n=t.next;;n=n.next){switch(n.type){case C.REST:i=n.ts_next;if(!i||i.st!=u||i.type!=C.NOTE&&i.type!=C.REST)break;case C.BAR:if(n.invis)break;case C.CLEF:h=d*n.x+v,t.stem>0?(h=n.ymx-h+BEAM_DEPTH+BEAM_SHIFT*(o-1)+2,h>0&&(v+=h)):(h=n.ymn-h-BEAM_DEPTH-BEAM_SHIFT*(o-1)-2,h<0&&(v+=h));break;case C.GRACE:for(i=n.extra;i;i=i.next)h=d*i.x+v,t.stem>0?(h=i.ymx-h+BEAM_DEPTH+BEAM_SHIFT*(o-1)+2,h>0&&(v+=h)):(h=i.ymn-h-BEAM_DEPTH-BEAM_SHIFT*(o-1)-2,h<0&&(v+=h))}if(n==r)break}d==0&&(v+=b_pos(t.grace,t.stem,o,v-staff_tb[u].y));for(n=t;;n=n.next){switch(n.type){case C.NOTE:n.ys=d*n.xs+v-staff_tb[n.st].y,n.stem>0?(n.ymx=n.ys+2.5,n.ts_prev&&n.ts_prev.stem>0&&n.ts_prev.st==n.st&&n.ts_prev.ymn<n.ymx&&n.ts_prev.x==n.x&&n.notes[0].shhd==0&&(n.ts_prev.x-=3,n.ts_prev.xs-=3)):n.ymn=n.ys-2.5;break;case C.REST:h=d*n.x+v-staff_tb[n.st].y,T=BEAM_DEPTH+BEAM_SHIFT*(o-1)+(n.head!=C.FULL?4:9);if(t.stem>0){h-=T,t.multi==0&&h>12&&(h=12);if(n.y<=h)break}else{h+=T,t.multi==0&&h<12&&(h=12);if(n.y>=h)break}n.head!=C.FULL&&(h=((h+3+12)/6|0)*6-12),n.y=h}if(n==r)break}return staff_tb[u].y==0?!1:(e.s1=t,e.a=d,e.b=v,e.nflags=o,!0)}function draw_beams(e){function v(e,t,n,r,i,s){var o,u,a=i.s1,f=a.nflags;a.ntrem&&(f-=a.ntrem),a.trem2&&s>f&&(a.dur>=C.BLEN/2?(e=a.x+6,t=i.s2.x-6):a.dur<C.BLEN/4&&(e+=5,t-=6)),o=i.a*e+i.b-n,t-=e,t/=stv_g.scale,u=i.a*t*stv_g.scale,xypath(e,o,!0),output+="l"+t.toFixed(2)+" "+(-u).toFixed(2)+"v"+r.toFixed(2)+"l"+(-t).toFixed(2)+" "+u.toFixed(2)+'z"/>\n'}var t,n,r,i,s,o,u,a,f,l,c,h,p=e.s1,d=e.s2;anno_start(p,"beam"),p.grace?(s=3.5,o=3.2,i=.29,u=1.8):(s=BEAM_SHIFT,o=BEAM_STUB,i=.34,u=BEAM_DEPTH),r=p.stem,p.stem!=d.stem&&p.nflags<d.nflags&&(r=d.stem),r<0&&(u=-u),v(p.xs-i,d.xs+i,0,u,e,1),a=0;for(t=p;;t=t.next){t.type==C.NOTE&&t.stem!=r&&(t.ys=e.a*t.xs+e.b-staff_tb[t.st].y+s*(t.nflags-1)*t.stem-u);if(t==d)break}p.feathered_beam&&(a=s/(d.xs-p.xs),p.feathered_beam>0?(a=-a,s=a*p.xs):s=a*d.xs,a*=r),i=0;for(n=2;n<=e.nflags;n++){i+=s,a!=0&&(e.a+=a);for(t=p;;t=t.next){if(t.type!=C.NOTE||t.nflags<n){if(t==d)break;continue}if(t.trem1&&n>t.nflags-t.ntrem){h=t.dur>=C.BLEN/2?t.x:t.xs,v(h-5,h+5,(i+2.5)*r,u,e,n);if(t==d)break;continue}l=t;for(;;){if(t==d)break;f=t.next;if(f.type==C.NOTE||f.type==C.REST)if(f.trem1){if(f.nflags-f.ntrem<n)break}else if(f.nflags<n)break;if(f.beam_br1||f.beam_br2&&n>2)break;t=f}c=t;while(c.type!=C.NOTE)c=c.prev;h=l.xs;if(l==c)if(l==p)h+=o;else if(l==d)h-=o;else if(l.beam_br1||l.beam_br2&&n>2)h+=o;else{f=l.next;while(f.type!=C.NOTE)f=f.next;if(f.beam_br1||f.beam_br2&&n>2)h-=o;else{l=l.prev;while(l.type!=C.NOTE)l=l.prev;l.nflags<f.nflags||l.nflags==f.nflags&&l.dots<f.dots?h+=o:h-=o}}v(h,c.xs,i*r,u,e,n);if(t==d)break}}p.tmp?unlksym(p):d.tmp&&unlksym(d),anno_stop(p,"beam")}function draw_lstaff(e){function u(e,t,n){var r,i,s,o;while(!cur_sy.st_print[t]){if(cur_sy.staves[t].flags&n)return;t++}r=i=t;for(;;){cur_sy.st_print[r]&&(i=r);if(cur_sy.staves[r].flags&n)break;r++}s=staff_tb[t].y+staff_tb[t].topbar*staff_tb[t].staffscale,o=staff_tb[i].y+staff_tb[i].botbar*staff_tb[i].staffscale,n&(CLOSE_BRACE|CLOSE_BRACE2)?out_brace(e,o,s-o):out_bracket(e,s,s-o)}var t,n,r,i,s=cur_sy.nstaff,o=0;for(t=0;;t++){cur_sy.staves[t].flags&(OPEN_BRACE|OPEN_BRACKET)&&o++;if(cur_sy.st_print[t])break;cur_sy.staves[t].flags&(CLOSE_BRACE|CLOSE_BRACKET)&&o--;if(t==s)break}for(n=s;n>t;n--)if(cur_sy.st_print[n])break;if(t==n&&o==0)return;r=staff_tb[n].y+staff_tb[n].botbar*staff_tb[n].staffscale,i=staff_tb[t].y+staff_tb[t].topbar*staff_tb[t].staffscale-r,xypath(e,r),output+="v"+(-i).toFixed(2)+'"/>\n';for(t=0;t<=s;t++)cur_sy.staves[t].flags&OPEN_BRACE&&u(e,t,CLOSE_BRACE),cur_sy.staves[t].flags&OPEN_BRACKET&&u(e,t,CLOSE_BRACKET),cur_sy.staves[t].flags&OPEN_BRACE2&&u(e-6,t,CLOSE_BRACE2),cur_sy.staves[t].flags&OPEN_BRACKET2&&u(e-6,t,CLOSE_BRACKET2)}function draw_meter(e,t){if(!t.a_meter)return;var n,r,i,s,o=t.st,u=staff_tb[o],a=u.y;u.stafflines!="|||||"&&(a+=(u.topbar+u.botbar)/2-12);for(r=0;r<t.a_meter.length;r++)s=t.a_meter[r],e=t.x+t.x_meter[r],s.bot?out_XYAB('<g transform="translate(X,Y)" text-anchor="middle">\n <text y="-12">A</text>\n <text>B</text>\n</g>\n',e,a+6,m_gl(s.top),m_gl(s.bot)):out_XYAB('<text x="X" y="Y" text-anchor="middle">A</text>\n',e,a+12,m_gl(s.top))}function draw_acc(e,t,n,r,i){if(r)if(r==i)n=n==-1?-2:2;else if(r*2!=i){xygl(e,t,"acc"+n+"_"+r+"_"+i);return}xygl(e,t,"acc"+n)}function draw_hl(e,t,n,r,i){var s,o,u=staff_tb[r],a=u.y,f=u.stafflines,l=(f.length-1)*6,c=u.botline;if(!/[\[|]/.test(f))return;t%6&&(t+=3),n%6&&(n-=3);if(f.indexOf("-")>=0&&(t>c&&t<l||n>c&&n<l||t<=c&&n>=l)){s=t,o=n;while(s>c&&f[s/6]=="-")s-=6;while(o<l&&f[o/6]=="-")o+=6;for(;s<o;s+=6)f[s/6]=="-"&&xygl(e,a+s,i)}for(;t<c;t+=6)xygl(e,a+t,i);for(;n>l;n-=6)xygl(e,a+n,i)}function draw_keysig(e,t,n){if(n.k_none)return;var r=n.k_old_sf,i=e.st,s=staff_tb[i].y,o,u,a,f=n.k_y_clef;f&1&&(f+=7),f/=2;while(f<0)f+=7;f%=7;if(!n.k_a_acc){if(cfmt.cancelkey||n.k_sf==0)if(n.k_sf==0||r*n.k_sf<0){u=sharp_cl[f],a=u>9?sharp1:sharp2;for(o=0;o<r;o++)xygl(t,s+u,"acc3"),u+=a[o],t+=5.5;u=flat_cl[f],a=u<18?flat1:flat2;for(o=0;o>r;o--)xygl(t,s+u,"acc3"),u+=a[-o],t+=5.5;n.k_sf!=0&&(t+=3)}if(n.k_sf>0){u=sharp_cl[f],a=u>9?sharp1:sharp2;for(o=0;o<n.k_sf;o++)xygl(t,s+u,"acc1"),u+=a[o],t+=5.5;if(cfmt.cancelkey&&o<r){t+=2;for(;o<r;o++)xygl(t,s+u,"acc3"),u+=a[o],t+=5.5}}if(n.k_sf<0){u=flat_cl[f],a=u<18?flat1:flat2;for(o=0;o>n.k_sf;o--)xygl(t,s+u,"acc-1"),u+=a[-o],t+=5.5;if(cfmt.cancelkey&&o>r){t+=2;for(;o>r;o--)xygl(t,s+u,"acc3"),u+=a[-o],t+=5.5}}}else if(n.k_a_acc.length){var l,c=n.k_a_acc[0].acc,h=100;for(o=0;o<n.k_a_acc.length;o++)l=n.k_a_acc[o],u=(n.k_y_clef+l.pit-18)*3,o!=0&&(u>h+18||u<h-18)?t-=5.5:l.acc!=c&&(t+=3),c=l.acc,draw_hl(t,u,u,i,"hl"),h=u,draw_acc(t,s+u,l.acc,l.micro_n,l.micro_d),t+=5.5}}function bar_cnv(e){switch(e){case"[":case"[]":return"";case"|:":case"|::":case"|:::":return"["+e;case":|":case"::|":case":::|":return e+"]";case"::":return cfmt.dblrepbar;case"||:":return"[|:"}return e}function draw_bar(e,t,n){var r,i,s,o=e.bar_type,u=e.st,a=staff_tb[u],f=e.x;if(!o)return;u!=0&&e.ts_prev&&e.ts_prev.type!=C.BAR&&(n=a.topbar*a.staffscale),e.ymx=e.ymn+n,set_sscale(-1),anno_start(e),s=a.y+12,a.stafflines!="|||||"&&(s+=(a.topbar+a.botbar)/2-12);if(e.bar_mrep){set_sscale(u);if(e.bar_mrep==1){for(i=e.prev;i.type!=C.REST;i=i.prev);xygl(i.x,s,"mrep")}else xygl(f,s,"mrep2"),e.v==cur_sy.top_voice&&(set_font("annotation"),xy_str(f,s+a.topbar-9,e.bar_mrep.toString(),"c"))}for(r=o.length;--r>=0;){switch(o[r]){case"|":set_sscale(-1),out_bar(f,t,n,e.bar_dotted?a.staffscale:0);break;default:f-=3,set_sscale(-1),out_thbar(f,t,n);break;case":":f-=2,set_sscale(u),xygl(f+1,s-12,"rdots")}f-=3}set_sscale(-1),anno_stop(e)}function draw_rest(e){var t,n,r,i,s,o,u,a,f,l=staff_tb[e.st];if(!l.topbar)return;if(e.dur==e.p_v.meter.wmeasure||e.rep_nb&&e.rep_nb>=0){t=e.ts_next;while(t&&t.time!=e.time+e.dur)t=t.ts_next;i=t?t.x:realwidth,t=e;while(!t.seqst)t=t.ts_prev;t=t.ts_prev,i=(i+t.x)/2,e.a_dd&&deco_update(e,i-e.x),e.x=i}else i=e.x,e.notes[0].shhd&&(i+=e.notes[0].shhd*stv_g.scale);if(e.invis)return;u=l.y;if(e.rep_nb){set_sscale(e.st),anno_start(e),l.stafflines=="|||||"?u+=12:u+=(l.topbar+l.botbar)/2,e.rep_nb<0?xygl(i,u,"srep"):(xygl(i,u,"mrep"),e.rep_nb>2&&e.v==cur_sy.top_voice&&(set_font("annotation"),xy_str(i,u+l.topbar-9,e.rep_nb.toString(),"c"))),anno_stop(e);return}set_scale(e),anno_start(e),s=e.y,n=5-e.nflags,n==7&&s==12&&l.stafflines.length<=2&&(s-=6),xygl(i,s+u,e.notes[0].head?e.notes[0].head:rest_tb[n]);if(n>=6){r=s/6;switch(n){default:switch(l.stafflines[r+1]){case"|":case"[":break;default:xygl(i,s+6+u,"hl1")}n==9&&(s-=6,r--);break;case 7:s+=6,r++;case 6:}switch(l.stafflines[r]){case"|":case"[":break;default:xygl(i,s+u,"hl1")}}if(e.dots){i+=8,s+=u+3;for(n=0;n<e.dots;n++)xygl(i,s,"dot"),i+=3.5}anno_stop(e)}function draw_gracenotes(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g={};for(d=e.extra;d;d=d.next){d.beam_st&&!d.beam_end&&self.calculate_beam(g,d)&&draw_beams(g),anno_start(d),draw_note(d,!g.s2),d==g.s2&&(g.s2=null),anno_stop(d);if(!d.next)break}e.sappo&&(d=e.extra,d.next?(i=(d.next.x-d.x)*.5+4,s=(d.ys+d.next.ys)*.5-d.y,d.stem>0?s-=1:s+=1):(i=9,s=d.stem>0?5:-5),m=d.notes[d.stem<0?0:d.nhd],out_acciac(x_head(d,m),y_head(d,m),i,s,d.stem>0));if(e.p_v.key.k_bagpipe||!cfmt.graceslurs||e.slur_start||!e.next||e.next.type!=C.NOTE)return;v=d;if(v.stem>=0){t=127;for(d=e.extra;d;d=d.next)d.y<t&&(t=d.y,v=d);n=v.x,r=v.y-5,e.extra!=v&&(n-=4,r+=1),e=e.next,a=e.x-1,e.stem<0&&(a-=4),f=3*(e.notes[0].pit-18)-5,h=(a-n)*.4,h>3&&(h=3),p=h,l=.2,c=.8,r>f+7?(n=v.x-1,r+=.5,f+=6.5,a=e.x-5.5,h=(r-f)*.8,p=(r-f)*.2,l=0):f>r+4&&(f=r+4,n=v.x+2,r=v.y-4)}else{t=-127;for(d=e.extra;d;d=d.next)d.y>t&&(t=d.y,v=d);n=v.x,r=v.y+5,e.extra!=v&&(n-=4,r-=1),e=e.next,a=e.x-1,e.stem>=0&&(a-=2),f=3*(e.notes[e.nhd].pit-18)+5,h=(n-a)*.4,h<-3&&(h=-3),p=h,l=.2,c=.8,r<f-7?(n=v.x-1,r-=.5,f-=6.5,a=e.x-5.5,h=(r-f)*.8,p=(r-f)*.2,l=0):f<r-4&&(f=r-4,n=v.x+2,r=v.y+4)}i=l*a+(1-l)*n-n,s=l*f+(1-l)*r-h-r,o=c*a+(1-c)*n-n,u=c*f+(1-c)*r-p-r,anno_start(e,"slur"),xypath(n,r+staff_tb[e.st].y),output+="c"+i.toFixed(2)+" "+(-s).toFixed(2)+" "+o.toFixed(2)+" "+(-u).toFixed(2)+" "+(a-n).toFixed(2)+" "+(-f+r).toFixed(2)+'"/>\n',anno_stop(e,"slur")}function setdoty(e,t){var n,r,i;for(n=0;n<=e.nhd;n++)i=3*(e.notes[n].pit-18),i%6==0&&(e.dot_low?i-=3:i+=3),t[n]=i;for(n=0;n<e.nhd;n++){if(t[n+1]>t[n])continue;r=n;while(r>0){if(t[r]>t[r-1]+6)break;r--}if(3*(e.notes[r].pit-18)-t[r]<t[n+1]-3*(e.notes[n+1].pit-18))while(r<=n)t[r++]-=6;else t[n+1]=t[n]+6}}function x_head(e,t){return e.x+t.shhd*stv_g.scale}function y_head(e,t){return staff_tb[e.st].y+3*(t.pit-18)}function draw_basic_note(e,t,n,r){var i,s,o,u,a,f,l,c=!1,h=t.notes[n],p=staff_tb[t.st].y,d=3*(h.pit-18),v=h.shhd*stv_g.scale,m=e+v,g=d+p,y=identify_note(t,h.dur),b=y[0],w=y[1],E=y[2];d%6==0&&v!=(t.stem>0?t.notes[0].shhd:t.notes[t.nhd].shhd)&&(u=0,d>=30?(u=d,u%6&&(u-=3)):d<=-6&&(u=d,u%6&&(u+=3)),u&&xygl(m,u+p,"hl"));if(!h.invis)if(t.grace)o="ghd",m-=4.5*stv_g.scale;else if(h.map&&h.map[0])i=t.head,o=h.map[0][i],o||(o=h.map[0][h.map[0].length-1]),i=o.indexOf("/"),i>=0&&(t.stem>=0?o=o.slice(0,i):o=o.slice(i+1));else if(t.type==C.CUSTOS)o="custos";else switch(b){case C.OVAL:o="HD";break;case C.OVALBARS:if(t.head!=C.SQUARE){o="HDD";break};case C.SQUARE:h.dur<C.BLEN*4?o="breve":(o="longa",l=t.stem>0),!tsnext&&t.next&&t.next.type==C.BAR&&!t.next.next&&(w=0);break;case C.EMPTY:o="Hd";break;default:o="hd"}h.color!=undefined?c=set_color(h.color):h.map&&h.map[2]&&(c=set_color(h.map[2])),o&&(l&&(g_open(m,g,0,1,-1),m=g=0),self.psxygl(m,g,o)||xygl(m,g,o),l&&g_close());if(w){a=e+(7.7+t.xmx)*stv_g.scale,r[n]==undefined&&(r[n]=3*(t.notes[n].pit-18),(t.notes[n].pit&1)==0&&(r[n]+=3)),f=r[n]+p;while(--w>=0)xygl(a,f,"dot"),a+=3.5}h.acc&&(e-=h.shac*stv_g.scale,t.grace?(g_open(e,d+p,0,.75),draw_acc(0,0,h.acc,h.micro_n,h.micro_d),g_close()):draw_acc(e,d+p,h.acc,h.micro_n,h.micro_d)),c!=0&&set_color(c)}function draw_note(e,t){var n,r,i,s,o,u,a,f,l,c,s,h,p=new Array(e.nhd+1);e.dots&&setdoty(e,p),h=e.notes[e.stem<0?e.nhd:0],c=x_head(e,h),o=staff_tb[e.st].y;if(e.grace)f="ghl";else switch(e.head){default:f="hl";break;case C.OVAL:case C.OVALBARS:f="hl1";break;case C.SQUARE:f="hl2"}draw_hl(c,3*(e.notes[0].pit-18),3*(e.notes[e.nhd].pit-18),e.st,f),s=y_head(e,h),e.stemless?e.xstem&&(n=e.ts_prev,u=(n.stem>0?n.y:n.ys)-e.y,u+=staff_tb[n.st].y-o,u/=e.p_v.scale,out_stem(c,s,u)):(u=e.ys-e.y,l=e.nflags,e.ntrem&&(l-=e.ntrem),!t||l<=0?(e.nflags>0&&(e.stem>=0?u-=1:u+=1),out_stem(c,s,u,e.grace)):out_stem(c,s,u,e.grace,l,cfmt.straightflags));if(t&&e.trem1){var d=e.ntrem||0,v=c;u=3*(e.notes[e.stem>0?e.nhd:0].pit-18),e.head==C.FULL||e.head==C.EMPTY?(v+=(e.grace?GSTEM_XOFF:3.5)*e.stem,e.stem>0?u+=6+5.4*d:u-=11.4):e.stem>0?u+=5+5.4*d:u-=10.4,u/=e.p_v.scale,out_trem(v,o+u,d)}c=e.x;for(i=0;i<=e.nhd;i++)draw_basic_note(c,e,i,p)}function next_scut(e){var t=e;for(e=e.next;e;e=e.next){if(e.rbstop)return e;t=e}return t}function prev_scut(e){while(e.prev){e=e.prev;if(e.rbstart)return e}e=e.p_v.sym;while(e.type!=C.CLEF)e=e.ts_prev;return e.next&&e.next.type==C.KEY&&(e=e.next),e.next&&e.next.type==C.METER?e.next:e}function slur_direction(e,t){var n,r,i;if(e.grace&&e.stem>0)return-1;for(n=e;;n=n.next){if(n.type==C.NOTE){if(!n.stemless){if(n.stem<0)return 1;r=!0}n.notes[0].pit<22&&(i=!0)}if(n==t)break}return!r&&!i?1:-1}function slur_out(e,t,n,r,i,s,o){var u,a,f,l=.3,c=.45;a=r-t,a<0&&(a=-a),u=n-e,u>40&&a/u<.7&&(l=.3+.002*(u-40),l>.7&&(l=.7));var h=.5*(e+n),p=.5*(t+r),d=h+l*(e-h),v=p+l*(t-p)+s;d=e+c*(d-e),v=t+c*(v-t);var m=h+l*(n-h),g=p+l*(r-p)+s;m=n+c*(m-n),g=r+c*(g-r),u=.03*(n-e),a=2*i,f=.2+.001*(n-e),f>.6&&(f=.6),f*=i;var y=stv_g.v?stv_g.scale:1;o?output+='<path class="stroke" stroke-dasharray="5,5" d="M':output+='<path class="fill" d="M',out_sxsy(e," ",t),output+="c"+((d-e)/stv_g.scale).toFixed(2)+" "+((t-v)/y).toFixed(2)+" "+((m-e)/stv_g.scale).toFixed(2)+" "+((t-g)/y).toFixed(2)+" "+((n-e)/stv_g.scale).toFixed(2)+" "+((t-r)/y).toFixed(2),o||(output+="\n v"+(-f).toFixed(2)+"c"+((m-u-n)/stv_g.scale).toFixed(2)+" "+((r+f-g-a)/y).toFixed(2)+" "+((d+u-n)/stv_g.scale).toFixed(2)+" "+((r+f-v-a)/y).toFixed(2)+" "+((e-n)/stv_g.scale).toFixed(2)+" "+((r+f-t)/y).toFixed(2)),output+='"/>\n'}function slur_multi(e,t){for(;;){if(e.multi)return e.multi;if(e==t)break;e=e.next}return 0}function draw_slur(e,t,n,r,i){var s=e,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w;while(s.v!=t.v)s=s.ts_next;switch(i&7){case C.SL_ABOVE:w=1;break;case C.SL_BELOW:w=-1;break;default:w=slur_multi(s,t),w||(w=slur_direction(s,t))}var E=1,S=s.st,x=!1;if(s!=t){o=s.next;for(;;){if(o.type==C.NOTE||o.type==C.REST)E++,o.st!=S&&(x=!0,o.st<S&&(S=o.st));if(o==t)break;o=o.next}}x&&error(2,s,"*** multi-staves slurs not treated yet"),a=e.x,e.notes&&e.notes[0].shhd&&(a+=e.notes[0].shhd);if(e!=t)l=t.x,t.notes&&(l+=t.notes[0].shhd);else{for(o=t.ts_next;o;o=o.ts_next)if(o.type==C.STAVES)break;l=o?o.x:realwidth}n>=0?f=3*(s.notes[n].pit-18)+5*w:(f=w>0?s.ymx+2:s.ymn-2,s.type==C.NOTE&&(w>0?s.stem>0&&(a+=5,s.beam_end&&s.nflags>=-1&&!s.in_tuplet&&(s.nflags>0?(a+=2,f=s.ys-3):f=s.ys-6)):s.stem<0&&(a-=1,t.grace?f=s.y-8:s.beam_end&&s.nflags>=-1&&(!s.in_tuplet||s.ys<f+3)&&(s.nflags>0?(a+=2,f=s.ys+3):f=s.ys+6)))),r>=0?c=3*(t.notes[r].pit-18)+5*w:(c=w>0?t.ymx+2:t.ymn-2,t.type==C.NOTE&&(w>0?t.stem>0&&(l+=1,t.beam_st&&t.nflags>=-1&&!t.in_tuplet&&(c=t.ys-6)):t.stem<0&&(l-=5,t.beam_st&&t.nflags>=-1&&!t.in_tuplet&&(c=t.ys+6)))),s.type!=C.NOTE&&(f=c+1.2*w,a=s.x+s.wr*.5,a>l-12&&(a=l-12)),t.type!=C.NOTE&&(s.type==C.NOTE?c=f+1.2*w:c=f,s!=t&&(l=t.x-t.wl*.3)),E>=3&&(s.next.type!=C.BAR&&s.next.x<a+48&&(w>0?(v=s.next.ymx-2,f<v&&(f=v)):(v=s.next.ymn+2,f>v&&(f=v))),t.prev&&t.prev.type!=C.BAR&&t.prev.x>l-48&&(w>0?(v=t.prev.ymx-2,c<v&&(c=v)):(v=t.prev.ymn+2,c>v&&(c=v)))),d=(c-f)/(l-a);if(d>SLUR_SLOPE||d<-SLUR_SLOPE)d=d>SLUR_SLOPE?SLUR_SLOPE:-SLUR_SLOPE,d*w>0?f=c-d*(l-a):c=f+d*(l-a);v=c-f,v>8?v=8:v<-8&&(v=-8),m=v,m<0&&(m=-m),y=.5*m,b=.3*v,v*w>0?(l-=y,c-=b):(a+=y,f+=b),s.grace&&(a=s.x-GSTEM_XOFF*.5),t.grace&&(l=t.x+GSTEM_XOFF*1.5),g=0,d=(c-f)/(l-a);if(s!=t&&s.v==t.v){p=f-d*a;for(o=s.next;o!=t;o=o.next){if(o.st!=S)continue;switch(o.type){case C.NOTE:case C.REST:w>0?(v=3*(o.notes[o.nhd].pit-18)+6,v<o.ymx&&(v=o.ymx),v-=d*o.x+p,v>g&&(g=v)):(v=3*(o.notes[0].pit-18)-6,v>o.ymn&&(v=o.ymn),v-=d*o.x+p,v<g&&(g=v));break;case C.GRACE:for(u=o.extra;u;u=u.next)w>0?(v=3*(u.notes[u.nhd].pit-18)+6,v<u.ymx&&(v=u.ymx),v-=d*u.x+p,v>g&&(g=v)):(v=3*(u.notes[0].pit-18)-6,v>u.ymn&&(v=u.ymn),v-=d*u.x+p,v<g&&(g=v))}}f+=.45*g,c+=.45*g,g*=.65}E>3?h=(.08*(l-a)+12)*w:h=(.03*(l-a)+8)*w,w>0?(h<3*g&&(h=3*g),h>40&&(h=40)):(h>3*g&&(h=3*g),h<-40&&(h=-40)),v=c-f,v<0&&(v=-v),w>0?h<.8*v&&(h=.8*v):h>-0.8*v&&(h=-0.8*v),h*=cfmt.slurheight,slur_out(a,f,l,c,w,h,i&C.SL_DOTTED),y=l-a,d=(c-f)/y,p=f-d*a+.4*h;if(s.v==t.v)for(o=s;o!=t;o=o.next){if(o.st!=S)continue;v=d*o.x+p,o.ymx<v?o.ymx=v:o.ymn>v&&(o.ymn=v),o.next==t?(y=l,t.sl1&&(y-=5)):y=o.next.x,o!=s&&(a=o.x),y-=a,y_set(S,w>0,a,y,v)}return(w>0?C.SL_ABOVE:C.SL_BELOW)|i&C.SL_DOTTED}function draw_slurs(e,t){var n,r,i,s,o,u,a,f,l,c=e;for(;;){if(!c||c==t){if(!i||!(c=i.next)||c==t)break;i=null}if(c.type==C.GRACE){i=c,c=c.extra;continue}if(c.type!=C.NOTE&&c.type!=C.REST&&c.type!=C.SPACE||!c.slur_start&&!c.sl1){c=c.next;continue}r=null,n=c.next;var h=!1;for(;;){if(!n){if(s){n=s.next,s=null;continue}if(!i||h)break;n=i.next,h=!0;continue}if(n.type==C.GRACE){s=n,n=n.extra;continue}if(n.type==C.BAR&&(n.bar_type[0]==":"||n.bar_type=="|]"||n.bar_type=="[|"||n.text&&n.text[0]!="1")){r=n;break}if(n.type!=C.NOTE&&n.type!=C.REST&&n.type!=C.SPACE){n=n.next;continue}if(n.slur_end||n.sl2){r=n;break}if(n.slur_start||n.sl1){if(s){for(r=n;r.next;r=r.next);r.next=s.next,s.next&&(s.next.prev=r),r=null}draw_slurs(n,t),s&&s.next&&(s.next.prev.next=null,s.next.prev=s)}if(n==t)break;n=n.next}if(!n)r=next_scut(c);else if(!r){c=n;if(c==t)break;continue}if(i){for(n=c;n.next;n=n.next);n.next=i.next,i.next&&(i.next.prev=n),i.slur_start=C.SL_AUTO}s&&(s.prev.next=s.extra,s.extra.prev=s.prev,s.slur_start=C.SL_AUTO);if(c.slur_start)f=c.slur_start&15,c.slur_start>>=4,u=-1;else{for(u=0;u<=c.nhd;u++)if(c.notes[u].sl1)break;f=c.notes[u].sl1&15,c.notes[u].sl1>>=4,c.sl1--}a=-1,l=0;if(r.type!=C.NOTE&&r.type!=C.REST&&r.type!=C.SPACE||!r.slur_end&&!r.sl2){if(r.type!=C.BAR||r.bar_type[0]!=":"&&r.bar_type!="|]"&&r.bar_type!="[|"&&(!r.text||r.text[0]=="1"))l=1}else if(r.slur_end)r.slur_end--;else{for(a=0;a<=r.nhd;a++)if(r.notes[a].sl2)break;r.notes[a].sl2--,r.sl2--}f=draw_slur(c,r,u,a,f),l&&(r.p_v.slur_start||(r.p_v.slur_start=0),r.p_v.slur_start<<=4,r.p_v.slur_start+=f),i&&i.next&&(i.next.prev.next=null,i.next.prev=i),s&&(s.prev.next=s,s.extra.prev=null);if(c.slur_start||c.sl1)continue;if(c==t)break;c=c.next}}function draw_tuplet(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,d,b,w,E,S,x;s=e.st;for(n=e;n;n=n.next){if(n.type!=C.NOTE&&n.type!=C.REST){if(n.type==C.GRACE)for(i=n.extra;i;i=i.next)if(i.slur_start||i.sl1)u=!0;continue}if(n.slur_start||n.slur_end||n.sl1||n.sl2)u=!0;n.st<s&&(s=n.st);if(t==0){n.tp1&&draw_tuplet(n,1);if(n.te0)break}else if(n.te1)break}if(!n){error(1,e,"No end of tuplet in this music line"),t==0?e.tp0=0:e.tp1=0;return}if(u){draw_slurs(e,n);if(e.slur_start||e.sl1)return;for(r=e.next;r!=n;r=r.next)if(r.slur_start||r.slur_end||r.sl1||r.sl2)return;if(n.slur_end||n.sl2)return}t==0?(E=e.tp0,e.tp0=0,S=e.tq0):(E=e.tp1,e.tp1=0,S=e.tq1);if(e.tf[0]==1)return;w=e.tf[3],w||(w=e.stem>0?C.SL_ABOVE:C.SL_BELOW);if(e==n)o=!0;else if(e.tf[1]==1)o=!0,draw_slur(e,n,-1,-1,w);else if(e.tf[0]==2||e.type!=C.NOTE||n.type!=C.NOTE)o=!1;else{o=!0;for(r=e;;r=r.next){if(r.type!=C.NOTE&&r.type!=C.REST){if(r.type==C.GRACE||r.type==C.SPACE)continue;o=!1;break}if(r==n)break;if(r.beam_end){o=!1;break}}if(o&&!e.beam_st&&!e.beam_br1&&!e.beam_br2)for(r=e.prev;r;r=r.prev)if(r.type==C.NOTE||r.type==C.REST){r.nflags>=e.nflags&&(o=!1);break}if(o&&!n.beam_end)for(r=n.next;r;r=r.next)if(r.type==C.NOTE||r.type==C.REST){!r.beam_br1&&!r.beam_br2&&r.nflags>=n.nflags&&(o=!1);break}}if(o){if(e.tf[2]==1)return;h=(n.x+e.x)/2,e==n?d=0:d=(n.ys-e.ys)/(n.x-e.x),b=e.ys-d*e.x,m=d*h+b,w==C.SL_ABOVE?(p=y_get(s,1,h-4,8),p>m&&(b+=p-m),b+=2):(p=y_get(s,0,h-4,8),p<m&&(b+=p-m),b-=10);for(r=e;;r=r.next)if(r.x>=h)break;e.stem*n.stem>0&&(e.stem>0?h+=1.5:h-=1.5),p=d*h+b,e.tf[2]==0?out_bnum(h,p,E):out_bnum(h,p,E+":"+S),w==C.SL_ABOVE?(p+=10,r.ymx<p&&(r.ymx=p),y_set(s,!0,h-3,6,p)):(r.ymn>p&&(r.ymn=p),y_set(s,!1,h-3,6,p));return}e.tf[1]!=0&&error(2,e,"'what' value of %%tuplets not yet coded"),w=e.tf[3],w||(w=e.multi>=0?C.SL_ABOVE:C.SL_BELOW);if(w==C.SL_ABOVE){e.st==n.st?l=c=staff_tb[s].topbar+4:(l=e.ymx,c=n.ymx),a=e.x-4;if(e.st==s){for(r=e;!r.dur;r=r.next);p=y_get(s,1,r.x-4,8),p>l&&(l=p),e.stem>0&&(a+=3)}if(n.st==s){for(r=n;!r.dur;r=r.prev);p=y_get(s,1,r.x-4,8),p>c&&(c=p)}n.dur>n.prev.dur?n.next?f=n.next.x-n.next.wl-5:f=realwidth-6:(f=n.x+4,x=n.stem>=0?0:n.nhd,n.notes[x].shhd>0&&(f+=n.notes[x].shhd),n.st==s&&n.stem>0&&(f+=3.5)),h=.5*(a+f),p=.5*(l+c),d=(c-l)/(f-a),v=3*(n.notes[n.nhd].pit-e.notes[e.nhd].pit)/(f-a),v>0?d<0?d=0:d>v&&(d=v):d>0?d=0:d<v&&(d=v),d*d<.1*.1&&(d=0),y=0;for(r=e;;r=r.next){if(!r.dur||r.st!=s){if(r==n)break;continue}m=p+(r.x-h)*d,g=y_get(s,1,r.x-4,8)+2,g-m>y&&(y=g-m);if(r==n)break}p+=y,l=p+d*(a-h),c=p+d*(f-h),p+=8;for(r=e;;r=r.next)if(r.st==s){m=p+(r.x-h)*d,r.ymx<m&&(r.ymx=m);if(r==n)break;y_set(s,!0,r.x,r.next.x-r.x,m)}else if(r==n)break}else{a=e.x-7,n.dur>n.prev.dur?n.next?f=n.next.x-n.next.wl-8:f=realwidth-6:(f=n.x+2,n.notes[n.nhd].shhd>0&&(f+=n.notes[n.nhd].shhd)),e.stem>=0&&(a+=2,f+=2);if(e.st==s){for(r=e;!r.dur;r=r.next);l=y_get(s,0,r.x-4,8)}else l=0;if(n.st==s){for(r=n;!r.dur;r=r.prev);c=y_get(s,0,r.x-4,8)}else c=0;h=.5*(a+f),p=.5*(l+c),d=(c-l)/(f-a),v=3*(n.notes[0].pit-e.notes[0].pit)/(f-a),v>0?d<0?d=0:d>v&&(d=v):d>0?d=0:d<v&&(d=v),d*d<.1*.1&&(d=0),y=0;for(r=e;;r=r.next){if(!r.dur||r.st!=s){if(r==n)break;continue}m=p+(r.x-h)*d,g=y_get(s,0,r.x-4,8),g-m<y&&(y=g-m);if(r==n)break}p+=y-10,l=p+d*(a-h),c=p+d*(f-h),p-=2;for(r=e;;r=r.next){if(r.st==s){if(r==n)break;m=p+(r.x-h)*d,r.ymn>m&&(r.ymn=m),y_set(s,!1,r.x,r.next.x-r.x,m)}if(r==n)break}}if(e.tf[2]==1){out_tubr(a,l+4,f-a,c-l,w==C.SL_ABOVE);return}out_tubrn(a,l,f-a,c-l,w==C.SL_ABOVE,e.tf[2]==0?E.toString():E+":"+S),m=.5*(l+c),w==C.SL_ABOVE?y_set(s,!0,h-3,6,m+9):y_set(s,!1,h-3,6,m)}function draw_note_ties(e,t,n,r,i){var s,o,u,a,f,l,c,h,p,d,v,m,g,y;for(s=0;s<n.length;s++){u=n[s],f=e.notes[u].pit,a=r[s],l=i!=2?t.notes[a].pit:f,o=(e.notes[u].ti1&7)==C.SL_ABOVE?1:-1,d=e.x,g=e.notes[u].shhd,o>0?u<e.nhd&&f+1==e.notes[u+1].pit&&e.notes[u+1].shhd>g&&(g=e.notes[u+1].shhd):u>0&&f==e.notes[u-1].pit+1&&e.notes[u-1].shhd>g&&(g=e.notes[u-1].shhd),d+=g*.6,v=t.x,i!=2&&(g=t.notes[a].shhd,o>0?a<t.nhd&&l+1==t.notes[a+1].pit&&t.notes[a+1].shhd<g&&(g=t.notes[a+1].shhd):a>0&&l==t.notes[a-1].pit+1&&t.notes[a-1].shhd<g&&(g=t.notes[a-1].shhd),v+=g*.6),h=e.st;switch(i){case 0:f!=l&&!(f&1)&&(f=l);break;case 3:o=-o;case 1:d=e.x,d>v-20&&(d=v-20),f=l,h=t.st;break;default:if(e!=t)v-=t.wl,t.type==C.BAR&&(v+=5);else{y=e.time+e.dur;for(p=e.ts_next;p;p=p.ts_next)if(p.time>y)break;v=p?p.x:realwidth}v<d+16&&(v=d+16)}v-d>20?(d+=3.5,v-=3.5):(d+=1.5,v-=1.5),c=3*(f-18),m=(.04*(v-d)+10)*o,slur_out(d,staff_tb[h].y+c,v,staff_tb[h].y+c,o,m,e.notes[u].ti1&C.SL_DOTTED)}}function draw_ties(e,t,n){var r,i,s,o,u,a,f,l=[],c=[],h=[],p=e.nhd,d=e.time+e.dur;if(n==2){for(i=0;i<=p;i++)e.notes[i].ti1&&h.push(i);draw_note_ties(e,t||e,h,h,n);return}for(i=0;i<=p;i++){if(!e.notes[i].ti1)continue;f=-1,u=e.notes[i].opit||e.notes[i].pit;for(o=t.nhd;o>=0;o--){a=t.notes[o].opit||t.notes[o].pit;switch(a-u){case 1:case-1:e.notes[i].acc!=t.notes[o].acc&&(f=o);default:continue;case 0:f=o}break}f>=0?(l.push(i),c.push(f)):h.push(i)}draw_note_ties(e,t,l,c,n);if(!h.length)return;r=e.ts_next;while(r&&r.time<d)r=r.ts_next;while(r&&r.time==d){if(r.type!=C.NOTE||r.st!=e.st){r=r.ts_next;continue}l.length=0,c.length=0;for(i=h.length;--i>=0;){s=h[i],u=e.notes[s].opit||e.notes[s].pit;for(o=r.nhd;o>=0;o--){a=r.notes[o].opit||r.notes[o].pit;if(a==u){l.push(s),c.push(o),h[i]=h.pop();break}}}if(l.length>0){draw_note_ties(e,r,l,c,n==1?1:0);if(h.length==0)return}r=r.ts_next}h.length!=0&&error(1,e,"Bad tie")}function tie_comb(e){var t,n,r;n=e.time+e.dur,r=e.st;for(t=e.ts_next;t;t=t.ts_next){if(t.st!=r)continue;if(t.time==n){if(t.type==C.NOTE)return t;continue}if(t.time>n)return e}return}function draw_all_ties(e){function l(e,t,n){var r;if(e.type==C.GRACE)for(r=e.extra;r;r=r.next)r.ti1&&draw_ties(r,t,n);else draw_ties(e,t,n)}var t,n,r,i,s,o,u,a,f;for(t=e.sym;t;t=t.next){switch(t.type){case C.CLEF:case C.KEY:case C.METER:continue}break}o=e.s_rtie;for(n=t;n;n=n.next){if(n.dur||n.type==C.GRACE)break;if(n.type!=C.BAR||!n.text)continue;n.text[0]=="1"?o=e.s_tie:e.s_tie=o}if(!n)return;e.s_tie&&(e.s_tie.x=t.x+t.wr,t=e.s_tie,e.s_tie=null,t.st=n.st,t.ts_next=n.ts_next,t.time=n.time-t.dur,draw_ties(t,n,1));for(;;){for(t=n;t;t=t.next){if(t.ti1)break;if(!o)continue;if(t.type!=C.BAR||!t.text)continue;if(t.text[0]=="1"){o=null;continue}if(t.bar_type=="|")continue;for(n=t.next;n;n=n.next)if(n.type==C.NOTE)break;if(!n){t=null;break}u=clone(o),u.x=t.x,u.next=n,u.st=n.st,u.time=n.time-u.dur,draw_ties(u,n,1)}if(!t)break;s=t.time+t.dur;for(n=t.next;n;n=n.next){if(n.dur)break;if(n.type==C.BAR&&n.text){if(n.text[0]!="1")break;o=t}}if(!n){for(n=t.ts_next;n;n=n.ts_next){if(n.st!=t.st)continue;if(n.time<s)continue;if(n.time>s){n=null;break}if(n.dur)break}if(!n){l(t,null,2),e.s_tie=t;break}}else{if(n.type!=C.NOTE&&n.type!=C.BAR){error(1,t,"Bad tie");continue}if(n.time!=s){r=tie_comb(t);if(r==t){error(1,t,"Bad tie");continue}n=r}}for(r=t.ts_next;r;r=r.ts_next){if(r.st!=t.st)continue;if(r.time>s)break;if(r.type==C.CLEF){i=!0;continue}}if(i||t.st!=n.st){i=!1,f=(n.x-t.x)*.4,a=n.x,n.x-=f,n.x>t.x+32&&(n.x=t.x+32),l(t,n,2),n.x=a,a=t.x,t.x+=f,t.x<n.x-24&&(t.x=n.x-24),draw_ties(t,n,3),t.x=a;continue}l(t,n,n.type==C.NOTE?0:2)}e.s_rtie=o}function draw_all_slurs(e){var t,n,r,i=e.sym,s=e.slur_start,o=0;if(!i)return;if(s){e.slur_start=0;while(s!=0)o<<=4,o|=s&15,s>>=4}draw_slurs(i,undefined);for(;i;i=i.next)while(i.slur_end||i.sl2){if(i.slur_end)i.slur_end--,r=-1;else{for(r=0;r<=i.nhd;r++)if(i.notes[r].sl2)break;i.notes[r].sl2--,i.sl2--}s=o&15,t=prev_scut(i),draw_slur(t,i,-1,r,s);if(t.type!=C.BAR||t.bar_type[0]!=":"&&t.bar_type!="|]"&&t.bar_type!="[|"&&(!t.text||t.text[0]=="1"))o>>=4}i=e.sym;while(o!=0){s=o&15,o>>=4,t=next_scut(i),draw_slur(i,t,-1,-1,s);if(t.type!=C.BAR||t.bar_type[0]!=":"&&t.bar_type!="|]"&&t.bar_type!="[|"&&(!t.text||t.text[0]=="1"))e.slur_start||(e.slur_start=0),e.slur_start<<=4,e.slur_start+=s}}function draw_sym_near(){var e,t,n,r,i,s,o,u,a,i,f,l,c,h;h=output,output="";for(r=0;r<voice_tb.length;r++){var p={},d=!0;e=voice_tb[r];for(n=e.sym;n;n=n.next)switch(n.type){case C.GRACE:for(o=n.extra;o;o=o.next)o.beam_st&&!o.beam_end&&self.calculate_beam(p,o);break;case C.NOTE:if(n.beam_st&&!n.beam_end||d&&!n.beam_st)d=!1,self.calculate_beam(p,n)}}for(i=0;i<=nstaff;i++){t=staff_tb[i],t.top||(t.top=new Float32Array(YSTEP),t.bot=new Float32Array(YSTEP));for(a=0;a<YSTEP;a++)t.top[a]=0,t.bot[a]=24}set_tie_room(),draw_deco_near();for(n=tsfirst;n;n=n.ts_next){if(n.invis)continue;switch(n.type){case C.GRACE:for(o=n.extra;o;o=o.next)y_set(n.st,!0,o.x-2,4,o.ymx+1),y_set(n.st,!1,o.x-2,4,o.ymn-1);continue;case C.MREST:y_set(n.st,!0,n.x+16,32,n.ymx+2);continue;default:y_set(n.st,!0,n.x-n.wl,n.wl+n.wr,n.ymx+2),y_set(n.st,!1,n.x-n.wl,n.wl+n.wr,n.ymn-2);continue;case C.NOTE:}n.stem>0?(n.beam_st?(f=3,u=n.beam_end?4:10):(f=-8,u=n.beam_end?11:16),y_set(n.st,!0,n.x+f,u,n.ymx),y_set(n.st,!1,n.x-n.wl,n.wl+n.wr,n.ymn)):(y_set(n.st,!0,n.x-n.wl,n.wl+n.wr,n.ymx),n.beam_st?(f=-6,u=n.beam_end?4:10):(f=-8,u=n.beam_end?5:16),f+=n.notes[0].shhd,y_set(n.st,!1,n.x+f,u,n.ymn)),n.notes[n.nhd].acc&&(s=n.y+8,n.ymx<s&&(n.ymx=s),y_set(n.st,!0,n.x,0,s)),n.notes[0].acc&&(s=n.y,n.notes[0].acc==1||n.notes[0].acc==3?s-=7:s-=5,n.ymn>s&&(n.ymn=s),y_set(n.st,!1,n.x,0,s))}for(r=0;r<voice_tb.length;r++){e=voice_tb[r],n=e.sym;if(!n)continue;set_color(n.color),i=e.st,set_dscale(i);for(;n;n=n.next)n.tp0&&draw_tuplet(n,0);draw_all_slurs(e);for(n=e.sym;n;n=n.next)n.tp0&&draw_tuplet(n,0)}for(i=0;i<=nstaff;i++){t=staff_tb[i],l=t.topbar+2,c=t.botbar-2;for(a=0;a<YSTEP;a++)l>t.top[a]&&(t.top[a]=l),c<t.bot[a]&&(t.bot[a]=c)}set_color(undefined),draw_deco_note(),draw_deco_staff(),set_dscale(-1);for(r=0;r<voice_tb.length;r++){e=voice_tb[r];if(e.have_ly){draw_all_lyrics();break}}cfmt.measurenb>=0&&draw_measnb(),set_dscale(-1),output=h}function draw_vname(e){var t,n,r,i,s,o,u,a,f=[];for(r=cur_sy.nstaff;r>=0;r--)if(cur_sy.st_print[r])break;if(r<0)return;for(i=0;i<voice_tb.length;i++){t=voice_tb[i];if(!t.sym)continue;r=cur_sy.voices[i].st;if(!cur_sy.st_print[r])continue;if(t.new_name){a=2;break}t.snm&&(a=1)}if(!a)return;for(i=0;i<voice_tb.length;i++){t=voice_tb[i];if(!t.sym)continue;r=cur_sy.voices[i].st;if(!cur_sy.st_print[r])continue;t.new_name&&delete t.new_name,o=a==2?t.nm:t.snm;if(!o)continue;if(cur_sy.staves[r].flags&CLOSE_BRACE2)while(!(cur_sy.staves[r].flags&OPEN_BRACE2))r--;else if(cur_sy.staves[r].flags&CLOSE_BRACE)while(!(cur_sy.staves[r].flags&OPEN_BRACE))r--;f[r]?f[r]+="\\n"+o:f[r]=o}if(f.length==0)return;set_font("voice"),e=-e*.5;for(r=0;r<f.length;r++){if(!f[r])continue;s=f[r].split("\\n"),u=staff_tb[r].y+staff_tb[r].topbar*.5*staff_tb[r].staffscale+9*(s.length-1)-gene.curfont.size*.3,n=r;if(cur_sy.staves[r].flags&OPEN_BRACE2)while(!(cur_sy.staves[n].flags&CLOSE_BRACE2))n++;else if(cur_sy.staves[r].flags&OPEN_BRACE)while(!(cur_sy.staves[n].flags&CLOSE_BRACE))n++;n!=r&&(u-=(staff_tb[r].y-staff_tb[n].y)*.5);for(n=0;n<s.length;n++)o=s[n],xy_str(e,u,o,"c"),u-=18}}function set_staff(){var e,t,n,r,i,s,o,u,a,f,l,c,h;for(i=0;i<voice_tb.length;i++)c=voice_tb[i],c.scale!=1&&(c.scale_str='transform="scale('+c.scale.toFixed(2)+')"');for(n=0;n<=nstaff;n++)if(gene.st_print[n])break;s=0;if(n>nstaff)n--,h=staff_tb[n];else{h=staff_tb[n];for(t=0;t<YSTEP;t++)l=h.top[t],s<l&&(s=l)}s+=draw_partempo(n,s);if(!gene.st_print[n])return s;s*=h.staffscale,o=cfmt.staffsep*.5+h.topbar*h.staffscale,s<o&&(s=o),s<h.ann_top&&(s=h.ann_top),h.y=-s,r=n;var p=cur_sy.staves[r];for(n++;n<=nstaff;n++){h=staff_tb[n];if(!gene.st_print[n])continue;o=p.sep||cfmt.sysstaffsep,a=p.maxsep||cfmt.maxsysstaffsep,u=0;if(h.staffscale==staff_tb[r].staffscale){for(t=0;t<YSTEP;t++)l=h.top[t]-staff_tb[r].bot[t],u<l&&(u=l);u*=h.staffscale}else for(t=0;t<YSTEP;t++)l=h.top[t]*h.staffscale-staff_tb[r].bot[t]*staff_tb[r].staffscale,u<l&&(u=l);o+=h.topbar*h.staffscale,u<o&&(u=o),a+=h.topbar*h.staffscale,u>a&&(u=a),s+=u,h.y=-s,r=n,p=cur_sy.staves[r]}f=0;for(t=0;t<YSTEP;t++)l=staff_tb[r].bot[t],f>l&&(f=l);f>h.ann_bot&&(f=h.ann_bot),f*=staff_tb[r].staffscale;for(n=0;n<=nstaff;n++)h=staff_tb[n],u=h.y,h.staffscale!=1&&(h.scale_str='transform="translate(0,'+(posy-u).toFixed(2)+") "+"scale("+h.staffscale.toFixed(2)+')"');if(f==0){for(n=nstaff;n>=0;n--)if(gene.st_print[n])break;if(n<0)return s}return u=-f,o=cfmt.staffsep*.5,u<o&&(u=o),a=cfmt.maxstaffsep*.5,u>a&&(u=a),s+u}function draw_systems(e){function p(){var e,t,n,r,i=0;for(e=0;e<=cur_sy.nstaff;e++){if(l[e]<0){c[e]=h[e]=0;continue}t=staff_tb[e].staffscale,n=staff_tb[e].topbar*t,r=staff_tb[e].botbar*t,i==0&&(i=staff_tb[e].y+n),c[e]=staff_tb[e].y+r,h[e]=i-c[e],i=cur_sy.staves[e].flags&STOP_BAR?0:c[e]}}function d(e,t,n){var r,i,s,o,u,a=0,f="",l=cur_sy.staves[e].stafflines,c=l.length;if(!/[\[|]/.test(l))return;r=n-t,set_sscale(e),i=r/stv_g.scale;if(cache&&cache.st_l==l&&cache.st_ws==i){xygl(t,staff_tb[e].y,"stdef"+cfmt.fullsvg);return}for(s=0;s<c;s++,a-=6){if(l[s]==".")continue;o=0;for(;s<c;s++,a-=6,o-=6){switch(l[s]){case".":case"-":continue;case u:f+="m-"+i.toFixed(2)+" "+o+"h"+i.toFixed(2),o=0;continue}u!=undefined&&(f+='"/>\n'),u=l[s],f+='<path class="stroke"',u=="["&&(f+=' stroke-width="1.5"'),f+=' d="m0 '+a+"h"+i.toFixed(2),o=0}f+='"/>\n'}a=staff_tb[e].y;if(!cache&&r==get_lwidth()){cache={st_l:l,st_ws:i},s="stdef"+cfmt.fullsvg,glyphs[s]='<g id="'+s+'">\n'+f+"</g>",xygl(t,a,s);return}out_XYAB('<g transform="translate(X, Y)">\n'+f+"</g>\n",t,a)}var t,n,r,i,s,o,u,a,f,l=[],c=[],h=[];draw_vname(e);for(r=0;r<=nstaff;r++)l[r]=cur_sy.st_print[r]?0:-1;p(),draw_lstaff(0);for(t=tsfirst;t;t=t.ts_next){if(f&&t.time!=f){f=0;for(r=0;r<=nstaff;r++)cur_sy.st_print[r]||(l[r]=-1);p()}switch(t.type){case C.STAVES:a=t.ts_prev.type==C.BAR?t.ts_prev.x:0;if(!a){for(n=t.ts_next;n;n=n.ts_next){if(n.time!=t.time)break;switch(n.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:a=n.x;continue}break}n||(a=realwidth)}u=t.sy;for(r=0;r<=nstaff;r++){i=l[r];if(i<0){u.st_print[r]&&(l[r]=a?a:t.x-t.wl-2);continue}if(u.st_print[r]&&u.staves[r].stafflines==cur_sy.staves[r].stafflines)continue;a?(s=a,f=t.time):(s=t.x-t.wl-2,l[r]=-1),d(r,i,s),u.st_print[r]&&(l[r]=s)}cur_sy=u,p();continue;case C.BAR:r=t.st;if(t.second||t.invis)break;draw_bar(t,c[r],h[r]);break;case C.STBRK:if(cur_sy.voices[t.v].range==0&&t.xmx>14){var v=0;for(var m=0;m<voice_tb.length;m++)cur_sy.voices[m].range>0&&v++;for(n=t.ts_next;n;n=n.ts_next){if(n.type!=C.STBRK)break;v--}v==0&&draw_lstaff(t.x)}n=t.prev;if(!n)break;s=n.x,n.type!=C.BAR&&(s+=n.wr),r=t.st,i=l[r];if(i>=0){if(i>=s)continue;d(r,i,s)}l[r]=t.x}}for(r=0;r<=nstaff;r++){if(f&&!cur_sy.st_print[r])continue;i=l[r];if(i<0||i>=realwidth)continue;d(r,i,realwidth)}}function draw_symbols(e){var t={},n,r,i,s,o;for(n=e.sym;n;n=n.next){if(n.invis)switch(n.type){case C.KEY:e.key=n;default:continue;case C.NOTE:}i=n.x,set_color(n.color);switch(n.type){case C.NOTE:set_scale(n),n.beam_st&&!n.beam_end&&self.calculate_beam(t,n)&&draw_beams(t),n.invis||(anno_start(n),draw_note(n,!t.s2),anno_stop(n)),n==t.s2&&(t.s2=null);break;case C.REST:draw_rest(n);break;case C.BAR:break;case C.CLEF:o=n.st,n.time>staff_tb[o].clef.time&&(staff_tb[o].clef=n);if(n.second)break;if(!staff_tb[n.st].topbar)break;set_color(undefined),set_sscale(o),anno_start(n),s=staff_tb[o].y,n.clef_name?xygl(i,s+n.y,n.clef_name):n.clef_small?xygl(i,s+n.y,"s"+n.clef_type+"clef"):xygl(i,s+n.y,n.clef_type+"clef"),n.clef_octave&&(n.clef_octave>0?(s+=n.ymx-10,n.clef_small&&(s-=1)):(s+=n.ymn+6,n.clef_small&&(s+=1)),xygl(i-2,s,"oct")),anno_stop(n);break;case C.METER:e.meter=n;if(n.second||!staff_tb[n.st].topbar)break;if(cfmt.alignbars&&n.st!=0)break;set_color(undefined),set_sscale(n.st),anno_start(n),draw_meter(i,n),anno_stop(n);break;case C.KEY:e.key=n;if(n.second||!staff_tb[n.st].topbar)break;set_color(undefined),set_sscale(n.st),anno_start(n),draw_keysig(e,i,n),anno_stop(n);break;case C.MREST:set_scale(n),i+=32,anno_start(n),xygl(i,staff_tb[n.st].y+12,"mrest"),out_XYAB('<text style="font:bold 15px serif"\n x ="X" y="Y" text-anchor="middle">A</text>\n',i,staff_tb[n.st].y+28,n.nmes),anno_stop(n);break;case C.GRACE:set_scale(n),draw_gracenotes(n);break;case C.SPACE:case C.STBRK:break;case C.CUSTOS:set_scale(n),draw_note(n,0);break;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:break;default:error(2,n,"draw_symbols - Cannot draw symbol "+n.type)}}set_scale(e.sym),draw_all_ties(e),set_color(undefined)}function draw_all_sym(){var e,t,n=voice_tb.length;for(t=0;t<n;t++)e=voice_tb[t],e.sym&&e.sym.x!=undefined&&self.draw_symbols(e);draw_all_deco(),set_sscale(-1)}function set_tie_dir(e){var t,n,r,i,s,o,u;for(t=e;t;t=t.next){if(!t.ti1)continue;if(t.multi!=0){i=t.multi>0?C.SL_ABOVE:C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if((u&7)!=C.SL_AUTO)continue;t.notes[n].ti1=u&C.SL_DOTTED|i}continue}s=r=0,o=128;for(n=0;n<=t.nhd;n++)t.notes[n].ti1&&(r++,o<128&&t.notes[n].pit<=o+1&&s++,o=t.notes[n].pit);if(r<=1){i=t.stem<0?C.SL_ABOVE:C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u){(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i);break}}continue}if(s==0){if(r&1){r=(r-1)/2,i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;r==0&&t.notes[n].pit>=22&&(i=C.SL_ABOVE),(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i),r--==0&&(i=C.SL_ABOVE)}continue}r/=2,i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i),--r==0&&(i=C.SL_ABOVE)}continue}o=128;for(n=0;n<=t.nhd;n++)if(t.notes[n].ti1){if(o<128&&t.notes[n].pit<=o+1){r=n;break}o=t.notes[n].pit}i=C.SL_BELOW;for(n=0;n<=t.nhd;n++){u=t.notes[n].ti1;if(u==0)continue;r==n&&(i=C.SL_ABOVE),(u&7)==C.SL_AUTO&&(t.notes[n].ti1=u&C.SL_DOTTED|i)}}}function set_tie_room(){var e,t,n,r,i,s,o;for(r=0;r<voice_tb.length;r++){e=voice_tb[r],t=e.sym;if(!t)continue;t=t.next;if(!t)continue;set_tie_dir(t);for(;t;t=t.next){if(!t.ti1)continue;if(!(t.notes[0].pit<20&&(t.notes[0].ti1&7)==C.SL_BELOW||t.notes[t.nhd].pit>24&&(t.notes[t.nhd].ti1&7)==C.SL_ABOVE))continue;n=t.next;while(n&&n.type!=C.NOTE)n=n.next;if(n){if(n.st!=t.st)continue;i=n.x-t.x-10}else i=realwidth-t.x-10;i<100?o=9:i<300?o=12:o=16,t.notes[t.nhd].pit>24&&(s=3*(t.notes[t.nhd].pit-18)+o,t.ymx<s&&(t.ymx=s),n&&n.ymx<s&&(n.ymx=s),y_set(t.st,!0,t.x+5,i,s)),t.notes[0].pit<20&&(s=3*(t.notes[0].pit-18)-o,t.ymn>s&&(t.ymn=s),n&&n.ymn>s&&(n.ymn=s),y_set(t.st,!1,t.x+5,i,s))}}}function get_bool(e){return!e||!/^(0|n|f)/i.test(e)}function get_font_scale(e){var t=e.split(/\s+/);if(t.length<=1)return;var n=parseFloat(t[t.length-1]);if(isNaN(n)||t<=0){syntax(1,"Bad scale value in %%font");return}font_scale_tb[t[0]]=n;for(var r in font_tb){if(!font_tb.hasOwnProperty(r))continue;var i=font_tb[r];i.name==t[0]&&(i.swfac=i.size*n)}}function param_set_font(e,t){var n,r,i,s,o,u,a,f,l,c;if(e[e.length-2]=="-"){s=e[e.length-1];if(s<"1"||s>"9")return;e="u"+s+"font"}r=cfmt[e],r&&(n=font_tb[r],n&&(i=n.name+"."+n.size,n.class&&(i+="."+n.class))),s=t.indexOf("class="),s>=0&&(s+=6,o=t.indexOf(" ",s),o>0?c=t.slice(s,o):c=t.slice(s),t=t.replace(new RegExp("class="+c),"").trim()),o=t.split(/\s+/),u=o[0],u=="*"&&n?u=n.name:(u=u.replace("Times-Roman","serif"),u=u.replace("Times","serif"),u=u.replace("Helvetica","sans-serif"),u=u.replace("Courier","monospace")),o.length>1?(f=o[o.length-1],f=="*"&&n&&(f=n.size)):n&&(f=n.size);if(!f)return;a=u+"."+f,c&&(a+="."+c);if(a==i)return;n=font_tb[a],n||(l=font_scale_tb[u],l||(l=1.1),n={name:u,size:Number(f),swfac:f*l},font_tb[a]=n),c&&(n.class=c),cfmt[e]=a}function get_unit(e){var t=parseFloat(e);switch(e.slice(-2)){case"CM":case"cm":t*=CM;break;case"IN":case"in":t*=IN;break;case"PT":case"pt":t*=.75}return t}function set_infoname(e){var t=cfmt.infoname.split("\n"),n=e[0];for(var r=0;r<t.length;r++){var i=t[r];if(i[0]!=n)continue;e.length==1?t.splice(r,1):t[r]=e,cfmt.infoname=t.join("\n");return}cfmt.infoname+="\n"+e}function get_textopt(e){return textopt[e]}function set_pos(e,t){e=e.slice(0,3),e=="ste"&&(e="stm"),self.set_v_param("pos",e+" "+t)}function set_writefields(e){var t,n,r=e.split(/\s+/);if(get_bool(r[1]))for(n=0;n<r[0].length;n++)t=r[0][n],cfmt.writefields.indexOf(t)<0&&(cfmt.writefields+=t);else for(n=0;n<r[0].length;n++)t=r[0][n],cfmt.writefields.indexOf(t)>=0&&(cfmt.writefields=cfmt.writefields.replace(t,""))}function set_v_param(e,t){if(curvoice){self.set_vp([e+"=",t]);return}e=[e+"=",t];var n="*";info.V||(info.V={}),info.V[n]?Array.prototype.push.apply(info.V[n],e):info.V[n]=e}function set_page(){if(!img.chg)return;img.chg=!1,img.lm=cfmt.leftmargin-cfmt.printmargin,img.lm<0&&(img.lm=0),img.rm=cfmt.rightmargin-cfmt.printmargin,img.rm<0&&(img.rm=0),img.width=cfmt.pagewidth-2*cfmt.printmargin,img.width-img.lm-img.rm<100&&(error(0,undefined,"Bad staff width"),img.width=img.lm+img.rm+150),set_posx()}function set_format(e,t,n){var r,i,s,o,u;if(n)fmt_lock[e]=!0;else if(fmt_lock[e])return;if(/.+font(-[\d])?$/.test(e)){t.slice(-4)==" box"&&(o=!0,t=t.slice(0,-4)),param_set_font(e,t);switch(e){case"gchordfont":cfmt.gchordbox=o;break;case"measurefont":cfmt.measurebox=o;break;case"partsfont":cfmt.partsbox=o}return}switch(e){case"aligncomposer":case"barsperstaff":case"infoline":case"measurefirst":case"measurenb":case"rbmax":case"rbmin":case"shiftunison":s=parseInt(t);if(isNaN(s)){syntax(1,"Bad integer value");break}cfmt[e]=s;break;case"microscale":r=parseInt(t);if(isNaN(r)||r<4||r>256||r%1){syntax(1,errs.bad_val,"%%"+e);break}self.set_v_param("uscale",r);break;case"bgcolor":case"dblrepbar":case"titleformat":cfmt[e]=t;break;case"breaklimit":case"lineskipfac":case"maxshrink":case"pagescale":case"parskipfac":case"scale":case"slurheight":case"stemheight":case"stretchlast":r=parseFloat(t);if(isNaN(r)){syntax(1,errs.bad_val,"%%"+e);break}switch(e){case"scale":r/=.75;case"pagescale":e="scale",img.chg=!0}cfmt[e]=r;break;case"bstemdown":case"breakoneoln":case"cancelkey":case"contbarnb":case"custos":case"decoerr":case"dynalign":case"flatbeams":case"gchordbox":case"graceslurs":case"graceword":case"hyphencont":case"keywarn":case"linewarn":case"measurebox":case"partsbox":case"rbdbstop":case"singleline":case"squarebreve":case"straightflags":case"stretchstaff":case"timewarn":case"titlecaps":case"titleleft":cfmt[e]=get_bool(t);break;case"chordnames":s=t.split(","),cfmt.chordnames={};for(u=0;u<s.length;u++)cfmt.chordnames["CDEFGAB"[u]]=s[u];break;case"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":r=get_unit(t),isNaN(r)?syntax(1,errs.bad_val,"%%"+e):cfmt[e]=r;break;case"print-leftmargin":syntax(0,"$1 is deprecated - use %%printmargin instead","%%"+e),e="printmargin";case"printmargin":case"leftmargin":case"pagewidth":case"rightmargin":r=get_unit(t);if(isNaN(r)){syntax(1,errs.bad_val,"%%"+e);break}cfmt[e]=r,img.chg=!0;break;case"concert-score":cfmt.sound!="play"&&(cfmt.sound="concert");break;case"writefields":set_writefields(t);break;case"dynamic":case"gchord":case"gstemdir":case"ornament":case"stemdir":case"vocal":case"volume":set_pos(e,t);break;case"font":get_font_scale(t);break;case"fullsvg":if(parse.state!=0){syntax(1,"Cannot have %%fullsvg inside a tune");break}cfmt[e]=t;break;case"gracespace":s=t.split(/\s+/);for(u=0;u<3;u++)if(isNaN(Number(s[u]))){syntax(1,errs.bad_val,"%%gracespace");break}for(u=0;u<3;u++)cfmt[e]=Number(s[u]);break;case"tuplets":cfmt[e]=t.split(/\s+/),s=cfmt[e][3],s&&posval[s]&&(cfmt[e][3]=posval[s]);break;case"infoname":set_infoname(t);break;case"notespacingfactor":r=parseFloat(t);if(isNaN(r)||r<1||r>2){syntax(1,errs.bad_val,"%%"+e);break}u=5,i=space_tb[u];for(;--u>=0;)i/=r,space_tb[u]=i;u=5,i=space_tb[u];for(;++u<space_tb.length;)i*=r,space_tb[u]=i;break;case"play":cfmt.sound="play";break;case"pos":e=t.split(/\s+/),set_pos(e[0],e[1]);break;case"sounding-score":cfmt.sound!="play"&&(cfmt.sound="sounding");break;case"staffwidth":s=get_unit(t);if(isNaN(s)){syntax(1,errs.bad_val,"%%"+e);break}if(s<100){syntax(1,"%%staffwidth too small");break}s=cfmt.pagewidth-s-cfmt.leftmargin;if(s<2){syntax(1,"%%staffwidth too big");break}cfmt.rightmargin=s,img.chg=!0;break;case"textoption":cfmt[e]=get_textopt(t);break;case"titletrim":s=Number(t),isNaN(s)?cfmt[e]=get_bool(t):cfmt[e]=s;break;case"combinevoices":syntax(1,"%%combinevoices is deprecated - use %%voicecombine instead");break;case"voicemap":self.set_v_param("map",t);break;case"voicescale":self.set_v_param("scale",t);break;default:parse.state==0&&(cfmt[e]=t)}}function font_init(){param_set_font("annotationfont","sans-serif 12"),param_set_font("composerfont","serifItalic 14"),param_set_font("footerfont","serif 16"),param_set_font("gchordfont","sans-serif 12"),param_set_font("headerfont","serif 16"),param_set_font("historyfont","serif 16"),param_set_font("infofont","serifItalic 14"),param_set_font("measurefont","serifItalic 14"),param_set_font("partsfont","serif 15"),param_set_font("repeatfont","serif 13"),param_set_font("subtitlefont","serif 16"),param_set_font("tempofont","serifBold 15"),param_set_font("textfont","serif 16"),param_set_font("titlefont","serif 20"),param_set_font("vocalfont","serifBold 13"),param_set_font("voicefont","serifBold 13"),param_set_font("wordsfont","serif 16")}function style_font(e){var t=e.split("."),n=t[1],r,i;return e=t[0].toLowerCase(),t="",r=e.indexOf("-"),r<0&&(r=e.length),i=e.indexOf("italic"),i>=0&&(t+="italic ",i<r&&(r=i)),i=e.indexOf("oblique"),i>=0&&(t+="oblique ",i<r&&(r=i)),i=e.indexOf("bold"),i>=0&&(t+="bold ",i<r&&(r=i)),r>0&&(e=e.slice(0,r)),"font:"+t+n+"px "+e}function font_class(e){return e.class?"f"+e.fid+cfmt.fullsvg+" "+e.class:"f"+e.fid+cfmt.fullsvg}function style_add_font(e){font_style+="\n.f"+e.fid+cfmt.fullsvg+" {"+style_font(e.name+"."+e.size)+"}"}function use_font(e){defined_font[e.fid]||(defined_font[e.fid]=!0,style_add_font(e))}function get_font(e){e+="font";var t=cfmt[e],n=font_tb[t];return n||(syntax(1,"Unknown font $1",e),n=gene.curfont),n.fid||(n.fid=fid++),use_font(n),n}function cnv_escape(e){var t,n,r="",i,s=0,o;for(;;){i=e.indexOf("\\",s);if(i<0)break;r+=e.slice(s,i),t=e[++i];if(!t)return r+"\\";switch(t){case"0":case"2":if(e[i+1]!="0")break;n=oct_acc[e[i+2]];if(n){r+=n,s=i+3;continue}break;case"u":s=Number("0x"+e.slice(i+1,i+5));if(isNaN(s)||s<32){r+=e[++i]+"̆",s=i+1;continue}o=[s];if(s>=55296&&s<=57343){s=Number("0x"+e.slice(i+7,i+11));if(isNaN(s))break;o.push(s),s=i+11}else s=i+5;r+=String.fromCharCode.apply(null,o);continue;case"t":r+=" ",s=i+1;continue;default:n=abc_utf[e.slice(i,i+2)];if(n){r+=n,s=i+2;continue}switch(t){case"`":r+=e[++i]+"̀",s=i+1;continue;case"'":r+=e[++i]+"́",s=i+1;continue;case"^":r+=e[++i]+"̂",s=i+1;continue;case"~":r+=e[++i]+"̃",s=i+1;continue;case"=":r+=e[++i]+"̄",s=i+1;continue;case"_":r+=e[++i]+"̅",s=i+1;continue;case".":r+=e[++i]+"̇",s=i+1;continue;case'"':r+=e[++i]+"̈",s=i+1;continue;case"o":r+=e[++i]+"̊",s=i+1;continue;case"H":r+=e[++i]+"̋",s=i+1;continue;case"v":r+=e[++i]+"̌",s=i+1;continue;case"c":r+=e[++i]+"̧",s=i+1;continue;case";":r+=e[++i]+"̨",s=i+1;continue}}r+="\\"+t,s=i+1}return r+e.slice(s)}function do_include(e){var t,n;if(!user.read_file){syntax(1,"No read_file support");return}if(include>2){syntax(1,"Too many include levels");return}include++,t=user.read_file(e);if(!t){syntax(1,"Cannot read file '$1'",e);return}n=clone(parse),tosvg(e,t),parse=n,include--}function tosvg(e,t,n,r){function C(){var e,i,s=t.indexOf("K:",n);return s<0?!1:(s=t.indexOf("\n",s),parse.select.test(t.slice(parse.bol,s))?!0:(e=/\n\w*\n/,e.lastIndex=s,i=e.exec(t),i?o=e.lastIndex:o=r,!1))}function k(e,t){var n;return e.indexOf("%")>=0&&(e=e.replace(/([^\\])%.*/,"$1").replace(/\\%/g,"%")),e=e.replace(/\s+$/,""),t&&e.indexOf("\\")>=0?cnv_escape(e):e}function L(){generate(),info.W&&put_words(info.W),put_history(),blk_flush(),parse.state=0,cfmt=g,info=y,char_tb=b,glovar=w,maps=E,mac=S,maci=x,init_tune(),img.chg=!0,set_page()}var i,s,n,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S,x,T,N="\n";abc2svg.modules&&(abc2svg.modules.hooks.length||abc2svg.modules.g_hooks.length)&&set_hooks(),parse.file=t,parse.fname=e,n==undefined&&(n=0),r||(r=t.length);for(;n<r;n=parse.eol+1){o=t.indexOf("\n",n);if(o<0||o>r)o=r;parse.eol=o;for(;;){o--;switch(t[o]){case" ":case" ":continue}break}o++;if(o==n){parse.state==1?(parse.istart=n,syntax(1,"Empty line in tune header - ignored")):parse.state>=2&&(L(),parse.select&&(o=t.indexOf("\nX:",parse.eol),o<0&&(o=r),parse.eol=o));continue}parse.istart=parse.bol=n,parse.iend=o,parse.line.index=0,f=t[n],l=t[n+1];if(f=="%"){if(parse.prefix.indexOf(l)<0)continue;t[n+2]=="a"&&t[n+3]=="b"&&t[n+4]=="c"&&t[n+5]==" "?(n+=6,f=t[n],l=t[n+1]):T=!0}else f=="I"&&l==":"&&(T=!0);if(T){T=!1,n+=2;for(;;){switch(t[n]){case" ":case" ":n++;continue}break}p=t.slice(n,o);if(!p||p[0]=="%")continue;d=p.split(/\s+/,2),d[0]||d.shift();switch(d[0]){case"abcm2ps":case"ss-pref":parse.prefix=d[1];continue;case"abc-include":do_include(d[1]);continue}if(d[0].slice(0,5)=="begin"){v=d[0].substr(5),u="\n"+f+l+"end"+v,i=t.indexOf(u,o);if(i<0){syntax(1,"No $1 after %%$2",u.slice(1),d[0]),parse.eol=r;continue}self.do_begin_end(v,d[1],t.slice(o+1,i).replace(new RegExp("^"+f+l,"gm"),"")),parse.eol=t.indexOf("\n",i+6),parse.eol<0&&(parse.eol=r);continue}switch(d[0]){case"select":if(parse.state!=0){syntax(1,"%%select ignored");continue}a=k(p.slice(7),!1),a[0]=='"'&&(a=a.slice(1,-1));if(!a){delete parse.select;continue}a=a.replace(/\(/g,"\\("),a=a.replace(/\)/g,"\\)"),parse.select=new RegExp(a,"m");continue;case"tune":syntax(1,"%%tune not treated yet");continue;case"voice":if(parse.state!=0){syntax(1,"%%voice ignored");continue}a=k(p.slice(6),!1);if(!a){parse.cur_tune_opts?parse.cur_tune_opts.voice_opts=null:parse.voice_opts=null;continue}if(a=="end")continue;parse.cur_tune_opts?(parse.cur_tune_opts.voice_opts||(parse.cur_tune_opts.voice_opts={}),h=parse.cur_tune_opts.voice_opts):(parse.voice_opts||(parse.voice_opts={}),h=parse.voice_opts),h[a]=[];for(;;){n=++o;if(t[n]!="%")break;o=t.indexOf("\n",o);if(t[n+1]!=l)continue;n+=2,o<0?p=t.slice(n):p=t.slice(n,o),d=p.match(/\S+/);switch(d[0]){default:h[a].push(k(p,!0));continue;case"score":case"staves":case"tune":case"voice":n-=2}break}parse.eol=n-1;continue}self.do_pscom(k(p,!0));continue}if(l!=":"||!/[A-Za-z+]/.test(f)){c=undefined;if(parse.state<2)continue;parse.line.buffer=k(t.slice(n,o),!0),parse_music_line();continue}n+=2;for(;;){switch(t[n]){case" ":case" ":n++;continue}break}p=k(t.slice(n,o),!0);if(f=="+"){if(!c){syntax(1,"+: without previous info field");continue}N=" ",f=c}switch(f){case"X":if(parse.state!=0){syntax(1,errs.ignored,f);continue}if(parse.select&&!C()){o=t.indexOf("\nX:",parse.eol),o<0&&(o=r),parse.eol=o;continue}g=clone(cfmt),cfmt.pos=clone(cfmt.pos),y=clone(info,1),b=clone(char_tb),w=clone(glovar),E=clone(maps,1),S=clone(mac),x=new Int8Array(maci),info.X=p,parse.state=1;continue;case"T":switch(parse.state){case 0:continue;case 1:info.T==undefined?info.T=p:info.T+="\n"+p;continue}m=new_block("title"),m.text=p;continue;case"K":switch(parse.state){case 0:continue;case 1:info.K=p}do_info(f,p);continue;case"W":if(parse.state==0||cfmt.writefields.indexOf(f)<0)break;info.W==undefined?info.W=p:info.W+=N+p;break;case"m":if(parse.state>=2){syntax(1,errs.ignored,f);continue}if((!cfmt.sound||cfmt.sound!="play")&&cfmt.writefields.indexOf(f)<0)break;d=p.match(/(.*?)[= ]+(.*)/);if(!d||!d[2]){syntax(1,errs.bad_val,"m:");continue}mac[d[1]]=d[2],maci[d[1].charCodeAt(0)]=1;break;case"s":if(parse.state!=3||cfmt.writefields.indexOf(f)<0)break;get_sym(p,N==" ");break;case"w":if(parse.state!=3||cfmt.writefields.indexOf(f)<0)break;get_lyrics(p,N==" ");if(p.slice(-1)=="\\"){N=" ",c=f;continue}break;case"|":if(parse.state<2)continue;parse.line.buffer=k(t.slice(n,o),!0),parse_music_line();continue;default:if("ABCDFGHOSZ".indexOf(f)>=0){if(parse.state>=2){syntax(1,errs.ignored,f);continue}info[f]?info[f]+=N+p:info[f]=p;break}do_info(f,p);continue}N="\n",c=f}if(include)return;parse.state>=2&&L(),parse.state=0}function set_head_shift(e){var t,n,r,i,s,o,u=dx_tb[e.head],a=e.stem,f=e.nhd;if(f==0)return;o=u*.78,e.grace&&(o*=.5),a>=0?(n=1,r=f+1,s=e.notes[0].pit):(o=-o,n=f-1,r=-1,s=e.notes[f].pit);var l=!1,c=0;for(t=n;t!=r;t+=a){i=e.notes[t].pit-s,s=e.notes[t].pit;if(i==0){if(l){var h=e.notes[t].shhd=e.notes[t-a].shhd+o;c<h&&(c=h);continue}if(t+a!=r&&s+a==e.notes[t+a].pit){e.notes[t].shhd=-o,c<-o&&(c=-o);continue}}i<0&&(i=-i),i>3||i>=2&&e.head!=C.SQUARE?l=!1:(l=!l,l&&(e.notes[t].shhd=o,c<o&&(c=o)))}e.xmx=c}function acc_shift(e,t){var n,r,i,s,o,u,a,f=e.length;for(n=f-1;--n>=0;){i=e[n].shhd;if(!i||i>0)continue;i=t-i,o=e[n].pit;for(r=f;--r>=0;){if(!e[r].acc)continue;u=e[r].pit;if(u<o-3)break;if(u>o+3)continue;e[r].shac<i&&(e[r].shac=i)}}for(n=f;--n>=0;){a=e[n].acc;if(!a)continue;i=e[n].shac,i||(i=e[n].shhd,i<0?i=t-i:i=t),o=e[n].pit;for(r=f;--r>n;){if(!e[r].acc)continue;u=e[r].pit;if(u>=o+4)if(u>o+4||a<0||e[r].acc<0)continue;i>e[r].shac-6&&(s=e[r].shac+7,s>i&&(i=s))}e[n].shac=i}}function set_acc_shft(){var e,t,n,r,i,n,s,o;e=tsfirst;while(e){if(e.type!=C.NOTE||e.invis){e=e.ts_next;continue}n=e.st,s=e.time,i=!1;for(t=e;t;t=t.ts_next){if(t.time!=s||t.type!=C.NOTE||t.st!=n)break;if(i)continue;for(r=0;r<=t.nhd;r++)if(t.notes[r].acc){i=!0;break}}if(!i){e=t;continue}o=dx_tb[e.head],n={notes:[]};for(;e!=t;e=e.ts_next)n.notes=n.notes.concat(e.notes);sort_pitch(n),acc_shift(n.notes,o)}}function lkvsym(e,t){e.next=t,e.prev=t.prev,e.prev?e.prev.next=e:e.p_v.sym=e,t.prev=e}function lktsym(e,t){t?(e.ts_next=t,e.ts_prev=t.ts_prev,e.ts_prev&&(e.ts_prev.ts_next=e),t.ts_prev=e):e.ts_next=e.ts_prev=null}function unlksym(e){e.next&&(e.next.prev=e.prev),e.prev?e.prev.next=e.next:e.p_v.sym=e.next,e.ts_next&&(e.seqst&&!e.ts_next.seqst&&(e.ts_next.seqst=!0,e.ts_next.shrink=e.shrink,e.ts_next.space=e.space),e.ts_next.ts_prev=e.ts_prev),e.ts_prev&&(e.ts_prev.ts_next=e.ts_next),tsfirst==e&&(tsfirst=e.ts_next),tsnext==e&&(tsnext=e.ts_next)}function insert_clef(e,t,n){var r=e.p_v,i,s=e.st;e.type==C.BAR&&e.prev&&e.prev.type==C.BAR&&(e=e.prev),r.last_sym=e.prev,r.last_sym||(r.sym=null),r.time=e.time,i=sym_add(r,C.CLEF),i.next=e,e.prev=i,i.clef_type=t,i.clef_line=n,i.st=s,i.clef_small=!0,delete i.second,i.notes=[],i.notes[0]={pit:e.notes[0].pit},i.nhd=0;while(!e.seqst)e=e.ts_prev;return lktsym(i,e),i.ts_prev.type!=C.CLEF&&(i.seqst=!0),i}function set_float(){var e,t,n,r,i,s,o,u;for(r=0;r<voice_tb.length;r++){e=voice_tb[r],n=!1,t=e.st;for(i=e.sym;i;i=i.next){if(!i.floating){while(i&&!i.floating)i=i.next;if(!i)break;n=!1}if(!i.dur){n&&i.st++;continue}if(i.notes[0].pit>=19){n=!1;continue}if(i.notes[i.nhd].pit<=12){n=!0,i.st++;continue}o=127;for(s=i.ts_prev;s;s=s.ts_prev){if(s.st!=t||s.v==i.v)break;s.type==C.NOTE&&s.notes[0].pit<o&&(o=s.notes[0].pit)}if(o==127){n&&i.st++;continue}if(i.notes[i.nhd].pit>o-3){n=!1;continue}u=-127;for(s=i.ts_next;s;s=s.ts_next){if(s.st!=t+1||s.v==i.v)break;s.type==C.NOTE&&s.notes[s.nhd].pit>u&&(u=s.notes[s.nhd].pit)}if(u==-127){n&&i.st++;continue}if(i.notes[0].pit<u+3){n=!0,i.st++;continue}o-=i.notes[i.nhd].pit,u=i.notes[0].pit-u;if(!n){if(o<u+3)continue;n=!0}else if(o<u-3){n=!1;continue}i.st++}}}function set_graceoffs(e){var t,n,r,i,s=cfmt.gracespace[0],o=cfmt.gracespace[1],u=cfmt.gracespace[2],a=e.extra;e.prev&&e.prev.type==C.BAR&&(s-=3),i=s,a.beam_st=!0;for(;;a=a.next){set_head_shift(a),acc_shift(a.notes,7),r=0;for(n=a.nhd;n>=0;n--)a.notes[n].shac>r&&(r=a.notes[n].shac);i+=r,a.x=i,a.nflags<=0&&(a.beam_st=!0,a.beam_end=!0),t=a.next;if(!t){a.beam_end=!0;break}t.nflags<=0&&(a.beam_end=!0),a.beam_end&&(t.beam_st=!0,i+=o/4),a.nflags<=0&&(i+=o/4),a.y>t.y+8&&(i-=1.5),i+=o}return t=e.next,t&&t.type==C.NOTE&&(a.y>=3*(t.notes[t.nhd].pit-18)?u-=1:a.beam_st&&a.y<3*(t.notes[t.nhd].pit-18)-4&&(u+=2)),i+=u,i}function gchord_width(e,t,n){var r,i,s,o,u,a=0,f=0,l=0,c=0;for(u=0;u<e.a_gch.length;u++){i=e.a_gch[u];switch(i.type){default:o=-i.x,o>a&&(a=o),s=i.w+2-o,s>f&&(f=s);break;case"<":s=i.w+t,s>l&&(l=s);break;case">":s=i.w+e.wr,s>c&&(c=s)}}r=e.prev;if(r){if(r.a_gch)for(r=e.ts_prev;;r=r.ts_prev){if(r==e.prev){n<a&&(n=a);break}r.seqst&&(a-=r.shrink)}l!=0&&n<l&&(n=l)}r=e.next;if(r){if(r.a_gch)for(r=e.ts_next;;r=r.ts_next){if(r==e.next){e.wr<f&&(e.wr=f);break}r.seqst&&(f-=8)}c!=0&&e.wr<c&&(e.wr=l)}return n}function set_width(e){var t,n,r,i,s,o,u,a,f,l,c,h,p,d,v;switch(e.type){case C.NOTE:case C.REST:e.wr=o=hw_tb[e.head],e.xmx>0&&(e.wr+=e.xmx+4);for(t=e.prev;t;t=t.prev)if(w_tb[t.type]!=0)break;if(t)switch(t.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:o+=3}for(r=0;r<=e.nhd;r++)i=e.notes[r].shhd,i<0&&o<-i+5&&(o=-i+5),e.notes[r].acc&&(v=e.notes[r].shac+(e.notes[r].micro?5.5:3.5),o<v&&(o=v));if(t)switch(t.type){case C.BAR:case C.CLEF:case C.KEY:case C.METER:o-=3}e.a_dd&&(o+=deco_width(e)),e.beam_st&&e.beam_end&&e.stem>0&&e.nflags>0&&e.wr<e.xmx+9&&(e.wr=e.xmx+9);if(e.dots){if(e.wl==undefined)switch(e.head){case C.SQUARE:e.xmx+=4;break;case C.OVALBARS:case C.OVAL:e.xmx+=2;break;case C.EMPTY:e.xmx+=1}e.wr<e.xmx+8&&(e.wr=e.xmx+8),e.dots>=2&&(e.wr+=3.5*(e.dots-1))}e.trem2&&e.beam_end&&o<20&&(o=20),u=o;if(t)switch(t.type){case C.NOTE:t.stem>0&&e.stem<0&&u<7&&(u=7),(e.y>27&&t.y>27||e.y<-3&&t.y<-3)&&u<6&&(u=6),t.ti1&&u<14&&(u=14);break;case C.CLEF:if(t.second||t.clef_small)break;u+=8;break;case C.KEY:u+=4}e.a_gch&&(u=gchord_width(e,o,u)),e.a_ly&&(u=ly_width(e,u)),t&&t.type==C.GRACE?e.wl=o-4.5:e.wl=u;return;case C.SPACE:i=e.width/2,e.wr=i,e.a_gch&&(i=gchord_width(e,i,i)),e.a_dd&&(i+=deco_width(e)),e.wl=i;return;case C.BAR:if(e.norepbra)break;f=e.bar_type;switch(f){case"|":s=7;break;default:s=4+3*f.length;for(n=0;n<f.length;n++)switch(f[n]){case"[":case"]":s+=3;break;case":":s+=2}}e.wl=s,e.next&&e.next.type!=C.METER?e.wr=7:e.wr=5;for(t=e.prev;t;t=t.prev)if(w_tb[t.type]!=0){t.type==C.GRACE&&(e.wl-=8);break}e.a_dd&&(e.wl+=deco_width(e)),e.text&&e.text.length<4&&e.next&&e.next.a_gch&&(set_font("repeat"),e.wr+=strwh(e.text)[0]+2);return;case C.CLEF:if(e.invis){e.wl=e.wr=1;return}e.wl=e.wr=e.clef_small?8:12;return;case C.KEY:e.wl=3,d=4;if(!e.k_a_acc)h=e.k_sf,e.k_old_sf&&(cfmt.cancelkey||h==0)?p=e.k_old_sf:p=0,h*p>=0?(h<0&&(h=-h),p<0&&(p=-p),p>h&&(h=p)):(h-=p,h<0&&(h=-h),d+=3);else{h=p=e.k_a_acc.length,p&&(c=e.k_a_acc[0].acc);for(n=1;n<p;n++)a=e.k_a_acc[n],a.pit>e.k_a_acc[n-1].pit+6||a.pit<e.k_a_acc[n-1].pit-6?h--:a.acc!=c&&(d+=3),c=a.acc}e.wr=5.5*h+d;return;case C.METER:u=0,e.x_meter=[];for(n=0;n<e.a_meter.length;n++){l=e.a_meter[n];switch(l.top[0]){case"C":case"c":case"o":e.x_meter[n]=u+6,u+=12;break;case".":case"|":e.x_meter[n]=e.x_meter[n-1];break;default:s=0,!l.bot||l.top.length>l.bot.length?l=l.top:l=l.bot;for(r=0;r<l.length;r++)switch(l[r]){case"(":u+=4;case")":case"1":s+=4;break;default:s+=12}e.x_meter[n]=u+s/2,u+=s}}e.wl=0,e.wr=u+6;return;case C.MREST:e.wl=6,e.wr=66;return;case C.GRACE:e.wl=set_graceoffs(e),e.wr=0,e.a_ly&&ly_width(e,u);return;case C.STBRK:e.wl=e.xmx,e.next&&e.next.type==C.CLEF?(e.wr=2,delete e.next.clef_small):e.wr=8;return;case C.CUSTOS:e.wl=e.wr=4;return;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:break;default:error(2,e,"set_width - Cannot set width for symbol $1",e.type)}e.wl=e.wr=0}function time2space(e,t){var n,r,i;return smallest_duration>=C.BLEN/2?smallest_duration>=C.BLEN?t/=4:t/=2:!e.next&&t>=C.BLEN&&(t/=2),t>=C.BLEN/4?t<C.BLEN/2?n=5:t<C.BLEN?n=6:t<C.BLEN*2?n=7:t<C.BLEN*4?n=8:n=9:t>=C.BLEN/8?n=4:t>=C.BLEN/16?n=3:t>=C.BLEN/32?n=2:t>=C.BLEN/64?n=1:n=0,r=t-(C.BLEN/16/8<<n),i=space_tb[n],r!=0&&(r<0?i=space_tb[0]*t/(C.BLEN/16/8):(n>=9&&(n=8),i+=(space_tb[n+1]-space_tb[n])*r/t)),i}function set_space(e){var t,n,r=e.ts_prev.time,i=e.time-r;if(i==0){switch(e.type){case C.MREST:return e.wl}return 0}if(e.ts_prev.type==C.MREST)return 71;n=time2space(e,i);while(!e.dur){switch(e.type){case C.BAR:return n*.9-7;case C.CLEF:return n-e.wl-e.wr;case C.BLOCK:case C.PART:case C.REMARK:case C.STAVES:case C.TEMPO:e=e.ts_next;if(!e)return n;continue}break}e.beam_st||(n*=.9);if(e.type==C.NOTE&&e.nflags>=-1&&e.stem>0){var s=!0;for(t=e.ts_prev;t&&t.time==r;t=t.ts_prev)if(t.type==C.NOTE&&(t.nflags<-1||t.stem>0)){s=!1;break}if(s){for(t=e.ts_next;t&&t.time==e.time;t=t.ts_next)if(t.type==C.NOTE&&(t.nflags<-1||t.stem<0)){s=!1;break}s&&(n*=.9)}}return n}function set_sp_tup(e,t){var n,r,i=e.time,s=t.time+t.dur,o=s-i,u=time2space(e,o/e.tq0)*e.tq0/o;do e=e.ts_next;while(!e.seqst);while(!e.dur)e=e.ts_next;while(!e.seqst)e=e.ts_prev;do t.ts_next?t=t.ts_next:(r=add_end_bar(t),t=r);while(!t.seqst);r=e;for(;;){r.dur&&r.dur*u<r.shrink&&(u=r.shrink/r.dur);if(r==t)break;r=r.ts_next}for(;;){e.seqst&&(n=(e.time-i)*u,i=e.time),e.space=n;if(e==t)break;e=e.ts_next}}function add_end_bar(e){var t={type:C.BAR,bar_type:"|",fname:e.fname,istart:e.istart,iend:e.iend,v:e.v,p_v:e.p_v,st:e.st,dur:0,seqst:!0,invis:!0,time:e.time+e.dur,nhd:0,notes:[{pit:e.notes[0].pit}],wl:0,wr:0,prev:e,ts_prev:e,shrink:e.wr+3};return e.next=e.ts_next=t,t}function set_allsymwidth(){var e,t,n,r,i,s=tsfirst,o=s,u=0,a=[],f=[],l=0;for(;;){e=u;do self.set_width(s),i=s.st,a[i]==undefined&&(a[i]=0),f[i]==undefined&&(f[i]=0),t=a[i]+f[i]+s.wl,t>e&&(e=t),s=s.ts_next;while(s&&!s.seqst);o.shrink=e-u,l||(o.space=o.ts_prev?set_space(o):0),o.shrink==0&&o.space==0&&o.type==C.CLEF&&(delete o.seqst,o.time=o.ts_prev.time);if(!s)break;for(i=0;i<f.length;i++)f[i]=0;u=e;do i=o.st,a[i]=u,o.wr>f[i]&&(f[i]=o.wr),o.tp0&&++l==1&&!n&&(n=o),o.te0&&l--,o=o.ts_next;while(!o.seqst)}s=n;if(!s)return;do{o=s,l=1;do s=s.ts_next,s.tp0&&l++,s.te0&&l--;while(l!=0);set_sp_tup(o,s);do s=s.ts_next;while(s&&!s.tp0)}while(s)}function to_rest(e){e.type=C.REST,delete e.in_tuplet,delete e.sl1,delete e.sl2,delete e.a_dd,delete e.a_gch,e.slur_start=e.slur_end=0}function set_repeat(e){var t,n,r,i,s,o=e.repeat_n,u=e.repeat_k,a=e.st,f=e.v;e.repeat_n=0;if(o<0){o=-o,r=o;for(n=e.prev;n;n=n.prev){if(!n.dur){if(n.type==C.BAR){error(1,n,"Bar in repeat sequence");return}continue}if(--r<=0)break}if(!n){error(1,e,errs.not_enough_n);return}s=e.time-n.time,r=u*o;for(t=e;t;t=t.next){if(!t.dur){if(t.type==C.BAR){error(1,t,"Bar in repeat sequence");return}continue}if(--r<=0)break}if(!t||!t.next){error(1,e,errs.not_enough_n);return}for(t=e.prev;t!=n;t=t.prev)if(t.type==C.NOTE){t.beam_end=!0;break}for(i=u;--i>=0;){r=o,e.dur&&r--,t=e.ts_next;while(r>0)t.st==a&&(unlksym(t),t.v==f&&t.dur&&r--),t=t.ts_next;to_rest(e),e.dur=e.notes[0].dur=s,e.rep_nb=-1,e.beam_st=!0,self.set_width(e),e.seqst&&(e.space=set_space(e)),e.head=C.SQUARE;for(e=t;e;e=e.ts_next)if(e.st==a&&e.v==f&&e.dur)break}return}r=o;for(t=e.prev.prev;t;t=t.prev)if(t.type==C.BAR||t.time==tsfirst.time)if(--r<=0)break;if(!t){error(1,e,errs.not_enough_m);return}s=e.time-t.time,o==1?r=u:r=o;for(t=e;t;t=t.next)if(t.type==C.BAR&&--r<=0)break;if(!t){error(1,e,errs.not_enough_m);return}r=u;if(o==2&&r>1){t=t.next;if(!t){error(1,e,errs.not_enough_m);return}t.repeat_n=o,t.repeat_k=--r}s/=o;if(o==2){n=e;for(t=e.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.invis=!0,n.seqst&&(n.space=set_space(n)),t.bar_mrep=2,t.seqst&&(t.space=set_space(t)),n=t.next;for(t=n.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.invis=!0,self.set_width(n),n.seqst&&(n.space=set_space(n)),t.seqst&&(t.space=set_space(t));return}n=e;for(i=u;--i>=0;){for(t=n.ts_next;;t=t.ts_next){if(t.st!=a)continue;if(t.v==f&&t.type==C.BAR)break;unlksym(t)}to_rest(n),n.dur=n.notes[0].dur=s,n.beam_st=!0,n.seqst&&(n.space=set_space(n)),t.seqst&&(t.space=set_space(t));if(u==1){n.rep_nb=1;break}n.rep_nb=u-i+1,n=t.next}}function custos_add(e){var t,n,r,i=e;for(;;){if(i.type==C.NOTE)break;i=i.next;if(!i)return}t=e.p_v,t.last_sym=e.prev,t.time=e.time,n=sym_add(t,C.CUSTOS),n.next=e,e.prev=n,lktsym(n,e),n.seqst=!0,n.shrink=e.shrink,n.shrink<12&&(n.shrink=12),n.space=i.space,n.wl=0,n.wr=4,n.nhd=i.nhd,n.notes=[];for(r=0;r<e.notes.length;r++)n.notes[r]={pit:i.notes[r].pit,shhd:0,dur:C.BLEN/4};n.stemless=!0}function set_nl(e){function i(e){cfmt.custos&&voice_tb.length==1&&custos_add(e);for(var t=e.ts_next;t;t=t.ts_next)if(t.seqst){e.nl=!0;break}}function s(e){if(!e.next)return i(e),e;for(e=e.ts_next;e;e=e.ts_next)if(e.seqst){i(e);break}return e}var t,n,r;if(e.eoln&&!cfmt.keywarn&&!cfmt.timewarn)return s(e);switch(e.type){case C.CLEF:case C.BAR:case C.STAVES:break;case C.KEY:if(cfmt.keywarn&&!e.k_none)break;return s(e);case C.METER:if(cfmt.timewarn)break;return s(e);case C.GRACE:e=e.next;if(!e)return e;default:return s(e)}for(;e;e=e.ts_prev){if(!e.seqst)continue;switch(e.type){case C.KEY:case C.CLEF:case C.METER:continue}break}r=0;for(;;e=e.ts_next){if(!e)return e;if(!e.seqst)continue;if(r<0)break;switch(e.type){case C.STAVES:if(e.ts_prev&&e.ts_prev.type==C.BAR)break;while(e.ts_next){if(w_tb[e.ts_next.type]!=0&&e.ts_next.type!=C.CLEF)break;e=e.ts_next}if(!e.ts_next||e.ts_next.type!=C.BAR)continue;e=e.ts_next;case C.BAR:if(r)break;r=1;continue;case C.STBRK:e.stbrk_forced?r=-1:unlksym(e);continue;case C.METER:if(!cfmt.timewarn)break;continue;case C.CLEF:if(r)break;continue;case C.KEY:if(!cfmt.keywarn||e.k_none)break;continue;default:if(!r||e.prev&&e.prev.type==C.GRACE)continue}break}return i(e),e}function get_ck_width(){var e,t,n=voice_tb[0];return self.set_width(n.clef),self.set_width(n.key),self.set_width(n.meter),[n.clef.wl+n.clef.wr+n.key.wl+n.key.wr,n.meter.wl+n.meter.wr]}function get_width(e,t){var n,r,i=0,s=1-cfmt.maxshrink;do{e.seqst&&(n=e.shrink,(r=e.space)<n?i+=n:i+=n*cfmt.maxshrink+r*s,e.x=i);if(e==t)break;e=e.ts_next}while(e);return i}function set_lines(e,t,n,r){var i,s,o,u,a,f,l,c,h,p,d,v;for(;t;t=t.ts_next)if(t.eoln)break;c=get_width(e,t)+r;for(;;){d=Math.ceil(c/n);if(d<=1)return t&&(t=set_nl(t)),t;s=i=e,a=e.x-e.shrink-r,l=a+n,f=a+c/d,a+=c/d*cfmt.breaklimit;for(e=e.ts_next;e!=t;e=e.ts_next){if(!e.x)continue;e.type==C.BAR&&(s=e);if(e.x>=a)break}if(e==t)return t&&(t=set_nl(t)),t;v=!1,o=null;for(;e!=t;e=e.ts_next){u=e.x;if(!u)continue;if(u>l)break;if(e.type!=C.BAR)continue;if(u<f){o=e;continue}if(!o||e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}o&&(e=o,v=!0);if(!v){var m=0,g=s.time;l-=8,e=s,o=null;for(;e!=t;e=e.ts_next){e.beam_st&&m++,e.beam_end&&m>0&&m--,u=e.x;if(!u)continue;if(u+e.wr>=l)break;if(m||e.in_tuplet)continue;if((e.time-g)%(C.BLEN/4)==0){o=e;continue}if(!o||e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}o&&(e=o,v=!0)}if(!v){o=e=s;for(;e!=t;e=e.ts_next){u=e.x;if(!u)continue;if(e.x<f){o=e;continue}if(o>f)break;if(f-o.x<e.x-f)break;o=e;break}e=o}if(e.nl){error(0,e,"Line split problem - adjust maxshrink and/or breaklimit"),d=2;for(e=e.ts_next;e!=t;e=e.ts_next){if(!e.x)continue;if(--d<=0)break}}e=set_nl(e);if(!e||t&&e.time>=t.time)break;c-=e.x-i.x,r=0}return e}function cut_tune(e,t){var n,r,i,s,o,n=tsfirst;t!=0&&(s=set_indent(),e-=s,t-=s),s=get_ck_width(),e-=s[0],t+=s[1],cfmt.custos&&voice_tb.length==1&&(e-=12);if(cfmt.barsperstaff){s=cfmt.barsperstaff;for(r=n;r;r=r.ts_next){if(r.type!=C.BAR||!r.bar_num||--s>0)continue;r.eoln=!0,s=cfmt.barsperstaff}}o=t,r=n;for(;n;n=n.ts_next){if(!n.seqst&&!n.eoln)continue;o+=n.shrink;if(o>e)r=set_lines(r,n,e,t);else{if(!n.eoln)continue;delete n.eoln;if(n.dur){for(i=n.ts_next;i;i=i.ts_next)if(i.seqst||i.dur<n.dur)break;i&&!i.seqst?r=set_lines(r,n,e,t):r=set_nl(n)}else r=set_nl(n)}if(!r)break;if(!r.ts_prev){delete r.nl;continue}o=r.shrink,n=r.ts_prev,t=0}}function set_yval(e){switch(e.type){case C.CLEF:if(e.second||e.invis){e.ymx=e.ymn=12;break}e.y=(e.clef_line-1)*6;switch(e.clef_type){default:e.ymx=e.y+28,e.ymn=e.y-14;break;case"c":e.ymx=e.y+13,e.ymn=e.y-11;break;case"b":e.ymx=e.y+7,e.ymn=e.y-12}e.clef_small&&(e.ymx-=2,e.ymn+=2),e.ymx<26&&(e.ymx=26),e.ymn>-1&&(e.ymn=-1),e.clef_octave&&(e.clef_octave>0?e.ymx+=12:e.ymn-=12);break;case C.KEY:e.k_sf>2?e.ymx=34:e.k_sf>0?e.ymx=30:e.ymx=26,e.ymn=-2;break;default:e.ymx=24,e.ymn=0}}function set_auto_clef(e,t,n){var r,i,s,o,u,a;s=12,i=20;for(r=t;r;r=r.ts_next){if(r.type==C.STAVES&&r!=t)break;if(r.st!=e)continue;if(r.type!=C.NOTE){if(r.type==C.CLEF){if(r.clef_type!="a")break;unlksym(r)}continue}r.notes[0].pit<i?i=r.notes[0].pit:r.notes[r.nhd].pit>s&&(s=r.notes[r.nhd].pit)}if(i>=19||i>=13&&n!="b")return"t";if(s<=13||s<=19&&n!="t")return"b";n=="a"&&((s+i)/2>=16?n="t":n="b");var f=n,l=r,c=null;for(r=t;r!=l;r=r.ts_next){if(r.type==C.STAVES&&r!=t)break;if(r.st!=e||r.type!=C.NOTE)continue;o=r.time;if(f=="t"){if(r.notes[0].pit>12||r.notes[r.nhd].pit>20){r.notes[0].pit>20&&(c=r);continue}u=r.ts_prev;if(u&&u.time==o&&u.st==e&&u.type==C.NOTE&&u.notes[0].pit>=19)continue;u=r.ts_next;if(u&&u.st==e&&u.time==o&&u.type==C.NOTE&&u.notes[0].pit>=19)continue}else{if(r.notes[0].pit<12||r.notes[r.nhd].pit<20){r.notes[r.nhd].pit<12&&(c=r);continue}u=r.ts_prev;if(u&&u.time==o&&u.st==e&&u.type==C.NOTE&&u.notes[0].pit<=13)continue;u=r.ts_next;if(u&&u.st==e&&u.time==o&&u.type==C.NOTE&&u.notes[0].pit<=13)continue}if(!c){f=n=f=="t"?"b":"t",c=r;continue}a=r;for(u=r.ts_prev;u!=c;u=u.ts_prev){if(u.st!=e)continue;if(u.type==C.BAR&&u.v==r.v){a=u;break}if(u.type!=C.NOTE)continue;u.beam_st&&!u.p_v.second&&(a=u)}if(a.time==c.time){c=r;continue}c=r,f=f=="t"?"b":"t",u=insert_clef(a,f,f=="t"?2:4),u.clef_auto=!0}return n}function set_clefs(){var e,t,n,r,i,s,o,u,a,f,l=new Array(nstaff),c=cur_sy,h=[];staff_tb=new Array(nstaff);for(n=0;n<=nstaff;n++)l[n]={autoclef:!0},staff_tb[n]={output:"",sc_out:""};for(r=0;r<voice_tb.length;r++){i=voice_tb[r];if(c.voices[r].range<0)continue;n=c.voices[r].st,c.voices[r].second||(i.staffnonote!=undefined&&(c.staves[n].staffnonote=i.staffnonote),i.staffscale&&(c.staves[n].staffscale=i.staffscale),c.voices[r].sep&&(c.staves[n].sep=c.voices[r].sep),c.voices[r].maxsep&&(c.staves[n].maxsep=c.voices[r].maxsep)),!c.voices[r].second&&!i.clef.clef_auto&&(l[n].autoclef=!1)}for(r=0;r<voice_tb.length;r++){i=voice_tb[r];if(c.voices[r].range<0||c.voices[r].second)continue;n=c.voices[r].st,e=i.clef,l[n].autoclef&&(e.clef_type=set_auto_clef(n,tsfirst,e.clef_type),e.clef_line=e.clef_type=="t"?2:4),l[n].clef=staff_tb[n].clef=e}for(n=0;n<=c.nstaff;n++)h[n]=(c.staves[n].stafflines.length-1)*3;for(e=tsfirst;e;e=e.ts_next){e.repeat_n&&set_repeat(e);switch(e.type){case C.STAVES:c=e.sy;for(n=0;n<=nstaff;n++)l[n].autoclef=!0;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0)continue;i=voice_tb[r],n=c.voices[r].st,c.voices[r].second||(i.staffnonote!=undefined&&(c.staves[n].staffnonote=i.staffnonote),i.staffscale&&(c.staves[n].staffscale=i.staffscale),c.voices[r].sep&&(c.staves[n].sep=c.voices[r].sep),c.voices[r].maxsep&&(c.staves[n].maxsep=c.voices[r].maxsep)),t=i.clef,t.clef_auto||(l[n].autoclef=!1)}for(n=0;n<=c.nstaff;n++)h[n]=(c.staves[n].stafflines.length-1)*3;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0||c.voices[r].second)continue;i=voice_tb[r],n=c.voices[r].st,t=i.clef,t.clef_auto?(o=set_auto_clef(n,e,l[n].clef?l[n].clef.clef_type:"a"),u=o=="t"?2:4):(o=t.clef_type,u=t.clef_line);if(!l[n].clef){t.clef_auto&&(t.type!="a"&&(i.clef=clone(i.clef)),i.clef.clef_type=o,i.clef.clef_line=u),staff_tb[n].clef=l[n].clef=i.clef;continue}if(o==l[n].clef.clef_type&&u==l[n].clef.clef_line)continue;s=e.ts_next;while(s&&(s.v!=r||s.st!=n))s=s.ts_next;if(!s)continue;s.type!=C.CLEF&&(s=insert_clef(s,o,u),t.clef_auto&&(s.clef_auto=!0)),l[n].clef=i.clef=s}continue;default:e.mid=h[e.st];continue;case C.CLEF:}e.clef_type=="a"&&(e.clef_type=set_auto_clef(e.st,e.ts_next,l[e.st].clef.clef_type),e.clef_line=e.clef_type=="t"?2:4),i=e.p_v,i.clef=e;if(e.second){unlksym(e);continue}n=e.st;if(l[n].clef){if(e.clef_type==l[n].clef.clef_type&&e.clef_line==l[n].clef.clef_line)continue}else staff_tb[n].clef=e;l[n].clef=e}c=cur_sy;for(r=0;r<voice_tb.length;r++){if(c.voices[r].range<0)continue;t=voice_tb[r].sym;if(!t||t.notes[0].pit!=127)continue;n=c.voices[r].st;switch(staff_tb[n].clef.clef_type){default:f=22;break;case"c":f=16;break;case"b":f=10}for(e=t;e;e=e.next)e.notes[0].pit=f}}function set_pitch(e){var t,n,r,i,s,o,u,a,f=C.BLEN,l=new Array(nstaff),c=cur_sy;for(i=0;i<=nstaff;i++)t=staff_tb[i].clef,l[i]=delta_tb[t.clef_type]+t.clef_line*2,t.clefpit&&(l[i]+=t.clefpit),cfmt.sound?t.clef_octave&&!t.clef_oct_transp&&(l[i]+=t.clef_octave):t.clef_oct_transp&&(l[i]-=t.clef_octave);for(t=tsfirst;t!=e;t=t.ts_next){i=t.st;switch(t.type){case C.CLEF:l[i]=delta_tb[t.clef_type]+t.clef_line*2,t.clefpit&&(l[i]+=t.clefpit),cfmt.sound?t.clef_octave&&!t.clef_oct_transp&&(l[i]+=t.clef_octave):t.clef_oct_transp&&(l[i]-=t.clef_octave),set_yval(t);break;case C.GRACE:for(r=t.extra;r;r=r.next){s=l[r.st];if(s!=0&&!t.p_v.key.k_drum)for(o=0;o<=r.nhd;o++)a=r.notes[o],a.pit+=s;r.ymn=3*(r.notes[0].pit-18)-2,r.ymx=3*(r.notes[r.nhd].pit-18)+2}set_yval(t);break;case C.KEY:t.k_y_clef=l[i];default:set_yval(t);break;case C.MREST:if(t.invis)break;t.y=12,t.ymx=39,t.ymn=-2;break;case C.REST:if(voice_tb.length==1){t.y=12,t.ymx=24,t.ymn=0;break};case C.NOTE:s=l[i];if(s!=0&&!t.p_v.key.k_drum)for(o=t.nhd;o>=0;o--)t.notes[o].opit=t.notes[o].pit,t.notes[o].pit+=s;t.type==C.NOTE?(t.ymx=3*(t.notes[t.nhd].pit-18)+4,t.ymn=3*(t.notes[0].pit-18)-4):(t.y=((t.notes[0].pit-18)/2|0)*6,t.ymx=t.y+rest_sp[5-t.nflags][0],t.ymn=t.y-rest_sp[5-t.nflags][1]),t.dur<f&&(f=t.dur)}}e||(smallest_duration=f)}function set_stem_dir(){var e,t,n,r,i,s,o,u,a,f,l=[],c=tsfirst,h=cur_sy,p=h.nstaff;while(c){for(r=0;r<=p;r++)l[r]=[];f=[];for(t=c;t;t=t.ts_next){if(t.type==C.BAR)break;if(t.type==C.STAVES){if(t!=c)break;h=c.sy;for(r=p;r<=h.nstaff;r++)l[r]=[];p=h.nstaff;continue}if(t.type!=C.NOTE&&t.type!=C.REST||t.invis)continue;r=t.st;if(r>p){var d="*** fatal set_stem_dir(): bad staff number "+r+" max "+p;throw error(2,null,d),new Error(d)}s=t.v,o=f[s],o||(o={st1:-1,st2:-1},f[s]=o),o.st1<0?o.st1=r:o.st1!=r&&(r>o.st1?r>o.st2&&(o.st2=r):(o.st1>o.st2&&(o.st2=o.st1),o.st1=r)),u=l[r],i=h.voices[s].range;for(n=u.length;--n>=0;){a=u[n];if(a.v==i)break}if(n<0){a={v:i,ymx:0,ymn:24};for(n=0;n<u.length;n++)if(i<u[n].v){u.splice(n,0,a);break}n==u.length&&u.push(a)}if(t.type!=C.NOTE)continue;t.ymx>a.ymx&&(a.ymx=t.ymx),t.ymn<a.ymn&&(a.ymn=t.ymn),t.xstem&&(t.ts_prev.st!=r-1||t.ts_prev.type!=C.NOTE?(error(1,c,"Bad !xstem!"),t.xstem=!1):(t.ts_prev.multi=1,t.multi=1,t.stemless=!0))}for(;c!=t;c=c.ts_next){if(c.multi)continue;switch(c.type){default:continue;case C.REST:if(c.combine!=undefined&&c.combine<0||!c.ts_next||c.ts_next.type!=C.REST||c.ts_next.st!=c.st||c.time!=c.ts_next.time||c.dur!=c.ts_next.dur||c.invis)break;unlksym(c.ts_next);break;case C.NOTE:case C.GRACE:}r=c.st,s=c.v,o=f[s],u=l[r];if(o&&o.st2>=0){r==o.st1?c.multi=-1:r==o.st2&&(c.multi=1);continue}if(u.length<=1){c.floating&&(c.multi=r==voice_tb[s].st?-1:1);continue}i=h.voices[s].range;for(n=u.length;--n>=0;)if(u[n].v==i)break;if(n<0)continue;n==u.length-1?c.multi=-1:(c.multi=1,n!=0&&n+2==u.length&&(u[n].ymn-cfmt.stemheight>u[n+1].ymx&&(c.multi=-1),e=c.ts_next,c.ts_prev&&c.ts_prev.time==c.time&&c.ts_prev.st==c.st&&c.notes[c.nhd].pit==c.ts_prev.notes[0].pit&&c.beam_st&&c.beam_end&&(!e||e.st!=c.st||e.time!=c.time)&&(c.multi=-1)))}while(c&&c.type==C.BAR)c=c.ts_next}}function set_rest_offset(){var e,t,n,r,i,s,o,u,a,f,l,c,h=[],p=cur_sy;for(e=tsfirst;e;e=e.ts_next){if(e.invis)continue;e.type==C.STAVES&&(p=e.sy);if(!e.dur)continue;s=h[e.v],s||(s={},h[e.v]=s),s.s=e,s.st=e.st,s.end_time=e.time+e.dur;if(e.type!=C.REST)continue;a=-127,u=127,i=l=!1;for(n=0;n<=h.length;n++){s=h[n];if(!s||!s.s||s.st!=e.st||n==e.v)continue;if(s.end_time<=e.time)continue;i=!0,t=s.s,p.voices[n].range<p.voices[e.v].range?t.time==e.time?t.ymn<u&&(u=t.ymn,t.dots&&(l=!0)):t.y<u&&(u=t.y):t.time==e.time?t.ymx>a&&(a=t.ymx,t.dots&&(l=!0)):t.y>a&&(a=t.y)}r=e.time+e.dur;for(t=e.ts_next;t;t=t.ts_next){if(t.time>=r)break;if(t.st!=e.st||!t.dur||t.invis)continue;i=!0,p.voices[t.v].range<p.voices[e.v].range?t.time==e.time?t.ymn<u&&(u=t.ymn,t.dots&&(l=!0)):t.y<u&&(u=t.y):t.time==e.time?t.ymx>a&&(a=t.ymx,t.dots&&(l=!0)):t.y>a&&(a=t.y)}if(!i){e.y=12,e.ymx=24,e.ymn=0;continue}u==127&&e.y<12&&(f=12-e.y,e.y+=f,e.ymx+=f,e.ymn+=f),a==-127&&e.y>12&&(f=e.y-12,e.y-=f,e.ymx-=f,e.ymn-=f),f=u-e.ymx;if(f<0){f=Math.ceil(-f/6)*6;if(e.ymn-f>=a){e.y-=f,e.ymx-=f,e.ymn-=f;continue}c=l?15:10,e.notes[0].shhd=c,e.xmx=c;continue}f=a-e.ymn;if(f>0){f=Math.ceil(f/6)*6;if(e.ymx+f<=u){e.y+=f,e.ymx+=f,e.ymn+=f;continue}c=l?15:10,e.notes[0].shhd=c,e.xmx=c;continue}}}function new_sym(e,t,n){var r={type:e,fname:n.fname,v:t.v,p_v:t,st:t.st,time:n.time,next:t.last_sym.next};return r.next&&(r.next.prev=r),t.last_sym.next=r,r.prev=t.last_sym,t.last_sym=r,lktsym(r,n),r.ts_prev.type!=e&&(r.seqst=!0),n.type==e&&r.v!=n.v&&(delete n.seqst,n.shrink=0),r}function init_music_line(){var e,t,n,r,i,s,o,u,a,f=voice_tb.length;for(s=0;s<f;s++){if(cur_sy.voices[s].range<0)continue;e=voice_tb[s],e.second=cur_sy.voices[s].second,e.last_sym=e.sym,o=cur_sy.voices[s].st;while(o<nstaff&&!cur_sy.st_print[o])o++;e.st=o}i=tsfirst;while(i.type==C.CLEF)s=i.v,cur_sy.voices[s].range>=0&&!cur_sy.voices[s].second&&(delete i.clef_small,e=i.p_v,e.last_sym=e.sym=i),i=i.ts_next;for(s=0;s<f;s++){e=voice_tb[s];if(e.sym&&e.sym.type==C.CLEF)continue;if(cur_sy.voices[s].range<0||cur_sy.voices[s].second&&!e.bar_start)continue;o=cur_sy.voices[s].st;if(!staff_tb[o]||!staff_tb[o].clef)continue;t=clone(staff_tb[o].clef),t.v=s,t.p_v=e,t.st=o,t.time=tsfirst.time,t.prev=null,t.next=e.sym,t.next&&(t.next.prev=t),e.sym=t,e.last_sym=t,t.ts_next=i,i?t.ts_prev=i.ts_prev:t.ts_prev=null,t.ts_prev?(t.ts_prev.ts_next=t,delete t.seqst):(tsfirst=t,t.seqst=!0),i&&(i.ts_prev=t,i.type==C.CLEF&&delete i.seqst),delete t.clef_small,t.second=cur_sy.voices[s].second,cur_sy.st_print[o]||(t.invis=!0)}for(s=0;s<f;s++){if(cur_sy.voices[s].range<0||cur_sy.voices[s].second||!cur_sy.st_print[cur_sy.voices[s].st])continue;e=voice_tb[s];if(i&&i.v==s&&i.type==C.KEY){e.last_sym=i,i.k_old_sf=i.k_sf,i=i.ts_next;continue}n=e.key;if(n.k_sf||n.k_a_acc)t=new_sym(C.KEY,e,i),t.k_sf=n.k_sf,t.k_old_sf=n.k_sf,t.k_none=n.k_none,t.k_a_acc=n.k_a_acc,t.istart=n.istart,t.iend=n.iend,n.k_bagpipe&&(t.k_bagpipe=n.k_bagpipe,t.k_bagpipe=="p"&&(t.k_old_sf=3))}if(insert_meter&1){for(s=0;s<f;s++){e=voice_tb[s],n=e.meter;if(cur_sy.voices[s].range<0||cur_sy.voices[s].second||!cur_sy.st_print[cur_sy.voices[s].st]||n.a_meter.length==0)continue;if(i&&i.v==s&&i.type==C.METER){e.last_sym=i,i=i.ts_next;continue}t=new_sym(C.METER,e,i),t.istart=n.istart,t.iend=n.iend,t.wmeasure=n.wmeasure,t.a_meter=n.a_meter}insert_meter&=-2}for(s=0;s<f;s++){e=voice_tb[s],n=e.bar_start,e.bar_start=null;if(i&&i.v==s&&i.type==C.BAR){e.last_sym=i,i=i.ts_next;continue}if(!n)continue;if(cur_sy.voices[s].range<0||!cur_sy.st_print[cur_sy.voices[s].st])continue;n.next=e.last_sym.next,n.next&&(n.next.prev=n),e.last_sym.next=n,n.prev=e.last_sym,e.last_sym=n,lktsym(n,i),n.time=tsfirst.time,n.ts_prev.type!=n.type&&(n.seqst=!0),i&&i.type==n.type&&n.v!=i.v&&delete i.seqst}self.set_pitch(i);for(t=i;t;t=t.ts_next)if(t.seqst){for(t=t.ts_next;t;t=t.ts_next)if(t.seqst)break;break}while(i){if(i.seqst){do i=i.ts_next;while(i&&!i.seqst);break}i=i.ts_next}t=tsfirst;for(;;){n=t,a=0;do{self.set_width(t),u=t.wl;for(r=t.prev;r;r=r.prev)if(w_tb[r.type]!=0){u+=r.wr;break}u>a&&(a=u),t=t.ts_next}while(t!=i&&!t.seqst);n.shrink=a,n.space=0;if(t==i)break}}function set_words(e){var t,n,r,i,s=!0,o=127;for(t=e.sym;t;t=t.next)if(t.type==C.NOTE){o=t.notes[0].pit;break}for(t=e.sym;t;t=t.next){switch(t.type){case C.MREST:s=!0;break;case C.BAR:t.bar_type=bar_cnv(t.bar_type),t.beam_on||(s=!0),!t.next&&t.prev&&t.prev.head==C.OVALBARS&&(t.prev.head=C.SQUARE);break;case C.NOTE:case C.REST:if(t.trem2)break;r=t.nflags,t.ntrem&&(r+=t.ntrem),t.type==C.REST&&t.beam_end&&(t.beam_end=!1,s=!0);if(s||r<=0)i&&(i.beam_end=!0,i=null),r<=0?(t.beam_st=!0,t.beam_end=!0):t.type==C.NOTE&&(t.beam_st=!0,s=!1);t.beam_end&&(s=!0),t.type==C.NOTE&&(i=t)}if(t.type==C.NOTE){t.nhd!=0&&sort_pitch(t),o=t.notes[0].pit;for(n=t.prev;n;n=n.prev){if(n.type!=C.REST)break;n.notes[0].pit=o}}else t.notes||(t.notes=[],t.notes[0]={},t.nhd=0),t.notes[0].pit=o}i&&(i.beam_end=!0)}function set_rb(e){var t,n,r,i=e.sym;while(i){if(i.type!=C.BAR||!i.rbstart||i.norepbra){i=i.next;continue}n=cfmt.rbmax;if(i.text&&i.text[0]=="1"){r=0,t=null;for(i=i.next;i;i=i.next){if(i.type!=C.BAR)continue;r++;if(i.rbstop){r<=cfmt.rbmax&&(n=r,t=null);break}r==cfmt.rbmin&&(t=i)}t&&(t.rbstop=1,n=cfmt.rbmin)}while(i){if(i.rbstart!=2){i=i.next;if(!i)break;if(i.rbstart!=2){i=i.next;if(!i)break;if(i.rbstart!=2)break}}r=0,t=null;for(i=i.next;i;i=i.next){if(i.type!=C.BAR)continue;r++;if(i.rbstop)break;i.next?r==n&&(i.rbstop=1):i.rbstop=2}}}}function set_global(){var e,t,n,r,i;i=cur_sy,t=i.nstaff;for(;;){i=i.next;if(!i)break;i.nstaff>t&&(t=i.nstaff)}nstaff=t,r=voice_tb.length;for(n=0;n<r;n++)e=voice_tb[n],set_words(e),set_rb(e);set_float(),set_clefs(),self.set_pitch(null)}function set_indent(e){var t,n,r,i,s,o,u,a,f=voice_tb.length,l=0;for(n=0;n<f;n++){i=voice_tb[n];if(cur_sy.voices[n].range<0)continue;t=cur_sy.voices[n].st,s=(e||i.new_name)&&i.nm?i.nm:i.snm;if(!s)continue;a||(a=get_font("voice"),set_font(a)),o=0;for(;;){u=s.indexOf("\\n",o),u<0?r=strwh(s.slice(o)):r=strwh(s.slice(o,u)),r=r[0],r>l&&(l=r);if(u<0)break;o=u+1}}a&&(l+=4*cwid(" ")*a.swfac),r=.5;for(t=0;t<=cur_sy.nstaff;t++){if(cur_sy.staves[t].flags&(OPEN_BRACE2|OPEN_BRACKET2)){r=12;break}cur_sy.staves[t].flags&(OPEN_BRACE|OPEN_BRACKET)&&(r=6)}return l+=r,e&&(l+=cfmt.indent),l}function set_beams(e){var t,n,r,i,s,o,u,a,f,l,c,h,p=-1;for(t=e;t;t=t.next){if(t.type!=C.NOTE){if(t.type!=C.GRACE)continue;r=t.extra;if(r.stem==2){s=t;continue}!t.stem&&(t.stem=t.multi)==0&&(t.stem=1);for(;r;r=r.next)r.stem=t.stem,r.multi=t.multi;continue}if(!t.stem&&(t.stem=t.multi)==0){l=t.mid/3+18;if(i)t.stem=p;else if(t.beam_st&&!t.beam_end){i=!0,c=t.notes[t.nhd].pit,h=t.notes[0].pit;for(r=t.next;r;r=r.next){if(r.type!=C.NOTE)continue;if(r.stem||r.multi){t.stem=r.stem||r.multi;break}r.notes[r.nhd].pit>c&&(c=r.notes[r.nhd].pit),r.notes[0].pit<h&&(h=r.notes[0].pit);if(r.beam_end)break}r.beam_end&&((c+h)/2<l?t.stem=1:(c+h)/2>l?t.stem=-1:cfmt.bstemdown&&(t.stem=-1)),t.stem||(t.stem=p)}else{a=(t.notes[t.nhd].pit+t.notes[0].pit)/2;if(a==l){a=0;for(f=0;f<=t.nhd;f++)a+=t.notes[f].pit;a/=t.nhd+1}a<l?t.stem=1:a>l?t.stem=-1:cfmt.bstemdown?t.stem=-1:t.stem=p}}else t.beam_st&&!t.beam_end&&(i=!0);t.beam_end&&(i=!1),p=t.stem;if(s){for(r=s.extra;r;r=r.next)r.stem=-p;s.stem=-p,s=null}}}function same_head(e,t){var n,r,i,s,o,u,a,f,l,c,h;if(e.shiftunison&&e.shiftunison>=3)return!1;if((i=e.dur)>=C.BLEN)return!1;if((s=t.dur)>=C.BLEN)return!1;if(e.stemless&&t.stemless)return!1;if(e.dots!=t.dots)if(e.shiftunison&&e.shiftunison&1||e.dots*t.dots!=0)return!1;if(e.stem*t.stem>0)return!1;n=r=0;if(e.notes[0].pit>t.notes[0].pit){if(e.stem<0)return!1;while(t.notes[r].pit!=e.notes[0].pit)if(++r>t.nhd)return!1}else if(e.notes[0].pit<t.notes[0].pit){if(t.stem<0)return!1;while(t.notes[0].pit!=e.notes[n].pit)if(++n>e.nhd)return!1}if(t.notes[r].acc!=e.notes[n].acc)return!1;u=n,f=r,c=e.notes[n].shhd,h=t.notes[r].shhd;do{n++,r++;if(n>e.nhd)break;if(r>t.nhd)break;if(t.notes[r].acc!=e.notes[n].acc)return!1;c<e.notes[n].shhd&&(c=e.notes[n].shhd),h<t.notes[r].shhd&&(h=t.notes[r].shhd)}while(t.notes[r].pit==e.notes[n].pit);if(n<=e.nhd){if(r<=t.nhd)return!1;if(t.stem>0)return!1}else if(r<=t.nhd&&e.stem>0)return!1;a=n,l=r,o=0;if(i!=s){i<s&&(i=s,s=e.dur);if(i<C.BLEN/2)t.dots?o=2:e.dots&&(o=1);else{if(!(s<C.BLEN/4))return!1;if(e.shiftunison&&e.shiftunison&2)return!1;o=t.dur>=C.BLEN/2?2:1}}o==0&&(o=e.p_v.scale<t.p_v.scale?2:1);if(o==1){for(r=f;r<l;r++)t.notes[r].invis=!0,delete t.notes[r].acc;for(r=0;r<=t.nhd;r++)t.notes[r].shhd+=c}else{for(n=u;n<a;n++)e.notes[n].invis=!0,delete e.notes[n].acc;for(n=0;n<=e.nhd;n++)e.notes[n].shhd+=h}return!0}function unison_acc(e,t,n,r){var i,s;if(!t.notes[r].acc){s=w_note[t.head]*2+t.xmx+e.notes[n].shac+2,e.notes[n].micro&&(s+=2),t.dots&&(s+=6);for(i=0;i<=e.nhd;i++)e.notes[i].shhd+=s,e.notes[i].shac-=s;e.xmx+=s}else{s=w_note[e.head]*2+e.xmx+t.notes[r].shac+2,t.notes[r].micro&&(s+=2),e.dots&&(s+=6);for(i=0;i<=t.nhd;i++)t.notes[i].shhd+=s,t.notes[i].shac-=s;t.xmx+=s}}function set_left(e){var t,n,r,i,s=w_note[e.head],o=s,u=[];for(n=0;n<MAXPIT;n++)u.push(-100);if(e.nflags>-2){e.stem>0?(o=-o,n=e.notes[0].pit*2,r=(Math.ceil((e.ymx-2)/3)+18)*2):(n=(Math.ceil((e.ymn+2)/3)+18)*2,r=e.notes[e.nhd].pit*2),n<0&&(n=0),r>=MAXPIT&&(r=MAXPIT-1);while(n<=r)u[n++]=o}i=e.notes[e.stem>0?0:e.nhd].shhd;for(t=0;t<=e.nhd;t++)o=-e.notes[t].shhd+s+i,n=e.notes[t].pit*2,n<0?n=0:n>=MAXPIT-1&&(n=MAXPIT-2),o>u[n]&&(u[n]=o),e.head!=C.SQUARE&&(o-=1),o>u[n-1]&&(u[n-1]=o),o>u[n+1]&&(u[n+1]=o);return u}function set_right(e){var t,n,r,i,s,o=w_note[e.head],u=o,a=e.nflags>0&&e.beam_st&&e.beam_end,f=[];for(n=0;n<MAXPIT;n++)f.push(-100);if(e.nflags>-2){e.stem<0?(u=-u,n=(Math.ceil((e.ymn+2)/3)+18)*2,r=e.notes[e.nhd].pit*2,i=n+4):(n=e.notes[0].pit*2,r=(Math.ceil((e.ymx-2)/3)+18)*2),n<0&&(n=0),r>MAXPIT&&(r=MAXPIT);while(n<r)f[n++]=u}if(a)if(e.stem>0){e.xmx==0?n=e.notes[e.nhd].pit*2:n=e.notes[0].pit*2,n+=4,n<0&&(n=0);for(;n<MAXPIT&&n<=r-4;n++)f[n]=11}else{n=i,n<0&&(n=0);for(;n<MAXPIT&&n<=e.notes[0].pit*2-4;n++)f[n]=3.5}s=e.notes[e.stem>0?0:e.nhd].shhd;for(t=0;t<=e.nhd;t++)u=e.notes[t].shhd+o-s,n=e.notes[t].pit*2,n<0?n=0:n>=MAXPIT-1&&(n=MAXPIT-2),u>f[n]&&(f[n]=u),e.head!=C.SQUARE&&(u-=1),u>f[n-1]&&(f[n-1]=u),u>f[n+1]&&(f[n+1]=u);return f}function set_overlap(){function x(){t=n,n=e,c=h,E=m,S=g,d=p}var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d,v,m,g,y,b,w,E,S;for(e=tsfirst;e;e=e.ts_next){if(e.type!=C.NOTE||e.invis)continue;if(e.xstem&&e.ts_prev.stem<0)for(u=0;u<=e.nhd;u++)e.notes[u].shhd-=7,e.notes[u].shac+=16;n=e;for(;;){n=n.ts_next;if(!n)break;if(n.time!=e.time){n=null;break}if(n.type==C.NOTE&&!n.invis&&n.st==e.st)break}if(!n)continue;t=e,cur_sy.voices[t.v].range<cur_sy.voices[n.v].range?n.dot_low=!0:t.dot_low=!0;if(t.ymn>n.ymx||t.ymx<n.ymn)continue;if(same_head(t,n))continue;g=set_right(t),y=set_left(n),r=t.ts_prev;if(r&&r.time==t.time&&r.st==t.st&&r.type==C.NOTE&&!r.invis){w=set_right(r);for(i=0;i<MAXPIT;i++)w[i]>g[i]&&(g[i]=w[i])}else r=null;c=-10;for(i=0;i<MAXPIT;i++)y[i]+g[i]>c&&(c=y[i]+g[i]);if(c<-3)if(!t.dots||!n.dots||!n.dot_low||t.stem>0||n.stem<0||t.notes[t.nhd].pit+2!=n.notes[0].pit||n.notes[0].pit&1)continue;b=set_right(n),m=set_left(t);if(r){w=set_left(r);for(i=0;i<MAXPIT;i++)w[i]>m[i]&&(m[i]=w[i])}h=p=d=-100;for(i=0;i<MAXPIT;i++)m[i]+b[i]>h&&(h=m[i]+b[i]),b[i]>d&&(d=b[i]),g[i]>p&&(p=g[i]);f=0,s=t.nhd,o=n.nhd;for(;;){l=t.notes[s].pit-n.notes[o].pit;switch(l){case 0:if(t.notes[s].acc!=n.notes[o].acc){f=-1;break}n.notes[o].acc&&(n.notes[o].acc=0),t.dots&&n.dots&&t.notes[s].pit&1&&(f=1);break;case-1:t.dots&&n.dots&&(t.notes[s].pit&1?(t.dot_low=!1,n.dot_low=!1):(t.dot_low=!0,n.dot_low=!0));break;case-2:if(t.dots&&n.dots&&!(t.notes[s].pit&1)){t.dot_low=!1,n.dot_low=!1;break}}if(f<0)break;if(l>=0&&--s<0)break;if(l<=0&&--o<0)break}if(f<0){unison_acc(t,n,s,o);continue}a=0,t.dots?n.dots&&(f||(a=1)):n.dots&&h+p<c+d&&(a=1),E=y,S=b,!r&&h+p<c+d&&x(),c+=3,c<0&&(c=0),u=t.stem>=0?0:t.nhd,c+=t.notes[u].shhd,u=n.stem>=0?0:n.nhd,c-=n.notes[u].shhd;if(t.dots){v=7.7+t.xmx+3.5*t.dots-3.5+3;if(!a){h=-100;for(s=0;s<=t.nhd;s++)i=t.notes[s].pit,i&1||(t.dot_low?i--:i++),i*=2,i<1?i=1:i>=MAXPIT-1&&(i=MAXPIT-2),E[i]>h&&(h=E[i]),E[i-1]+1>h&&(h=E[i-1]+1),E[i+1]+1>h&&(h=E[i+1]+1);v+h+2>c&&(c=v+h+2)}else if(v<c+d+n.xmx){h=0;for(s=0;s<=t.nhd;s++)i=t.notes[s].pit,i&1||(t.dot_low?i--:i++),i*=2,i<1?i=1:i>=MAXPIT-1&&(i=MAXPIT-2),S[i]>h&&(h=S[i]),S[i-1]+1>h&&(h=S[i-1]=1),S[i+1]+1>h&&(h=S[i+1]+1);h>4.5&&7.7+t.xmx+2<c+h+n.xmx&&(n.xmx=h+3-7.7)}}for(u=n.nhd;u>=0;u--)n.notes[u].shhd+=c;n.xmx+=c,a&&(t.xmx=n.xmx)}}function set_stems(){var e,t,n,r,i,s,o,u,a,f;for(e=tsfirst;e;e=e.ts_next){if(e.type!=C.NOTE){if(e.type!=C.GRACE)continue;a=f=e.mid;for(n=e.extra;n;n=n.next)r=GSTEM,n.nflags>1&&(r+=1.2*(n.nflags-1)),s=3*(n.notes[0].pit-18),o=3*(n.notes[n.nhd].pit-18),e.stem>=0?(n.y=s,n.ys=o+r,o=Math.round(n.ys)):(n.y=o,n.ys=s-r,s=Math.round(n.ys)),o+=2,s-=2,s<a?a=s:o>f&&(f=o),n.ymx=o,n.ymn=s;e.ymx=f,e.ymn=a;continue}set_head_shift(e),u=e.nflags;if(e.beam_st&&!e.beam_end){e.feathered_beam&&(u=++e.nflags);for(t=e.next;;t=t.next)if(t.type==C.NOTE){e.feathered_beam&&t.nflags++;if(t.beam_end)break}t.nflags>u&&(u=t.nflags)}else if(!e.beam_st&&e.beam_end){for(t=e.prev;;t=t.prev)if(t.beam_st)break;t.nflags>u&&(u=t.nflags)}r=cfmt.stemheight;switch(u){case 2:r+=2;break;case 3:r+=5;break;case 4:r+=10;break;case 5:r+=16}(i=e.p_v.scale)!=1&&(r*=(i+1)*.5),s=3*(e.notes[0].pit-18),e.nhd>0?(r-=2,o=3*(e.notes[e.nhd].pit-18)):o=s,e.ntrem&&(r+=2*e.ntrem),e.stemless?(e.stem>=0?(e.y=s,e.ys=o):(e.ys=s,e.y=o),u==-4&&(s-=6),e.ymx=o+4,e.ymn=s-4):e.stem>=0?(u>=2&&(r-=1),e.notes[e.nhd].pit>26&&(u<=0||!e.beam_st||!e.beam_end)&&(r-=2,e.notes[e.nhd].pit>28&&(r-=2)),e.y=s,e.notes[0].ti1&&(s-=3),e.ymn=s-4,e.ys=o+r,e.ys<e.mid&&(e.ys=e.mid),e.ymx=e.ys+2.5|0):(e.notes[0].pit<18&&(u<=0||!e.beam_st||!e.beam_end)&&(r-=2,e.notes[0].pit<16&&(r-=2)),e.ys=s-r,e.ys>e.mid&&(e.ys=e.mid),e.ymn=e.ys-2.5|0,e.y=o,e.notes[e.nhd].ti1&&(o+=3),e.ymx=o+4)}}function check_bar(e){var t,n,r,i,s=e.p_v;while(e.type==C.CLEF||e.type==C.KEY||e.type==C.METER){e.type==C.METER&&e.time>s.sym.time&&(insert_meter|=1),e=e.prev;if(!e)return}if(e.type!=C.BAR)return;e.text!=undefined&&(s.bar_start=clone(e),s.bar_start.bar_type="",delete e.text,delete e.a_gch),t=e.bar_type;if(t==":")return;if(t.slice(-1)!=":")return;s.bar_start||(s.bar_start=clone(e));if(t[0]!=":"){if(t=="||:")return s.bar_start.bar_type="[|:",e.bar_type="||",!0;s.bar_start.bar_type=t,e.prev&&e.prev.type==C.BAR?unlksym(e):e.bar_type="|";return}if(t=="||:")return s.bar_start.bar_type="[|:",e.bar_type="||",!0;n=0;while(t[n]==":")n++;if(n<t.length){e.bar_type=t.slice(0,n)+"|]",n=t.length-1;while(t[n]==":")n--;s.bar_start.bar_type="[|"+t.slice(n+1)}else n=t.length/2|0,e.bar_type=t.slice(0,n)+"|]",s.bar_start.bar_type="[|"+t.slice(n);return!0}function sym_staff_move(e){for(var t=tsfirst;t;t=t.ts_next){if(t.nl)break;t.st==e&&t.type!=C.CLEF&&(t.st++,t.invis=!0)}}function block_gen(e){switch(e.subtype){case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"scale":case"staffwidth":svg_flush(),self.set_format(e.subtype,e.param);break;case"ml":svg_flush(),user.img_out(e.text);break;case"newpage":blk_flush(),block.newpage=!0,blk_out();break;case"sep":set_page(),vskip(e.sk1),output+='<path class="stroke"\n d="M',out_sxsy(e.x," ",0),output+="h"+e.l.toFixed(2)+'"/>\n',vskip(e.sk2);break;case"text":write_text(e.text,e.opt);break;case"title":write_title(e.text,!0);break;case"vskip":vskip(e.sk);break;default:error(2,e,"Block $1 not treated",e.subtype)}}function set_piece(){function c(e){var t=staff_tb[e],n=l.staves[e];t||(t=staff_tb[e]={}),t.y=0,t.stafflines=n.stafflines,t.staffscale=n.staffscale,t.ann_top=t.ann_bot=0}function h(){var e,t,n,r=l.staves.length;for(e=0;e<r;e++){if(!(l.staves[e].flags&(OPEN_BRACE|OPEN_BRACE2)))continue;n=0,t=e;while(e<r){n|=a[e]?1:2;if(l.staves[e].flags&(CLOSE_BRACE|CLOSE_BRACE2))break;e++}if(n==3)while(t<=e)a[t]=!0,f[t++]=!0}}function p(){var e,t,n,r,i;for(e=0;e<=nstaff;e++){t=staff_tb[e];if(!f[e]){t.botbar=t.topbar=0;continue}r=t.stafflines.length,t.topbar=6*(r-1);for(n=0;n<r-1;n++)if(t.stafflines[n]!=".")break;t.botline=t.botbar=n*6,n>=r-2&&(t.stafflines[n]!="."?(t.botbar-=6,t.topbar+=6):(t.botbar-=12,t.topbar+=12))}}var e,t,n,r,i,s,o,u,a=[],f=[],l=cur_sy;nstaff=s=l.nstaff;for(r=0;r<=s;r++)c(r);for(e=tsfirst;e;e=e.ts_next){if(e.nl)break;e.ts_next||(t=e);switch(e.type){case C.STAVES:h(),l.st_print=new Uint8Array(a),l=e.sy,s=l.nstaff;if(nstaff<s){for(r=nstaff+1;r<=s;r++)c(r);nstaff=s}a=[];continue;case C.BLOCK:blocks.push(e),unlksym(e),t&&(t=e.ts_prev);continue}r=e.st;if(a[r])continue;switch(e.type){case C.CLEF:r>nstaff&&(staff_tb[r].clef=e,unlksym(e));break;case C.BAR:if(!l.staves[r].staffnonote||l.staves[r].staffnonote<=1)break;case C.GRACE:f[r]=a[r]=!0;break;case C.NOTE:case C.REST:case C.SPACE:case C.MREST:l.staves[r].staffnonote>1?f[r]=a[r]=!0:!e.invis&&(l.staves[r].staffnonote!=0||e.type==C.NOTE)&&(f[r]=a[r]=!0)}}tsnext=e,h(),l.st_print=new Uint8Array(a),p();for(r=0;r<nstaff;r++)f[r]||sym_staff_move(r);f[nstaff]||(staff_tb[nstaff].topbar=0),init_music_line(),gene.st_print=new Uint8Array(f);if(tsnext){e=tsnext,delete e.nl,t=e.ts_prev,t.ts_next=null,o=voice_tb.length;for(i=0;i<o;i++){n=voice_tb[i];if(n.sym&&n.sym.time<=tsnext.time){for(e=tsnext.ts_prev;e;e=e.ts_prev)if(e.v==i){n.s_next=e.next,e.next=null,check_bar(e)&&(u=e.wl,self.set_width(e),e.shrink+=e.wl-u);break}if(e)continue}n.s_next=n.sym,n.sym=null}}t.type!=C.BAR&&(e=add_end_bar(t),e.space=set_space(e),e.space<e.shrink&&t.type!=C.KEY&&(e.space=e.shrink))}function set_sym_glue(e){var t,n,r,i,s,o=0,u=0,a=0,f=0,l=0;for(t=tsfirst;t;t=t.ts_next)t.type==C.GRACE&&!i&&(i=t),t.seqst&&(o+=t.shrink,t.space?t.space<t.shrink?(l+=t.shrink,u+=t.shrink):u+=t.space:f+=t.shrink);if(u==0){realwidth=0;return}r=!tsnext||tsnext.type==C.BLOCK||blocks.length;if(o>=e||u==l){o>e&&error(1,t,"Line too much shrunk $1 $2 $3",o.toFixed(2),u.toFixed(2),e.toFixed(2)),a=0;for(t=tsfirst;t;t=t.ts_next)t.seqst&&(a+=t.shrink),t.x=a;spf_last=0}else if(r&&u+f>e*(1-cfmt.stretchlast)||!r&&(u+f>e||cfmt.stretchstaff)){for(var c=4;--c>=0;){s=(e-f-l)/(u-l),u=0,l=0,a=0;for(t=tsfirst;t;t=t.ts_next)t.seqst&&(t.space?t.space*s<=t.shrink?(l+=t.shrink,u+=t.shrink,a+=t.shrink):(u+=t.space,a+=t.space*s):a+=t.shrink),t.x=a;if(Math.abs(a-e)<.1)break}spf_last=s}else{s=(e-f-l)/u,spf_last<s&&(s=spf_last);for(t=tsfirst;t;t=t.ts_next)t.seqst&&(a+=t.space*s<=t.shrink?t.shrink:t.space*s),t.x=a}realwidth=a;for(t=i;t;t=t.ts_next){if(t.type!=C.GRACE)continue;t.gr_shift?a=t.prev.x+t.prev.wr:a=t.x-t.wl;for(n=t.extra;n;n=n.next)n.x+=a}}function set_sym_line(){var e,t,n,r=voice_tb.length;for(n=0;n<r;n++)e=voice_tb[n],t=e.s_next,e.sym=t,t&&(t.prev=null)}function set_posx(){posx=img.lm/cfmt.scale}function gen_init(){var e=tsfirst,t=e.time;for(;e;e=e.ts_next){if(e.time!=t){set_page();return}switch(e.type){case C.NOTE:case C.REST:case C.MREST:set_page();return;default:continue;case C.STAVES:cur_sy=e.sy;break;case C.BLOCK:block_gen(e)}unlksym(e),e.p_v.s_next==e&&(e.p_v.s_next=e.next)}tsfirst=null}function output_music(){var e,t,n,r;gen_init();if(!tsfirst)return;set_global(),voice_tb.length>1&&self.set_stem_dir();for(e=0;e<voice_tb.length;e++)set_beams(voice_tb[e].sym);self.set_stems(),voice_tb.length>1&&(set_rest_offset(),set_overlap()),set_acc_shft(),set_allsymwidth(),n=set_indent(!0),cfmt.singleline?(e=get_ck_width(),t=n+e[0]+e[1]+get_width(tsfirst,null),img.width=t*cfmt.scale+img.lm+img.rm+2):(t=get_lwidth(),cut_tune(t,n)),spf_last=1.2;for(;;){set_piece(),self.set_sym_glue(t-n);if(realwidth!=0){n!=0&&(posx+=n),draw_sym_near(),r=set_staff(),delayed_update(),draw_systems(n),draw_all_sym(),vskip(r),n!=0&&(posx-=n,insert_meter&=-3);while(blocks.length!=0)block_gen(blocks.shift())}tsfirst=tsnext,svg_flush();if(!tsnext)break;gen_init();if(!tsfirst)break;tsfirst.ts_prev=null,set_sym_line(),t=get_lwidth(),n=set_indent()}}function reset_gen(){insert_meter=cfmt.writefields.indexOf("M")>=0?3:2}function set_ref(e){e.fname=parse.fname,e.istart=parse.istart,e.iend=parse.iend}function new_clef(e){var t={type:C.CLEF,clef_line:2,clef_type:"t",v:curvoice.v,p_v:curvoice,time:curvoice.time,dur:0},n=1;set_ref(t);switch(e[0]){case'"':n=e.indexOf('"',1),t.clef_name=e.slice(1,n),n++;break;case"a":if(e[1]=="u"){t.clef_type="a",t.clef_auto=!0,n=4;break}n=4;case"C":t.clef_type="c",t.clef_line=3;break;case"b":n=4;case"F":t.clef_type="b",t.clef_line=4;break;case"n":n=4,t.invis=!0;break;case"t":if(e[1]=="e"){t.clef_type="c",t.clef_line=4;break}n=6;case"G":break;case"p":n=4;case"P":t.clef_type="p",t.clef_line=3,curvoice.key.k_sf=0,curvoice.ckey.k_drum=!0;break;default:syntax(1,"Unknown clef '$1'",e);return}e[n]>="1"&&e[n]<="9"&&(t.clef_line=Number(e[n]),n++);if(e[n+1]!="8")return t;switch(e[n]){case"^":t.clef_oct_transp=!0;case"+":t.clef_octave=7;break;case"_":t.clef_oct_transp=!0;case"-":t.clef_octave=-7}return t}function get_transp(e,t){var n,r,i,s,o=[];if(e[0]=="0")return 0;if("123456789-+".indexOf(e[0])>=0){r=parseInt(e)*3;if(isNaN(r)||r<-108||r>108){syntax(1,"Bad transpose value");return}switch(e.slice(-1)){default:return r;case"#":r++;break;case"b":r+=2}return r>0?r:r-3}if(t=="instr"){i=e.indexOf("/");if(!cfmt.sound){if(i<0)return 0;e=e.replace("/","")}else i<0?e="c"+e:e=e.replace(/.*\//,"c")}i=new scanBuf,i.buffer=e;for(n=0;n<2;n++){s=i.buffer[i.index]?parse_acc_pit(i):null;if(!s){syntax(1,"Bad transpose value");return}s.pit+=124,r=(s.pit/7|0)*12+note_pit[s.pit%7],s.acc&&s.acc!=3&&(r+=s.acc),o[n]=r}r=(o[1]-o[0])*3;if(s)switch(s.acc){default:return r;case 2:case 1:r++;break;case-1:case-2:r+=2}return r>0?r:r-3}function set_linebreak(e){var t,n;for(t=0;t<128;t++)char_tb[t]=="\n"&&(char_tb[t]=nil);e=e.split(/\s+/);for(t=0;t<e.length;t++){n=e[t];switch(n){case"!":case"$":case"*":case";":case"?":case"@":break;case"<none>":continue;case"<EOL>":n="\n";break;default:syntax(1,"Bad value '$1' in %%linebreak - ignored",n);continue}char_tb[n.charCodeAt(0)]="\n"}}function set_user(e){var t,n,r,i=e.match(/(.*?)[= ]*([!"].*[!"])/);if(!i){syntax(1,'Lack of starting ! or " in U: / %%user');return}n=i[1],r=i[2];if(r.slice(-1)!=r[0]){syntax(1,"Lack of ending $1 in U:/%%user",r[0]);return}n[0]=="\\"&&(n[1]=="t"?n=" ":n[1]||(n=" ")),t=n.charCodeAt(0);if(t>=128){syntax(1,errs.not_ascii);return}switch(char_tb[t][0]){case"0":case"d":case"i":case" ":break;case'"':case"!":if(char_tb[t].length>1)break;default:syntax(1,"Bad user character '$1'",n);return}switch(r){case"!beambreak!":r=" ";break;case"!ignore!":r="i";break;case"!nil!":case"!none!":r="d"}char_tb[t]=r}function get_st_lines(e){var t,n;if(!e)return;if(/^[\]\[|.-]+$/.test(e))return e.replace(/\]/g,"[");t=parseInt(e);switch(t){case 0:return"...";case 1:return"..|";case 2:return".||";case 3:return".|||"}if(isNaN(t)||t<0||t>16)return;n="|";while(--t>0)n+="|";return n}function new_block(e){var t={type:C.BLOCK,subtype:e,dur:0};parse.state==2&&goto_tune();var n=curvoice;return curvoice=voice_tb[par_sy.top_voice],sym_link(t),curvoice=n,t}function set_vp(e){var t,n,r,i,s;for(;;){n=e.shift();if(!n)break;if(n[n.length-1]=="="&&e.length==0){syntax(1,errs.bad_val,n);break}switch(n){case"clef=":t=e.shift();break;case"clefpitch=":n=e.shift();if(n){i=ntb.indexOf(n[0]);if(i>=0){switch(n[1]){case"'":i+=7;break;case",":i-=7,n[2]==","&&(i-=7)}s=4-i;break}}syntax(1,errs.bad_val,n);break;case"octave=":case"uscale=":i=parseInt(e.shift()),isNaN(i)?syntax(1,errs.bad_val,n):curvoice[n.slice(0,-1)]=i;break;case"cue=":curvoice.scale=e.shift()=="on"?.7:1;break;case"instrument=":curvoice.transp=get_transp(e.shift(),"instr");break;case"map=":curvoice.map=e.shift();break;case"name=":case"nm=":curvoice.nm=e.shift(),curvoice.nm[0]=='"'&&(curvoice.nm=curvoice.nm.slice(1,-1)),curvoice.new_name=!0;break;case"stem=":case"pos=":n=="pos="?n=e.shift().split(" "):n=["stm",e.shift()],i=posval[n[1]];if(i==undefined){syntax(1,errs.bad_val,n[0]);break}r||(r={}),r[n[0]]=i;break;case"scale=":i=parseFloat(e.shift()),isNaN(i)||i<.6||i>1.5?syntax(1,errs.bad_val,"%%voicescale"):curvoice.scale=i;break;case"score=":if(cfmt.sound)break;n=e.shift(),n.indexOf("/")<0&&(n+="/c"),curvoice.transp=get_transp(n);break;case"shift=":curvoice.shift=get_transp(e.shift());break;case"sound=":case"transpose=":if(!cfmt.sound)break;curvoice.transp=get_transp(e.shift());break;case"subname=":case"sname=":case"snm=":curvoice.snm=e.shift(),curvoice.snm[0]=='"'&&(curvoice.snm=curvoice.snm.slice(1,-1));break;case"stafflines=":i=get_st_lines(e.shift()),i==undefined?syntax(1,"Bad %%stafflines value"):curvoice.st!=undefined?par_sy.staves[curvoice.st].stafflines=i:curvoice.stafflines=i;break;case"staffnonote=":i=parseInt(e.shift()),isNaN(i)?syntax(1,"Bad %%staffnonote value"):curvoice.staffnonote=i;break;case"staffscale=":i=parseFloat(e.shift()),isNaN(i)||i<.3||i>2?syntax(1,"Bad %%staffscale value"):curvoice.staffscale=i;break;default:switch(n.slice(0,4)){case"treb":case"bass":case"alto":case"teno":case"perc":t=n;break;default:"GFC".indexOf(n[0])>=0?t=n:n.slice(-1)=="="&&e.shift()}}}if(r){curvoice.pos=clone(curvoice.pos);for(n in r)r.hasOwnProperty(n)&&(curvoice.pos[n]=r[n])}t&&(t=new_clef(t),t&&(s&&(t.clefpit=s),get_clef(t)))}function set_kv_parm(e){curvoice.init||(curvoice.init=!0,info.V&&(info.V["*"]&&(e=info.V["*"].concat(e)),info.V[curvoice.id]&&(e=info.V[curvoice.id].concat(e)))),e.length!=0&&self.set_vp(e)}function memo_kv_parm(e,t){if(t.length==0)return;info.V||(info.V={}),info.V[e]?Array.prototype.push.apply(info.V[e],t):info.V[e]=t}function new_key(e){var t,n,r,i,s,o=0,u={type:C.KEY,k_delta:0,dur:0};set_ref(u),t=1;switch(e[0]){case"A":u.k_sf=3;break;case"B":u.k_sf=5;break;case"C":u.k_sf=0;break;case"D":u.k_sf=2;break;case"E":u.k_sf=4;break;case"F":u.k_sf=-1;break;case"G":u.k_sf=1;break;case"H":switch(e[1]){case"P":case"p":u.k_bagpipe=e[1],u.k_sf=e[1]=="P"?0:2,t++;break;default:syntax(1,"Unknown bagpipe-like key")}break;case"P":syntax(1,"K:P is deprecated"),u.k_drum=!0,r=!0;break;case"n":e.indexOf("none")==0&&(u.k_sf=0,u.k_none=!0,t=4);default:r=!0}if(!r){switch(e[t]){case"#":u.k_sf+=7,t++;break;case"b":u.k_sf-=7,t++}e=e.slice(t).trim();switch(e.slice(0,3).toLowerCase()){default:if(e[0]!="m"||e[1]!=" "&&e[1]!=" "&&e[1]!="\n"){r=!0;break};case"aeo":case"m":case"min":u.k_sf-=3,o=5;break;case"dor":u.k_sf-=2,o=1;break;case"ion":case"maj":break;case"loc":u.k_sf-=5,o=6;break;case"lyd":u.k_sf+=1,o=3;break;case"mix":u.k_sf-=1,o=4;break;case"phr":u.k_sf-=4,o=2}r||(e=e.replace(/\w+\s*/,"")),e.indexOf("exp ")==0&&(e=e.replace(/\w+\s*/,""),e||syntax(1,"No accidental after 'exp'"),u.k_exp=!0),i=e[0];if(i=="^"||i=="_"||i=="="){u.k_a_acc=[],s=new scanBuf,s.buffer=e;do{var a=parse_acc_pit(s);if(!a)return[u,null];u.k_a_acc.push(a),i=e[s.index];while(i==" ")i=e[++s.index]}while(i=="^"||i=="_"||i=="=");e=e.slice(s.index)}else u.k_exp&&e.indexOf("none")==0&&(u.k_sf=0,e=e.replace(/\w+\s*/,""))}return u.k_delta=cgd2cde[(u.k_sf+7)%7],u.k_mode=o,[u,info_split(e,0)]}function new_meter(e){var t={type:C.METER,dur:0,a_meter:[]},n={},r,i,s=0,o,u=0,a,f,l=e,c;set_ref(t);if(l.indexOf("none")==0)u=4,f=1;else{f=0;while(u<e.length){if(l[u]=="=")break;switch(l[u]){case"C":n.top=l[u++],s||(s=4,o=4);break;case"c":case"o":n.top=l[u++];if(!s){l[-1]=="c"?(s=2,o=4):(s=3,o=4);switch(l[u]){case"|":o/=2;break;case".":s*=3,o*=2}}break;case".":case"|":n.top=l[u++];break;case"(":l[u+1]=="("&&(c=!0,n.top=l[u++],t.a_meter.push(n),n={}),a=u+1;while(a<e.length){if(l[a]==")"||l[a]=="/")break;a++}if(l[a]==")"&&l[a+1]=="/"){u++;continue};case")":c=l[u]=="(",n.top=l[u++],t.a_meter.push(n),n={};continue;default:if(l[u]<="0"||l[u]>"9"){syntax(1,"Bad char '$1' in M:",l[u]);return}o=2,n.top=l[u++];for(;;){while(l[u]>="0"&&l[u]<="9")n.top+=l[u++];if(l[u]==")"){if(l[u+1]!="/")break;u++}if(l[u]=="/"){u++;if(l[u]<="0"||l[u]>"9"){syntax(1,"Bad char '$1' in M:",l[u]);return}n.bot=l[u++];while(l[u]>="0"&&l[u]<="9")n.bot+=l[u++];break}if(l[u]!=" "&&l[u]!="+")break;if(u>=e.length||l[u+1]=="(")break;n.top+=l[u++]}s=parseInt(n.top)}c||(n.bot&&(o=parseInt(n.bot)),f+=s*C.BLEN/o),t.a_meter.push(n),n={};while(l[u]==" ")u++;l[u]=="+"&&(n.top=l[u++],t.a_meter.push(n),n={})}}if(l[u]=="="){r=l.substring(++u).match(/^(\d+)\/(\d+)$/);if(!r){syntax(1,"Bad duration '$1' in M:",l.substring(u));return}f=C.BLEN*r[1]/r[2]}t.wmeasure=f;if(parse.state!=3){info.M=e,glovar.meter=t;if(parse.state>=1){glovar.ulen||(f<=1||f>=C.BLEN*3/4?glovar.ulen=C.BLEN/8:glovar.ulen=C.BLEN/16);for(i=0;i<voice_tb.length;i++)voice_tb[i].meter=t,voice_tb[i].wmeasure=f}}else curvoice.wmeasure=f,is_voice_sig()?(curvoice.meter=t,reset_gen()):sym_link(t)}function new_tempo(e){var t=0,n,r,i,s,o={type:C.TEMPO,dur:0};set_ref(o),cfmt.writefields.indexOf("Q")<0&&(o.del=!0);if(e[0]=='"'){t=e.indexOf('"',1);if(t<0){syntax(1,"Unterminated string in Q:");return}o.tempo_str1=e.slice(1,t),t++;while(e[t]==" ")t++}s=new scanBuf,s.buffer=e,s.index=t;for(;;){r=e[s.index];if(r==undefined||r<="0"||r>"9")break;i=parse_dur(s),o.tempo_notes||(o.tempo_notes=[]),o.tempo_notes.push(C.BLEN*i[0]/i[1]);for(;;){r=e[s.index];if(r!=" ")break;s.index++}}if(r=="="){r=e[++s.index];while(r==" ")r=e[++s.index];t=s.index,r=="c"&&e[t+1]=="a"&&e[t+2]=="."&&e[t+3]==" "&&(o.tempo_ca="ca. ",s.index+=4),e[s.index+1]!="/"?o.tempo=s.get_int():(i=parse_dur(s),o.new_beat=C.BLEN*i[0]/i[1]),r=e[s.index];while(r==" ")r=e[++s.index]}if(r=='"'){s.index++,t=e.indexOf('"',s.index+1);if(t<0){syntax(1,"Unterminated string in Q:");return}o.tempo_str2=e.slice(s.index,t)}if(parse.state!=3){if(parse.state==1){info.Q=e,glovar.tempo=o;return}goto_tune()}curvoice.v==par_sy.top_voice&&(sym_link(o),glovar.tempo&&curvoice.time==0&&(glovar.tempo.del=!0))}function do_info(e,t){var n,r,i,s,o;switch(e){case"I":self.do_pscom(t);break;case"L":parse.state==2&&goto_tune(),s=t.match(/^1\/(\d+)(=(\d+)\/(\d+))?$/);if(s){r=Number(s[1]);if(!r||(r&r-1)!=0)break;r=C.BLEN/r;if(s[2]){i=Number(s[4]);if(!i||(i&i-1)!=0){i=0;break}i=Number(s[3])/i*C.BLEN}else i=r}else t=="auto"&&(r=i=-1);if(!i){syntax(1,"Bad L: value");break}parse.state<2?glovar.ulen=r:(curvoice.ulen=r,curvoice.dur_fact=i/r);break;case"M":new_meter(t);break;case"U":set_user(t);break;case"P":if(parse.state==0)break;if(parse.state==1){info.P=t;break}parse.state==2&&goto_tune();if(cfmt.writefields.indexOf(e)<0)break;n={type:C.PART,text:t,dur:0};var u=voice_tb[par_sy.top_voice];if(curvoice.v!=u.v){if(curvoice.time!=u.time)break;if(u.last_sym&&u.last_sym.type==C.PART)break;var a=curvoice;curvoice=u,sym_link(n),curvoice=a}else sym_link(n);break;case"Q":if(parse.state==0)break;new_tempo(t);break;case"V":get_voice(t);break;case"K":if(parse.state==0)break;get_key(t);break;case"N":case"R":info[e]?info[e]+="\n"+t:info[e]=t;break;case"r":if(!user.keep_remark||parse.state!=3)break;n={type:C.REMARK,text:t,dur:0},sym_link(n);break;default:syntax(0,"'$1:' line ignored",e)}}function adjust_dur(e){var t,n,r,i,s;t=curvoice.last_sym;if(!t)return;if(t.type==C.MREST||t.type==C.BAR)return;while(t.type!=C.BAR&&t.prev)t=t.prev;n=t.time,r=curvoice.time-n;if(n==0){while(t&&!t.dur)t=t.next;t&&t.type==C.REST&&t.invis&&(n+=t.dur*curvoice.wmeasure/r,t.prev?t.prev.next=t.next:curvoice.sym=t.next,t.next&&(t.next.prev=t.prev),t=t.next)}if(curvoice.wmeasure==r)return;for(;t;t=t.next){t.time=n;if(!t.dur||t.grace)continue;t.dur=t.dur*curvoice.wmeasure/r,t.dur_orig=t.dur_orig*curvoice.wmeasure/r,n+=t.dur;if(t.type!=C.NOTE&&t.type!=C.REST)continue;for(i=0;i<=t.nhd;i++)t.notes[i].dur=t.notes[i].dur*curvoice.wmeasure/r;s=identify_note(t,t.dur_orig),t.head=s[0],t.dots=s[1],t.nflags=s[2],t.nflags<=-2?t.stemless=!0:delete t.stemless}curvoice.time=e.time=n}function new_bar(){var e,t,n,r=parse.line,i={type:C.BAR,fname:parse.fname,istart:parse.bol+r.index,dur:0,multi:0};vover&&vover.bar&&get_vover("|"),glovar.new_nbar&&(i.bar_num=glovar.new_nbar,glovar.new_nbar=0),n=r.char();for(;;){t=r.next_char();switch(t){case"|":case"[":case"]":case":":n+=t;continue}break}n[0]==":"&&(n.length==1?(n="|",i.bar_dotted=!0):i.rbstop=2),a_gch&&self.gch_build(i),a_dcn&&(deco_cnv(a_dcn,i),a_dcn=null);switch(n.slice(-1)){case"[":if(/[0-9" ]/.test(t))break;n=n.slice(0,-1),r.index--,t="[";break;case":":i.rbstop=2}if(t>"0"&&t<="9"){n.slice(-1)=="["&&(n=n.slice(0,-1)),i.text=t;for(;;){t=r.next_char();if("0123456789,.-".indexOf(t)<0)break;i.text+=t}i.rbstop=2,i.rbstart=2}else if(t=='"'&&n.slice(-1)=="["){n=n.slice(0,-1),i.text="";for(;;){t=r.next_char();if(!t){syntax(1,"No end of repeat string");return}if(t=='"'){r.index++;break}t=="\\"&&(i.text+=t,t=r.next_char()),i.text+=t}i.text=cnv_escape(i.text),i.rbstop=2,i.rbstart=2}n[0]=="]"&&(i.rbstop=2,n.length!=1?n=n.slice(1):i.invis=!0),i.iend=parse.bol+r.index,i.rbstart&&curvoice.norepbra&&!curvoice.second&&(i.norepbra=!0),curvoice.ulen<0&&adjust_dur(i),e=curvoice.last_sym;if(e&&e.type==C.SPACE)e.time--;else if(e&&e.type==C.BAR){if(n=="["&&!e.text&&(curvoice.st==0||par_sy.staves[curvoice.st-1].flags&STOP_BAR||i.norepbra)){i.text&&(e.text=i.text),i.a_gch&&(e.a_gch=i.a_gch),i.norepbra&&(e.norepbra=i.norepbra),i.rbstart&&(e.rbstart=i.rbstart),i.rbstop&&(e.rbstop=i.rbstop);return}if(n=="|:"){if(e.bar_type==":|"){e.bar_type="::",e.rbstop=2;return}if(e.bar_type=="||"){e.bar_type="||:",e.rbstop=2;return}}}switch(n){case"[":i.rbstop=2;case"[]":case"[|]":i.invis=!0,n="[]";break;case":|:":case":||:":n="::";break;case"||":if(!cfmt.rbdbstop)break;case"[|":case"|]":i.rbstop=2}i.bar_type=n,curvoice.lyric_restart||(curvoice.lyric_restart=i),curvoice.sym_restart||(curvoice.sym_restart=i),e&&e.type==C.KEY&&(!e.prev||e.prev.type!=C.BAR)?(curvoice.last_sym=e.prev,e.prev||(curvoice.sym=e.prev),sym_link(i),i.next=e,e.prev=i,curvoice.last_sym=e):sym_link(i),i.st=curvoice.st,i.rbstart&&!curvoice.norepbra&&curvoice.st>0&&!(par_sy.staves[curvoice.st-1].flags&STOP_BAR)&&(e={type:C.BAR,fname:i.fname,istart:i.istart,iend:i.iend,bar_type:"[",multi:0,invis:!0,text:i.text,rbstart:2},sym_link(e),e.st=curvoice.st,delete i.text,i.rbstart=0)}function parse_staves(e){var t,n,r=[],i=!1,s=0,o=0,u=0,a=0,f=0,l=0;while(l<e.length){switch(e[l]){case" ":case" ":break;case"[":if(a||o+u>=2){syntax(1,errs.misplaced,"["),i=!0;break}s|=o+u==0?OPEN_BRACKET:OPEN_BRACKET2,u++,f<<=8,f|=OPEN_BRACKET;break;case"{":if(a||o||u>=2){syntax(1,errs.misplaced,"{"),i=!0;break}s|=u?OPEN_BRACE2:OPEN_BRACE,o++,f<<=8,f|=OPEN_BRACE;break;case"(":if(a){syntax(1,errs.misplaced,"("),i=!0;break}s|=OPEN_PARENTH,a++,f<<=8,f|=OPEN_PARENTH;break;case"*":o&&!a&&!(s&(OPEN_BRACE|OPEN_BRACE2))&&(s|=FL_VOICE);break;case"+":s|=MASTER_VOICE;break;default:if(!/\w/.test(e[l])){syntax(1,"Bad voice ID in %%staves"),i=!0;break}n="";while(l<e.length){if(" ()[]{}|*".indexOf(e[l])>=0)break;n+=e[l++]}for(;l<e.length;l++){switch(e[l]){case" ":case" ":continue;case"]":if(!(f&OPEN_BRACKET)){syntax(1,errs.misplaced,"]"),i=!0;break}u--,s|=o+u==0?CLOSE_BRACKET:CLOSE_BRACKET2,f>>=8;continue;case"}":if(!(f&OPEN_BRACE)){syntax(1,errs.misplaced,"}"),i=!0;break}o--,s|=u?CLOSE_BRACE2:CLOSE_BRACE,s&=~FL_VOICE,f>>=8;continue;case")":if(!(f&OPEN_PARENTH)){syntax(1,errs.misplaced,")"),i=!0;break}a--,s|=CLOSE_PARENTH,f>>=8;continue;case"|":s|=STOP_BAR;continue}break}r.push([n,s]),s=0;continue}l++}f!=0&&(syntax(1,"'}', ')' or ']' missing in %%staves"),i=!0);if(i||r.length==0)return;return r}function info_split(e){if(!e)return[];var t=e.match(/(".+?"|.+?)(\s+|=|$)/g);if(!t)return syntax(1,"Unterminated string"),[];for(var n=0;n<t.length;n++)t[n]=t[n].trim();return t}function identify_note(e,t){var n,r,i,r=0,s=t;s%12!=0&&syntax(1,"Invalid note duration $1",s),s/=12,s==0&&syntax(1,"Note too short");for(i=5;s!=0;s>>=1,i--)if(s&1)break;s>>=1;switch(s){case 0:break;case 1:r=1;break;case 3:r=2;break;case 7:r=3;break;default:syntax(1,"Invalid note duration $1",t),i+=(11-s)/4|0,r=4}i-=r;if(i>=0)n=C.FULL;else switch(i){default:syntax(1,"Note too long"),i=-4;case-4:n=C.SQUARE;break;case-3:n=cfmt.squarebreve?C.SQUARE:C.OVALBARS;break;case-2:n=C.OVAL;break;case-1:n=C.EMPTY}return[n,r,i]}function parse_dur(e){var t,n,r;return reg_dur.lastIndex=e.index,t=reg_dur.exec(e.buffer),t[0]?(n=t[1]||1,r=t[3]||1,t[3]||(r*=1<<t[2].length),e.index=reg_dur.lastIndex,[n,r]):[1,1]}function parse_acc_pit(e){var t,n,r,i,s,o,u=e.char();switch(u){case"^":u=e.next_char(),u=="^"?(n=2,u=e.next_char()):n=1;break;case"=":n=3,u=e.next_char();break;case"_":u=e.next_char(),u=="_"?(n=-2,u=e.next_char()):n=-1}if(n&&n!=3&&u>="1"&&u<="9"||u=="/")o=parse_dur(e),r=o[0],i=o[1],i==1?i=curvoice?curvoice.uscale:1:i*=2,u=e.char();s=ntb.indexOf(u)+16,u=e.next_char();if(s<16){syntax(1,"'$1' is not a note",e.buffer[e.index-1]);return}while(u=="'")s+=7,u=e.next_char();while(u==",")s-=7,u=e.next_char();return t={pit:s,shhd:0,shac:0,ti1:0},n&&(t.acc=n,r&&(t.micro_n=r,t.micro_d=i)),t}function note2abc(e){var t,n="abcdefg"[(e.pit+77)%7];e.acc&&(n=["__","_","","^","^^","="][e.acc+2]+n);for(t=e.pit;t>=30;t-=7)n+="'";for(t=e.pit;t<23;t+=7)n+=",";return n}function set_map(e){var t=maps[curvoice.map],n=note2abc(e);if(!t[n]){n="octave,"+n.replace(/[',]/g,"");if(!t[n]){n="key,"+"abcdefg"[(e.pit+77-curvoice.ckey.k_delta)%7];if(!t[n]){n="all";if(!t[n])return}}}e.map=t[n],e.map[1]&&(e.pit=e.map[1].pit,e.acc=e.map[1].acc)}function parse_basic_note(e,t){var n,r=parse_acc_pit(e);if(!r)return;return e.char()=="0"&&(parse.stemless=!0,e.index++),n=parse_dur(e),r.dur=t*n[0]/n[1],r}function parse_vpos(){var e,t=parse.line,n=0;t.buffer[t.index-1]=="."&&!a_dcn&&(n=C.SL_DOTTED);switch(t.next_char()){case"'":return t.index++,n+C.SL_ABOVE;case",":return t.index++,n+C.SL_BELOW}return n+C.SL_AUTO}function note_transp(e){var t,n,r,i,s,o,u,a,f,l,c=e.nhd,h=curvoice.okey.k_sf,p=curvoice.ckey.k_sf-h,d=cgd2cde[(p+28)%7],v=curvoice.vtransp;v<0&&d!=0&&(d-=7),d+=(v/3/12|0)*7;for(t=0;t<=c;t++){l=e.notes[t],r=l.pit,l.pit+=d,u=cde2fcg[(r+5+112)%7],s=l.acc;if(!s)if(!curvoice.okey.a_acc)h>0?u<h-1&&(s=1):h<0&&u>=h+6&&(s=-1);else for(n=0;n<curvoice.okey.a_acc.length;n++){o=curvoice.okey.a_acc[n];if((r+16*7-o.pit)%7==0){s=o.acc;break}}a=u+p,s&&s!=3&&(a+=s*7),u=(((a+1+21)/7|0)+2-3+160)%5,s=acc2[u];if(!l.acc)if(curvoice.ckey.k_none){if(s==3||acc_same_pitch(l.pit))continue}else{if(!curvoice.ckey.a_acc)continue;f=cgd2cde[(a+112)%7];for(n=0;n<curvoice.ckey.a_acc.length;n++)if((f+16*7-curvoice.ckey.a_acc[n].pits)%7==0)break;if(n<curvoice.ckey.a_acc.length)continue}u=l.acc,i=l.micro_d;if(i&&u!=s){r=l.micro_n;switch(s){case 3:r>i/2?(r-=i/2,l.micro_n=r,s=u):s=-u;break;case 2:r>i/2?(l.pit+=1,r-=i/2):r+=i/2,s=u,l.micro_n=r;break;case-2:r>=i/2?(l.pit-=1,r-=i/2):r+=i/2,s=u,l.micro_n=r}}l.acc=s}}function sort_pitch(e){e.notes=e.notes.sort(function(e,t){return e.pit-t.pit})}function new_note(e,t){var n,r,i,s,o,u,a,f,l,c,h,p,d,v=0,m=parse.line,g=a_dcn;a_dcn=null,parse.stemless=!1,r={type:C.NOTE,fname:parse.fname,stem:0,multi:0,nhd:0,xmx:0},r.istart=parse.bol+m.index,curvoice.color&&(r.color=curvoice.color),e?r.grace=!0:(a_gch&&self.gch_build(r),parse.repeat_n&&(r.repeat_n=parse.repeat_n,r.repeat_k=parse.repeat_k,parse.repeat_n=0)),s=m.char();switch(s){case"X":r.invis=!0;case"Z":r.type=C.MREST,s=m.next_char(),r.nmes=s>"0"&&s<="9"?m.get_int():1,r.dur=curvoice.wmeasure*r.nmes;if(curvoice.second){curvoice.time+=r.dur;return}r.nmes==1&&(r.type=C.REST,r.dur_orig=r.dur,r.notes=[{pit:18,dur:r.dur}]);break;case"y":r.type=C.SPACE,r.invis=!0,r.dur=0,s=m.next_char(),s>="0"&&s<="9"?r.width=m.get_int():r.width=10;break;case"x":r.invis=!0;case"z":r.type=C.REST,m.index++,c=parse_dur(m),r.dur_orig=(curvoice.ulen<0?15120:curvoice.ulen)*c[0]/c[1],r.dur=r.dur_orig*curvoice.dur_fact,r.notes=[{pit:18,dur:r.dur_orig}];break;case"[":i=!0,s=m.next_char();default:curvoice.uscale&&(r.uscale=curvoice.uscale),r.notes=[];for(;;){if(i)for(;;){if(!s)break;a=s.charCodeAt(0);if(a>=128){syntax(1,errs.not_ascii);return}u=char_tb[a];switch(u[0]){case"(":v<<=4,v+=parse_vpos(),s=m.char();continue;case"!":a_dcn||(a_dcn=[]);if(u.length>1)a_dcn.push(u.slice(1,-1));else{o="";for(;;){s=m.next_char();if(!s){syntax(1,"No end of decoration");return}if(s=="!")break;o+=s}a_dcn.push(o)}s=m.next_char();continue}break}n=parse_basic_note(m,r.grace?C.BLEN/4:curvoice.ulen<0?15120:curvoice.ulen);if(!n)return;curvoice.octave&&(n.pit+=curvoice.octave*7),curvoice.ottava&&(n.pit+=curvoice.ottava),v&&(n.sl1=v,r.sl1?r.sl1++:r.sl1=1,v=0),a_dcn&&(n.a_dcn=a_dcn,a_dcn=null),r.notes.push(n);if(!i)break;s=m.char();for(;;){switch(s){case")":n.sl2?n.sl2++:n.sl2=1,r.sl2?r.sl2++:r.sl2=1,s=m.next_char();continue;case"-":n.ti1=parse_vpos(),r.ti1=!0,s=m.char();continue;case".":s=m.next_char();if(s!="-"){syntax(1,"Misplaced dot");break}continue}break}if(s=="]"){m.index++,c=parse_dur(m),r.nhd=r.notes.length-1;for(a=0;a<=r.nhd;a++)n=r.notes[a],n.dur=n.dur*c[0]/c[1];break}}r.dur_orig=r.notes[0].dur,r.dur=r.notes[0].dur*curvoice.dur_fact}if(r.grace&&r.type!=C.NOTE){syntax(1,"Not a note in grace note sequence");return}if(r.notes){if(!r.grace){switch(curvoice.pos.stm){case C.SL_ABOVE:r.stem=1;break;case C.SL_BELOW:r.stem=-1;break;case C.SL_HIDDEN:r.stemless=!0}r.dur*=t,p=curvoice.brk_rhythm;if(p){curvoice.brk_rhythm=0,l=curvoice.last_note;if(p>0){f=p*2-1,r.dur=r.dur*f/p,r.dur_orig=r.dur_orig*f/p;for(a=0;a<=r.nhd;a++)r.notes[a].dur=r.notes[a].dur*f/p;l.dur/=p,l.dur_orig/=p;for(a=0;a<=l.nhd;a++)l.notes[a].dur/=p}else{p=-p,f=p*2-1,r.dur/=p,r.dur_orig/=p;for(a=0;a<=r.nhd;a++)r.notes[a].dur/=p;l.dur=l.dur*f/p,l.dur_orig=l.dur_orig*f/p;for(a=0;a<=l.nhd;a++)l.notes[a].dur=l.notes[a].dur*f/p}curvoice.time=l.time+l.dur,h=identify_note(l,l.dur_orig),l.head=h[0],l.dots=h[1],l.nflags=h[2],l.nflags<=-2?l.stemless=!0:delete l.stemless;for(l=l.next;l;l=l.next)l.time=curvoice.time}}else{var y=curvoice.ckey.k_bagpipe?8:4;for(a=0;a<=r.nhd;a++)r.notes[a].dur/=y;r.dur/=y,r.dur_orig/=y,e.stem&&(r.stem=e.stem)}r.type==C.NOTE?(h=identify_note(r,r.dur_orig),r.head=h[0],r.dots=h[1],r.nflags=h[2],r.nflags<=-2&&(r.stemless=!0)):(d=r.dur_orig,d==curvoice.wmeasure&&(d<C.BLEN*2?d=C.BLEN:d<C.BLEN*4?d=C.BLEN*2:d=C.BLEN*4),h=identify_note(r,d),r.head=h[0],r.dots=h[1],r.nflags=h[2]),curvoice.last_note=r}sym_link(r);if(r.type==C.NOTE){curvoice.vtransp&¬e_transp(r);if(curvoice.map&&maps[curvoice.map])for(a=0;a<=r.nhd;a++)set_map(r.notes[a])}return cfmt.shiftunison&&(r.shiftunison=cfmt.shiftunison),e||(curvoice.lyric_restart||(curvoice.lyric_restart=r),curvoice.sym_restart||(curvoice.sym_restart=r)),g&&deco_cnv(g,r,r.prev),parse.stemless&&(r.stemless=!0),r.iend=parse.bol+m.index,r}function parse_music_line(){function h(e){var t,n,r;for(t=1,n=c.index+1;t<e.length;t++,n++){if(e[t]==c.buffer[n])continue;if(e[t]!="n")return;r=ntb.indexOf(c.buffer[n]);if(r<0)return;while(c.buffer[n+1]=="'")r+=7,n++;while(c.buffer[n+1]==",")r-=7,n++}return c.index=n,r}function p(e,t){var n,r,s="",o=e.length;for(i=0;i<o;i++){n=e[i];if(n>="h"&&n<="z"){r=t+n.charCodeAt(0)-"n".charCodeAt(0),n="";while(r<0)r+=7,n+=",";while(r>14)r-=7,n+="'";s+=ntb[r]+n}else s+=n}return s}function d(e,t){var n,r=c,i=parse.istart;parse.line=c=new scanBuf,parse.istart+=r.index,c.buffer=t?p(e,t):e,v(!0),parse.line=c=r,parse.istart=i}function v(i){var s,p,v,m,g,y,b,w,E;for(;;){s=c.char();if(!s)break;if(s==".")switch(c.buffer[c.index+1]){case"(":case"-":case"|":s=c.next_char()}p=s.charCodeAt(0);if(p>=128){syntax(1,errs.not_ascii),c.index++;break}if(!i&&maci[p]){w=0;for(m in mac){if(!mac.hasOwnProperty(m)||m[0]!=s)continue;if(m.indexOf("n")<0){if(c.buffer.indexOf(m,c.index)!=c.index)continue;c.index+=m.length}else{w=h(m);if(!w)continue}d(mac[m],w),w=1;break}if(w)continue}v=char_tb[p];switch(v[0]){case" ":g=curvoice.last_note,g&&(g.beam_end=!0,e&&(e.gr_shift=!0));break;case"\n":if(cfmt.barsperstaff)break;par_sy.voices[curvoice.v].range==0&&curvoice.last_sym&&(curvoice.last_sym.eoln=!0);break;case"&":if(e){syntax(1,errs.bad_char,s);break}s=c.next_char();if(s==")"){get_vover(")");break}get_vover("&");continue;case"(":s=c.next_char();if(s>"0"&&s<="9"){var S=c.get_int(),x=qplet_tb[S],T=S,s=c.char();if(s==":"){s=c.next_char(),s>"0"&&s<="9"&&(x=c.get_int(),s=c.char());if(s==":"){s=c.next_char();if(!(s>"0"&&s<="9")){syntax(1,"Invalid 'r' in tuplet");continue}T=c.get_int(),s=c.char()}}if(x==0||x==undefined)x=curvoice.wmeasure%9==0?3:2;u=o[++a],u||(o[a]=u={}),u.p=S,u.q=x,u.r=T,u.f=cfmt.tuplets,u.fact=f*x/S,f=u.fact;continue}if(s=="&"){if(e){syntax(1,errs.bad_char,s);break}get_vover("(");break}l<<=4,c.index--,l+=parse_vpos();continue;case")":if(curvoice.ignore)break;g=curvoice.last_sym;if(g)switch(g.type){case C.NOTE:case C.REST:case C.SPACE:break;default:g=null}if(!g){syntax(1,errs.bad_char,s);break}g.slur_end?g.slur_end++:g.slur_end=1;break;case"!":a_dcn||(a_dcn=[]);if(v.length>1)y=v.slice(1,-1);else{y="",b=c.index;for(;;){s=c.next_char();if(!s)break;if(s=="!")break;y+=s}if(!s){c.index=b,syntax(1,"No end of decoration");break}}ottava[y]&&set_ottava(y),a_dcn.push(y);break;case'"':parse_gchord(v);break;case"-":var N=0;if(!curvoice.last_note||curvoice.last_note.type!=C.NOTE){syntax(1,"No note before '-'");break}N=parse_vpos(),g=curvoice.last_note;for(b=0;b<=g.nhd;b++)g.notes[b].ti1?g.nhd==0&&syntax(1,"Too many ties"):g.notes[b].ti1=N;g.ti1=!0,e&&(e.ti1=!0);continue;case"[":var k=c.buffer[c.index+1];if('|[]: "'.indexOf(k)>=0||k>="1"&&k<="9"){if(e){syntax(1,errs.bar_grace);break}new_bar();continue}if(c.buffer[c.index+2]==":"){b=c.buffer.indexOf("]",c.index+1);if(b<0){syntax(1,"Lack of ']'");break}E=c.buffer.slice(c.index+3,b).trim(),parse.istart=parse.bol+c.index,parse.iend=parse.bol+ ++b,c.index=0,do_info(k,E),c.index=b;continue};case"n":g=self.new_note(e,f);if(!g)continue;g.type==C.NOTE&&l&&(g.slur_start=l,l=0);if(e){a>=0&&(g.in_tuplet=!0);continue}a>=0&&g.notes&&(g.in_tuplet=!0,a>0?(o[0].p&&(g.tp0=o[0].p,g.tq0=o[0].q,g.tf=o[0].f,o[0].p=0),o[0].r--,u.p&&(g.tp1=u.p,g.tq1=u.q,g.tf=u.f,u.p=0)):u.p&&(g.tp0=u.p,g.tq0=u.q,g.tf=u.f,u.p=0),u.r--,u.r==0&&(a--==0?(g.tp0?g.tp0=!1:g.te0=!0,f=1,curvoice.time=Math.round(curvoice.time),g.dur=curvoice.time-g.time):(g.tp1?g.tp1=!1:g.te1=!0,u=o[0],u.r==0?(a--,g.te0=!0,f=1,curvoice.time=Math.round(curvoice.time),g.dur=curvoice.time-g.time):f=u.fact)));continue;case"<":if(!curvoice.last_note){syntax(1,"No note before '<'");break}if(e){syntax(1,"Cannot have a broken rhythm in grace notes");break}w=s=="<"?1:-1;while(s=="<"||s==">")w*=2,s=c.next_char();curvoice.brk_rhythm=w;continue;case"i":break;case"{":if(e){syntax(1,"'{' in grace note");break}t=curvoice.last_note,curvoice.last_note=null,n=a_dcn,a_dcn=undefined,e={type:C.GRACE,fname:parse.fname,istart:parse.bol+c.index,dur:0,multi:0};switch(curvoice.pos.gst){case C.SL_ABOVE:e.stem=1;break;case C.SL_BELOW:e.stem=-1;break;case C.SL_HIDDEN:e.stem=2}sym_link(e),s=c.next_char();if(s=="/"){e.sappo=!0;break}continue;case"|":if(e){syntax(1,errs.bar_grace);break}s=c.buffer[c.index-1],new_bar(),s=="."&&(curvoice.last_sym.bar_dotted=!0);continue;case"}":g=curvoice.last_note;if(!e||!g){syntax(1,errs.bad_char,s);break}a_dcn&&syntax(1,"Decoration ignored"),g.gr_end=!0,e.extra=e.next,e.extra.prev=null,e.next=null,curvoice.last_sym=e,e=null;if(!g.prev&&!curvoice.ckey.k_bagpipe){for(b=0;b<=g.nhd;b++)g.notes[b].dur*=2;g.dur*=2,g.dur_orig*=2;var L=identify_note(g,g.dur_orig);g.head=L[0],g.dots=L[1],g.nflags=L[2]}curvoice.last_note=t,a_dcn=n;break;case"\\":s=c.buffer[c.index+1];if(!s){r=!0;break};default:syntax(1,errs.bad_char,s)}c.index++}}var e,t,n,r,s,o=[],u,a=-1,f=1,l=0,c=parse.line;if(parse.state!=3){if(parse.state!=2)return;goto_tune()}v();if(a>=0){syntax(1,"No end of tuplet");for(s=curvoice.last_note;s;s=s.prev){s.tp1&&(s.tp1=0);if(s.tp0){s.tp0=0;break}}}e&&(syntax(1,"No end of grace note sequence"),curvoice.last_sym=e.prev,curvoice.last_note=t,e.prev&&(e.prev.next=null)),cfmt.breakoneoln&&curvoice.last_note&&(curvoice.last_note.beam_end=!0);if(r||cfmt.barsperstaff)return;char_tb["\n".charCodeAt(0)]=="\n"&&par_sy.voices[curvoice.v].range==0&&curvoice.last_sym&&(curvoice.last_sym.eoln=!0)}function cwid(e){var t=e.charCodeAt(0);if(t>=128){if(t>=768&&t<880)return 0;t=97}return cw_tb[t]}function strwh(e){var t=gene.curfont,n=t.swfac,r=t.size,i=0,s,o,u,a=e.length;for(s=0;s<a;s++){u=e[s];switch(u){case"$":u=e[s+1];if(u=="0")t=gene.deffont;else{if(!(u>="1"&&u<="9")){u="$";break}t=get_font("u"+u)}s++,n=t.swfac,t.size>r&&(r=t.size);continue;case"&":o=e.indexOf(";",s),o>0&&o-s<10&&(s=o,u="a")}i+=cwid(u)*n}return gene.curfont=t,[i,r]}function set_font(e){typeof e=="string"&&(e=get_font(e)),gene.curfont=gene.deffont=e}function out_str(e){var t,n=gene.curfont,r=n;output+=e.replace(/<|>|&.*?;|&| |\$./g,function(e){switch(e[0]){case"<":return"<";case">":return">";case"&":if(e=="&")return"&";return e;case" ":return" ";case"$":if(e[1]=="0")t=gene.deffont,use_font(t);else{if(!(e[1]>="1"&&e[1]<="9"))return e;t=get_font("u"+e[1])}e="";if(t==r)return e;r!=n&&(e="</tspan>"),r=t;if(r==n)return e;return e+'<tspan\n class="'+font_class(t)+'">'}}),r!=n&&(output+="</tspan>",gene.curfont=r)}function xy_str(e,t,n,r,i){var s=strwh(n)[1];t+=s*.2,output+='<text class="'+font_class(gene.curfont)+'" x="',out_sxsy(e,'" y="',t);switch(r){case"c":output+='" text-anchor="middle">';break;case"j":output+='" textLength="'+i.toFixed(2)+'">';break;case"r":output+='" text-anchor="end">';break;default:output+='">'}out_str(n),output+="</text>\n"}function xy_str_b(e,t,n){var r=strwh(n);output+='<rect class="stroke" x="',out_sxsy(e-2,'" y="',t+r[1]+1),output+='" width="'+(r[0]+4).toFixed(2)+'" height="'+(r[1]+3).toFixed(2)+'"/>\n',xy_str(e,t,n)}function trim_title(e,t){var n;if(cfmt.titletrim){n=e.lastIndexOf(", ");if(n<0||e[n+2]<"A"||e[n+2]>"Z")n=0;else if(cfmt.titletrim==1){if(n<e.length-7||e.indexOf(" ",n+3)>=0)n=0}else n<e.length-cfmt.titletrim-2&&(n=0)}return!t&&cfmt.writefields.indexOf("X")>=0&&(e=info.X+". "+e),n&&(e=e.slice(n+2).trim()+" "+e.slice(0,n)),cfmt.titlecaps?e.toUpperCase():e}function get_lwidth(){return(img.width-img.lm-img.rm-2)/cfmt.scale}function write_title(e,t){var n,r;if(!e)return;set_page(),e=trim_title(e,t),t?(set_font("subtitle"),r=cfmt.subtitlespace):(set_font("title"),r=cfmt.titlespace),vskip(strwh(e)[1]+r),cfmt.titleleft?xy_str(0,0,e):xy_str(get_lwidth()/2,0,e,"c")}function put_inf2r(e,t,n,r,i){if(!n){if(!r)return;n=r,r=null}r?xy_str(e,t,n+" ("+r+")",i):xy_str(e,t,n,i)}function str_skip(e){vskip(strwh(e)[1]*cfmt.lineskipfac)}function write_text(e,t){if(t=="s")return;set_font("text"),set_page();var n=get_lwidth(),r=gene.curfont.size,i=r*cfmt.lineskipfac,s=r*cfmt.parskipfac,o=block.started?function(){}:blk_out,u=block.started?svg_flush:blk_flush,a,f,l,c,h,p,d,v;o();switch(t){default:switch(t){case"c":l=n/2;break;case"r":l=n;break;default:l=0}f=0;for(;;){a=e.indexOf("\n",f);if(a<0){v=e.slice(f),str_skip(v),xy_str(l,0,v,t);break}if(a==f){vskip(s),u(),use_font(gene.curfont);while(e[a+1]=="\n")vskip(i),a++;if(a==e.length)break;o()}else v=e.slice(f,a),str_skip(v),xy_str(l,0,v,t);f=a+1}vskip(s),u();break;case"f":case"j":f=0;for(;;){a=e.indexOf("\n\n",f),a<0?c=e.slice(f):c=e.slice(f,a),c=c.split(/\s+/),h=p=0;for(f=0;f<c.length;f++)d=strwh(c[f]+" ")[0],h+=d,h>=n&&(v=c.slice(p,f).join(" "),str_skip(v),xy_str(0,0,v,t,n),p=f,h=d);h!=0&&(v=c.slice(p).join(" "),str_skip(v),xy_str(0,0,v)),vskip(s),u();if(a<0)break;while(e[a+2]=="\n")vskip(i),a++;if(a==e.length)break;o(),use_font(gene.curfont),f=a+2}}}function put_words(e){function f(e,t,n){var r=0,i,s;e[r]=="$"&&e[r+1]>="0"&&e[r+1]<="9"&&(r+=2),s=0,i=r;if(e[r]>="0"&&e[r]<="9"||e[r+1]=="."){while(r<e.length){r++;if(e[r]==" "||e[r-1]==":"||e[r-1]==".")break}s=r;while(e[r]==" ")r++}return s!=0&&xy_str(t,0,e.slice(i,s),"r"),r<e.length&&xy_str(t+5,0,e.slice(r),"l"),r>=e.length&&s==0}var t,n,r,i,s,o,u,a;blk_out(),set_font("words");var l=get_lwidth()/2,c=(l-45)/(cwid("a")*gene.curfont.swfac);i=0,e=e.split("\n"),s=e.length;for(n=0;n<s;n++){t=e[n];if(t.length>c){i=0;break}t?a=!0:a&&(i++,a=!1)}if(i>0){n=i=(i+1)/2|0,a=!1;for(u=0;u<s;u++){t=e[u],r=0;while(t[r]==" ")r++;if(r==t.length){if(a&&--n<=0)break;a=!1}else a=!0}o=u+1}else o=u=s;vskip(cfmt.wordsspace);for(n=0;n<u||o<s;n++)n<u&&e[n].length==0&&(blk_out(),use_font(gene.curfont)),vskip(cfmt.lineskipfac*gene.curfont.size),n<u&&f(e[n],45,0),o<s&&(f(e[o],20+l,1)&&--i==0&&(n<u?i++:o<e.length-1&&(l*=.6)),o++)}function put_history(){var e,t,n,r,i,s,o,u,a=cfmt.infoname.split("\n"),f=a.length;for(e=0;e<f;e++){n=a[e][0];if(cfmt.writefields.indexOf(n)<0)continue;r=info[n];if(!r)continue;i||(i=!0,set_font("history"),vskip(cfmt.textspace),s=gene.curfont.size*cfmt.lineskipfac),u=a[e].slice(2),u[0]=='"'&&(u=u.slice(1,-1)),vskip(s),xy_str(0,0,u),o=strwh(u)[0],r=r.split("\n"),xy_str(o,0,r[0]);for(t=1;t<r.length;t++)vskip(s),xy_str(o,0,r[t]);vskip(s*.3),blk_out(),use_font(gene.curfont)}}function write_headform(e){var t,n,r,i,s,o,u,a={},f=clone(info_font_init),l={A:cfmt.infospace,C:cfmt.composerspace,O:cfmt.composerspace,R:cfmt.infospace},c={},h="",p=cfmt.titleformat,d=0,v=0;for(;;){while(p[v]==" ")v++;if(v>=p.length)break;t=p[v++];if(t<"A"||t>"Z"){if(t=="+"){if(h.length==0||h.slice(-1)=="+")continue;h=h.slice(0,-1)+"+"}else t==","&&(h.slice(-1)=="+"&&(h=h.slice(0,-1)+"l"),h+="\n");continue}if(!a[t]){if(!info[t])continue;a[t]=info[t].split("\n"),c[t]=1}else c[t]++;h+=t;switch(p[v]){case"-":h+="l",v++;break;case"0":h+="c",v++;break;case"1":h+="r",v++;break;default:h+="c"}}h.slice(-1)=="+"&&(h=h.slice(0,-1)+"l"),h+="\n";var m={l:cfmt.titlespace,c:cfmt.titlespace,r:cfmt.titlespace},g={l:0,c:e*.5,r:e},y={},b;p=h,v=0;for(;;){y.l=y.c=y.r=o=0,d=v;for(;;){t=p[d++];if(t=="\n")break;i=p[d++];if(i=="+")i=p[d+1];else if(y[i]!=0)continue;b=a[t];if(!b)continue;r=f[t],r||(r="history"),n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),o<u&&(o=u),y[i]=u}m.l+=o-y.l,m.c+=o-y.c,m.r+=o-y.r;for(;;){t=p[v++];if(t=="\n")break;i=p[v++];if(a[t].length==0)continue;b=a[t].shift(),i=="+"&&(c[t]--,t=p[v++],i=p[v++],a[t].length>0&&(b?b+=" "+a[t].shift():b=" "+a[t].shift())),r=f[t],r||(r="history"),n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),set_font(n),s=g[i],o=m[i]+u;if(t=="Q"){if(!glovar.tempo.del){if(i!="l"){var w=tempo_width(glovar.tempo);i=="c"&&(w*=.5),s-=w}write_tempo(glovar.tempo,s,-o)}}else b&&xy_str(s,-o,b,i);t=="T"&&(r=f.T="subtitle",l.T=cfmt.subtitlespace);if(c[t]<=1){t=="T"&&(n=get_font(r),u=n.size*1.1,l[t]&&(u+=l[t]),set_font(n));while(a[t].length>0)o+=u,b=a[t].shift(),xy_str(s,-o,b,i)}c[t]--,m[i]=o}m.c>m.l&&(m.l=m.c),m.r>m.l&&(m.l=m.r);if(v>=h.length)break;m.c=m.r=m.l}vskip(m.l)}function write_heading(){var e,t,n,r,i,s,o,u,a=get_lwidth();blk_out(),vskip(cfmt.topspace);if(cfmt.titleformat){write_headform(a),vskip(cfmt.musicspace);return}if(info.T&&cfmt.writefields.indexOf("T")>=0){e=0;for(;;){t=info.T.indexOf("\n",e);if(t<0){write_title(info.T.substring(e),e!=0);break}write_title(info.T.slice(e,t),e!=0),e=t+1}}set_font("composer"),o=u=0,parse.ckey.k_bagpipe&&!cfmt.infoline&&cfmt.writefields.indexOf("R")>=0&&(s=info.R),s&&(xy_str(0,-cfmt.composerspace,s),o=cfmt.composerspace),n=info.A,cfmt.writefields.indexOf("C")>=0&&(r=info.C),cfmt.writefields.indexOf("O")>=0&&(i=info.O);if(r||i||cfmt.infoline){var f,l;vskip(cfmt.composerspace),cfmt.aligncomposer<0?(f=0,l=" "):cfmt.aligncomposer==0?(f=a*.5,l="c"):(f=a,l="r"),u=o;if(r||i){cfmt.aligncomposer>=0&&o!=u&&vskip(o-u),e=0;for(;;){vskip(gene.curfont.size),r?t=r.indexOf("\n",e):t=-1;if(t<0){put_inf2r(f,0,r?r.substring(e):null,i,l);break}xy_str(f,0,r.slice(e,t),l),o+=gene.curfont.size,e=t+1}u>o&&vskip(u-o)}s=s?null:info.R,(s||n)&&cfmt.infoline&&(set_font("info"),vskip(gene.curfont.size+cfmt.infospace),put_inf2r(a,0,s,n,"r"),o+=gene.curfont.size+cfmt.infospace)}else u=cfmt.composerspace;info.P&&cfmt.writefields.indexOf("P")>=0&&(set_font("parts"),o=cfmt.partsspace+gene.curfont.size-o,o>0&&(u+=o),u>.01&&vskip(u),xy_str(0,0,info.P),u=0),vskip(u+cfmt.musicspace)}function m_gl(e){return e.replace(/[Cco]\||[co]\.|./g,function(e){return mgls[e]})}function def_use(e){var t,n,r;if(defined_glyph[e])return;defined_glyph[e]=!0,r=glyphs[e];if(!r){error(1,null,"Unknown glyph: '$1'",e);return}n=0;for(;;){t=r.indexOf('xlink:href="#',n);if(t<0)break;t+=13,n=r.indexOf('"',t),def_use(r.slice(t,n))}defs+="\n"+r}function defs_add(e){var t,n,r,i,s,o=0;e=e.replace(/<!--.*?-->/g,"");for(;;){s=e.indexOf("<",o);if(s<0)break;t=e.indexOf('id="',s);if(t<0)break;t+=4,n=e.indexOf('"',t);if(n<0)break;r=e.slice(t,n),o=e.indexOf(">",n);if(o<0)break;if(e[o-1]=="/")o++;else{t=e.indexOf(" ",s);if(t<0)break;i=e.slice(s+1,t),o=e.indexOf("</"+i+">",o);if(o<0)break;o+=3+i.length}e.substr(s,7)=="<filter"?fulldefs+="\n"+e.slice(s,o):glyphs[r]=e.slice(s,o)}}function set_g(){stv_g.started&&(stv_g.started=!1,output+="</g>\n");if(stv_g.scale==1&&!stv_g.color)return;output+="<g ",stv_g.scale!=1&&(stv_g.st>=0?output+=staff_tb[stv_g.st].scale_str:output+=voice_tb[stv_g.v].scale_str),stv_g.color&&(stv_g.scale!=1&&(output+=" "),output+='style="color:'+stv_g.color+'"'),output+=">\n",stv_g.started=!0}function set_color(e){if(e==stv_g.color)return undefined;var t=stv_g.color;return stv_g.color=e,set_g(),t}function set_sscale(e){var t,n;e!=stv_g.st&&stv_g.scale!=1&&(stv_g.scale=0),t=e>=0?staff_tb[e].staffscale:1,e>=0&&t!=1?n=staff_tb[e].y:n=posy;if(t==stv_g.scale&&n==stv_g.dy)return;stv_g.scale=t,stv_g.dy=n,stv_g.st=e,set_g()}function set_scale(e){var t=e.p_v.scale;if(t==1){set_sscale(e.st);return}if(t==stv_g.scale&&stv_g.dy==posy)return;stv_g.scale=t,stv_g.dy=posy,stv_g.st=-1,stv_g.v=e.v,set_g()}function set_dscale(e,t){output&&(stv_g.st<0?staff_tb[0].output+=output:stv_g.scale==1?staff_tb[stv_g.st].output+=output:staff_tb[stv_g.st].sc_out+=output,output=""),e<0?stv_g.scale=1:stv_g.scale=t?1:staff_tb[e].staffscale,stv_g.st=e,stv_g.dy=0}function delayed_update(){var e,t,n;for(e=0;e<=nstaff;e++){staff_tb[e].sc_out&&(output+='<g transform="translate(0,'+(posy-staff_tb[e].y).toFixed(2)+") scale("+staff_tb[e].staffscale.toFixed(2)+')">\n'+staff_tb[e].sc_out+"</g>\n",staff_tb[e].sc_out="");if(!staff_tb[e].output)continue;output+='<g transform="translate(0,'+(-staff_tb[e].y).toFixed(2)+')">\n'+staff_tb[e].output+"</g>\n",staff_tb[e].output=""}}function anno_out(e,t,n){if(e.istart==undefined)return;var r=e.type,i=e.ymx-e.ymn+4,s=e.wl||2,o=e.wr||2;e.grace&&(r=C.GRACE),n(t||anno_type[r],e.istart,e.iend,e.x-s-2,staff_tb[e.st].y+e.ymn+i-2,s+o+4,i,e)}function a_start(e,t){anno_out(e,t,user.anno_start)}function a_stop(e,t){anno_out(e,t,user.anno_stop)}function empty_function(){}function out_XYAB(e,t,n,r,i){t=sx(t),n=sy(n),output+=e.replace(/X|Y|A|B|F|G/g,function(e){switch(e){case"X":return t.toFixed(2);case"Y":return n.toFixed(2);case"A":return r;case"B":return i;case"F":return r.toFixed(2);default:return i.toFixed(2)}})}function g_open(e,t,n,r,i){out_XYAB('<g transform="translate(X,Y',e,t),n&&(output+=") rotate("+n.toFixed(2)),r&&(i?output+=") scale("+r.toFixed(2)+", "+i.toFixed(2):output+=") scale("+r.toFixed(2)),output+=')">\n',stv_g.g++}function g_close(){stv_g.g--,output+="</g>\n"}function sx(e){return stv_g.g?e:(e+posx)/stv_g.scale}function sy(e){return stv_g.g?-e:stv_g.scale==1?posy-e:stv_g.st<0?(posy-e)/stv_g.scale:stv_g.dy-e}function out_sxsy(e,t,n){e=sx(e),n=sy(n),output+=e.toFixed(2)+t+n.toFixed(2)}function xypath(e,t,n){out_XYAB('<path class="A" d="mX Y\n',e,t,n?"fill":"stroke")}function xygl(e,t,n){var r=tgls[n];if(r&&!glyphs[n]){e+=r.x*stv_g.scale,t-=r.y,r.sc?out_XYAB('<text transform="translate(X,Y) scale(F)">B</text>\n',e,t,r.sc,r.c):out_XYAB('<text x="X" y="Y">A</text>\n',e,t,r.c);return}if(!glyphs[n]){error(1,null,"no definition of $1",n);return}def_use(n),out_XYAB('<use x="X" y="Y" xlink:href="#A"/>\n',e,t,n)}function out_acciac(e,t,n,r,i){i?(e-=1,t+=4):(e-=5,t-=4),out_XYAB('<path class="stroke" d="mX YlF G"/>\n',e,t,n,-r)}function out_bar(e,t,n,r){if(r){var i=(5*r).toFixed(2);r='stroke-dasharray="'+i+","+i+'" '}else r="";output+='<path class="stroke" stroke-width="1" '+r+'d="m'+(e+posx).toFixed(2)+" "+(posy-t).toFixed(2)+"v"+(-n).toFixed(2)+'"/>\n'}function out_bnum(e,t,n){out_XYAB('<text style="font:italic 12px serif"\n x="X" y="Y" text-anchor="middle">A</text>\n',e,t,n.toString())}function out_brace(e,t,n){e+=posx-6,t=posy-t,n/=24,output+='<text transform="translate('+e.toFixed(2)+","+t.toFixed(2)+") scale(2.5,"+n.toFixed(2)+')">'+tgls.brace.c+"</text>\n"}function out_bracket(e,t,n){e+=posx-5,t=posy-t-3,n+=2,output+='<path class="fill"\n d="m'+e.toFixed(2)+" "+t.toFixed(2)+"\n c10.5 1 12 -4.5 12 -3.5c0 1 -3.5 5.5 -8.5 5.5\n v"+n.toFixed(2)+'\n c5 0 8.5 4.5 8.5 5.5c0 1 -1.5 -4.5 -12 -3.5"/>\n'}function out_hyph(e,t,n){var r,i,s=25+(n/20|0)*3;n>15?r=(n-15)/s|0:r=0,e+=(n-s*r-5)/2,out_XYAB('<path class="stroke" stroke-width="1.2"\n stroke-dasharray="5,A"\n d="mX YhB"/>\n',e,t+6,Math.round((s-5)/stv_g.scale),s*r+5)}function out_stem(e,t,n,r,i,s){var o=r?GSTEM_XOFF:3.5,u=-n;n<0&&(o=-o),e+=o*stv_g.scale,stv_g.st<0&&(u/=stv_g.scale),out_XYAB('<path class="stroke" d="mX YvF"/>\n',e,t,u);if(!i)return;output+='<path class="fill"\n d="',t+=n;if(n>0)if(!s)if(!r)if(i==1)out_XYAB("MX Yc0.6 5.6 9.6 9 5.6 18.4\n 1.6 -6 -1.3 -11.6 -5.6 -12.8\n",e,t);else while(--i>=0)out_XYAB("MX Yc0.9 3.7 9.1 6.4 6 12.4\n 1 -5.4 -4.2 -8.4 -6 -8.4\n",e,t),t-=5.4;else if(i==1)out_XYAB("MX Yc0.6 3.4 5.6 3.8 3 10\n 1.2 -4.4 -1.4 -7 -3 -7\n",e,t);else while(--i>=0)out_XYAB("MX Yc1 3.2 5.6 2.8 3.2 8\n 1.4 -4.8 -2.4 -5.4 -3.2 -5.2\n",e,t),t-=3.5;else if(!r){t+=1;while(--i>=0)out_XYAB("MX Yl7 3.2 0 3.2 -7 -3.2z\n",e,t),t-=5.4}else while(--i>=0)out_XYAB("MX Yl3 1.5 0 2 -3 -1.5z\n",e,t),t-=3;else if(!s)if(!r)if(i==1)out_XYAB("MX Yc0.6 -5.6 9.6 -9 5.6 -18.4\n 1.6 6 -1.3 11.6 -5.6 12.8\n",e,t);else while(--i>=0)out_XYAB("MX Yc0.9 -3.7 9.1 -6.4 6 -12.4\n 1 5.4 -4.2 8.4 -6 8.4\n",e,t),t+=5.4;else if(i==1)out_XYAB("MX Yc0.6 -3.4 5.6 -3.8 3 -10\n 1.2 4.4 -1.4 7 -3 7\n",e,t);else while(--i>=0)out_XYAB("MX Yc1 -3.2 5.6 -2.8 3.2 -8\n 1.4 4.8 -2.4 5.4 -3.2 5.2\n",e,t),t+=3.5;else if(!r){t+=1;while(--i>=0)out_XYAB("MX Yl7 -3.2 0 -3.2 -7 3.2z\n",e,t),t+=5.4}output+='"/>\n'}function out_thbar(e,t,n){e+=posx+1.5,t=posy-t,output+='<path class="stroke" stroke-width="3" d="m'+e.toFixed(2)+" "+t.toFixed(2)+"v"+(-n).toFixed(2)+'"/>\n'}function out_trem(e,t,n){out_XYAB('<path class="fill" d="mX Y\n ',e-4.5,t);for(;;){output+="l9 -3v3l-9 3z";if(--n<=0)break;output+="m0 5.4"}output+='"/>\n'}function out_tubr(e,t,n,r,i){var s=i?-3:3;t+=s,n/=stv_g.scale,output+='<path class="stroke" d="m',out_sxsy(e," ",t),output+="v"+s.toFixed(2)+"l"+n.toFixed(2)+" "+(-r).toFixed(2)+"v"+(-s).toFixed(2)+'"/>\n'}function out_tubrn(e,t,n,r,i,s){var o=s.length*10,u=i?-3:3;out_XYAB('<text style="font:italic 12px serif"\n x="X" y="Y" text-anchor="middle">A</text>\n',e+n/2,t+r/2,s),n/=stv_g.scale,i||(t+=6),output+='<path class="stroke" d="m',out_sxsy(e," ",t),output+="v"+u.toFixed(2)+"m"+n.toFixed(2)+" "+(-r).toFixed(2)+"v"+(-u).toFixed(2)+'"/>\n'+'<path class="stroke" stroke-dasharray="'+((n-o)/2).toFixed(2)+" "+o.toFixed(2)+'" d="m',out_sxsy(e," ",t-u),output+="l"+n.toFixed(2)+" "+(-r).toFixed(2)+'"/>\n'}function out_wln(e,t,n){out_XYAB('<path class="stroke" stroke-width="0.8" d="mX YhF"/>\n',e,t+3,n)}function out_deco_str(e,t,n,r){var i,s,o=deco_str_style[n];if(!o){xygl(e,t,n);return}e+=o.dx,t+=o.dy,o.def||(style+="\n."+n+" {"+o.style+"}",o.def=!0),out_XYAB('<text x="X" y="Y" class="A"B>',e,t,n,o.anchor||""),set_font("annotation"),out_str(r),output+="</text>\n"}function out_arp(e,t,n){g_open(e,t,270),e=0,n=Math.ceil(n/6);while(--n>=0)xygl(e,6,"ltr"),e+=6;g_close()}function out_cresc(e,t,n,r){e+=n,n=-n,out_XYAB('<path class="stroke"\n d="mX YlA ',e,t+5,n),r.nost?output+="-2.2m0 -3.6l"+(-n).toFixed(2)+' -2.2"/>\n':output+="-4l"+(-n).toFixed(2)+' -4"/>\n'}function out_dim(e,t,n,r){out_XYAB('<path class="stroke"\n d="mX YlA ',e,t+5,n),r.noen?output+="-2.2m0 -3.6l"+(-n).toFixed(2)+' -2.2"/>\n':output+="-4l"+(-n).toFixed(2)+' -4"/>\n'}function out_ltr(e,t,n){t+=4,n=Math.ceil(n/6);while(--n>=0)xygl(e,t,"ltr"),e+=6}function out_8va(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">8<tspan dy="-4" style="font-size:10px">va</tspan></text>\n',e-8,t),e+=12,n-=12),t+=6,out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv6"/>\n',e+n,t)}function out_8vb(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">8<tspan dy="-4" style="font-size:10px">vb</tspan></text>\n',e-8,t),e+=4,n-=4),out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',e+n,t)}function out_15ma(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">15<tspan dy="-4" style="font-size:10px">ma</tspan></text>\n',e-10,t),e+=20,n-=20),t+=6,out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv6"/>\n',e+n,t)}function out_15mb(e,t,n,r){r.nost?n-=5:(out_XYAB('<text x="X" y="Y" style="font:italic bold 12px serif">15<tspan dy="-4" style="font-size:10px">mb</tspan></text>\n',e-10,t),e+=7,n-=7),out_XYAB('<path class="stroke" stroke-dasharray="6,6" d="mX YhA"/>\n',e,t,n),r.noen||out_XYAB('<path class="stroke" d="mX Yv-6"/>\n',e+n,t)}function out_deco_val(e,t,n,r,i){deco_val_tb[n]?deco_val_tb[n](e,t,r,i):error(1,null,"No function for decoration '$1'",n)}function out_glisq(e,t,n){var r=n.start,i=r.x,s=r.y+staff_tb[r.st].y,o=Math.atan2(s-t,e-i),u=o/Math.PI*180,a=(e-i)/Math.cos(o);g_open(i,s,u),i=r.s.dots?13+r.s.xmx:8,a=(a-i-6)/6|0,a<1&&(a=1);while(--a>=0)xygl(i,0,"ltr"),i+=6;g_close()}function out_gliss(e,t,n){var r=n.start,i=r.x,s=r.y+staff_tb[r.st].y,o=-Math.atan2(t-s,e-i),u=o/Math.PI*180,a=(e-i)/Math.cos(o);g_open(i,s,u),i=r.s.dots?13+r.s.xmx:8,a-=i+8,xypath(i,0),output+="l"+a.toFixed(2)+' 0" stroke-width="1"/>\n',g_close()}function out_deco_long(e,t,n){var r=n.dd.glyph;deco_l_tb[r]?deco_l_tb[r](e,t,n):error(1,null,"No function for decoration '$1'",r)}function vskip(e){posy+=e}function svg_flush(){if(multicol||!output||!user.img_out||posy==0)return;var e='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n color="black" class="music" stroke-width=".7"',t="";cfmt.bgcolor&&(e+=' style="background-color: '+cfmt.bgcolor+'"'),posy*=cfmt.scale,user.imagesize?e+="\n"+user.imagesize+' viewBox="0 0 '+img.width.toFixed(0)+" "+posy.toFixed(0)+'">\n':e+='\n width="'+img.width.toFixed(0)+'px" height="'+posy.toFixed(0)+'px">\n';if(style||font_style||musicfont)e+='<style type="text/css">'+style+font_style,musicfont&&(musicfont.indexOf("(")>0?e+='\n.music {font:24px music; fill:currentColor}\n@font-face {\n font-family:"music";\n src:'+musicfont+"}":e+="\n.music {font:24px "+musicfont+"; fill:currentColor}"),e+="\n</style>\n";defs+=fulldefs,defs&&(e+="<defs>"+defs+"\n</defs>\n"),cfmt.scale!=1&&(e+='<g class="g" transform="scale('+cfmt.scale.toFixed(2)+')">\n',t="</g>\n"),psvg&&psvg.ps_flush(!0),user.img_out(e+output+t+"</svg>"),output="",font_style="",cfmt.fullsvg?(defined_glyph={},defined_font={}):(musicfont="",style="",fulldefs=""),defs="",posy=0}function blk_out(){if(multicol||!user.img_out)return;blk_flush(),user.page_format&&!block.started&&(block.started=!0,block.newpage?(block.newpage=!1,user.img_out('<div class="nobrk newpage">')):user.img_out('<div class="nobrk">'))}function blk_flush(){svg_flush(),block.started&&(block.started=!1,user.img_out("</div>"))}function voice_filter(){var e,t,n;for(e in parse.voice_opts){if(!parse.voice_opts.hasOwnProperty(e))continue;t=new RegExp(e);if(t.test(curvoice.id)||t.test(curvoice.nm))for(n in parse.voice_opts[e])parse.voice_opts[e].hasOwnProperty(n)&&self.do_pscom(parse.voice_opts[e][n])}}function sym_link(e){e.fname||set_ref(e),curvoice.ignore||(parse.last_sym=e,e.prev=curvoice.last_sym,curvoice.last_sym?curvoice.last_sym.next=e:curvoice.sym=e,curvoice.last_sym=e),e.v=curvoice.v,e.p_v=curvoice,e.st=curvoice.cst,e.time=curvoice.time,e.dur&&!e.grace&&(curvoice.time+=e.dur),e.pos=curvoice.pos,curvoice.second&&(e.second=!0),curvoice.floating&&(e.floating=!0)}function sym_add(e,t){var n={type:t,dur:0},r,i=curvoice;return curvoice=e,sym_link(n),curvoice=i,r=n.prev,r||(r=n.next),r&&(n.fname=r.fname,n.istart=r.istart,n.iend=r.iend),n}function mrest_expand(e){var t,n,r,i=e.nmes,s=e.dur/i,o=e.a_dd;e.type=C.REST,e.dur=s,e.head=C.FULL,e.nflags=-2,r=e.next,t=e.p_v,t.last_sym=e,t.time=e.time+s,t.cst=e.st,n=e;while(--i>0)n=sym_add(t,C.BAR),n.bar_type="|",n=sym_add(t,C.REST),e.invis&&(n.invis=!0),n.dur=s,n.head=C.FULL,n.nflags=-2,t.time+=s;n.next=r,r&&(r.prev=n),n.a_dd=o}function sort_all(){var e,t,n,r,i,s,o,u,a,f,l,c,h,p,d=voice_tb.length,v=[],m=[],g=-1;for(r=0;r<d;r++)v.push(voice_tb[r].sym);var y=1,b=cur_sy;for(;;){if(b&&y){p=b,b=null,a=-1,m=[];for(r=0;r<d;r++){if(!p.voices[r]){p.voices[r]={range:-1};continue}u=p.voices[r].range;if(u<0)continue;m[u]=r,a++}}o=i=1e6;for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time>i)continue;s=w_tb[e.type],e.time<i?(i=e.time,o=s):s<o&&(o=s),e.type==C.MREST&&(e.nmes==1?mrest_expand(e):a>0&&(g=i))}if(o>127)break;if(i==g){l=0;for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time!=i||w_tb[e.type]!=o)continue;if(e.type!=C.MREST){g=-1;break}if(l==0)l=e.nmes;else if(l!=e.nmes){g=-1;break}}if(g<0)for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r],e&&e.type==C.MREST&&mrest_expand(e)}}for(u=0;u<d;u++){r=m[u];if(r==undefined)break;e=v[r];if(!e||e.time!=i||w_tb[e.type]!=o)continue;if(e.type==C.STAVES){b=e.sy;for(c=0;c<d;c++)if(m[c]==undefined)break;for(h=0;h<d;h++){if(!b.voices[h])continue;u=b.voices[h].range;if(u<0||p.voices[h].range>=0)continue;m[c++]=h}}y&&(y=0,e.seqst=!0),e.ts_prev=f,f?f.ts_next=e:tsfirst=e,f=e,v[r]=e.next}y=o}}function voice_adj(){function i(e){var t,n,r,i,s,o,u,i=e.dur,a=1;for(t=e;t;t=t.next){if(t.beam_end||!t.next)break;a++}if(a<=1){delete e.feathered_beam;return}n=t,s=i/2,u=i/(a-1),r=e.time;if(e.feathered_beam>0)for(t=e,o=a-1;t!=n;t=t.next,o--)i=(u*o|0)+s,t.dur=i,t.time=r,r+=i;else for(t=e,o=0;t!=n;t=t.next,o++)i=(u*o|0)+s,t.dur=i,t.time=r,r+=i;t.dur=t.time+t.dur-r,t.time=r}var e,t,n,r;t=glovar.tempo,t&&staves_found<=0&&(r=par_sy.top_voice,e=voice_tb[r],e.sym&&e.sym.type!=C.TEMPO&&(t=clone(t),t.v=r,t.p_v=e,t.st=e.st,t.time=0,t.next=e.sym,t.next&&(t.next.prev=t),e.sym=t));for(r=0;r<voice_tb.length;r++){e=voice_tb[r],e.ignore&&(e.ignore=!1);for(t=e.sym;t;t=t.next)if(t.time>=staves_found)break;for(;t;t=t.next){switch(t.type){case C.GRACE:t.next&&t.next.type==C.BAR&&t.time--;if(!cfmt.graceword)continue;for(n=t.next;n;n=n.next){switch(n.type){case C.SPACE:continue;case C.NOTE:if(!n.a_ly)break;t.a_ly=n.a_ly,n.a_ly=null}break}continue}t.feathered_beam&&i(t)}}}function dupl_voice(){var e,t,n,r,i,s,o,u,a=voice_tb.length;for(o=0;o<a;o++){e=voice_tb[o],t=e.clone;if(!t)continue;e.clone=null;for(n=e.sym;n;n=n.next)if(n.time>=staves_found)break;t.clef=clone(e.clef),curvoice=t;for(;n;n=n.next){if(n.type==C.STAVES)continue;r=clone(n);if(n.notes){r.notes=[];for(u=0;u<=n.nhd;u++)r.notes.push(clone(n.notes[u]))}sym_link(r),t.second?r.second=!0:delete r.second,t.floating?r.floating=!0:delete r.floating,delete r.a_ly,i=r.extra;if(!i)continue;s=clone(i),r.extra=s,r=s,r.v=t.v,r.p_v=t,r.st=t.st;for(i=i.next;i;i=i.next){s=clone(i);if(i.notes){s.notes=[];for(u=0;u<=i.nhd;u++)s.notes.push(clone(i.notes[u]))}r.next=s,s.prev=r,r=s,r.v=t.v,r.p_v=t,r.st=t.st}}}}function new_syst(e){var t,n,r={voices:[],staves:[],top_voice:0};if(e){cur_sy=par_sy=r;return}for(n=0;n<voice_tb.length;n++){t=par_sy.voices[n].st;var i=par_sy.staves[t],s=voice_tb[n];s.staffnonote!=undefined&&(i.staffnonote=s.staffnonote),s.staffscale&&(i.staffscale=s.staffscale),r.voices[n]=clone(par_sy.voices[n]),r.voices[n].range=-1,delete r.voices[n].second}for(t=0;t<par_sy.staves.length;t++)r.staves[t]=clone(par_sy.staves[t]),r.staves[t].flags=0;par_sy.next=r,par_sy=r}function set_bar_num(){var e,t,n,r,i,s,o=cur_sy.top_voice,u=voice_tb[o].meter.wmeasure,a=gene.nbar;for(e=tsfirst;;e=e.ts_next){if(!e)return;switch(e.type){case C.METER:u=e.wmeasure;case C.CLEF:case C.KEY:case C.STBRK:continue;case C.BAR:if(e.bar_num){gene.nbar=e.bar_num;break}e.text&&!cfmt.contbarnb&&(e.text[0]=="1"?a=gene.nbar:(gene.nbar=a,e.bar_num=gene.nbar))}break}r=e.time+u;if(e.time==0)for(t=e.ts_next;t;t=t.ts_next)if(t.type==C.BAR&&t.time){t.time<r&&(e=t,r=e.time+u);break}i=gene.nbar;for(;e;e=e.ts_next)switch(e.type){case C.METER:u=e.wmeasure,e.time<r&&(r=e.time+u);break;case C.MREST:i+=e.nmes-1;while(e.ts_next&&e.ts_next.type!=C.BAR)e=e.ts_next;break;case C.BAR:e.bar_num&&(i=e.bar_num);if(e.time<r){e.text&&e.text[0]=="1"&&(a=i,s=r-e.time);break}n=e.time,t=e;do{if(t.dur)break;if(t.type==C.BAR&&t.text)break;t=t.next}while(t&&t.time==n);i++;if(t&&t.type==C.BAR&&t.text)if(t.text[0]=="1")s=0,a=i;else{cfmt.contbarnb||(i=a);if(s){cfmt.contbarnb&&i--,r=n+s;break}}e.bar_num=i,r=n+u;while(e.ts_next&&!e.ts_next.seqst)e=e.ts_next}cfmt.measurenb<0&&(gene.nbar=i)}function get_map(e){if(!e)return;var t,n,r,i,s,o,u=info_split(e,2);if(u.length<3){syntax(1,"Not enough parameters in %%map");return}o=u[1];if(o.indexOf("octave,")==0||o.indexOf("key,")==0)o=o.replace(/[,']+$/m,"").toLowerCase(),o[0]=="k"&&(o=o.replace(/[_=^]+/,""));else if(o[0]=="*"||o.indexOf("all")==0)o="all";else{s=new scanBuf,s.buffer=u[1],n=parse_acc_pit(s);if(!n){syntax(1,"Bad note in %%map");return}o=note2abc(n)}r=maps[u[0]],r||(maps[u[0]]=r={}),i=r[o],i||(r[o]=i=[]);if(!u[2])return;t=2;if(u[2].indexOf("=")<0){u[2][0]!="*"&&(s=new scanBuf,s.buffer=u[2],i[1]=parse_acc_pit(s));if(!u[3])return;t++,u[3].indexOf("=")<0&&(i[0]=u[3].split(","),t++)}for(;t<u.length;t++)switch(u[t]){case"heads=":i[0]=u[++t].split(",");break;case"print=":if(cfmt.sound=="play")break;s=new scanBuf,s.buffer=u[++t],i[1]=parse_acc_pit(s);break;case"color=":i[2]=u[++t]}}function set_transp(){var e,t,n;if(curvoice.ckey.k_bagpipe||curvoice.ckey.k_drum)return;cfmt.transp&&curvoice.transp&&syntax(0,"Mix of old and new transposition syntaxes"),t=(cfmt.transp||0)+(curvoice.transp||0)+(curvoice.shift||0),n=curvoice.vtransp||0;if(t==n)return;curvoice.vtransp=t,e=curvoice.last_sym;if(!e){curvoice.key=clone(curvoice.okey),key_transp(curvoice.key),curvoice.ckey=clone(curvoice.key),curvoice.key.k_none&&(curvoice.key.k_sf=0);return}for(;;){if(e.type==C.KEY)break;if(!e.prev){e=curvoice.key;break}e=e.prev}key_transp(e),curvoice.ckey=clone(e),curvoice.key.k_none&&(e.k_sf=0)}function set_ottava(e){if(cfmt.sound)return;switch(e){case"15ma(":curvoice.ottava=-14;break;case"8va(":curvoice.ottava=-7;break;case"8vb(":curvoice.ottava=7;break;case"15mb(":curvoice.ottava=14;break;case"15ma)":case"8va)":case"8vb)":case"15mb)":curvoice.ottava=0}}function do_pscom(e){var t,n,r,i,s,o,u,a,f=!1;e.slice(-5)==" lock"&&(f=!0,e=e.slice(0,-5).trim()),i=e.match(/(\w|-)+/);if(!i)return;i=i[0],s=e.replace(i,"").trim();switch(i){case"center":if(parse.state>=2){r=new_block("text"),r.text=cnv_escape(s),r.opt="c";return}write_text(cnv_escape(s),"c");return;case"clef":parse.state>=2&&(parse.state==2&&goto_tune(),r=new_clef(s),r&&get_clef(r));return;case"deco":deco_add(s);return;case"linebreak":set_linebreak(s);return;case"map":get_map(s);return;case"maxsysstaffsep":if(parse.state==3){par_sy.voices[curvoice.v].maxsep=get_unit(s);return}break;case"multicol":generate();switch(s){case"start":blk_out(),multicol={posy:posy,maxy:posy,lmarg:cfmt.leftmargin,rmarg:cfmt.rightmargin,state:parse.state};break;case"new":if(!multicol){syntax(1,"%%multicol new without start");break}posy>multicol.maxy&&(multicol.maxy=posy),cfmt.leftmargin=multicol.lmarg,cfmt.rightmargin=multicol.rmarg,img.chg=!0,set_page(),posy=multicol.posy;break;case"end":if(!multicol){syntax(1,"%%multicol end without start");break}posy<multicol.maxy&&(posy=multicol.maxy),cfmt.leftmargin=multicol.lmarg,cfmt.rightmargin=multicol.rmarg,multicol=undefined,blk_flush(),img.chg=!0,set_page();break;default:syntax(1,"Unknown keyword '$1' in %%multicol",s)}return;case"musicfont":musicfont=s;return;case"ottava":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}o=parseInt(s);if(isNaN(o)||o<-2||o>2){syntax(1,errs.bad_val,"%%ottava");return}switch(curvoice.ottava){case 14:a="15mb)";break;case 7:a="8vb)";break;case-7:a="8va)";break;case-14:a="15ma)"}a&&(a_dcn||(a_dcn=[]),a_dcn.push(a),set_ottava(a));switch(o){case-2:a="15mb(";break;case-1:a="8vb(";break;case 0:return;case 1:a="8va(";break;case 2:a="15ma("}a_dcn||(a_dcn=[]),a_dcn.push(a),set_ottava(a);return;case"repbra":parse.state>=2&&(parse.state==2&&goto_tune(),curvoice.norepbra=!get_bool(s));return;case"repeat":if(parse.state!=3)return;if(!curvoice.last_sym){syntax(1,"%%repeat cannot start a tune");return}if(!s.length)o=1,u=1;else{a=s.split(/\s+/),o=parseInt(a[0]),u=parseInt(a[1]);if(isNaN(o)||o<1||curvoice.last_sym.type==C.BAR&&o>2){syntax(1,"Incorrect 1st value in %%repeat");return}if(isNaN(u))u=1;else if(u<1){syntax(1,"Incorrect 2nd value in %%repeat");return}}parse.repeat_n=curvoice.last_sym.type==C.BAR?o:-o,parse.repeat_k=u;return;case"sep":var l,c,h,p;set_page(),p=img.width-img.lm-img.rm,t=l=c=0,s&&(h=s.split(/\s+/),t=get_unit(h[0]),h[1]&&(l=get_unit(h[1]),h[2]&&(c=get_unit(h[2])))),t<1&&(t=14),l<1&&(l=t),c<1&&(c=90);if(parse.state>=2){r=new_block(i),r.x=(p-c)/2/cfmt.scale,r.l=c/cfmt.scale,r.sk1=t,r.sk2=l;return}blk_out(),vskip(t),output+='<path class="stroke"\n d="M',out_sxsy((p-c)/2/cfmt.scale," ",0),output+="h"+(c/cfmt.scale).toFixed(2)+'"/>\n',vskip(l),blk_flush();return;case"setbarnb":n=parseInt(s),isNaN(n)?syntax(1,"Bad %%setbarnb value"):parse.state>=2?glovar.new_nbar=n:cfmt.measurefirst=n;return;case"staff":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}n=parseInt(s);if(isNaN(n)){syntax(1,"Bad %%staff value '$1'",s);return}var d;s[0]=="+"||s[0]=="-"?d=curvoice.cst+n:d=n-1;if(d<0||d>nstaff){syntax(1,"Bad %%staff number $1 (cur $2, max $3)",d,curvoice.cst,nstaff);return}delete curvoice.floating,curvoice.cst=d;return;case"staffbreak":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}r={type:C.STBRK,dur:0},s[0]>="0"&&s[0]<="9"?(r.xmx=get_unit(s),s.slice(-1)=="f"&&(r.stbrk_forced=!0)):(r.xmx=14,s[0]=="f"&&(r.stbrk_forced=!0)),sym_link(r);return;case"stafflines":case"staffscale":case"staffnonote":self.set_v_param(i,s);return;case"staves":case"score":if(parse.state==0)return;get_staves(i,s);return;case"sysstaffsep":if(parse.state==3){par_sy.voices[curvoice.v].sep=get_unit(s);return}break;case"text":if(parse.state>=2){r=new_block(i),r.text=cnv_escape(s),r.opt=cfmt.textoption;return}write_text(cnv_escape(s),cfmt.textoption);return;case"transpose":if(cfmt.sound)return;switch(parse.state){case 0:cfmt.transp=0;case 1:case 2:cfmt.transp=(cfmt.transp||0)+get_transp(s);return}for(r=curvoice.last_sym;r;r=r.prev){switch(r.type){case C.NOTE:r=clone(curvoice.okey),r.k_old_sf=curvoice.ckey.k_sf,sym_link(r);break;case C.KEY:break;default:continue}break}do_info("V",curvoice.id+" shift="+s);return;case"tune":return;case"user":set_user(s);return;case"voicecolor":if(parse.state!=3){if(parse.state!=2)return;goto_tune()}curvoice.color=s;return;case"vskip":n=get_unit(s);if(n<0){syntax(1,"%%vskip cannot be negative");return}if(parse.state>=2){r=new_block(i),r.sk=n;return}vskip(n);return;case"newpage":case"leftmargin":case"rightmargin":case"pagescale":case"pagewidth":case"printmargin":case"scale":case"staffwidth":if(parse.state==3){r=new_block(i),r.param=s;return}if(i=="newpage"){blk_flush(),block.newpage=!0;return}}self.set_format(i,s,f)}function do_begin_end(e,t,n){var r,i,s,o;switch(e){case"js":js_inject(n);break;case"ml":parse.state>=2?(o=new_block(e),o.text=n):(svg_flush(),user.img_out(n));break;case"svg":i=0;for(;;){r=n.indexOf('<style type="text/css">\n',i);if(r<0)break;i=n.indexOf("</style>",r);if(i<0){syntax(1,"No </style> in %%beginsvg sequence");break}style+=n.slice(r+23,i).replace(/\s+$/,"")}i=0;for(;;){r=n.indexOf("<defs>\n",i);if(r<0)break;i=n.indexOf("</defs>",r);if(i<0){syntax(1,"No </defs> in %%beginsvg sequence");break}defs_add(n.slice(r+6,i))}break;case"text":s=get_textopt(t),s||(s=cfmt.textoption);if(parse.state>=2){o=new_block(e),o.text=cnv_escape(n),o.opt=s;break}write_text(cnv_escape(n),s)}}function generate(){var e,t;vover&&(syntax(1,"No end of voice overlay"),get_vover(vover.bar?"|":")"));if(voice_tb.length==0)return;voice_adj(),dupl_voice(),sort_all();if(!tsfirst)return;self.set_bar_num();if(!tsfirst)return;user.get_abcmodel&&user.get_abcmodel(tsfirst,voice_tb,anno_type,info),user.img_out&&self.output_music();for(e=0;e<voice_tb.length;e++)t=voice_tb[e],t.time=0,t.sym=t.last_sym=null,t.st=cur_sy.voices[e].st,t.second=cur_sy.voices[e].second,delete t.have_ly,t.hy_st=0,delete t.bar_start,delete t.slur_st,delete t.s_tie,delete t.s_rtie;staves_found=0}function key_transp(e){var t=curvoice.vtransp/3|0,n=(t&-2)+(t&1)*7+e.k_sf;switch((curvoice.vtransp+210)%3){case 1:n=(n+4+48)%12-4;break;case 2:n=(n+7+48)%12-7;break;default:n=(n+5+48)%12-5}e.k_sf=n,e.k_delta=cgd2cde[(n+7)%7]}function set_k_acc(e){var t,n,r,i,s,o=[],u=[],a=[],f=[];if(e.k_sf>0)for(i=0;i<e.k_sf;i++)o[i]=1,u[i]=[26,23,27,24,21,25,22][i];else for(i=0;i<-e.k_sf;i++)o[i]=-1,u[i]=[22,25,21,24,20,23,26][i];r=e.k_a_acc.length;for(t=0;t<r;t++){s=e.k_a_acc[t];for(n=0;n<i;n++)if(u[n]==s.pit){o[n]=s.acc,s.micro_n&&(a[n]=s.micro_n,f[n]=s.micro_d);break}n==i&&(o[n]=s.acc,u[n]=s.pit,s.micro_n&&(a[n]=s.micro_n,f[n]=s.micro_d),i++)}for(t=0;t<i;t++)s=e.k_a_acc[t],s||(s=e.k_a_acc[t]={}),s.acc=o[t],s.pit=u[t],a[t]?(s.micro_n=a[t],s.micro_d=f[t]):(delete s.micro_n,delete s.micro_d)}function acc_same_pitch(e){var t,n,r=curvoice.last_sym.prev;if(!r)return;n=r.time;for(;r;r=r.prev)switch(r.type){case C.BAR:if(r.time<n)return;for(;;){r=r.prev;if(!r)return;if(r.type==C.NOTE){if(r.time+r.dur==n)break;return}if(r.time<n)return}for(t=0;t<=r.nhd;t++)if(r.notes[t].pit==e&&r.notes[t].ti1)return r.notes[t].acc;return;case C.NOTE:for(t=0;t<=r.nhd;t++)if(r.notes[t].pit==e)return r.notes[t].acc}return}function get_staves(e,t){var n,r,i,s,o,u,a,f,l,c=parse_staves(t);if(!c)return;voice_tb.length!=0&&(voice_adj(),dupl_voice());var h=0,p=!0;for(u=0;u<voice_tb.length;u++)r=voice_tb[u],r.time>h&&(h=r.time),r.sym&&(p=!1);if(p||h==0&&staves_found<0)for(u=0;u<par_sy.voices.length;u++)par_sy.voices[u].range=-1;else{for(u=0;u<par_sy.voices.length;u++)if(par_sy.voices[u].range>=0){curvoice=voice_tb[u];break}curvoice.time=h,n={type:C.STAVES,dur:0},sym_link(n),par_sy.nstaff=nstaff,new_syst(),n.sy=par_sy}staves_found=h;for(u=0;u<voice_tb.length;u++)r=voice_tb[u],delete r.second,delete r.ignore,delete r.floating;l=0;for(s=0;s<c.length;s++){a=c[s][0],r=new_voice(a),r.time=h,u=r.v,s==0&&(par_sy.top_voice=r.v);if(par_sy.voices[u].range>=0){i=clone(r),par_sy.voices[voice_tb.length]=clone(par_sy.voices[u]),u=voice_tb.length,i.v=u,i.sym=i.last_sym=null,i.time=h,voice_tb.push(i),delete i.clone;while(r.clone)r=r.clone;r.clone=i,r=i}c[s][0]=r,par_sy.voices[u].range=l++}if(e[1]=="t")for(s=0;s<c.length;s++){o=c[s][1];if(!(o&(OPEN_BRACE|OPEN_BRACE2)))continue;if((o&(OPEN_BRACE|CLOSE_BRACE))==(OPEN_BRACE|CLOSE_BRACE)||(o&(OPEN_BRACE2|CLOSE_BRACE2))==(OPEN_BRACE2|CLOSE_BRACE2))continue;if(c[s+1][1]!=0)continue;if(o&OPEN_PARENTH||c[s+2][1]&OPEN_PARENTH)continue;c[s+2][1]&(CLOSE_BRACE|CLOSE_BRACE2)?c[s+1][1]|=FL_VOICE:c[s+2][1]==0&&c[s+3][1]&(CLOSE_BRACE|CLOSE_BRACE2)&&(c[s][1]|=OPEN_PARENTH,c[s+1][1]|=CLOSE_PARENTH,c[s+2][1]|=OPEN_PARENTH,c[s+3][1]|=CLOSE_PARENTH)}f=-1;for(s=0;s<c.length;s++){o=c[s][1],(o&(OPEN_PARENTH|CLOSE_PARENTH))==(OPEN_PARENTH|CLOSE_PARENTH)&&(o&=~(OPEN_PARENTH|CLOSE_PARENTH),c[s][1]=o),r=c[s][0],o&FL_VOICE?(r.floating=!0,r.second=!0):(f++,par_sy.staves[f]||(par_sy.staves[f]={stafflines:"|||||",staffscale:1}),par_sy.staves[f].flags=0),u=r.v,r.st=r.cst=par_sy.voices[u].st=f,par_sy.staves[f].flags|=o;if(o&OPEN_PARENTH){i=r;while(s<c.length-1){r=c[++s][0],u=r.v,c[s][1]&MASTER_VOICE?(i.second=!0,i=r):r.second=!0,r.st=r.cst=par_sy.voices[u].st=f;if(c[s][1]&CLOSE_PARENTH)break}par_sy.staves[f].flags|=c[s][1]}}f<0&&(f=0),par_sy.nstaff=nstaff=f;if(e[1]=="c")for(f=0;f<nstaff;f++)par_sy.staves[f].flags^=STOP_BAR;for(u=0;u<voice_tb.length;u++){r=voice_tb[u];if(par_sy.voices[u].range<0){r.ignore=!0;continue}par_sy.voices[u].second=r.second,f=r.st,f>0&&!r.norepbra&&!(par_sy.staves[f-1].flags&STOP_BAR)&&(r.norepbra=!0)}curvoice=parse.state>=2?voice_tb[par_sy.top_voice]:null}function get_vover(e){function l(e){var t,n;for(t=0;t<voice_tb.length;t++){n=voice_tb[t];if(n.id==e)return n}return n=clone(curvoice),n.v=voice_tb.length,n.id=e,n.sym=n.last_sym=null,delete n.nm,delete n.snm,delete n.new_name,delete n.lyric_restart,delete n.lyric_cont,delete n.ly_a_h,delete n.sym_restart,delete n.sym_cont,delete n.have_ly,voice_tb.push(n),n}var t,n,r,i,s,o,u,a,f=parse.line;if(curvoice.ignore)return;if(e=="|"||e==")"){if(!curvoice.last_note){syntax(1,errs.nonote_vo);return}curvoice.last_note.beam_end=!0;if(!vover){syntax(1,"Erroneous end of voice overlay");return}curvoice.time!=vover.p_voice.time&&(syntax(1,"Wrong duration in voice overlay"),curvoice.time>vover.p_voice.time&&(vover.p_voice.time=curvoice.time)),curvoice=vover.p_voice,vover=null;return}if(e=="("){if(vover){syntax(1,"Voice overlay already started");return}vover={p_voice:curvoice,time:curvoice.time};return}if(!curvoice.last_note){syntax(1,errs.nonote_vo);return}curvoice.last_note.beam_end=!0,t=curvoice.voice_down;if(!t){t=l(curvoice.id+"o"),curvoice.voice_down=t,t.time=0,t.second=!0,u=t.v,par_sy.voices[u]={st:curvoice.st,second:!0};var c=curvoice.clone!=undefined?1:0;r=par_sy.voices[curvoice.v].range;for(o=0;o<par_sy.voices.length;o++)par_sy.voices[o].range>r&&(par_sy.voices[o].range+=c+1);par_sy.voices[u].range=r+1,c&&(n=l(t.id+"c"),n.second=!0,a=n.v,par_sy.voices[a]={second:!0,range:r+2},t.clone=n)}t.ulen=curvoice.ulen,t.dur_fact=curvoice.dur_fact,curvoice.uscale&&(t.uscale=curvoice.uscale);if(!vover){vover={bar:!0,p_voice:curvoice},s=t.time;for(i=curvoice.last_sym;;i=i.prev)if(i.type==C.BAR||i.time<=s)break;vover.time=i.time}else curvoice!=vover.p_voice&&curvoice.time!=vover.p_voice.time&&(syntax(1,"Wrong duration in voice overlay"),curvoice.time>vover.p_voice.time&&(vover.p_voice.time=curvoice.time));t.time=vover.time,curvoice=t}function is_voice_sig(){var e;if(!curvoice.sym)return!0;if(curvoice.time!=0)return!1;for(e=curvoice.last_sym;e;e=e.prev)if(w_tb[e.type]!=0)return!1;return!0}function get_clef(e){var t,n;if(is_voice_sig()){curvoice.clef=e;return}for(t=curvoice.last_sym;t&&t.prev&&t.time==curvoice.time;t=t.prev)if(w_tb[t.type]!=0)break;if(t&&t.prev&&t.time==curvoice.time&&(t.type==C.KEY&&!t.k_none||t.type==C.BAR)){for(n=t;n.prev;n=n.prev){switch(n.prev.type){case C.KEY:case C.BAR:continue}break}t=curvoice.last_sym,curvoice.last_sym=n.prev,sym_link(e),e.next=n,n.prev=e,curvoice.last_sym=t}else sym_link(e);e.clef_small=!0}function get_key(e){var t,n,r,i,s=new_key(e),o=s[0];s=s[1],o.k_sf&&!o.k_exp&&o.k_a_acc&&set_k_acc(o);switch(parse.state){case 1:o.k_sf==undefined&&!o.k_a_acc&&(o.k_sf=0,o.k_none=!0);for(t=0;t<voice_tb.length;t++)n=voice_tb[t],n.key=clone(o),n.okey=clone(o),n.ckey=clone(o);parse.ckey=o,s.length!=0&&memo_kv_parm("*",s),glovar.ulen||(glovar.ulen=C.BLEN/8),parse.state=2,set_page(),write_heading(),reset_gen(),gene.nbar=cfmt.measurefirst;return;case 2:goto_tune(!0)}s.length!=0&&set_kv_parm(s),!curvoice.ckey.k_bagpipe&&!curvoice.ckey.k_drum&&(i=(cfmt.transp||0)+(curvoice.transp||0)+(curvoice.shift||0));if(o.k_sf==undefined){if(!o.k_a_acc&&!i)return;o.k_sf=curvoice.okey.k_sf}curvoice.okey=clone(o),i&&(curvoice.vtransp=i,key_transp(o)),o.k_old_sf=curvoice.ckey.k_sf,curvoice.ckey=o;if(is_voice_sig()){curvoice.key=clone(o),o.k_none&&(curvoice.key.k_sf=0);return}r=curvoice.last_sym,r&&r.type==C.METER?(curvoice.last_sym=r.prev,curvoice.last_sym||(curvoice.sym=null),sym_link(o),o.next=r,r.prev=o,curvoice.last_sym=r):sym_link(o)}function new_voice(e){var t,n,r,i=voice_tb.length;if(i==1&&voice_tb[0].default){delete voice_tb[0].default;if(voice_tb[0].time==0)return t=voice_tb[0],t.id=e,cfmt.transp&&parse.state>=2&&(r=curvoice,curvoice=t,set_transp(),curvoice=r),t}for(n=0;n<i;n++){t=voice_tb[n];if(t.id==e)return t}return t={v:n,id:e,time:0,"new":!0,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,clef:{type:C.CLEF,clef_auto:!0,clef_type:"a",time:0},hy_st:0},voice_tb.push(t),par_sy.voices[n]={range:-1},t}function init_tune(){nstaff=-1,voice_tb=[],curvoice=null,new_syst(!0),staves_found=-1,gene={},a_de=[],od={}}function do_cloning(e){var t,n,r=parse.file,i=parse.eol+1,s=i;for(;;){n=r.indexOf("\n",s);if(n<0){n=0;break}if(/%.*|\n.*|.:.|\[.:/.test(r.slice(n+1,n+4)))break;s=n+1}include++,tosvg(parse.fname,r,i,n);for(t=0;t<e.length;t++)get_voice(e[t]),tosvg(parse.fname,r,i,n);include--}function get_voice(e){var t,n,r,i,s=info_split(e,1),o=s.shift();if(!o)return;o.indexOf(",")>0&&(i=o.split(","),o=i.shift());if(parse.state<2){s.length!=0&&memo_kv_parm(o,s),o!="*"&&parse.state==1&&new_voice(o);return}if(o=="*"){syntax(1,"Cannot have V:* in tune body");return}curvoice=new_voice(o),set_kv_parm(s),parse.state==2&&goto_tune(),set_transp(),t=curvoice.v,curvoice.new&&(delete curvoice.new,staves_found<0&&(curvoice.st=curvoice.cst=++nstaff,par_sy.nstaff=nstaff,par_sy.voices[t].st=nstaff,par_sy.voices[t].range=t,par_sy.staves[nstaff]={stafflines:curvoice.stafflines||"|||||",staffscale:1}),par_sy.voices[t].range<0&&staves_found>=0&&(curvoice.ignore=!0)),!curvoice.filtered&&!curvoice.ignore&&parse.voice_opts&&(curvoice.filtered=!0,voice_filter()),i&&do_cloning(i)}function goto_tune(e){var t,n,r={type:C.STAVES,dur:0,sy:par_sy};parse.state=3,voice_tb.length==0?(get_voice("1"),curvoice.clef.istart=curvoice.key.istart,curvoice.clef.iend=curvoice.key.iend,curvoice.default=!0):curvoice||(curvoice=voice_tb[staves_found<0?0:par_sy.top_voice]),!curvoice.init&&!e&&(set_kv_parm([]),set_transp());for(t=0;t<voice_tb.length;t++)n=voice_tb[t],n.ulen=glovar.ulen,n.ckey.k_bagpipe&&!n.pos.stm&&(n.pos=clone(n.pos),n.pos.stm=C.SL_BELOW);if(staves_found<0){nstaff=voice_tb.length-1;for(t=0;t<=nstaff;t++)n=voice_tb[t],delete n.new,n.st=n.cst=par_sy.voices[t].st=par_sy.voices[t].range=t,par_sy.staves[t]={stafflines:n.stafflines||"|||||",staffscale:1};par_sy.nstaff=nstaff}n=curvoice,curvoice=voice_tb[par_sy.top_voice],sym_link(r),curvoice=n}function get_sym(e,t){var n,r,i,s,o;if(curvoice.ignore)return;if(t){n=curvoice.sym_cont;if(!n){syntax(1,"+: symbol line without music");return}}else{curvoice.sym_restart?(curvoice.sym_start=n=curvoice.sym_restart,curvoice.sym_restart=null):n=curvoice.sym_start,n||(n=curvoice.sym);if(!n){syntax(1,"s: without music");return}}i=0;for(;;){while(e[i]==" "||e[i]==" ")i++;r=e[i];if(!r)break;switch(r){case"|":while(n&&n.type!=C.BAR)n=n.next;if(!n){syntax(1,"Not enough measure bars for symbol line");return}n=n.next,i++;continue;case"!":case'"':s=++i,i=e.indexOf(r,s);if(i<0){syntax(1,r=="!"?"No end of decoration":"No end of guitar chord"),i=e.length;continue}o=e.slice(s-1,i+1);break;case"*":break;default:o=r.charCodeAt(0);if(o<128){o=char_tb[o];if(o.length>1&&(o[0]=="!"||o[0]=='"')){r=o[0];break}}syntax(1,errs.bad_char,r)}while(n&&(n.type!=C.NOTE||n.grace))n=n.next;if(!n){syntax(1,"Too many elements in symbol line");return}switch(r){default:break;case"!":deco_cnv([o.slice(1,-1)],n,n.prev);break;case'"':a_gch=n.a_gch,parse_gchord(o),a_gch&&self.gch_build(n)}n=n.next,i++}curvoice.lyric_cont=n}function get_lyrics(e,t){var n,r,i,s,o,u;if(curvoice.ignore)return;curvoice.pos.voc!=C.SL_HIDDEN&&(curvoice.have_ly=!0);if(t){n=curvoice.lyric_cont;if(!n){syntax(1,"+: lyric without music");return}}else{set_font("vocal"),curvoice.lyric_restart?(curvoice.lyric_start=n=curvoice.lyric_restart,curvoice.lyric_restart=null,curvoice.lyric_line=0):(curvoice.lyric_line++,n=curvoice.lyric_start),n||(n=curvoice.sym);if(!n){syntax(1,"w: without music");return}}i=e,s=0;for(;;){while(i[s]==" "||i[s]==" ")s++;if(!i[s])break;o=parse.istart+s+2;switch(i[s]){case"|":while(n&&n.type!=C.BAR)n=n.next;if(!n){syntax(1,"Not enough measure bars for lyric line");return}n=n.next,s++;continue;case"-":r="-\n";break;case"_":r="_\n";break;case"*":r="";break;default:if(i[s]=="\\"&&s==i.length-1){curvoice.lyric_cont=n;return}r="";for(;;){if(!i[s])break;switch(i[s]){case"_":case"*":case"|":s--;case" ":case" ":break;case"~":r+=" ",s++;continue;case"-":r+="\n";break;case"\\":r+=i[++s],s++;continue;default:r+=i[s++];continue}break}}while(n&&(n.type!=C.NOTE||n.grace))n=n.next;if(!n){syntax(1,"Too many words in lyric line");return}r&&n.pos.voc!=C.SL_HIDDEN&&(r.match(/^\$\d/)&&(r[1]=="0"?set_font("vocal"):set_font("u"+r[1]),r=r.slice(2)),u={t:r,font:gene.curfont,w:strwh(r)[0],istart:o,iend:o+r.length},n.a_ly||(n.a_ly=[]),n.a_ly[curvoice.lyric_line]=u),n=n.next,s++}curvoice.lyric_cont=n}function ly_width(e,t){var n,r,i,s,o,u,a,f,l,c,h,p=e.a_ly;s=0;for(a=0;a<p.length;a++){n=p[a];if(!n)continue;h=n.t;if(h=="-\n"||h=="_\n"){n.shift=0;continue}u=n.w,i=n.font.swfac,o=u+2*cwid(" ")*i,e.type==C.GRACE?c=e.wl:h[0]>="0"&&h[0]<="9"&&h.length>2||h[1]==":"||h[0]=="("||h[0]==")"?(h[0]=="("?r=cwid("(")*i:(f=h.indexOf(" "),set_font(n.font),f>0?r=strwh(h.slice(0,f))[0]:r=u),c=(u-r+2*cwid(" ")*i)*.4,c>20&&(c=20),c+=r,n.t[0]>="0"&&n.t[0]<="9"&&c>s&&(s=c)):(c=o*.4,c>20&&(c=20)),n.shift=c,t<c&&(t=c),o-=c,c=2*cwid(" ")*i;for(l=e.next;l;l=l.next){switch(l.type){case C.NOTE:case C.REST:if(!l.a_ly||!l.a_ly[a]||l.a_ly[a].w==0)o-=9;else{if(l.a_ly[a].t!="-\n"&&l.a_ly[a].t!="_\n")break;o-=c}if(o<=0)break;continue;case C.CLEF:case C.METER:case C.KEY:o-=10;continue;default:o-=5}break}o>e.wr&&(e.wr=o)}if(s>0)for(a=0;a<p.length;a++)n=p[a],n&&n.t[0]>="0"&&n.t[0]<="9"&&(n.shift=s);return t}function draw_lyric_line(e,t,n){var r,i,s,o,u,a,f,l,c,h,p,d;e.hy_st&1<<t&&(l=!0,e.hy_st&=~(1<<t));for(o=e.sym;;o=o.next)if(o.type!=C.CLEF&&o.type!=C.KEY&&o.type!=C.METER)break;i=o.prev?o.prev.x:tsfirst.x,h=0;for(;o;o=o.next){o.a_ly?a=o.a_ly[t]:a=null;if(!a){switch(o.type){case C.REST:case C.MREST:c&&(out_wln(i+3,n,h-i),c=!1,i=o.x+o.wr)}continue}a.font!=gene.curfont&&(gene.curfont=p=a.font),r=a.t,s=a.w,d=a.shift,l&&(r=="_\n"?r="-\n":r!="-\n"&&(out_hyph(i,n,o.x-d-i),l=!1,i=o.x+o.wr)),c&&r!="_\n"&&(out_wln(i+3,n,h-i+3),c=!1,i=o.x+o.wr);if(r=="-\n"||r=="_\n"){h==0&&i>o.x-18&&(i=o.x-18),r[0]=="-"?l=!0:c=!0,h=o.x-d;continue}h=o.x-d,r.slice(-1)=="\n"&&(r=r.slice(0,-1),l=!0);if(user.anno_start||user.anno_stop)u={st:o.st,istart:a.istart,iend:a.iend,x:h,y:n,ymn:n,ymx:n+gene.curfont.size,wl:0,wr:s},anno_start(u,"lyrics");xy_str(h,n,r),anno_stop(u,"lyrics"),i=h+s}l&&(l=!1,h=realwidth-10,h<i+10&&(h=i+10),out_hyph(i,n,h-i),cfmt.hyphencont&&(e.hy_st|=1<<t));for(e.s_next;o;o=o.next)if(o.type==C.NOTE){if(!o.a_ly)break;a=o.a_ly[t],a&&a.t=="_\n"&&(c=!0,h=realwidth-15,h<i+12&&(h=i+12));break}c&&(out_wln(i+3,n,h-i+3),c=!1)}function draw_lyrics(e,t,n,r,i){var s,o,u=staff_tb[e.st].staffscale;set_font("vocal");if(i>0){r>-cfmt.vocalspace&&(r=-cfmt.vocalspace),r*=u;for(s=0;s<t;s++)r-=n[s]*1.1,draw_lyric_line(e,s,r);return(r-n[s-1]/6)/u}o=staff_tb[e.st].topbar+cfmt.vocalspace,r<o&&(r=o),r*=u;for(s=t;--s>=0;)draw_lyric_line(e,s,r),r+=n[s]*1.1;return r/u}function draw_all_lyrics(){var e,t,n,r,i,s,o,u,a,f,l=new Array(nstaff),c=voice_tb.length,h=new Array(c),p=new Array(c),d=new Array(c),v=new Array(c),m=0,g=0,y=-1;for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;e.st!=y&&(m=0,g=0,y=e.st),r=0;if(e.have_ly){h[n]||(h[n]=[]);for(t=e.sym;t;t=t.next){a=t.a_ly;if(!a)continue;s=t.x,u=10;for(i=0;i<a.length;i++){f=a[i];if(f&&f.w!=0){s-=f.shift,u=f.w;break}}o=y_get(e.st,1,s,u),m<o&&(m=o),o=y_get(e.st,0,s,u),g>o&&(g=o);while(r<a.length)h[n][r++]=0;for(i=0;i<a.length;i++){f=a[i];if(!f)continue;if(!h[n][i]||f.font.size>h[n][i])h[n][i]=f.font.size}}}else o=y_get(e.st,1,0,realwidth),m<o&&(m=o),o=y_get(e.st,0,0,realwidth),g>o&&(g=o);l[y]||(l[y]={}),l[y].top=m,l[y].bot=g,p[n]=r;if(r==0)continue;e.pos.voc?d[n]=e.pos.voc==C.SL_ABOVE:voice_tb[n+1]&&voice_tb[n+1].st==y&&voice_tb[n+1].have_ly?d[n]=!0:d[n]=!1,d[n]?l[y].a=!0:l[y].b=!0}i=0;for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;if(!e.have_ly)continue;if(d[n]){v[i++]=n;continue}y=e.st,set_dscale(y,!0),p[n]>0&&(l[y].bot=draw_lyrics(e,p[n],h[n],l[y].bot,1))}while(--i>=0)n=v[i],e=voice_tb[n],y=e.st,set_dscale(y,!0),l[y].top=draw_lyrics(e,p[n],h[n],l[y].top,-1);for(n=0;n<c;n++){e=voice_tb[n];if(!e.sym)continue;y=e.st;if(l[y].a){m=l[y].top+2;for(t=e.sym.next;t;t=t.next)t.a_ly&&y_set(y,1,t.x-2,10,m)}if(l[y].b){g=l[y].bot-2;if(p[e.v]>0)for(t=e.sym.next;t;t=t.next)t.a_ly&&y_set(y,0,t.x-2,10,g);else y_set(y,0,0,realwidth,g)}}}function parse_gchord(e){function h(){var e="";for(;;){t=n[o++];if("1234567890.-".indexOf(t)<0)return parseFloat(e);e+=t}}var t,n,r,i,s,e,o,u,a,f=get_font("annotation"),l=f.size,c=parse.line;u=parse.bol+c.index;if(e.length>1)n=e.slice(1,-1),a=u+1;else{n="";for(;;){t=c.next_char();if(!t){syntax(1,"No end of guitar chord");return}if(t=='"')break;t=="\\"&&(n+=t,t=c.next_char()),n+=t}a=parse.bol+c.index+1}if(curvoice.pos.gch==C.SL_HIDDEN)return;o=0,e="g";for(;;){t=n[o];if(!t)break;r={text:"",istart:u,iend:a,font:f};switch(t){case"@":e=t,o++,i=h(),t!=","?(syntax(1,"',' lacking in annotation '@x,y'"),s=0):(s=h(),t!=" "&&o--),r.x=i,r.y=s-l/2;break;case"^":case"_":case"<":case">":o++,e=t;break;default:switch(e){case"g":r.font=get_font("gchord");break;case"@":r.x=i,s-=l,r.y=s-l/2}}r.type=e;for(;;){t=n[o];if(!t)break;switch(t){case"\\":t=n[++o];if(!t||t=="n")break;r.text+="\\";default:r.text+=t,o++;continue;case"&":for(;;){r.text+=t,t=n[++o];switch(t){default:continue;case";":case undefined:case"\\":}break}if(t==";"){o++,r.text+=t;continue}break;case";":}o++;break}a_gch||(a_gch=[]),a_gch.push(r)}}function gch_tr1(e,t){var n,r,i,s,o,u,a,f,l,c,h=0;switch(e[0]){case"A":i=5;break;case"B":i=6;break;case"C":i=0;break;case"D":if(e[1]=="o"){h++,i=0;break}i=1;break;case"E":i=2;break;case"F":e[1]=="a"&&h++,i=3;break;case"G":i=4;break;case"L":h++,i=5;break;case"M":h++,i=2;break;case"R":h++,i=1;break;case"S":h++,e[1]=="o"?(h++,i=4):i=6;break;case"/":h--;break;default:return e}f=0,l=h+1;if(h>=0){while(e[l]=="#")f++,l++;while(e[l]=="b")f--,l++;o=cde2fcg[i]+t+f*7,u=cgd2cde[(o+112)%7],s=(((o+22)/7|0)+159)%5,n=(h?latin_names[u]:note_names[u])+acc_name[s]}else n="";return c=e.indexOf("/",l),c<0?n+e.slice(l):(i=note_names.indexOf(e[++c]),i<0?n+e.slice(l):(n+=e.slice(l,c),f=0,e[++c]=="#"?(f++,e[++c]=="#"&&(f++,c++)):e[c]=="b"&&(f--,e[++c]=="b"&&(f--,c++)),o=cde2fcg[i]+t+f*7,u=cgd2cde[(o+112)%7],s=(((o+22)/7|0)+159)%5,n+note_names[u]+acc_name[s]+e.slice(c)))}function gch_transp(e){var t,n,r,i=0,s=curvoice.ckey.k_sf-curvoice.okey.k_sf;for(;;){t=e.a_gch[i++];if(!t)return;if(t.type!="g")continue;n=t.text,r=n.indexOf(" "),r>=0&&(r++,n=n.slice(0,r)+gch_tr1(n.slice(r),s)),t.text=gch_tr1(n,s)}}function gch_build(e){var t,n,r,i,s=curvoice.pos.gch==C.SL_BELOW?-1:1,o=0,u=0,a=0,f=0,l=cfmt.gchordbox,c=.4;e.a_gch=a_gch,a_gch=null,curvoice.vtransp&&gch_transp(e);for(i=0;i<e.a_gch.length;i++){t=e.a_gch[i];if(t.type=="g")cfmt.chordnames&&(t.otext=t.text,t.text=t.text.replace(/A|B|C|D|E|F|G/g,function(e){return cfmt.chordnames[e]}),cfmt.chordnames.B=="H"&&(t.text=t.text.replace(/Hb/g,"Bb"))),t.text=t.text.replace(/##|#|=|bb|b/g,function(e){switch(e){case"##":return"x";case"#":return"♯";case"=":return"♮";case"b":return"♭"}return"bb"});else{t.text=cnv_escape(t.text);if(t.type=="@"&&!user.anno_start&&!user.anno_stop)continue}gene.curfont=t.font,n=strwh(t.text),t.w=n[0];switch(t.type){case"@":break;case"^":r=n[0]*c,r>8&&(r=8),t.x=-r,o-=n[1],t.y=o;break;case"_":r=n[0]*c,r>8&&(r=8),t.x=-r,u-=n[1],t.y=u;break;case"<":t.x=-(n[0]+6),a-=n[1],t.y=a+n[1]/2;break;case">":t.x=6,f-=n[1],t.y=f+n[1]/2;break;default:t.box=l,r=n[0]*c,r>8&&(r=8),t.x=-r,s<0?(u-=n[1],t.y=u,l&&(u-=2,t.y-=1)):(o-=n[1],t.y=o,l&&(o-=2,t.y-=1))}}a/=2,f/=2;for(i=0;i<e.a_gch.length;i++){t=e.a_gch[i];switch(t.type){case"^":t.y-=o;break;case"<":t.y-=a;break;case">":t.y-=f;break;case"g":s>0&&(t.y-=o)}}}function draw_gchord(e,t,n){var r,i,s,o,u,a,f,l,c,h,p,d=e.a_gch[0].w,v=y_get(e.st,1,e.x-2,d),m=y_get(e.st,0,e.x-2,d),g=e.dur?((e.notes[e.nhd].pit+e.notes[0].pit>>1)-18)*3:12;for(o=0;o<e.a_gch.length;o++){r=e.a_gch[o];if(r.type!="g")continue;i=r;if(r.y<0)break}i&&(i.y>=0?v<n&&(v=n):m>t&&(m=t)),set_dscale(e.st);for(o=0;o<e.a_gch.length;o++){r=e.a_gch[o],use_font(r.font),set_font(r.font),p=r.font.size,d=r.w,u=e.x+r.x,s=r.text;switch(r.type){case"_":a=r.y+m,y_set(e.st,0,u,d,a-p*.2-2);break;case"^":a=r.y+v,y_set(e.st,1,u,d,a+p*.8+2);break;case"<":e.notes[0].acc&&(u-=e.notes[0].shac),a=r.y+g-p/2;break;case">":e.xmx&&(u+=e.xmx),e.dots&&(u+=1.5+3.5*e.dots),a=r.y+g-p/2;break;default:h=r.box?3:2,r.y>=0?(a=r.y+v,y_set(e.st,!0,u,d,a+p+h)):(a=r.y+m,y_set(e.st,!1,u,d,a-h)),l=s.indexOf(" ");if(l>=0){u=realwidth;for(var y=e.next;y;y=y.next){switch(y.type){default:continue;case C.NOTE:case C.REST:case C.BAR:u=y.x}break}c=2;for(;;){l=s.indexOf(" ",l+1);if(l<0)break;c++}var b=(u-e.x)/c;u=e.x,a*=staff_tb[e.st].staffscale,user.anno_start&&user.anno_start("gchord",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e),l=0,c=l;for(;;){l=s.indexOf(" ",c);if(l<0)break;xy_str(u,a,s.slice(c,l),"c"),u+=b,c=l+1}xy_str(u,a,s.slice(c),"c"),user.anno_stop&&user.anno_stop("gchord",r.istart,r.iend,e.x-2,a+p+2,d+4,p+4,e);continue}break;case"@":a=r.y+g,a>0?(f=a+p,f>staff_tb[e.st].ann_top&&(staff_tb[e.st].ann_top=f)):a<staff_tb[e.st].ann_bot&&(staff_tb[e.st].ann_bot=a)}user.anno_start&&user.anno_start("annot",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e),r.box?xy_str_b(u,a,s):xy_str(u,a,s),user.anno_stop&&user.anno_stop("annot",r.istart,r.iend,u-2,a+p+2,d+4,p+4,e)}}function psdeco(){return!1}function psxygl(){return!1}function set_hooks(){function n(e){for(var t=0;t<e.length;t++)e[t](self)}var e=abc2svg.modules.hooks,t=abc2svg.modules.g_hooks;hook_init?e.length&&(n(e),t.push.apply(t,e),abc2svg.modules.hooks=[]):(e.length&&(t.push.apply(t,e),abc2svg.modules.hooks=[]),n(t),hook_init=!0)}var C=abc2svg.C,require=empty_function,system=empty_function,write=empty_function,XMLHttpRequest=empty_function,OPEN_BRACE=1,CLOSE_BRACE=2,OPEN_BRACKET=4,CLOSE_BRACKET=8,OPEN_PARENTH=16,CLOSE_PARENTH=32,STOP_BAR=64,FL_VOICE=128,OPEN_BRACE2=256,CLOSE_BRACE2=512,OPEN_BRACKET2=1024,CLOSE_BRACKET2=2048,MASTER_VOICE=4096,IN=96,CM=37.8,YSTEP=256,errs={bad_char:"Bad character '$1'",bad_val:"Bad value in $1",bar_grace:"Cannot have a bar in grace notes",ignored:"$1: inside tune - ignored",misplaced:"Misplaced '$1' in %%staves",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_enough_n:"Not enough notes/rests for %%repeat",not_enough_m:"Not enough measures for %%repeat",not_ascii:"Not an ASCII character"},self=this,glovar={meter:{type:C.METER,wmeasure:1,a_meter:[]}},info={},mac={},maci=new Int8Array(128),parse={ctx:{},prefix:"%",state:0,line:new scanBuf},psvg,dd_tb={},a_de,od,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 12 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:"3 wedge 8 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 12 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 0 0","trill)":"3 ltr 8 0 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 20 0 0","ped-up":"4 pedoff 20 0 0","crescendo(":"7 cresc 18 0 0","crescendo)":"7 cresc 18 0 0","<(":"7 cresc 18 0 0","<)":"7 cresc 18 0 0","diminuendo(":"7 dim 18 0 0","diminuendo)":"7 dim 18 0 0",">(":"7 dim 18 0 0",">)":"7 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"},f_near=[!0,!0,!0],f_note=[!1,!1,!1,!0,!0,!0,!1,!1,!0],f_staff=[!1,!1,!1,!1,!1,!1,!0,!0],func_tb=[d_near,d_slide,d_arp,d_upstaff,d_upstaff,d_trill,d_pf,d_cresc],ottava={"8va(":1,"8va)":1,"15ma(":1,"15ma)":1,"8vb(":1,"8vb)":1,"15mb(":1,"15mb)":1},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_SLOPE=.4,BEAM_STUB=8,SLUR_SLOPE=.5,GSTEM=15,GSTEM_XOFF=2.3,cache,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]],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]),rest_tb=["r128","r64","r32","r16","r8","r4","r2","r1","r0","r00"],musicfont='url("data:application/x-font-ttf;base64,AAEAAAAOAIAAAwBgRkZUTYGVv6sAAEzkAAAAHEdERUYAFQAUAABMyAAAABxPUy8yWJ9bEgAAAWgAAABWY21hcONO1KwAAAOkAAADImN2dCAAIgKIAAAGyAAAAARnYXNw//8AAwAATMAAAAAIZ2x5Zp7WR84AAAfAAAA9LGhlYW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QHdW5pRTRFNQd1bmlFNEU2B3VuaUU0RTcHdW5pRTRFOAd1bmlFNEU5B3VuaUU0RUEHdW5pRTRFRQd1bmlFNTAwB3VuaUU1MDEHdW5pRTUyMAd1bmlFNTIxB3VuaUU1MjIHdW5pRTUyNAd1bmlFNTI1B3VuaUU1MjkHdW5pRTUyQQd1bmlFNTJCB3VuaUU1MkMHdW5pRTUyRAd1bmlFNTJGB3VuaUU1MzAHdW5pRTUzMQd1bmlFNTM5B3VuaUU1NjYHdW5pRTU2Nwd1bmlFNTY5B3VuaUU1NkMHdW5pRTU2RAd1bmlFNTgyB3VuaUU1RDAHdW5pRTVFMgd1bmlFNjEwB3VuaUU2MTIHdW5pRTYxNAd1bmlFNjE4B3VuaUU2MjQHdW5pRTYzMAd1bmlFNjUwB3VuaUU2NTUHdW5pRTkxMAd1bmlFOTExB3VuaUU5MTIHdW5pRTkxNAd1bmlFOTE1B3VuaUU5MTgHdW5pRTkyMAd1bmlFOTI1B3VuaUU5NUQHdW5pRUEwMgd1bmlFQUE0AAAAAAH//wACAAEAAAAAAAAADAAUAAQAAAACAAAAAQAAAAEAAAAAAAEAAAAA1+feHQAAAADRlyIXAAAAANgWv3Y=")',defined_font={},font_tb={},fid=1,font_scale_tb={serif:1.05,serifBold:1.05,"sans-serif":1.1,"sans-serifBold":1.1,Palatino:1.1,Mono:1.35},fmt_lock={},cfmt={aligncomposer:1,breaklimit:.7,breakoneoln:!0,cancelkey:!0,composerspace:6,dblrepbar:":][:",decoerr:!0,dynalign:!0,fullsvg:"",gracespace:new Float32Array([4,8,11]),graceslurs:!0,hyphencont:!0,indent:0,infoname:'R "Rhythm: "\nB "Book: "\nS "Source: "\nD "Discography: "\nN "Notes: "\nZ "Transcription: "\nH "History: "',infospace:0,keywarn:!0,leftmargin:1.4*CM,lineskipfac:1.1,linewarn:!0,maxshrink:.65,maxstaffsep:2e3,maxsysstaffsep:2e3,measurefirst:1,measurenb:-1,musicspace:6,parskipfac:.4,partsspace:8,pagewidth:21*CM,printmargin:0,rightmargin:1.4*CM,rbdbstop:!0,rbmax:4,rbmin:2,scale:1,slurheight:1,staffsep:46,stemheight:21,stretchlast:.25,stretchstaff:!0,subtitlespace:3,sysstaffsep:34,textspace:14,titlespace:6,titletrim:!0,topspace:22,tuplets:[0,0,0,0],vocalspace:10,writefields:"CMOPQsTWw",wordsspace:5},textopt={align:"j",center:"c",fill:"f",justify:"j",ragged:"f",right:"r",skip:"s"},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};Abc.prototype.style_font=style_font;var 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:"þ"},oct_acc={1:"♯",2:"♭",3:"♮",4:"x",5:"bb"},include=0;Abc.prototype.tosvg=tosvg;var gene,staff_tb,nstaff,tsnext,realwidth,insert_meter,spf_last,space_tb=new Float32Array([7,10,14.15,20,28.3,40,56.6,80,100,120]),smallest_duration,dx_tb=new Float32Array([10,10,11,13,13]),hw_tb=new Float32Array([4.5,5,6,7,8]),w_note=new Float32Array([3.5,3.7,5,6,7]),delta_tb={t:-4,c:0,b:4,p:-6},rest_sp=[[18,18],[12,18],[12,12],[0,12],[6,8],[10,10],[6,4],[10,0],[10,4],[10,10]],delpit=[0,-7,-14,0],MAXPIT=96,blocks=[],a_gch,a_dcn,multicol,maps={},qplet_tb=new Int8Array([0,1,3,2,3,0,2,0,3,0]),ntb="CDEFGABcdefgab",note_pit=new Int8Array([0,2,4,5,7,9,11]),reg_dur=/(\d*)(\/*)(\d*)/g,cde2fcg=new Int8Array([0,2,4,-1,1,3,5]),cgd2cde=new Int8Array([0,4,1,5,2,6,3]),acc2=new Int8Array([-2,-1,3,1,2]),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],cw_tb=new Float32Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,.25,.333,.408,.5,.5,.833,.778,.333,.333,.333,.5,.564,.25,.564,.25,.278,.5,.5,.5,.5,.5,.5,.5,.5,.5,.5,.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,.5,.333,.444,.5,.444,.5,.444,.333,.5,.5,.278,.278,.5,.278,.778,.5,.5,.5,.5,.333,.389,.278,.5,.5,.722,.5,.5,.444,.48,.2,.48,.541,.5]),info_font_init={A:"info",C:"composer",O:"composer",P:"parts",Q:"tempo",R:"info",T:"title",X:"title"},output="",style="\n.fill {fill: currentColor}\n.stroke {stroke: currentColor; fill: none}\n.music text, .music tspan {fill:currentColor}",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:0,g:0},block={},tgls={brace:{x:0,y:0,c:""},hl:{x:-4,y:0,c:""},hl1:{x:-6,y:0,c:""},hl2:{x:-6,y:0,c:""},ghl:{x:-4,y:0,c:""},lphr:{x:0,y:24,c:""},mphr:{x:0,y:24,c:""},sphr:{x:0,y:27,c:""},rdots:{x:-1,y:0,c:""},dsgn:{x:-4,y:-4,c:""},dcap:{x:-4,y:-4,c:""},sgno:{x:-6,y:0,c:""},coda:{x:-12,y:-6,c:""},tclef:{x:-8,y:0,c:""},cclef:{x:-8,y:0,c:""},bclef:{x:-8,y:0,c:""},pclef:{x:-6,y:0,c:""},spclef:{x:-6,y:0,c:""},stclef:{x:-8,y:0,c:""},scclef:{x:-8,y:0,c:""},sbclef:{x:-7,y:0,c:""},oct:{x:0,y:2,c:""},HDD:{x:-7,y:0,c:""},breve:{x:-6,y:0,c:""},HD:{x:-5.2,y:0,c:""},Hd:{x:-3.8,y:0,c:""},hd:{x:-3.7,y:0,c:""},ghd:{x:2,y:0,c:"",sc:.66},pshhd:{x:-3.7,y:0,c:""},pfthd:{x:-3.7,y:0,c:""},x:{x:-3.7,y:0,c:""},"circle-x":{x:-3.7,y:0,c:""},srep:{x:-5,y:0,c:""},diamond:{x:-4,y:0,c:""},triangle:{x:-4,y:0,c:""},dot:{x:-2,y:0,c:""},"acc-1":{x:-3,y:0,c:""},acc3:{x:-2,y:0,c:""},acc1:{x:-3,y:0,c:""},acc2:{x:-3,y:0,c:""},"acc-2":{x:-3,y:0,c:""},"acc-1_1_4":{x:-3,y:0,c:""},"acc-1_3_4":{x:-4,y:0,c:""},acc1_1_4:{x:-2,y:0,c:""},acc1_3_4:{x:-4,y:0,c:""},accent:{x:-3,y:0,c:""},stc:{x:-1,y:-2,c:""},emb:{x:-4,y:-2,c:""},wedge:{x:-1,y:0,c:""},marcato:{x:-3,y:0,c:""},hld:{x:-7,y:0,c:""},brth:{x:0,y:0,c:""},r00:{x:-1.5,y:0,c:""},r0:{x:-1.5,y:0,c:""},r1:{x:-3.5,y:-6,c:""},r2:{x:-3.2,y:0,c:""},r4:{x:-3,y:0,c:""},r8:{x:-3,y:0,c:""},r16:{x:-4,y:0,c:""},r32:{x:-4,y:0,c:""},r64:{x:-4,y:0,c:""},r128:{x:-4,y:0,c:""},mrest:{x:-10,y:0,c:""},mrep:{x:-6,y:0,c:""},mrep2:{x:-9,y:0,c:""},p:{x:-4,y:-6,c:""},f:{x:-4,y:-6,c:""},pppp:{x:-4,y:-6,c:""},ppp:{x:-4,y:-6,c:""},pp:{x:-4,y:-6,c:""},mp:{x:-4,y:-6,c:""},mf:{x:-4,y:-6,c:""},ff:{x:-4,y:-6,c:""},fff:{x:-4,y:-6,c:""},ffff:{x:-4,y:-6,c:""},sfz:{x:-4,y:-6,c:""},trl:{x:-4,y:-4,c:""},turn:{x:-5,y:-4,c:""},turnx:{x:-5,y:-4,c:""},umrd:{x:-7,y:-2,c:""},lmrd:{x:-7,y:-2,c:""},dplus:{x:-4,y:10,c:""},sld:{x:-8,y:12,c:""},grm:{x:-2,y:0,c:""},dnb:{x:-4,y:0,c:""},upb:{x:-3,y:0,c:""},opend:{x:-2,y:0,c:""},roll:{x:0,y:0,c:""},thumb:{x:0,y:0,c:""},snap:{x:-2,y:0,c:""},ped:{x:-10,y:0,c:""},pedoff:{x:-5,y:0,c:""},longa:{x:-6,y:0,c:""},custos:{x:-4,y:3,c:""},ltr:{x:2,y:6,c:""}},glyphs={},mgls={" ":" ",0:"",1:"",2:"",3:"",4:"",5:"",6:"",7:"",8:"",9:"",C:"","+":"","(":"",")":"",o:"",c:"",".":"","|":""},anno_type=["bar","clef","custos","","grace","key","meter","Zrest","note","part","rest","yspace","staves","Break","tempo","","block","remark"],anno_start=user.anno_start?a_start:empty_function,anno_stop=user.anno_stop?a_stop:empty_function;Abc.prototype.out_svg=function(e){output+=e},Abc.prototype.sx=sx,Abc.prototype.sy=sy,Abc.prototype.sh=function(e){return stv_g.st<0?e/stv_g.scale:e},Abc.prototype.ax=function(e){return e+posx},Abc.prototype.ay=function(e){return stv_g.st<0?posy-e:posy+(stv_g.dy-e)*stv_g.scale-stv_g.dy},Abc.prototype.ah=function(e){return stv_g.st<0?e:e*stv_g.scale},Abc.prototype.out_sxsy=out_sxsy,Abc.prototype.xypath=xypath;var 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"}},deco_val_tb={arp:out_arp,cresc:out_cresc,dim:out_dim,ltr:out_ltr,"8va":out_8va,"8vb":out_8vb,"15ma":out_15ma,"15mb":out_15mb},deco_l_tb={glisq:out_glisq,gliss:out_gliss};Abc.prototype.blk_out=blk_out,Abc.prototype.blk_flush=blk_flush;var par_sy,cur_sy,voice_tb,curvoice,staves_found,vover,tsfirst,w_tb=new Uint8Array([2,1,8,0,3,5,6,9,9,0,9,3,0,7,0,0,0,0]),note_names="CDEFGAB",latin_names=["Do","Re","Mi","Fa","Sol","La","Si"],acc_name=["bb","b","","#","##"];font_init(),init_tune(),Abc.prototype.add_style=function(e){style+=e},Abc.prototype.calculate_beam=calculate_beam,Abc.prototype.cfmt=function(){return cfmt},Abc.prototype.clone=clone,Abc.prototype.deco_cnv=deco_cnv,Abc.prototype.do_pscom=do_pscom,Abc.prototype.do_begin_end=do_begin_end,Abc.prototype.draw_gchord=draw_gchord,Abc.prototype.draw_note=draw_note,Abc.prototype.draw_symbols=draw_symbols,Abc.prototype.errs=errs,Abc.prototype.font_class=font_class,Abc.prototype.gch_build=gch_build,Abc.prototype.gch_tr1=gch_tr1,Abc.prototype.get_a_gch=function(){return a_gch},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_fname=function(){return parse.fname},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)return block.newpage=!1,!0},Abc.prototype.get_posy=function(){var e=posy;return posy=0,e},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_voice_tb=function(){return voice_tb},Abc.prototype.goto_tune=goto_tune,Abc.prototype.info=function(){return info},Abc.prototype.new_note=new_note,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.output_music=output_music,Abc.prototype.param_set_font=param_set_font,Abc.prototype.parse=parse,Abc.prototype.psdeco=psdeco,Abc.prototype.psxygl=psxygl,Abc.prototype.set_bar_num=set_bar_num,Abc.prototype.set_cur_sy=function(e){cur_sy=e},Abc.prototype.set_dscale=set_dscale,Abc.prototype.set_font=set_font,Abc.prototype.set_format=set_format,Abc.prototype.set_pitch=set_pitch,Abc.prototype.set_scale=set_scale,Abc.prototype.set_stem_dir=set_stem_dir,Abc.prototype.set_stems=set_stems,Abc.prototype.set_sym_glue=set_sym_glue,Abc.prototype.set_tsfirst=function(e){tsfirst=e},Abc.prototype.set_vp=set_vp,Abc.prototype.set_v_param=set_v_param,Abc.prototype.set_width=set_width,Abc.prototype.set_xhtml=function(e){var t=write_text;return write_text=e,t},Abc.prototype.sort_pitch=sort_pitch,Abc.prototype.strwh=strwh,Abc.prototype.stv_g=function(){return stv_g},Abc.prototype.svg_flush=svg_flush,Abc.prototype.syntax=syntax,Abc.prototype.unlksym=unlksym,Abc.prototype.use_font=use_font,Abc.prototype.xy_str=xy_str,Abc.prototype.xygl=xygl;var hook_init}};var Abc=abc2svg.Abc;typeof module=="object"&&typeof exports=="object"&&(exports.abc2svg=abc2svg,exports.Abc=Abc),abc2svg.loadjs=function(e,t,n){n&&n()},abc2svg.modules={ambitus:{fn:"ambitus-1.js"},beginps:{fn:"psvg-1.js"},"break":{fn:"break-1.js"},capo:{fn:"capo-1.js"},clip:{fn:"clip-1.js"},voicecombine:{fn:"combine-1.js"},diagram:{fn:"diag-1.js"},equalbars:{fn:"equalbars-1.js"},grid:{fn:"grid-1.js"},grid2:{fn:"grid2-1.js"},MIDI:{fn:"MIDI-1.js"},percmap:{fn:"perc-1.js"},soloffs:{fn:"soloffs-1.js"},sth:{fn:"sth-1.js"},temperament:{fn:"temper-1.js"},nreq:0,hooks:[],g_hooks:[],load:function(e,t,n){function r(){return typeof user=="object"&&user.errmsg?user.errmsg:typeof printErr=="function"?printErr:typeof alert=="function"?function(e){alert(e)}:typeof console=="object"?console.log:function(){}}var i,s,o=this.nreq,u=e.match(/(^|\n)(%%|I:).+?\b/g);if(!u)return!0;this.cbf=t||function(){},this.errmsg=n||r();for(var a=0;a<u.length;a++){i=abc2svg.modules[u[a].replace(/\n?(%%|I:)/,"")];if(!i||i.loaded)continue;i.loaded=!0,this.nreq++,abc2svg.loadjs(i.fn,function(){--abc2svg.modules.nreq==0&&abc2svg.modules.cbf()},function(){abc2svg.modules.errmsg("error loading "+i.fn),--abc2svg.modules.nreq==0&&abc2svg.modules.cbf()})}return this.nreq==o}},abc2svg.version="1.18.2",abc2svg.vdate="2018-11-18",abc2svg.MIDI={do_midi:function(e){function r(e){var r=Number(e);if(isNaN(r))return;return e=(r/12|0)*7-19,r%=12,e+=t[r],note={pit:e},n[r]&&(note.acc=n[r]),note}function i(e){var t=e.match(/^([_^=]*)([A-Ga-g])([,']*)$/);if(!t)return;return e.match(/[A-Z]/)&&(e=e.toLowerCase(),e.indexOf("'")>0?e=e.replace("'",""):e+=","),e}var t=new Int8Array([0,0,1,2,2,3,3,4,5,5,6,6]),n=new Int8Array([0,1,0,-1,0,0,1,0,-1,0,-1,0]),s,o,u=this.get_maps(),a=e.split(/\s+/);switch(a[1]){case"channel":if(a[2]!="10")break;this.set_v_param("midictl","0 1");break;case"drummap":if(this.cfmt().sound!="play")break;s=i(a[2]),o=r(a[3]);if(!s||!o){this.syntax(1,this.errs.bad_val,"%%MIDI drummap");break}u.MIDIdrum||(u.MIDIdrum={}),u.MIDIdrum[s]=[null,o],this.set_v_param("mididrum","MIDIdrum");break;case"program":a[3]!=undefined?o=a[3]:o=a[2],o=parseInt(o);if(isNaN(o)||o<0||o>128){this.syntax(1,"Bad program in %%MIDI");return}this.set_v_param("instr",o);break;case"control":s=parseInt(a[2]);if(isNaN(s)||s<0||s>127){this.syntax(1,"Bad controller number in %%MIDI");return}o=parseInt(a[3]);if(isNaN(o)||o<0||o>127){this.syntax(1,"Bad controller value in %%MIDI");return}this.set_v_param("midictl",a[2]+" "+a[3])}},set_midi:function(e){var t,n,r=this.get_curvoice();for(t=0;t<e.length;t++)switch(e[t]){case"instr=":r.instr=e[t+1];break;case"midictl=":r.midictl||(r.midictl={}),n=e[t+1].split(" "),r.midictl[n[0]]=Number(n[1]);break;case"mididrum=":r.map||(r.map={}),r.map=e[t+1]}},do_pscom:function(e,t){t.slice(0,5)=="MIDI "?abc2svg.MIDI.do_midi.call(this,t):e(t)},set_vp:function(e,t){abc2svg.MIDI.set_midi.call(this,t),e(t)},set_hooks:function(e){e.do_pscom=abc2svg.MIDI.do_pscom.bind(e,e.do_pscom),e.set_vp=abc2svg.MIDI.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.MIDI.set_hooks),abc2svg.modules.MIDI.loaded=!0,abc2svg.combine={comb_v:function(){function t(t){var n,r=t.ts_next;return!r||r.type!=e.NOTE&&r.type!=e.REST?!1:r.v==t.v||r.st!=t.st||r.time!=t.time||r.dur!=t.dur?!1:t.combine<=0&&r.type!=t.type?!1:t.a_gch&&r.a_gch?!1:t.type==e.REST?t.type==r.type&&t.invis&&!r.invis?!1:!0:r.a_ly||r.sl1||r.sl2||r.slur_start||r.slur_end?!1:r.beam_st!=t.beam_st||r.beam_end!=t.beam_end?!1:(n=r.nhd,t.combine<=1&&t.notes[0].pit<=r.notes[n].pit+1?!1:!0)}function n(t,n){var r,i,s;t.notes=t.notes.concat(n.notes),t.nhd=r=t.notes.length-1,this.sort_pitch(t);if(t.combine>=3){for(s=r;s>0;s--)t.notes[s].pit==t.notes[s-1].pit&&t.notes[s].acc==t.notes[s-1].acc&&t.notes.splice(s,1);t.nhd=r=t.notes.length-1}t.ymx=3*(t.notes[r].pit-18)+4,t.ymn=3*(t.notes[0].pit-18)-4,i=t.notes[0].ti1,(i&15)==e.SL_AUTO&&(t.notes[0].ti1=e.SL_BELOW|i&~e.SL_DOTTED),i=t.notes[r].ti1,(i&15)==e.SL_AUTO&&(t.notes[r].ti1=e.SL_ABOVE|i&~e.SL_DOTTED)}function r(r){var i,s,o,u;for(;;){s=r.nhd,i=r.ts_next,o=i.nhd,r.type!=i.type?i.type!=e.REST&&(i=r,r=i.ts_next):r.type==e.REST?r.invis&&!i.invis&&delete r.invis:n.call(this,r,i),i.a_gch&&(r.a_gch=i.a_gch),i.a_dd&&(r.a_dd?r.a_dd=r.a_dd.concat(i.a_dd):r.a_dd=i.a_dd),this.unlksym(i);if(r.in_tuplet||!t.call(this,r))break}}var e=abc2svg.C,i,s,o,u,a;for(i=this.get_tsfirst();i;i=i.ts_next){switch(i.type){case e.REST:if(i.combine==undefined||i.combine<0)continue;t.call(this,i)&&r.call(this,i);continue;default:continue;case e.NOTE:if(i.combine==undefined||i.combine<=0)continue}if(!i.beam_st)continue;if(i.beam_end){t.call(this,i)&&r.call(this,i);continue}s=i;for(;;){if(!t.call(this,s)){s=null;break}if(s.beam_end)break;do s=s.next;while(s.type!=e.NOTE&&s.type!=e.REST)}if(!s)continue;s=i;for(;;){r.call(this,s);if(s.beam_end)break;do s=s.next;while(s.type!=e.NOTE&&s.type!=e.REST)}}},do_pscom:function(e,t){t.slice(0,13)=="voicecombine "?this.set_v_param("combine",t.split(/[ \t]/)[1]):e(t)},new_note:function(e,t,n){var r=this.get_curvoice(),i=e(t,n);return i&&i.notes&&r.combine!=undefined&&(i.combine=r.combine),i},set_stem_dir:function(e){e(),abc2svg.combine.comb_v.call(this)},set_vp:function(e,t){var n,r=this.get_curvoice();for(n=0;n<t.length;n++)if(t[n]=="combine="){r.combine=t[n+1];break}e(t)},set_hooks:function(e){e.do_pscom=abc2svg.combine.do_pscom.bind(e,e.do_pscom),e.new_note=abc2svg.combine.new_note.bind(e,e.new_note),e.set_stem_dir=abc2svg.combine.set_stem_dir.bind(e,e.set_stem_dir),e.set_vp=abc2svg.combine.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.combine.set_hooks),abc2svg.modules.voicecombine.loaded=!0,abc2svg.diag={do_diag:function(){var e=this.get_glyphs(),t=this.get_voice_tb();if(!e.fb){var n,r,i,s=this.get_decos();ns="CDEFGAB",ms=["","m","7","m7","maj7","sus4"],this.add_style("\n.diag {font:6px sans-serif}\n.frn {font:italic 7px sans-serif}");for(n=0;n<ns.length;n++)for(r=0;r<ms.length;r++)i=ns[n]+ms[r],s[i]="3 "+i+" 40 0 0";for(r=0;r<ms.length;r++)i="F♯"+ms[r],s[i]="3 F#"+ms[r]+" 40 0 0";e.fb='<g id="fb">\n<path class="stroke" stroke-width="0.4" d="M-10 -34h20m0 6h-20m0 6h20m0 6h-20m0 6h20"/>\n<path class="stroke" stroke-width="0.5" d="M-10 -34v24m4 0v-24m4 0v24m4 0v-24m4 0v24m4 0v-24"/>\n</g>',e.nut='<path id="nut" class="stroke" stroke-width="1.6" d="M-10.2 -34.5h20.4"/>',e.barre='<path id="barre" class="stroke" stroke-width=".9" d="M-10.2 -31h20.4"/>',e.fr1='<text id="fr1" x="-20" y="-29" class="frn">fr1</text>',e.fr2='<text id="fr2" x="-20" y="-29" class="frn">fr2</text>',e.fr3='<text id="fr3" x="-20" y="-29" class="frn">fr3</text>',e.ddot='<circle id="ddot" class="fill" r="1.5"/>',e.C='<g id="C">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-3,4" y="-36" class="diag">321</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Cm='<g id="Cm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">342</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.C7='<g id="C7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0,4" y="-36" class="diag">3241</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Cm7='<g id="Cm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,4" y="-36" class="diag">x32</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.Cmaj7='<g id="Cmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,-4" y="-36" class="diag">x21</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Csus4='<g id="Csus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x34</text>\n<use x="6" y="-13" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n</g>',e.D='<g id="D">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x132</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Dm='<g id="Dm">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x231</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n</g>',e.D7='<g id="D7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4,8" y="-36" class="diag">x312</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Dm7='<g id="Dm7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx211</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.Dmaj7='<g id="Dmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx123</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Dsus4='<g id="Dsus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,0,4,8" y="-36" class="diag">xx123</text>\n<use x="10" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.E='<g id="E">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">231</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-31" xlink:href="#ddot"/>\n</g>',e.Em='<g id="Em">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">23</text>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.E7='<g id="E7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">21</text>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Em7='<g id="Em7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">1</text>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Emaj7='<g id="Emaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">312</text>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-31" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Esus4='<g id="Esus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">12</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.F='<g id="F">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">342</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.Fm='<g id="Fm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.F7='<g id="F7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">32</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fm7='<g id="Fm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fmaj7='<g id="Fmaj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">423</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Fsus4='<g id="Fsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr1"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e["F#"]='<g id="F#">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">342</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e["F#m"]='<g id="F#m">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#7"]='<g id="F#7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,0" y="-36" class="diag">32</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#m7"]='<g id="F#m7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#maj7"]='<g id="F#maj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4,0" y="-36" class="diag">423</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e["F#sus4"]='<g id="F#sus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.G='<g id="G">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">234</text>\n<use x="10" y="-19" xlink:href="#ddot"/>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n</g>',e.Gm='<g id="Gm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-8,-4" y="-36" class="diag">34</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.G7='<g id="G7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">321</text>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="10" y="-31" xlink:href="#ddot"/>\n</g>',e.Gm7='<g id="Gm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-8" y="-36" class="diag">3</text>\n<use x="-6" y="-19" xlink:href="#ddot"/>\n</g>',e.Gmaj7='<g id="Gmaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,8" y="-36" class="diag">312</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="-10" y="-19" xlink:href="#ddot"/>\n</g>',e.Gsus4='<g id="Gsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr3"/>\n<use xlink:href="#fb"/>\n<text x="-4,0" y="-36" class="diag">34</text>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.A='<g id="A">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">234</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Am='<g id="Am">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">231</text>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n<use x="6" y="-31" xlink:href="#ddot"/>\n</g>',e.A7='<g id="A7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,4" y="-36" class="diag">23</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Am7='<g id="Am7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-4,4" y="-36" class="diag">21</text>\n<use x="6" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Amaj7='<g id="Amaj7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,0,4" y="-36" class="diag">x213</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-31" xlink:href="#ddot"/>\n<use x="-2" y="-25" xlink:href="#ddot"/>\n</g>',e.Asus4='<g id="Asus4">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x12</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>',e.B='<g id="B">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">234</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.Bm='<g id="Bm">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-4,0,4" y="-36" class="diag">341</text>\n<use x="6" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-19" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.B7='<g id="B7">\n<use xlink:href="#nut"/>\n<use xlink:href="#fb"/>\n<text x="-12,-8,-4,0,8" y="-36" class="diag">x2134</text>\n<use x="10" y="-25" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-6" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-31" xlink:href="#ddot"/>\n</g>',e.Bm7='<g id="Bm7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,8" y="-36" class="diag">x32</text>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n<use x="6" y="-25" xlink:href="#ddot"/>\n</g>',e.Bmaj7='<g id="Bmaj7">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,-4,0,4" y="-36" class="diag">x324</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n<use x="-2" y="-19" xlink:href="#ddot"/>\n</g>',e.Bsus4='<g id="Bsus4">\n<use xlink:href="#barre"/>\n<use xlink:href="#fr2"/>\n<use xlink:href="#fb"/>\n<text x="-12,0,4" y="-36" class="diag">x34</text>\n<use x="6" y="-19" xlink:href="#ddot"/>\n<use x="2" y="-25" xlink:href="#ddot"/>\n</g>'}var o,n,u,a;for(o=t[0].sym;o;o=o.next){if(!o.a_gch)continue;for(n=0;n<o.a_gch.length;n++){u=o.a_gch[n];if(!u||u.type!="g"||u.capo)continue;a=u.otext||u.text,this.deco_cnv(a.split(/[ \t/]/,1),o,null)}}},output_music:function(e){this.cfmt().diag&&abc2svg.diag.do_diag.call(this),e()},set_fmt:function(e,t,n,r){if(t=="diagram"){this.cfmt().diag=n;return}e(t,n,r)},set_hooks:function(e){e.output_music=abc2svg.diag.output_music.bind(e,e.output_music),e.set_format=abc2svg.diag.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.diag.set_hooks),abc2svg.modules.diagram.loaded=!0,abc2svg.grid={do_grid:function(){function a(t){var n=e.BLEN/4;return!t.a_meter[0]||t.a_meter[0].top[0]=="C"||!t.a_meter[0].bot?n:(n=e.BLEN/t.a_meter[0].bot[0]|0,t.a_meter[0].bot[0]==8&&t.a_meter[0].top[0]%3==0&&(n=e.BLEN/8*3),n)}function f(e,t,n,a){function C(){var t,n,r="-";for(t=0;t<e.length;t++){n=e[t],n[0]||(n[0]=r);if(n.length==0)continue;if(n.length==1){r=n[0];continue}if(n.length==2){n[2]=n[1],r=n[2];continue}if(n.length==3){r=n[2];continue}n[2]||(n[2]=n[1]||n[0]),r=n[3]}}var f,l,c,h,p,d,v,m,g,y,b,w,E,S="",x="",T=[],N=u.n;C();if(!u.ls)T=e;else{v=t,t=[];for(f=0;f<u.ls.length;f++){h=u.ls[f],h.indexOf("-")<0?h=[h,h]:h=h.split("-");for(c=h[0]-1;c<h[1];c++){if(!e[c])break;T.push(e[c]),t.push(v[c])}}}N<0&&(N=-N),N<3&&(N=T.length%6==0?6:8),N>T.length&&(N=T.length),p=(T.length+N-1)/N|0,g=n.size*2,a<g*1.4&&(a=g*1.4),m=a*N,m>r.width&&(N/=2,p*=2,m/=2),d='<svg xmlns="http://www.w3.org/2000/svg" version="1.1"\n xmlns:xlink="http://www.w3.org/1999/xlink"\n color="black" width="'+r.width.toFixed(0)+'px" height="'+(g*p+6).toFixed(0)+'px"',f=o.bgcolor,f&&(d+=' style="background-color: '+f+'"'),d+='>\n<style type="text/css">\n.mid {text-anchor:middle}\n',o.fullsvg&&(d+=".stroke {stroke: currentColor; fill: none}\n."+i+" {"+this.style_font(n.name+"."+n.size)+"}\n"),d+="</style>\n",d+='<path class="stroke" d="\n',y=(r.width-m)/2,w=1;for(l=0;l<=p;l++)d+="M"+y.toFixed(2)+" "+w.toFixed(2)+"h"+m.toFixed(2)+"\n",w+=g;b=y;for(f=0;f<=N;f++)d+="M"+b.toFixed(2)+" 1v"+(g*p).toFixed(2)+"\n",b+=a;d+='"/>\n',w=1-g/2+n.size*.3,E=1;for(f=0;f<T.length;f++)S=T[f],f%N==0&&(w+=g,E+=g,b=y+a/2),S.length>1?(d+='<path class="stroke" stroke-width="1" d="M'+(b-a/2).toFixed(2)+" "+E.toFixed(2)+"l"+a.toFixed(2)+" -"+g.toFixed(2)+'"/>\n',S[1]?(d+='<path class="stroke" stroke-width="1" d="M'+(b-a/2).toFixed(2)+" "+(E-g).toFixed(2)+"l"+(a/2).toFixed(2)+" "+(g/2).toFixed(2)+'"/>\n',d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b-a/3).toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[0]+"</text>\n",d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+b.toFixed(2)+'" y="'+(w-g/3).toFixed(2)+'">'+S[1]+"</text>\n"):d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b-a*.2).toFixed(2)+'" y="'+(w-g/4).toFixed(2)+'">'+S[0]+"</text>\n",S.length>=3&&(S[3]?(d+='<path class="stroke" stroke-width="1" d="M'+b.toFixed(2)+" "+(E-g/2).toFixed(2)+"l"+(a/2).toFixed(2)+" "+(g/2).toFixed(2)+'"/>\n',d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+b.toFixed(2)+'" y="'+(w+g/3).toFixed(2)+'">'+S[2]+"</text>\n",d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b+a/3).toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[3]+"</text>\n"):d+='<text class="'+s+'" style="font-size:'+(n.size*.72).toFixed(2)+'" x="'+(b+a*.2).toFixed(2)+'" y="'+(w+g/4).toFixed(2)+'">'+S[2]+"</text>\n")):d+='<text class="'+s+'" x="'+b.toFixed(2)+'" y="'+w.toFixed(2)+'">'+S[0]+"</text>\n",b+=a;w=1-g/2+n.size*.3,b=y;for(f=0;f<t.length;f++)v=t[f],v[0]==":"&&(d+='<text class="'+s+'" x="'+(b-5).toFixed(2)+'" y="'+w.toFixed(2)+'" style="font-weight:bold;font-size:'+(n.size+2).toFixed(2)+'">:</text>\n'),f%N==0&&(w+=g,b=y),v[v.length-1]==":"&&(d+='<text class="'+s+'" x="'+(b+5).toFixed(2)+'" y="'+w.toFixed(2)+'" style="font-weight:bold;font-size:'+(n.size+2).toFixed(2)+'">:</text>\n'),b+=a;return d+"</svg>"}var e=abc2svg.C,t=this.get_tsfirst(),n=this.get_voice_tb(),r,i,s,o=this.cfmt(),u=o.grid,l,c,h,p,d,v,m,g,y,b,w,E,S,x=[],T=[],N=[];r=this.get_img(),c=a(n[0].meter),y=n[0].meter.wmeasure,o.gridfont||this.param_set_font("gridfont","serif 16"),g=this.get_font("grid"),i=this.font_class(g),s=i+" mid",this.set_font("grid"),h=d=m=E=0,x.push("|");for(l=n[0].sym;l;l=l.next){while(l.time>h)d<3&&d++,h+=c;switch(l.type){case e.NOTE:case e.REST:if(l.a_gch)for(p=0;p<l.a_gch.length;p++)if(l.a_gch[p].type=="g"){N[d]||(N[d]=l.a_gch[p].text,w=this.strwh(N[d])[0],w>E&&(E=w),m++);break}break;case e.BAR:b=u.norep?"|":l.bar_type;if(l.time<y)N.length?(T.push(N),x.push(b)):x[0]=b;else{if(!l.bar_num)break;T.push(N),x.push(b)}N=[],h=l.time,d=0,b.indexOf(":")&&(S=!0);break;case e.METER:c=a(l),y=l.wmeasure}}if(m==0)return;N.length!=0&&(x.push(""),T.push(N)),E+=this.strwh(S?" ":" ")[0],v=n[this.get_top_v()],l={type:e.BLOCK,subtype:"ml",dur:0,time:0,p_v:v,v:v.v,text:f.call(this,T,x,g,E)};if(o.grid.n<0){for(var C=t;C.ts_next;C=C.ts_next);l.time=C.time,l.prev=v.last_sym,l.ts_prev=C,v.last_sym.next=l,C.ts_next=l}else l.time=0,l.next=v.sym,l.ts_next=t,t.ts_prev=l,t=l,this.set_tsfirst(l),v.sym.prev=l,v.sym=l},output_music:function(e){this.cfmt().grid&&abc2svg.grid.do_grid.call(this),e()},set_fmt:function(e,t,n,r){if(t=="grid"){n||(n="1"),n=n.split(/\s+/);var i=this.cfmt().grid={n:Number(n.shift())};isNaN(i.n)&&(i.n=1);while(n.length){var s=n.shift();s=="norepeat"?i.norep=!0:s.slice(0,8)=="include="&&(i.ls=s.slice(8).split(","))}return}e(t,n,r)},set_hooks:function(e){e.output_music=abc2svg.grid.output_music.bind(e,e.output_music),e.set_format=abc2svg.grid.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.grid.set_hooks),abc2svg.modules.grid.loaded=!0,abc2svg.equalbars={output_music:function(e){this.equalbars_d=0,e()},set_fmt:function(e,t,n,r){t=="equalbars"?this.cfmt().equalbars=this.get_bool(n):e(t,n,r)},set_sym_glue:function(e,t){var n=abc2svg.C,r,i,s,o,u,a,l,c,h,p=[],v=this.get_tsfirst();e(t);if(!this.cfmt().equalbars)return;for(i=v;i;i=i.ts_next){if(!i.seqst)continue;switch(i.type){default:continue;case n.BAR:case n.GRACE:case n.MREST:case n.NOTE:case n.REST:case n.SPACE:}break}if(!i)return;r=i.ts_next,h=c=r.time;for(;;){if(!r.ts_next){p.push([r,r.time-c]),c=r.time,r.dur&&(c+=r.dur);break}r.type==n.BAR&&r.seqst&&(p.push([r,r.time-c]),c=r.time),r=r.ts_next}u=p.length;if(u==0)return;a=i.type==n.GRACE?i.extra.x:i.x,d=this.equalbars_d,d||(d=this.equalbars_d=a),s=(t-d)/(c-h);for(o=0;o<u;o++){r=p[o][0],f=s*p[o][1]/(r.x-a);for(;i!=r;i=i.ts_next)if(i.type==n.GRACE)for(l=i.extra;l;l=l.next)l.x=d+(l.x-a)*f;else i.x&&(i.x=d+(i.x-a)*f);d+=s*p[o][1],a=i.x;for(;;){i.x=d,i=i.ts_next;if(!i||i.seqst)break}if(!i)break}},set_hooks:function(e){e.output_music=abc2svg.equalbars.output_music.bind(e,e.output_music),e.set_format=abc2svg.equalbars.set_fmt.bind(e,e.set_format),e.set_sym_glue=abc2svg.equalbars.set_sym_glue.bind(e,e.set_sym_glue)}},abc2svg.modules.hooks.push(abc2svg.equalbars.set_hooks),abc2svg.modules.equalbars.loaded=!0,abc2svg.perc={do_perc:function(e){function i(e){var i,s,o,u=Number(e);if(isNaN(u)){o=e.match(/^([_^=]*)([A-Ga-g])([,']*)$/);if(o){i="CDEFGABcdefgab".indexOf(o[2])+16;switch(o[3]){case"'":i+=7*o[3].length;break;case",":i-=7*o[3].length}note={pit:i};switch(o[1]){case"^":note.acc=1;break;case"_":note.acc=-1}return note}e=e.toLowerCase(e),o=e[0],i=0;for(;;){s=e.indexOf("-",i);if(s<0)break;i=s+1,o+="-"+e[i]}u=r[o];if(!u)switch(e[0]){case"c":switch(e[1]){case"a":u=r.ca;break;case"l":u=r.cl;break;case"o":u=r.co}break;case"h":case"l":i=e.indexOf("-");if(e[i+1]!="t")break;switch(e[1]){case"i":case"o":u=r[o+e[1]]}}}if(!u)return;return e=(u/12|0)*7-19,u%=12,e+=t[u],note={pit:e},n[u]&&(note.acc=n[u]),note}function s(e){var t=e.match(/^([_^]*)([A-Ga-g])([,']*)$/);if(!t)return;return e.match(/[A-Z]/)&&(e=e.toLowerCase(),e.indexOf("'")>0?e=e.replace("'",""):e+=","),e}var t=new Int8Array([0,0,1,2,2,3,3,4,5,5,6,6]),n=new Int8Array([0,1,0,-1,0,0,1,0,-1,0,-1,0]),r={"a-b-d":35,"a-s":38,"b-d-1":36,ca:69,cl:75,co:56,"c-c":52,"c-c-1":49,"c-c-2":57,"c-h-h":42,"e-s":40,"h-a":67,"h-b":60,"h-c":39,"h-f-t":43,"h-m-t":48,"h-ti":65,"h-to":50,"h-w-b":76,"l-a":68,"l-b":61,"l-c":64,"l-f-t":41,"l-g":74,"l-m-t":47,"l-ti":66,"l-to":45,"l-w":72,"l-w-b":77,m:70,"m-c":78,"m-h-c":62,"m-t":80,"o-c":79,"o-h-c":63,"o-h-h":46,"o-t":81,"p-h-h":44,"r-b":53,"r-c-1":51,"r-c-2":59,"s-c":55,"s-g":73,"s-s":37,"s-w":71,t:54,v:58},o,u,a=this.get_maps(),f=e.split(/\s+/);o=s(f[1]);if(!o){this.syntax(1,this.errs.bad_val,"%%percmap");return}if(this.cfmt().sound!="play"){if(!f[3])return;a.MIDIdrum||(a.MIDIdrum={}),u=i(o);if(!u){this.syntax(1,this.errs.bad_val,"%%percmap");return}delete u.acc,a.MIDIdrum[o]=[[f[3]],u]}else{u=i(f[2]);if(!u){this.syntax(1,this.errs.bad_val,"%%percmap");return}a.MIDIdrum||(a.MIDIdrum={}),a.MIDIdrum[o]=[null,u]}this.set_v_param("perc","MIDIdrum")},set_perc:function(e){var t,n,r=this.get_curvoice();for(t=0;t<e.length;t++)switch(e[t]){case"perc=":r.map||(r.map={}),r.map=e[t+1],r.midictl||(r.midictl={}),r.midictl[0]=1}},do_pscom:function(e,t){t.slice(0,8)=="percmap "?abc2svg.perc.do_perc.call(this,t):e(t)},set_vp:function(e,t){abc2svg.perc.set_perc.call(this,t),e(t)},set_hooks:function(e){e.do_pscom=abc2svg.perc.do_pscom.bind(e,e.do_pscom),e.set_vp=abc2svg.perc.set_vp.bind(e,e.set_vp)}},abc2svg.modules.hooks.push(abc2svg.perc.set_hooks),abc2svg.modules.percmap.loaded=!0,abc2svg.ambitus={do_ambitus:function(){var e=abc2svg.C,t,n,r,i,s,o=this.get_voice_tb();for(n=0;n<o.length;n++){r=o[n];if(r.second)continue;i=100,s=-100;for(t=r.sym;t;t=t.next){if(t.type!=e.NOTE)continue;t.notes[t.nhd].pit>s&&(s=t.notes[t.nhd].pit),t.notes[0].pit<i&&(i=t.notes[0].pit)}if(i==100)continue;t=r.clef,t.stem=1,t.head=e.FULL,t.stemless=!0,t.nhd=1,t.notes=[{dur:e.BLEN/4,pit:i,shhd:0},{dur:e.BLEN/4,pit:s,shhd:0}]}},draw_symbols:function(e,t){var n=this.get_staff_tb(),r=t.sym;r.clef_type!=undefined&&r.nhd>0&&(r.x-=26,this.set_scale(r),this.draw_note(r),r.notes[1].pit-r.notes[0].pit>4&&(this.xypath(r.x,3*(r.notes[1].pit-18)+n[r.st].y),this.out_svg("v"+((r.notes[1].pit-r.notes[0].pit)*3).toFixed(2)+'" stroke-width=".6"/>\n')),r.x+=26,t.clef.nhd=0),e(t)},set_pitch:function(e,t){e(t),!t&&this.cfmt().ambitus&&abc2svg.ambitus.do_ambitus.call(this)},set_fmt:function(e,t,n,r){if(t=="ambitus"){this.cfmt().ambitus=n;return}e(t,n,r)},set_width:function(e,t){t.clef_type!=undefined&&t.nhd>0?(t.wl=40,t.wr=12):e(t)},set_hooks:function(e){e.draw_symbols=abc2svg.ambitus.draw_symbols.bind(e,e.draw_symbols),e.set_pitch=abc2svg.ambitus.set_pitch.bind(e,e.set_pitch),e.set_format=abc2svg.ambitus.set_fmt.bind(e,e.set_format),e.set_width=abc2svg.ambitus.set_width.bind(e,e.set_width)}},abc2svg.modules.hooks.push(abc2svg.ambitus.set_hooks),abc2svg.modules.ambitus.loaded=!0,abc2svg.break={get_break:function(e){var t=abc2svg.C,r,i,s,o,u=e.split(/[ ,]/),a=this.cfmt();a.break||(a.break=[]);for(n=1;n<u.length;n++){r=u[n],i=r.match(/(\d+)([a-z]?)(:\d+\/\d+)?/);if(!i){this.syntax(1,this.errs.bad_val,"%%break");continue}i[2]&&(o=i[2].charCodeAt(0)-97);if(!i[3]){a.break.push({m:i[1],t:0,sq:o});continue}s=i[3].match(/:(\d+)\/(\d+)/);if(!s||s[2]<1){this.syntax(1,"Bad denominator in %%break");continue}a.break.push({m:i[1],t:s[1]*t.BLEN/s[2],sq:o})}},do_break:function(){var e,t,n,r,i,o=this.get_voice_tb();v=this.get_cur_sy().top_voice,s1=o[v].sym,cfmt=this.cfmt();for(e=0;e<cfmt.break.length;e++){r=cfmt.break[e],t=r.m;for(s=s1;s;s=s.next)if(s.bar_num==t)break;if(!s)continue;if(r.sq){i=r.sq;for(s=s.ts_next;s;s=s.ts_next)if(s.bar_num==t&&--i==0)break;if(!s)continue}n=r.t;if(n){n=s.time+n;for(;s;s=s.next)if(s.time>=n)break;if(!s)continue;s=s.prev}s.eoln=!0}},do_pscom:function(e,t){t.slice(0,6)=="break "?abc2svg.break.get_break.call(this,t):e(t)},set_bar_num:function(e){e(),this.cfmt().break&&abc2svg.break.do_break.call(this)},set_hooks:function(e){e.do_pscom=abc2svg.break.do_pscom.bind(e,e.do_pscom),e.set_bar_num=abc2svg.break.set_bar_num.bind(e,e.set_bar_num)}},abc2svg.modules.hooks.push(abc2svg.break.set_hooks),abc2svg.modules.break.loaded=!0,abc2svg.capo={gch_capo:function(e){var t,n,r,i=this.cfmt(),s=i.capo,o=0;for(;;){t=e[o++];if(!t)return;if(t.type=="g")break}n=Object.create(t),n.capo=!1,n.text=this.gch_tr1(n.text,[0,5,-2,3,-4,1,-6,-1,4,-3,2,-5][s%12]),this.capo_first||(this.capo_first=!0,n.text+=" (capo: "+s.toString()+")"),n.font=this.get_font(i.capofont?"capo":"annotation"),e.splice(o,0,n),t.capo=!0},gch_build:function(e,t){var n=this.get_a_gch();this.cfmt().capo&&n&&abc2svg.capo.gch_capo.call(this,n),e(t)},output_music:function(e){this.capo_first=!1,e()},set_fmt:function(e,t,n,r){if(t=="capo"){this.cfmt().capo=n;return}e(t,n,r)},set_hooks:function(e){e.gch_build=abc2svg.capo.gch_build.bind(e,e.gch_build),e.output_music=abc2svg.capo.output_music.bind(e,e.output_music),e.set_format=abc2svg.capo.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.capo.set_hooks),abc2svg.modules.capo.loaded=!0,abc2svg.clip={get_clip:function(e){function n(e){var n,r,i,s=e.match(/(\d+)([a-z]?)(:\d+\/\d+)?/);if(!s)return;s[2]&&(i=s[2].charCodeAt(0)-97);if(!s[3])return{m:s[1],t:0,sq:i};e=s[3].match(/:(\d+)\/(\d+)/);if(!e||e[2]<1)return;return{m:s[1],t:e[1]*t.BLEN/e[2],sq:i}}var t=abc2svg.C,r,i,s=e.split(/[ -]/);if(s.length!=3){this.syntax(1,this.errs.bad_val,"%%clip");return}s[1]?r=n(s[1]):r={m:0,t:0},i=n(s[2]);if(!r||!i){this.syntax(1,this.errs.bad_val,"%%clip");return}this.cfmt().clip=[r,i]},do_clip:function(){function t(t,n){var r,i,s;if(n.m<=1){if(n.m==1){for(r=t;r;r=r.ts_next)if(r.type==e.BAR&&r.time!=0)break;r.time<voice_tb[this.get_cur_sy().top_voice].meter.wmeasure&&(t=r)}}else{for(;t;t=t.ts_next)if(t.type==e.BAR&&t.bar_num>=n.m)break;if(!t)return;if(n.sq){s=n.sq;for(t=t.ts_next;t;t=t.ts_next)if(t.type==e.BAR&&t.bar_num==n.m&&--s==0)break;if(!t)return}}if(n.t==0)return t;i=t.time+n.t;while(t.time<i){t=t.ts_next;if(!t)return t}do t=t.ts_prev;while(!t.seqst);return t}var e=abc2svg.C;voice_tb=this.get_voice_tb(),cfmt=this.cfmt();var n,r,i,s,o;n=this.get_tsfirst();if(cfmt.clip[0].m>0||cfmt.clip[0].t>0){n=t(n,cfmt.clip[0]);if(!n){this.set_tsfirst(null);return}i=this.get_cur_sy();for(r=this.get_tsfirst();r!=n;r=r.ts_next)switch(r.type){case e.CLEF:r.p_v.clef=r;break;case e.KEY:r.p_v.key=this.clone(r.as.u.key);break;case e.METER:r.p_v.meter=this.clone(r.as.u.meter);break;case e.STAVES:i=r.sy,this.set_cur_sy(i)}for(o=0;o<voice_tb.length;o++){s=voice_tb[o];for(r=n;r;r=r.ts_next)if(r.v==o){delete r.prev;break}s.sym=r}this.set_tsfirst(n),delete n.ts_prev}n=t(n,cfmt.clip[1]);if(!n)return;do{n=n.ts_next;if(!n)return}while(!n.seqst);for(o=0;o<voice_tb.length;o++){s=voice_tb[o];for(r=n.ts_prev;r;r=r.ts_prev)if(r.v==o){delete r.next;break}r||(s.sym=null)}delete n.ts_prev.ts_next},do_pscom:function(e,t){t.slice(0,5)=="clip "?abc2svg.clip.get_clip.call(this,t):e(t)},set_bar_num:function(e){e(),this.cfmt().clip&&abc2svg.clip.do_clip.call(this)},set_hooks:function(e){e.do_pscom=abc2svg.clip.do_pscom.bind(e,e.do_pscom),e.set_bar_num=abc2svg.clip.set_bar_num.bind(e,e.set_bar_num)}},abc2svg.modules.hooks.push(abc2svg.clip.set_hooks),abc2svg.modules.clip.loaded=!0,abc2svg.grid2={do_grid:function(){var e,t,n,r=this.get_voice_tb();for(t=0;t<r.length;t++){n=r[t];if(!n.grid2)continue;n.clef.invis=!0,n.key.k_sf=n.key.k_a_acc=0,n.staffnonote=2;for(e=n.sym;e;e=e.next)e.dur&&(e.invis=!0,delete e.sl1,e.ti1=0)}},draw_chosym:function(e){var t,n;this.set_dscale(e.st);for(t=0;t<e.a_gch.length;t++){n=e.a_gch[t];if(n.type!="g")continue;this.use_font(n.font),this.set_font(n.font),this.xy_str(e.x+n.x,n.y+6,n.text)}},draw_gchord:function(e,t,n,r){t.p_v.grid2?abc2svg.grid2.draw_chosym.call(this,t):e(t,n,r)},output_music:function(e){abc2svg.grid2.do_grid.call(this),e()},set_fmt:function(e,t,n,r){if(t=="grid2"){var i=this.get_curvoice();i&&(this.set_v_param("stafflines","..."),i.grid2=n);return}e(t,n,r)},set_hooks:function(e){e.draw_gchord=abc2svg.grid2.draw_gchord.bind(e,e.draw_gchord),e.output_music=abc2svg.grid2.output_music.bind(e,e.output_music),e.set_format=abc2svg.grid2.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.grid2.set_hooks),abc2svg.modules.grid2.loaded=!0,abc2svg.psvg={do_begin_end:function(e,t,n,r){if(t!="ps"){e(t,n,r);return}if(n=="nosvg")return;this.psvg||(this.psvg=new Psvg(this)),this.psvg.ps_eval.call(this.psvg,r)},psdeco:function(e,t,n,r,i){return this.psvg?this.psvg.psdeco.call(this.psvg,t,n,r,i):!1},psxygl:function(e,t,n,r){return this.psvg?this.psvg.psxygl.call(this.psvg,t,n,r):!1},set_hooks:function(e){e.do_begin_end=abc2svg.psvg.do_begin_end.bind(e,e.do_begin_end),e.psdeco=abc2svg.psvg.psdeco.bind(e,e.psdeco),e.psxygl=abc2svg.psvg.psxygl.bind(e,e.psxygl)}},abc2svg.modules.hooks.push(abc2svg.psvg.set_hooks),abc2svg.modules.beginps.loaded=!0,abc2svg.soloffs={set_fmt:function(e,t,n,r){if(t=="soloffs"){var i,s,o=abc2svg.C,u=this.cfmt().soloffs={};n=n.split(/\s+/);while(n.length){i=n.shift().split("="),s=Number(i[1]);if(isNaN(s))continue;switch(i[0]){case"part":u[o.PART]=s+10;break;case"tempo":u[o.TEMPO]=s+16;break;case"space":u[o.SPACE]=s}}return}e(t,n,r)},set_sym_glue:function(e,t){var n,r=abc2svg.C,i=this.get_tsfirst(),s=this.cfmt().soloffs;e(t);if(!s)return;for(n=i;n;n=n.ts_next){if(n.dur)break;s[n.type]!=undefined&&(n.x=s[n.type])}},set_hooks:function(e){e.set_sym_glue=abc2svg.soloffs.set_sym_glue.bind(e,e.set_sym_glue),e.set_format=abc2svg.soloffs.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.soloffs.set_hooks),abc2svg.modules.soloffs.loaded=!0,abc2svg.temper={set_bar_num:function(e){e();if(this.cfmt().temper){var t=this.get_voice_tb()[0];t.temper=new Float32Array(12);for(var n=0;n<12;n++)t.temper[n]=this.cfmt().temper[n]/100}},set_fmt:function(e,t,n,r){if(t=="temperament"){var i=new Float32Array(n.split(/ +/)),s=i.length;if(s==12){while(--s>=0)if(isNaN(parseInt(i[s])))break;if(s<0){this.cfmt().temper=i;return}}this.syntax(1,this.errs.bad_val,"%%temperament");return}e(t,n,r)},set_hooks:function(e){e.set_bar_num=abc2svg.temper.set_bar_num.bind(e,e.set_bar_num),e.set_format=abc2svg.temper.set_fmt.bind(e,e.set_format)}},abc2svg.modules.hooks.push(abc2svg.temper.set_hooks),abc2svg.modules.temperament.loaded=!0,abc2svg.sth={recal_beam:function(e,t){var n=this.get_staff_tb(),r=n[t.st].y,i=e.s2,s=n[i.st].y;t.sth&&(t.ys=t.sth),i.sth&&(i.ys=i.sth),e.a=(t.ys+r-i.ys-s)/(t.xs-i.xs),e.b=t.ys-t.xs*e.a+r;for(;;){t.ys=e.a*t.xs+e.b-r,t.stem>0?t.ymx=t.ys+2.5:t.ymn=t.ys-2.5,t=t.next;if(t==i)break}},set_sth:function(){var e,t,n,r,i,s=this.get_voice_tb();for(n=0;n<s.length;n++){i=s[n];if(i.sth!=null)continue;r=[];for(e=i.sym;e;e=e.next){e.sth&&(r=e.sth,e.sth=null);if(r.length==0||e.nflags<=-2||e.stemless||!e.beam_st&&!e.beam_end)continue;t=r.shift();if(t=="*")continue;if(t=="|"){for(e=e.next;e;e=e.next)if(e.bar_type)break;continue}t=Number(t);if(isNaN(t)||!t)continue;e.stem>=0?(e.ys=e.y+t,e.ymx=e.ys+2.5|0):(e.ys=e.y-t,e.ymn=e.ys-2.5|0),e.sth=e.ys}}},calculate_beam:function(e,t,n){var r=e(t,n);return r&&t.s2&&(n.sth||t.s2.sth)&&abc2svg.sth.recal_beam.call(this,t,n),r},new_note:function(e,t,n){var r=abc2svg.C,i=e(t,n),s=this.get_curvoice();return s.sth&&i&&i.type==r.NOTE&&(i.sth=s.sth,s.sth=null),i},set_format:function(e,t,n,r){if(t=="sth"){var i=this.get_curvoice();this.parse.state==2&&this.goto_tune(),i&&(i.sth=n.split(/[ \t;-]+/));return}e(t,n,r)},set_stems:function(e){e(),abc2svg.sth.set_sth.call(this)},set_hooks:function(e){e.calculate_beam=abc2svg.sth.calculate_beam.bind(e,e.calculate_beam),e.new_note=abc2svg.sth.new_note.bind(e,e.new_note),e.set_format=abc2svg.sth.set_format.bind(e,e.set_format),e.set_stems=abc2svg.sth.set_stems.bind(e,e.set_stems)}},abc2svg.modules.hooks.push(abc2svg.sth.set_hooks),abc2svg.modules.sth.loaded=!0