//~ xml2abc-js, Revision: 121, Copyright (C) 2014-2025: Willem Vree
//~ This program is free software; you can redistribute it and/or modify it under the terms of the
//~ Lesser GNU General Public License as published by the Free Software Foundation;
//~ This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
//~ without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
//~ See the Lesser GNU General Public License for more details. <http://www.gnu.org/licenses/lgpl.html>.
var $jscomp=$jscomp||{};$jscomp.scope={};$jscomp.arrayIteratorImpl=function(d){var m=0;return function(){return m<d.length?{done:!1,value:d[m++]}:{done:!0}}};$jscomp.arrayIterator=function(d){return{next:$jscomp.arrayIteratorImpl(d)}};$jscomp.makeIterator=function(d){var m="undefined"!=typeof Symbol&&Symbol.iterator&&d[Symbol.iterator];return m?m.call(d):$jscomp.arrayIterator(d)};$jscomp.ASSUME_ES5=!1;$jscomp.ASSUME_NO_NATIVE_MAP=!1;$jscomp.ASSUME_NO_NATIVE_SET=!1;$jscomp.SIMPLE_FROUND_POLYFILL=!1;
$jscomp.defineProperty=$jscomp.ASSUME_ES5||"function"==typeof Object.defineProperties?Object.defineProperty:function(d,m,n){d!=Array.prototype&&d!=Object.prototype&&(d[m]=n.value)};$jscomp.getGlobal=function(d){d=["object"==typeof window&&window,"object"==typeof self&&self,"object"==typeof global&&global,d];for(var m=0;m<d.length;++m){var n=d[m];if(n&&n.Math==Math)return n}return globalThis};$jscomp.global=$jscomp.getGlobal(this);
$jscomp.polyfill=function(d,m,n,k){if(m){n=$jscomp.global;d=d.split(".");for(k=0;k<d.length-1;k++){var t=d[k];t in n||(n[t]={});n=n[t]}d=d[d.length-1];k=n[d];m=m(k);m!=k&&null!=m&&$jscomp.defineProperty(n,d,{configurable:!0,writable:!0,value:m})}};$jscomp.polyfill("Array.prototype.fill",function(d){return d?d:function(d,n,k){var m=this.length||0;0>n&&(n=Math.max(0,m+n));if(null==k||k>m)k=m;k=Number(k);0>k&&(k=Math.max(0,m+k));for(n=Number(n||0);n<k;n++)this[n]=d;return this}},"es6","es3");
$jscomp.SYMBOL_PREFIX="jscomp_symbol_";$jscomp.initSymbol=function(){$jscomp.initSymbol=function(){};$jscomp.global.Symbol||($jscomp.global.Symbol=$jscomp.Symbol)};$jscomp.SymbolClass=function(d,m){this.$jscomp$symbol$id_=d;$jscomp.defineProperty(this,"description",{configurable:!0,writable:!0,value:m})};$jscomp.SymbolClass.prototype.toString=function(){return this.$jscomp$symbol$id_};
$jscomp.Symbol=function(){function d(n){if(this instanceof d)throw new TypeError("Symbol is not a constructor");return new $jscomp.SymbolClass($jscomp.SYMBOL_PREFIX+(n||"")+"_"+m++,n)}var m=0;return d}();
$jscomp.initSymbolIterator=function(){$jscomp.initSymbol();var d=$jscomp.global.Symbol.iterator;d||(d=$jscomp.global.Symbol.iterator=$jscomp.global.Symbol("Symbol.iterator"));"function"!=typeof Array.prototype[d]&&$jscomp.defineProperty(Array.prototype,d,{configurable:!0,writable:!0,value:function(){return $jscomp.iteratorPrototype($jscomp.arrayIteratorImpl(this))}});$jscomp.initSymbolIterator=function(){}};
$jscomp.initSymbolAsyncIterator=function(){$jscomp.initSymbol();var d=$jscomp.global.Symbol.asyncIterator;d||(d=$jscomp.global.Symbol.asyncIterator=$jscomp.global.Symbol("Symbol.asyncIterator"));$jscomp.initSymbolAsyncIterator=function(){}};$jscomp.iteratorPrototype=function(d){$jscomp.initSymbolIterator();d={next:d};d[$jscomp.global.Symbol.iterator]=function(){return this};return d};
$jscomp.iteratorFromArray=function(d,m){$jscomp.initSymbolIterator();d instanceof String&&(d+="");var n=0,k={next:function(){if(n<d.length){var t=n++;return{value:m(t,d[t]),done:!1}}k.next=function(){return{done:!0,value:void 0}};return k.next()}};k[Symbol.iterator]=function(){return k};return k};$jscomp.polyfill("Array.prototype.keys",function(d){return d?d:function(){return $jscomp.iteratorFromArray(this,function(d){return d})}},"es6","es3");
$jscomp.checkEs6ConformanceViaProxy=function(){try{var d={},m=Object.create(new $jscomp.global.Proxy(d,{get:function(n,k,t){return n==d&&"q"==k&&t==m}}));return!0===m.q}catch(n){return!1}};$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS=!1;$jscomp.ES6_CONFORMANCE=$jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS&&$jscomp.checkEs6ConformanceViaProxy();$jscomp.owns=function(d,m){return Object.prototype.hasOwnProperty.call(d,m)};
$jscomp.polyfill("WeakMap",function(d){function m(){if(!d||!Object.seal)return!1;try{var D=Object.seal({}),k=Object.seal({}),z=new d([[D,2],[k,3]]);if(2!=z.get(D)||3!=z.get(k))return!1;z.delete(D);z.set(k,4);return!z.has(D)&&4==z.get(k)}catch(y){return!1}}function n(){}function k(d){var k=typeof d;return"object"===k&&null!==d||"function"===k}function t(d){if(!$jscomp.owns(d,A)){var k=new n;$jscomp.defineProperty(d,A,{value:k})}}function u(d){var k=Object[d];k&&(Object[d]=function(d){if(d instanceof
n)return d;t(d);return k(d)})}if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(d&&$jscomp.ES6_CONFORMANCE)return d}else if(m())return d;var A="$jscomp_hidden_"+Math.random();u("freeze");u("preventExtensions");u("seal");var F=0,z=function(d){this.id_=(F+=Math.random()+1).toString();if(d){d=$jscomp.makeIterator(d);for(var k;!(k=d.next()).done;)k=k.value,this.set(k[0],k[1])}};z.prototype.set=function(d,z){if(!k(d))throw Error("Invalid WeakMap key");t(d);if(!$jscomp.owns(d,A))throw Error("WeakMap key fail: "+
d);d[A][this.id_]=z;return this};z.prototype.get=function(d){return k(d)&&$jscomp.owns(d,A)?d[A][this.id_]:void 0};z.prototype.has=function(d){return k(d)&&$jscomp.owns(d,A)&&$jscomp.owns(d[A],this.id_)};z.prototype.delete=function(d){return k(d)&&$jscomp.owns(d,A)&&$jscomp.owns(d[A],this.id_)?delete d[A][this.id_]:!1};return z},"es6","es3");$jscomp.MapEntry=function(){};
$jscomp.polyfill("Map",function(d){function m(){if($jscomp.ASSUME_NO_NATIVE_MAP||!d||"function"!=typeof d||!d.prototype.entries||"function"!=typeof Object.seal)return!1;try{var k=Object.seal({x:4}),n=new d($jscomp.makeIterator([[k,"s"]]));if("s"!=n.get(k)||1!=n.size||n.get({x:4})||n.set({x:4},"t")!=n||2!=n.size)return!1;var m=n.entries(),t=m.next();if(t.done||t.value[0]!=k||"s"!=t.value[1])return!1;t=m.next();return t.done||4!=t.value[0].x||"t"!=t.value[1]||!m.next().done?!1:!0}catch(y){return!1}}
if($jscomp.USE_PROXY_FOR_ES6_CONFORMANCE_CHECKS){if(d&&$jscomp.ES6_CONFORMANCE)return d}else if(m())return d;$jscomp.initSymbolIterator();var n=new WeakMap,k=function(d){this.data_={};this.head_=A();this.size=0;if(d){d=$jscomp.makeIterator(d);for(var k;!(k=d.next()).done;)k=k.value,this.set(k[0],k[1])}};k.prototype.set=function(d,k){d=0===d?0:d;var n=t(this,d);n.list||(n.list=this.data_[n.id]=[]);n.entry?n.entry.value=k:(n.entry={next:this.head_,previous:this.head_.previous,head:this.head_,key:d,
value:k},n.list.push(n.entry),this.head_.previous.next=n.entry,this.head_.previous=n.entry,this.size++);return this};k.prototype.delete=function(d){d=t(this,d);return d.entry&&d.list?(d.list.splice(d.index,1),d.list.length||delete this.data_[d.id],d.entry.previous.next=d.entry.next,d.entry.next.previous=d.entry.previous,d.entry.head=null,this.size--,!0):!1};k.prototype.clear=function(){this.data_={};this.head_=this.head_.previous=A();this.size=0};k.prototype.has=function(d){return!!t(this,d).entry};
k.prototype.get=function(d){return(d=t(this,d).entry)&&d.value};k.prototype.entries=function(){return u(this,function(d){return[d.key,d.value]})};k.prototype.keys=function(){return u(this,function(d){return d.key})};k.prototype.values=function(){return u(this,function(d){return d.value})};k.prototype.forEach=function(d,k){for(var n=this.entries(),m;!(m=n.next()).done;)m=m.value,d.call(k,m[1],m[0],this)};k.prototype[Symbol.iterator]=k.prototype.entries;var t=function(d,k){var m=k&&typeof k;"object"==
m||"function"==m?n.has(k)?m=n.get(k):(m=""+ ++F,n.set(k,m)):m="p_"+k;var t=d.data_[m];if(t&&$jscomp.owns(d.data_,m))for(d=0;d<t.length;d++){var z=t[d];if(k!==k&&z.key!==z.key||k===z.key)return{id:m,list:t,index:d,entry:z}}return{id:m,list:t,index:-1,entry:void 0}},u=function(d,k){var n=d.head_;return $jscomp.iteratorPrototype(function(){if(n){for(;n.head!=d.head_;)n=n.previous;for(;n.next!=n.head;)return n=n.next,{done:!1,value:k(n)};n=null}return{done:!0,value:void 0}})},A=function(){var d={};return d.previous=
d.next=d.head=d},F=0;return k},"es6","es3");$jscomp.findInternal=function(d,m,n){d instanceof String&&(d=String(d));for(var k=d.length,t=0;t<k;t++){var u=d[t];if(m.call(n,u,t,d))return{i:t,v:u}}return{i:-1,v:void 0}};$jscomp.polyfill("Array.prototype.find",function(d){return d?d:function(d,n){return $jscomp.findInternal(this,d,n).v}},"es6","es3");$jscomp.polyfill("Object.entries",function(d){return d?d:function(d){var n=[],k;for(k in d)$jscomp.owns(d,k)&&n.push([k,d[k]]);return n}},"es8","es3");
var xml2abc_VERSION=121,vertaal;
(function(){function d(a,b){return Array(a+1).join(b)}function m(a,b){for(var c=0,f={};c<a.length;++c)f[a[c]]=b[c];return f}function n(a,b){var c=a.split(/%[ds]/);c.length>b.length&&b.push("");return b.map(function(a,b){return c[b]+a}).join("")}function k(a,b){v.info(n(a,b))}function t(a,b){return-1!==a.indexOf(b,a.length-b.length)}function u(a){return Object.keys(a).map(function(a){return parseInt(a)})}function A(a){return{"double-flat":"flat-flat","double-sharp":"sharp-sharp"}[a]||a}function F(a,
b){var c=[],f;if(Array.isArray(a))for(f=0;f<a.length;++f)f in a&&c.push([f,a[f]]);else for(f in a)c.push([f,a[f]]);c.sort(b?function(a,b){return a[0]-b[0]}:function(a,b){return a[1]-b[1]||b[0]-a[0]});return c}function z(a,b,c){this.ixp=a;this.ixm=b;this.mdur=c.mdur?c.mdur:0;this.divs=c.divs?c.divs:1;this.mtr=c.mtr?c.mtr:[4,4];this.lline=this.attr="";this.rline="|";this.lnum=""}function D(a,b){this.tijd=0;this.dur=a;this.type="";this.fact=null;this.tup=[""];this.tupabc="";this.grace=this.beam=0;this.before=
[];this.after="";this.ns=b?[b]:[];this.lyrs={};this.pos=0;this.tab=null;this.ntdec="";this.xmlvce=this.xmlstf=1}function E(a,b){this.tijd=0;this.str=a;this.pos=0;this.xmlstf=b}function G(){}function y(a){this.maxtime=this.tijd=0;this.gMaten=[];this.gLyrics=[];this.vnums={};this.wev=a.wev;this.cnt=new G;this.vceCnt=1;this.lastnote=null;this.bpl=a.b;this.cpl=a.n;this.rbm=a.rbm;this.repbra=0;this.nvlt=a.v;this.nbr=a.nbr}function H(a,b,c,f){this.fnmext=a;this.outlist=[];this.infolist=[];this.title="T:Title";
this.key="none";this.clefs=new Map;this.mtr="none";this.tempo=0;this.tempo_units=[1,4];this.pad=b;this.X=c+1;this.denL=f.d;this.volpan=f.m;this.cmpL=[];this.scale="";this.tstep=f.t;this.stemless=0;this.rightmargin=this.leftmargin=this.pagewidth="";this.shiftStem=f.s;this.mnum=f.mnum;4==f.p.length&&(this.scale=""!=f.p[0]?parseFloat(f.p[0]):"",this.pagewidth=""!=f.p[1]?parseFloat(f.p[1]):"",this.leftmargin=""!=f.p[2]?parseFloat(f.p[2]):"",this.rightmargin=""!=f.p[3]?parseFloat(f.p[3]):"")}function W(a,
b){if(!a.join(""))return["",0];for(var c=[],f=0;f<a.length;++f){var g=a[f];""==g?g=b?"_":"*":t(g,"_")&&!t(g,"\\_")?(g=g.replace("_",""),b=1):b=0;c.push(g)}return[c.join(" "),b]}function I(a,b){for(var c=a,f=b,g;b;)g=a%b,a=b,b=g;return[c/a,f/a]}function N(a,b,c){if(0==a.dur&&!a.grace)return"";var f=$jscomp.makeIterator(I(c*a.dur,4*b));b=f.next().value;f=f.next().value;a.grace&&(f=$jscomp.makeIterator(I(16,a.type||c)),b=f.next().value,f=f.next().value);a.fact&&(c=$jscomp.makeIterator(a.fact),a=c.next().value,
c=c.next().value,f=$jscomp.makeIterator(I(b*a,f*c)),b=f.next().value,f=f.next().value);64<f&&(a=b/f,c=Math.floor(a),a-c<.1*a&&(b=c,f=1),a=I(Math.round(64*b/f)||1,64),k("denominator too small: %d/%d rounded to %d/%d",[b,f,a[0],a[1]]),b=a[0],f=a[1]);return 1==b?1==f?"":2==f?"/":"/"+f:1==f?""+b:b+"/"+f}function O(a){var b=a.match(/([_^]*)([A-Ga-g])([',]*)/);if(!b)return-1;a=b[1];var c=b[2];b=b[3];var f=c.toUpperCase();c=60+[0,2,4,5,7,9,11]["CDEFGAB".indexOf(f)]+(f!=c?12:0);a&&(c+=("^"==a[0]?1:-1)*a.length);
b&&(c+=("'"==b[0]?12:-12)*b.length);return c}function X(a,b,c,f){var g=0;0<=c.indexOf("stafflines=1")&&(g+=4);!f&&0<=c.indexOf("bass")&&(g+=12);g&&(c="CDEFGAB".split(""),g=c.indexOf(a)+g,a=c[g%7],b+=Math.floor(g/7));4<b&&(a=a.toLowerCase());5<b&&(a+=d(b-5,"'"));4>b&&(a+=d(4-b,","));return a}function Y(a,b,c){c={maj:8,ion:8,m:11,min:11,aeo:11,mix:9,dor:10,phr:12,lyd:7,loc:13,non:8};b=b.slice(0,3).toLowerCase();b="Fb Cb Gb Db Ab Eb Bb F C G D A E B F# C# G# D# A# E# B#".split(" ")[c[b]+a]+(8!=c[b]?
b:"");c="FCGDAEB".split("");a=0<=a?m(c.slice(0,a),Array(a).fill("sharp")):m(c.slice(a),Array(-a).fill("flat"));return[b,a]}function Z(a,b){var c="",f={},g="C exp ";a.find("key").children().each(function(){var a=$(this);"key-step"==a[0].tagName?(c&&(g+=" "+c),c=a.text().trim()):"key-alter"==a[0].tagName?(a=a.text().trim())&&(f[c]=Math.round(a)):"key-accidental"==a[0].tagName&&(a=A(a.text().trim()),f[c]=a,c=b.acc2abc(a)+c)});c&&(g+=" "+c);return[g,f]}function P(a,b,c){var f=0,g=b[a];var e=g.tup.indexOf("start");
-1<e&&g.tup.splice(e,1);var h=a;for(c=[g.fact[0]/c[0],g.fact[1]/c[1]];a<b.length;){g=b[a];if(!(g instanceof E||g.grace)){-1<g.tup.indexOf("start")?(e=P(a,b,c),a=e[0],e=e[1],f+=e):g.fact&&(f+=1);e=g.tup.indexOf("stop");if(-1<e){g.tup.splice(e,1);break}if(!g.fact){a=p;break}var p=a}a+=1}p=[c[0],c[1],f];p="3,2,3"==p.toString()?"(3":n("(%d:%d:%d",p);b[h].tupabc=p+b[h].tupabc;return[a,f]}function aa(a){a=a.filter(function(a){return a instanceof D});for(var b=0;b<a.length-1;){var c=a[b],f=a[b+1];!c.fact&&
!f.fact&&0<c.dur&&f.beam&&(3*c.dur==f.dur?(f.dur=2*f.dur/3,c.dur*=2,c.after="<"+c.after,b+=1):3*f.dur==c.dur&&(c.dur=2*c.dur/3,f.dur*=2,c.after=">"+c.after,b+=1));b+=1}}function ba(a,b,c){var f=b;8==c[1]&&(f=b/2);a=Math.floor(a.tijd/f);8==c[1]&&(a=7==c[0]||5==c[0]?[0,0,0,1,1,2,2][a]:Math.floor(a/3));return[a,f]}function ca(a,b,c,f,g,e,h){for(f=0;f<a.length;)c=a[f],c instanceof D&&c.fact&&!c.grace&&(c=P(f,a,[1,1]),f=c[0]),f+=1;f=[];for(var p,d,q=-1,k=0,r=0;r<a.length;++r){c=a[r];if(c instanceof D){p=
N(c,b,g);var n=1<c.ns.length;d=c.ns.filter(function(a){return t(a,"-")});d=d.map(function(a){return a.slice(0,-1)});var m="";n&&d.length==c.ns.length&&(c.ns=d,m="-");d=c.tupabc+c.before.join("");n&&(d+="[");d+=c.ns.join("");n&&(d+="]"+m);t(d,"-")&&(d=d.slice(0,-1),m="-");d+=p+m;d+=c.after;p=c.beam;m=$jscomp.makeIterator(ba(c,b,h));n=m.next().value;m=m.next().value;e&&c.dur<b&&k<b&&((p=n==q)||0==c.tijd%m||(p=!0));q=n;k=c.dur}else c.str instanceof Array&&(c.str=c.str[0]),d=c.str,p=1;p?f.push(d):f.push(" "+
d)}for(f=f.join("");0<=f.indexOf("!ped!!ped!");)f=f.replace(/!ped!!ped!/g,"!ped!");for(;0<=f.indexOf("!ped-up!!ped-up!");)f=f.replace(/!ped-up!!ped-up!/g,"!ped-up!");for(;0<=f.indexOf("!8va(!!8va)!");)f=f.replace(/!8va\(!!8va\)!/g,"");return f}function Q(a,b,c,f,g,e){var h=b[c];a.xmlstf&&0<a.xmlstf&&a.xmlstf!=h?(f=[g.length,h],h=a.xmlstf-h,b[c]=a.xmlstf,b=new E("[I:staff "+(0<h?"+":"")+h+"]"),b.tijd=e,g.push(b)):f=[];g.push(a);return f}function da(a,b,c,f,g){a.map(function(a,b){a.pos=b});a.sort(function(a,
b){return a.tijd-b.tijd||a.pos-b.pos});for(var e=0,h=[],d=[],l=0,q=[],x=0;x<a.length;++x){var r=a[x];r.tijd>e&&L(r.tijd-e,b)&&(h.push(new D(r.tijd-e,"x")),d.push(h.length-1));if(r instanceof E)r.tijd<e&&(r.tijd=e),Q(r,c,g,q,h,e),e=r.tijd;else{g=f?r.xmlvce+100*r.xmlstf:r.xmlvce;if(r.tijd<e){if("z"==r.ns[0])continue;var n=h[l];if(n.tijd<=r.tijd)if("z"==n.ns[0]){n.dur=r.tijd-n.tijd;if(0==n.dur&&(h.splice(l,1),q.length)){var m=$jscomp.makeIterator(q);n=m.next().value;m=m.next().value;h.splice(n,1);c[g]=
m}k("overlap in part %d, measure %d: rest shortened",[b.ixp+1,b.ixm+1])}else{n.ns=n.ns.concat(r.ns);k("overlap in part %d, measure %d: added chord",[b.ixp+1,b.ixm+1]);r.dur=r.tijd+r.dur-e;if(0>=r.dur)continue;r.tijd=e}else{k("overlapping notes in one voice! part %d, measure %d, note %s discarded",[b.ixp+1,b.ixm+1,r instanceof D?r.ns:r.str]);continue}}q=Q(r,c,g,q,h,e);if(r instanceof D)if(l=h.length-1,e=r.ns[0],"x"==e||"z"==e)d.push(h.length-1);else if(d.length){if(r.beam&&!r.grace)for(e=0;e<d.length;++e)h[d[e]].beam=
r.beam;d=[]}e=r.tijd+r.dur}}0==e&&(k("empty measure in part %d, measure %d, it should contain at least a rest to advance the time!",[b.ixp+1,b.ixm+1]),e=new D(b.mdur,"z"),a=h[h.length-1],a.str&&a.str.match(/[|:\]]/)&&(a.tijd=b.mdur,h=h.slice(0,-1).concat([e,a])));return h}function ea(a){function b(a){var b=$("<part-group></part-group>",f);b.attr("number",a);b.attr("type","stop");return b}var c,f=a[0];var g=[];var e=[];var d=a.children();for(c=0;c<d.length;c++)if(a=$(d[c]),"part-group"==a[0].tagName){var p=
a.attr("number");var l=a.attr("type");var q=e.indexOf(p);"start"==l?-1<q?(g.push(b(p)),g.push(a)):(g.push(a),e.push(p)):-1<q&&(e.splice(q,1),g.push(a))}else g.push(a);for(c=e.length-1;0<=c;--c)p=e[c],g.push(b(p));return g}function K(a,b,c){if(0==a.length)return[[],[]];var f=a.shift();if("part-group"==f[0].tagName){var g=f.attr("number");var e=f.attr("type");if("start"==e){e=[];for(d in{"group-symbol":0,"group-barline":0,"group-name":0,"group-abbreviation":0})e.push(f.find(d).text()||"");b[g]=e;c.push(g);
var d=K(a,b,c);a=d[0];f=d[1];d=K(f,b,c);b=d[0];c=d[1];return[[a].concat(b),c]}c=c.pop();a.length&&"stop"==a[0].attr("type")&&g!=c&&(d=b[c],b[c]=b[g],b[g]=d);b=b[g];return[[b],a]}d=K(a,b,c);b=d[0];a=d[1];return[[["name_tuple",f.find("part-name").text()||"",f.find("part-abbreviation").text()||""]].concat(b),a]}function R(a){var b,c;if(0==a.length)return[];var f=[];for(b=0;b<a.length;++b){var g=a[b];if(1==g.length)f.push(""+g[0]);else{f.push("(");for(c=0;c<g.length;++c)f.push(""+g[c]);f.push(")")}f.push("|")}f.splice(-1,
1);1<a.length&&(f=["{"].concat(f).concat(["}"]));return f}function S(a,b,c,f,g,e){if("name_tuple"==a[0])f=f.shift(),b[0]&&(a[1]=b[0]+":"+a[1],a[2]=b[1]+":"+a[2]),g.push(a),e.push.apply(e,R(f));else if(2==a.length&&"name_tuple"==a[0][0])f=f.shift(),c=["name_tuple","",""],c[1]=a[0][1]+":"+a[1][2],c[2]=a[0][2]+":"+a[1][3],g.push(c),e.push.apply(e,R(f));else{var d=a[a.length-1];b=d[0];var p=d[1];var l=d[2];d=d[3];p="yes"==p||c;e.push("brace"==b?"{":"[");for(c=0;c<a.length-1;++c)S(a[c],[l,d],p,f,g,e),
p&&e.push("|");p&&e.splice(-1,1);e.push("brace"==b?"}":"]")}}function fa(a,b,c){for(var f=0,d=ha,e,h,p=[4,8,16];p.length;){var l=p.shift(),q=0;for(e=0;e<b.length;++e){var k=b[e][a];for(h=0;h<k.length;++h){var r=k[h];r instanceof E||0==r.dur||(q+=N(r,c[e],l).length)}}q<d&&(f=l,d=q)}return f}function ia(a){for(var b="",c=a.children(),f=0;f<c.length;++f){var d=c[f];switch(d.tagName){case "elision":b+="~";break;case "text":b+=$(d).text().replace(/_/g,"\\_").replace(/-/g,"\\-").replace(/ /g,"~")}}if(!b)return b;
c=a.find("syllabic").text();if("begin"==c||"middle"==c)b+="-";a.find("extend").length&&(b+="_");return b}function ja(a,b,c,f){if(0!=c){b=b[c][f];var d=a[c][f];a=a[c-1][f];for(var e in a)if(c=a[e][1],!(e in d)&&c){c=b;f=[];for(var h=0;h<c.length;++h){var p=c[h];if(p instanceof D&&!p.grace){if("z"==p.ns[0]||"x"==p.ns[0])break;f.push("_")}}(c=f.join(" "))&&(d[e]=[c,0])}}}function ka(a){var b={diamond:1,triangle:1,square:1,normal:1},c=la,f,d="default",e={"default":[]},h={"default":[]};a=a.split("\n");
for(f=0;f<a.length;++f){var p=a[f];if(0<=p.indexOf("I:percmap")){p=p.split(" ").map(function(a){return a.trim()});var l=p[4];l in b&&(l=l+"+,"+l);p="%%map perc"+d+" "+p[1]+" print="+p[2]+" midi="+p[3]+" heads="+l;e[d].push(p)}0<=p.indexOf("%%MIDI")&&h[d].push(p);0<=p.indexOf("V:")&&(l=p.match(/V:\s*(\S+)/))&&(d=l[1],d in e||(e[d]=[],h[d]=[]))}b=Object.keys(e).sort();for(f=0;f<b.length;++f)c=c.concat(e[b[f]]);d="default";for(f=0;f<a.length;++f)p=a[f],0<=p.indexOf("I:percmap")||0<=p.indexOf("%%MIDI")||
(0<=p.indexOf("V:")||0<=p.indexOf("K:")?((l=p.match(/V:\s*(\S+)/))&&(d=l[1]),c.push(p),d in h&&h[d].length&&(c=c.concat(h[d]),delete h[d]),0<=p.indexOf("perc")&&-1==p.indexOf("map=")&&(p+=" map=perc"),0<=p.indexOf("map=perc")&&0<e[d].length&&c.push("%%voicemap perc"+d),0<=p.indexOf("map=off")&&c.push("%%voicemap")):c.push(p));return c.join("\n")}function M(a,b){var c=a;4<b&&(c=a.toLowerCase());5<b&&(c+=d(b-5,"'"));4>b&&(c+=d(4-b,","));return c}function L(a,b){if(a>b.divs/16)return 1;k("MuseScore bug: incorrect duration, smaller then 1/64! in measure %d, part %d",
[b.ixm,b.ixp]);return 0}function w(a){this.slurBuf={};this.dirStk={};this.ingrace=0;this.grcNotes=[];this.msc=new y(a);this.unfold=a.u;this.ctf=a.c;this.gStfMap=[];this.midiMap=[];this.drumInst={};this.drumNotes={};this.instMid=[];this.midDflt=[-1,-1,-1,-91];this.msralts={};this.curalts={};this.stfMap={};this.vce2stf={};this.clefMap={};this.curClef={};this.stemDir={};this.clefOct={};this.curStf={};this.nolbrk=a.x;this.doPageFmt=1==a.p.length;this.tstep=a.t;this.dirtov1=a.v1;this.ped=!a.noped;this.wstems=
a.stm;this.pedVce=null;this.repeat_str={};this.tabVceMap={};this.koppen={};this.altkey=this.edo=0;this.note_alts=["=C ^C =D ^D =E =F ^F =G ^G =A ^A =B".split(" "),"^B _D ^^C _E _F ^E _G ^^F _A ^^G _B _C".split(" "),"__D ^^B __E __F ^^D __G ^^E __A _/A __B __C ^^A".split(" ")];this.step_map={C:0,D:2,E:4,F:5,G:7,A:9,B:11};this.temp=a.temp;this.musfin=a.fin;this.autoacc=0>a.fin;0>this.musfin&&(this.musfin=2);this.edo12alt={"flat-flat":-2,flat:-1,natural:0,sharp:1,"sharp-sharp":2};this.edo53alt={"quarter-sharp":1,
"sharp-2":2,"sharp-3":3,sharp:4,"slash-quarter-sharp":5,"slash-sharp":8,"sharp-sharp":9,natural:0,"quarter-flat":-1,"flat-2":-2,"flat-3":-3,"slash-flat":-4,flat:-5,"double-slash-flat":-8,"flat-flat":-9};this.edo36alt={"flat-down":-4,flat:-3,"flat-up":-2,"natural-down":-1,natural:0,"natural-up":1,"sharp-down":2,sharp:3,"sharp-up":4};this.edomap={"flat-down":-8,"flat-up":-3,"natural-down":-2,"natural-up":2,"sharp-down":3,"sharp-up":8};this.edomix={"flat-down":-4,"flat-up":-2,"natural-down":-1,"natural-up":1,
"sharp-down":2,"sharp-up":4};this.note_type={whole:1,half:2,quarter:4,eighth:8,"16th":16,"32nd":32,"64th":64}}var ha=Math.pow(2,53),T={"ornaments>trill-mark":"T","ornaments>mordent":"M","ornaments>inverted-mordent":"P","ornaments>turn":"!turn!","ornaments>inverted-turn":"!invertedturn!","technical>up-bow":"u","technical>down-bow":"v","technical>harmonic":"!open!","technical>open-string":"!open!","technical>stopped":"!plus!","technical>snap-pizzicato":"!snap!","technical>thumb-position":"!thumb!",
"articulations>accent":"!>!","articulations>strong-accent":"!^!","articulations>staccato":".","articulations>staccatissimo":"!wedge!","articulations>scoop":"!slide!",fermata:"!fermata!",arpeggiate:"!arpeggio!","articulations>tenuto":"!tenuto!","articulations>spiccato":"!wedge!","articulations>breath-mark":"!breath!","articulations>detached-legato":"!tenuto!."},U={p:"!p!",pp:"!pp!",ppp:"!ppp!",pppp:"!pppp!",f:"!f!",ff:"!ff!",fff:"!fff!",ffff:"!ffff!",mp:"!mp!",mf:"!mf!",sfz:"!sfz!"},la='%%beginsvg\n<defs>,<text id="x" x="-3" y="0">&#xe263;</text>,<text id="x-" x="-3" y="0">&#xe263;</text>,<text id="x+" x="-3" y="0">&#xe263;</text>,<text id="normal" x="-3.7" y="0">&#xe0a3;</text>,<text id="normal-" x="-3.7" y="0">&#xe0a3;</text>,<text id="normal+" x="-3.7" y="0">&#xe0a4;</text>,<g id="circle-x"><text x="-3" y="0">&#xe263;</text><circle r="4" class="stroke"></circle></g>,<g id="circle-x-"><text x="-3" y="0">&#xe263;</text><circle r="4" class="stroke"></circle></g>,<path id="triangle" d="m-4 -3.2l4 6.4 4 -6.4z" class="stroke" style="stroke-width:1.4"></path>,<path id="triangle-" d="m-4 -3.2l4 6.4 4 -6.4z" class="stroke" style="stroke-width:1.4"></path>,<path id="triangle+" d="m-4 -3.2l4 6.4 4 -6.4z" class="stroke" style="fill:#000"></path>,<path id="square" d="m-3.5 3l0 -6.2 7.2 0 0 6.2z" class="stroke" style="stroke-width:1.4"></path>,<path id="square-" d="m-3.5 3l0 -6.2 7.2 0 0 6.2z" class="stroke" style="stroke-width:1.4"></path>,<path id="square+" d="m-3.5 3l0 -6.2 7.2 0 0 6.2z" class="stroke" style="fill:#000"></path>,<path id="diamond" d="m0 -3l4.2 3.2 -4.2 3.2 -4.2 -3.2z" class="stroke" style="stroke-width:1.4"></path>,<path id="diamond-" d="m0 -3l4.2 3.2 -4.2 3.2 -4.2 -3.2z" class="stroke" style="stroke-width:1.4"></path>,<path id="diamond+" d="m0 -3l4.2 3.2 -4.2 3.2 -4.2 -3.2z" class="stroke" style="fill:#000"></path>,</defs>\n%%endsvg'.split(","),
V='%%beginsvg\n,<style type="text/css">\n,.bf {font-family:sans-serif; font-size:7px}\n,</style>\n,<defs>\n,<rect id="clr" x="-3" y="-1" width="6" height="5" fill="white"></rect>\n,<rect id="clr2" x="-3" y="-1" width="11" height="5" fill="white"></rect>\n'.split(","),v;G.prototype.inc=function(a,b){this.counters[a][b]=(this.counters[a][b]||0)+1};G.prototype.clear=function(a){a=Object.keys(a);var b=Array(a.length).fill(0);this.counters={note:m(a,b),nopr:m(a,b),nopt:m(a,b)}};G.prototype.getv=function(a,
b){return this.counters[a][b]};G.prototype.prcnt=function(a,b){for(var c in this.counters.note)0!=this.getv("nopr",c)&&k("part %d, voice %d has %d skipped non printable notes",[a,c,this.getv("nopr",c)]),0!=this.getv("nopt",c)&&k("part %d, voice %d has %d notes without pitch",[a,c,this.getv("nopt",c)]),0!=this.getv("note",c)||b||k("part %d, skipped empty voice %d",[a,c])};y.prototype.initVoices=function(a){this.vtimes={};this.voices={};this.lyrics={};for(var b in this.vnums)this.vtimes[b]=0,this.voices[b]=
[],this.lyrics[b]=[];a&&this.cnt.clear(this.vnums)};y.prototype.incTime=function(a){this.tijd+=a;0>this.tijd&&(this.tijd=0);this.tijd>this.maxtime&&(this.maxtime=this.tijd)};y.prototype.appendElemCv=function(a,b){for(var c in a)this.appendElem(c,b)};y.prototype.insertElem=function(a,b){b=new E(b);b.tijd=0;this.voices[a].unshift(b)};y.prototype.appendObj=function(a,b,c){b.tijd=this.tijd;this.voices[a].push(b);this.incTime(c);this.tijd>this.vtimes[a]&&(this.vtimes[a]=this.tijd)};y.prototype.appendElemT=
function(a,b,c){b=new E(b);b.tijd=c;this.voices[a].push(b)};y.prototype.appendElem=function(a,b,c){this.appendObj(a,new E(b),0);c&&this.cnt.inc("note",a)};y.prototype.appendNote=function(a,b,c){b.ns.push(b.ntdec+c);this.appendObj(a,b,parseInt(b.dur));this.lastnote=b;"z"!=c&&"x"!=c&&(this.cnt.inc("note",a),b.grace||this.lyrics[a].push(b.lyrs))};y.prototype.getLastRec=function(a){return this.gMaten.length?(a=this.gMaten[this.gMaten.length-1][a],a[a.length-1]):null};y.prototype.getLastMelis=function(a,
b){return this.gLyrics.length&&(a=this.gLyrics[this.gLyrics.length-1][a],b in a)?a[b][1]:0};y.prototype.addChord=function(a,b){for(var c=0;c<a.before.length;c++){var f=a.before[c];0>this.lastnote.before.indexOf(f)&&this.lastnote.before.push(f)}this.lastnote.ns.push(a.ntdec+b)};y.prototype.addBar=function(a,b,c,f){b.mdur&&this.maxtime>b.mdur&&k("measure %d in part %d longer than metre",[b.ixm+1,b.ixp+1]);this.tijd=this.maxtime;for(var d in this.vnums){if(b.lline||b.lnum){var e=this.getLastRec(d);if(e){var h=
e.str;b.lline&&(h=(h+b.lline).replace(/:\|:/g,"::").replace(/\|\|/g,"|"));3==this.nvlt?b.ixp+parseInt(d)==Math.min.apply(null,u(this.vnums))&&(h+=b.lnum):4==this.nvlt?parseInt(d)==Math.min.apply(null,u(this.vnums))&&(h+=b.lnum):b.lnum&&(h+=b.lnum,this.repbra=1);e.str=h}else b.lline&&this.insertElem(d,"|:")}a&&(e=this.getLastRec(d))&&(e.str+=a);b.attr&&this.insertElem(d,""+b.attr);this.appendElem(d," "+b.rline);this.voices[d]=da(this.voices[d],b,c,f,d);e=this.lyrics[d];h={};for(var p=e.reduce(function(a,
b){return a.concat(u(b))},[]),l=Math.max.apply(null,p.concat([0]));0<l;--l){p=e.map(function(a){return a[l]||""});var q=this.getLastMelis(d,l);h[l]=W(p,q)}this.lyrics[d]=h;this.nbr||aa(this.voices[d])}this.gMaten.push(this.voices);this.gLyrics.push(this.lyrics);this.tijd=this.maxtime=0;this.initVoices()};y.prototype.outVoices=function(a,b){var c=a.map(function(a){return a.divs});a=a.map(function(a){return a.mtr});var f,d,e;var h={};var p=Math.min.apply(null,u(this.vnums)||[1]);for(d in this.vnums)if(0!=
this.cnt.getv("note",d)||this.wev){var l=v.denL?v.denL:fa(d,this.gMaten,c);v.cmpL.push(l);var q=[],k={};for(e=0;e<this.gMaten.length;++e){var r=this.gMaten[e][d];q.push(ca(r,c[e],e,b,l,this.rbm,a[e]));ja(this.gLyrics,this.gMaten,e,d);var n=this.gLyrics[e][d];for(m in n)if(r=n[m],r=r[0],m in k){for(;k[m].length<e;)k[m].push("");k[m].push(r)}else k[m]=Array(e).fill("").concat([r])}for(m in k)r=k[m],l=q.length-r.length,k[m]=r.concat(Array(l).fill(""));v.add("V:"+this.vceCnt);this.repbra&&(1==this.nvlt&&
1<this.vceCnt&&v.add("I:repbra 0"),2==this.nvlt&&parseInt(d)>p&&v.add("I:repbra 0"));0<this.cpl?this.bpl=0:0==this.bpl&&(this.cpl=100);for(l=0;q.length;){e=1;for(r=q[0];e<q.length&&!(0<this.cpl&&r.length+q[e].length>=this.cpl)&&!(0<this.bpl&&e>=this.bpl);)r+=q[e],e+=1;l+=e;v.add(r+" %"+l);q.splice(0,e);n=F(k,1);for(f=0;f<n.length;++f){r=n[f];var m=r[0];r=r[1];v.add("w: "+r.slice(0,e).join("|")+"|");r.splice(0,e)}}h[d]=this.vceCnt;this.vceCnt+=1}this.gMaten=[];this.gLyrics=[];this.cnt.prcnt(b+1,this.wev);
return h};H.prototype.add=function(a){this.outlist.push(a+"\n")};H.prototype.info=function(a,b){this.infolist.push(("undefined"==typeof b||b?"-- ":"")+a)};H.prototype.mkHeader=function(a,b,c,f,d,e){var h=[],g=[],l;var q=a.slice();for(l=0;l<b.length;++l){var x=b[l];try{S(x,["",""],"",a,h,g)}catch(ma){k("lousy musicxml: error in part-list",[])}}b=g.join(" ");a={};for(l=0;l<q.length&&l<h.length;++l){var r=q[l];x=h[l];var m=x[1];x=x[2];0!=r.length&&(r=r[0][0],m=m.replace(/\n/g,"\\n").replace(/\.:/g,".").replace(/^:|:$/g,
""),x=x.replace(/\n/g,"\\n").replace(/\.:/g,".").replace(/^:|:$/g,""),a[r]=(m?'nm="'+m+'"':"")+(x?' snm="'+x+'"':""))}h=[n("X:%d\n%s\n%s",[this.X,this.title,-1<this.mnum?"%%measurenb "+this.mnum+"\n":""])];e&&h.push("%%MIDI temperamentequal "+e+"\n");""!==this.scale&&h.push("%%scale "+this.scale+"\n");""!==this.pagewidth&&h.push("%%pagewidth "+this.pagewidth+"cm\n");""!==this.leftmargin&&h.push("%%leftmargin "+this.leftmargin+"cm\n");""!==this.rightmargin&&h.push("%%rightmargin "+this.rightmargin+
"cm\n");b&&1<g.length&&h.push("%%score "+b+"\n");g=this.tempo?n("Q:%d/%d=%s\n",[this.tempo_units[0],this.tempo_units[1],this.tempo]):"";e=[];for(l=0;l<this.cmpL.length;++l)x=this.cmpL[l],e[x]=(e[x]||0)+1;e=F(e);e=e[e.length-1][0];e=this.denL?this.denL:e;h.push(n("L:1/%d\n%sM:%s\n",[e,g,this.mtr]));h.push(n("I:linebreak $\nK:%s\n",[this.key]));this.stemless&&h.push("U:s=!stemless!\n");g=Object.keys(f).sort();for(l=0;l<g.length;++l)h=h.concat(f[g[l]]);this.dojef=0;g=$jscomp.makeIterator(this.clefs.keys());
for(l=g.next();!l.done;l=g.next()){q=l.value;x=c[q-1];l=x[0];b=x[1];m=x[2];r=x[3];x=x.slice(4);var t=this.clefs.get(q);x.length&&0>t.indexOf("perc")&&(t=(t+" map=perc").trim());h.push(n("V:%d %s %s\n",[q,t,a[q]||""]));q in f&&(h.push(n("%%voicemap tab%d\n",[q])),h.push("K:none\nM:none\n%%clef none\n%%staffscale 1.6\n%%flatbeams true\n%%stemdir down\n"));-1<t.indexOf("perc")&&h.push("K:none\n");1<this.volpan?(0<l&&l!=q&&h.push("%%MIDI channel "+l+"\n"),0<b&&h.push("%%MIDI program "+(b-1)+"\n"),0<=
m&&h.push("%%MIDI control 7 "+m+"\n"),0<=r&&h.push("%%MIDI control 10 "+r+"\n")):0<this.volpan&&(x.length&&0<l&&h.push("%%MIDI channel "+l+"\n"),0<b&&h.push("%%MIDI program "+(b-1)+"\n"));for(l=0;l<x.length;++l)if(b=x[l].nt,r=x[l].step,m=x[l].midi,(t=x[l].nhd)||(t="normal"),O(b)!=m||b!=r)0<this.volpan&&h.push("%%MIDI drummap "+b+" "+m+"\n"),h.push("I:percmap "+b+" "+r+" "+m+" "+t+"\n"),this.dojef=this.tstep;e!=this.cmpL[q-1]&&h.push("L:1/"+this.cmpL[q-1]+"\n")}this.outlist=h.concat(this.outlist);
c=Object.keys(d).sort();if(c.length){var v=[];var w=this.shiftStem?'<g id="kop%s" class="bf"><use xlink:href="#clr"></use><text x="-2" y="3">%s</text></g>\n'.replace("-2","-5"):'<g id="kop%s" class="bf"><use xlink:href="#clr"></use><text x="-2" y="3">%s</text></g>\n',C=this.shiftStem?'<g id="kop%s" class="bf"><use xlink:href="#clr2"></use><text x="-2" y="3">%s</text></g>\n'.replace("-2","-5"):'<g id="kop%s" class="bf"><use xlink:href="#clr2"></use><text x="-2" y="3">%s</text></g>\n';f=this.shiftStem?
V.map(function(a){return a.replace("-3","-6")}):V;c.forEach(function(a){v.push(1<a.length?n(C,[a,a]):n(w,[a,a]))});this.outlist=f.concat(v,"</defs>\n%%endsvg\n",this.outlist)}};H.prototype.writeall=function(){var a=v.outlist.join("");this.dojef&&(a=ka(a));return[a,this.infolist.join("\n")]};w.prototype.matchSlur=function(a,b,c,f,d,e){if(-1!=["start","stop"].indexOf(a))if(b||(b="1"),b in this.slurBuf){var g=this.slurBuf[b];e=g[0];var p=g[1];g=g[2];a!=e?(c==p&&"start"==e&&(g.before.unshift("("),f.after+=
")"),delete this.slurBuf[b]):(k("double slur numbers %s-%s in part %d, measure %d, voice %d note %s, first discarded",[a,b,this.msr.ixp+1,this.msr.ixm+1,c,f.ns]),this.slurBuf[b]=[a,c,f,d])}else this.slurBuf[b]=[a,c,f,d]};w.prototype.doNotations=function(a,b,c){for(var f=Object.keys(T).sort(),g=0;g<f.length;++g){var e=f[g],h=T[e];b.find(e).length&&a.before.push(h)}g=b.find("ornaments>tremolo");g.length&&(e=g.attr("type"),f=d(parseInt(g.text()),"/"),"single"==e?a.before.unshift("!"+f+"!"):(a.fact=null,
this.tstep?"stop"==e&&a.before.unshift("!trem"+g.text()+"!"):"start"==e&&a.before.unshift("!"+f+"-!")));f=b.find("technical>fingering");c||f.each(function(){a.before.push("!"+$(this).text()+"!")});f=b.find("technical>string");f.length&&c&&(this.tstep?(c=b.find("technical>fret"),c.length&&(a.tab=[f.eq(0).text(),c.eq(0).text()])):f.each(function(){var b="!"+$(this).text()+"!";0>a.ntdec.indexOf(b)&&(a.ntdec+=b)}));c=b.find("ornaments>wavy-line");c=$jscomp.makeIterator(c.toArray());for(f=c.next();!f.done;f=
c.next())switch(f=f.value,$(f).attr("type")){case "start":a.before.unshift("!trill(!");break;case "stop":a.after+="!trill)!"}c=b.find("glissando");0==c.length&&(c=b.find("slide"));c.length&&(b="wavy"==c.attr("line-type")?"~":"-","start"==c.attr("type")?a.before.unshift(n("!%s(!",[b])):"stop"==c.attr("type")&&a.before.unshift(n("!%s)!",[b])))};w.prototype.tabnote=function(a,b,c,f,d){var e;var g=this.step_map[b]+parseInt(a||"0");11<g&&(c+=1,g-=12);0>g&&(--c,g+=12);a=d.tab[0];b=d.tab[1];for(e=0;4>e;++e){var p=
this.note_alts[e%3][g];var l=c;-1<["^B","^^B"].indexOf(p)&&--l;-1<["_C","__C"].indexOf(p)&&(l+=1);if(-1<p.indexOf("/")||3==e)l=9;p=M(p,l);var q=this.tabmap[[f,p]]||["",""];l=q[0];q=q[1];if(!l)break;if(a==l)return p;3==e&&(k("rejected: voice %d note %s string %s fret %s remains: string %s fret %s",[f,p,a,b,l,q]),d.tab=[l,q])}this.tabmap[[f,p]]=d.tab;return p};w.prototype.scanEdo=function(a){var b=a.find("accidental").toArray();b=b.concat(a.find("key-accidental").toArray());var c=!1,f=!1;b=$jscomp.makeIterator(b);
for(var d=b.next();!d.done;d=b.next())d=A($(d.value).text()),d in this.edo12alt||(d in this.edo36alt&&(f=!0),d in this.edo53alt&&(c=!0));c&&f&&k("this score mixes edo53 and edo36 accidentals.",[]);f&&1==this.temp&&(c=!0,f=!1);this.edo=c?53:f?36:0;2==this.temp&&(this.edomap=this.edomix);0<this.edo&&((a=a.find("identification>encoding>software").text())&&this.autoacc&&(0<=a.search(/abc2xml/i)&&(this.musfin=0),0<=a.search(/burak/i)&&(this.musfin=1),0<=a.search(/finale/i)&&(this.musfin=3)),v.info("encoder: "+
["strict","burak","musescore","finale"][this.musfin]+", tuning: EDO"+this.edo+" ",""))};w.prototype.getcuralt=function(a,b,c,f){a=a+"#"+b+"#"+c;return a in this.curalts?this.curalts[a]:this.msralts[f]};w.prototype.alt2acc=function(a,b){/[+-]?[01]\.0/.test(a)&&(a=Math.round(a)+"");if(0<=a.indexOf("."))return!a.match(/[+-]?0\.5/)||1<this.musfin?"":"0.5"==a?"quarter-sharp":"quarter-flat";b=$jscomp.makeIterator(Object.keys(this.edo12alt));for(var c=b.next();!c.done;c=b.next())if(c=c.value,this.edo12alt[c]==
a)return c;return""};w.prototype.acc2abc=function(a){var b=0;switch(this.edo){case 53:var c=this.edo53alt[a];break;case 36:c=this.edo36alt[a];break;default:c=this.edo12alt[a]}void 0==c&&(c=this.edomap[a],b=1);return void 0==c?(k("unknown accidental %s",[a]),"="):0==c?"=":0<this.edo?(a=0<c?"^"+c:"_"+-c,2==this.temp&&b&&(a+="/3"),36==this.edo&&(a=a.replace("3","")),a):["__","_","=","^","^^"][c+2]};w.prototype.ntAbc=function(a,b,c,f,d,e,h){b+=this.clefOct[this.curStf[f]]||0;var g=A(c.find("accidental").text()),
l=c.find("pitch>alter").text();if(e.tab)return this.tabnote(l,a,b,f,e);h&&this.tstep&&(e=["__","_","","^","^^"][parseInt(l||"0")+2]+M(a,b),k("no string notation found for note %s in voice %d",[e,f]));b=M(a,b);e=b+"#"+f+"#"+d;if(g){if(3>this.musfin&&(l=this.altkey?this.getcuralt(b,f,d,a):this.curalts[e],g==l&&!h))return b;this.curalts[e]=g;return b=this.acc2abc(g)+b}""==l?3>this.musfin&&(l=this.getcuralt(b,f,d,a))&&(1==this.musfin?g=this.ingrace?l:"natural":this.edo12alt[l]?g="natural":2>this.musfin&&
(g="natural")):3>this.musfin&&(g=this.alt2acc(l));if(""!==g){l=this.getcuralt(b,f,d,a);if(g==l||"natural"==g&&!l||c.find("tie").add(c.find("notations>tied")).get().some(function(a){return"stop"==$(a).attr("type")}))return b;a=this.acc2abc(g);k("accidental %d added in part %d, measure %d, voice %d note %s",[a,this.msr.ixp+1,this.msr.ixm+1,f+1,b]);this.curalts[e]=g;b=a+b}return b};w.prototype.doNote=function(a){var b=new D(0,null),c=parseInt(a.find("voice").text()||"1"),d=parseInt(a.find("staff").text()||
"1");b.xmlvce=c;b.xmlstf=d;this.isSib&&(c+=100*d);var g=0<a.find("chord").length,e=a.find("pitch>step").text()||a.find("unpitched>display-step").text(),h=a.find("pitch>octave").text()||a.find("unpitched>display-octave").text(),p=0<a.find("rest").length,l=a.find("time-modification>actual-notes").text();if(l){var q=a.find("time-modification>normal-notes").text();b.fact=[parseInt(l),parseInt(q)]}b.tup=a.find("notations>tuplet").map(function(){return $(this).attr("type")}).get();var k=a.find("duration").text();
b.type=this.note_type[a.find("type").text()]||0;l=a.find("grace");b.grace=0<l.length;b.grace&&!g&&this.grcNotes.push(b);b.before=[""];b.after="";q=0==(this.curClef&&this.curClef[this.curStf[c]]||"").indexOf("tab");b.grace&&!this.ingrace&&(this.ingrace=1,b.before=["{"],"yes"!=l.attr("slash")||q||b.before.push("/"));if(l=!b.grace&&this.ingrace)1==this.grcNotes.length&&(this.grcNotes[0].type*=2),this.grcNotes=[],this.ingrace=0,this.msc.lastnote.after+="}";if(!k||b.grace)k=0;if(!p&&"no"==a.attr("print-object")){if(g)return;
p=1}b.dur=parseInt(k);p||e&&h||(this.msc.cnt.inc("nopt",c),h=5,e="E");k=a.find("notations");k.length&&this.doNotations(b,k,q);k=a.find("stem");!p&&k.length&&"none"==k.text()&&(!q||c in this.hasStems||this.tstep)&&(b.before.push("s"),v.stemless=1);k=a.find("accidental");k.length&&"yes"==k.attr("parentheses")&&(b.ntdec+="!courtesy!");d=p?"no"==a.attr("print-object")||q?"x":"z":this.ntAbc(e,parseInt(h),a,c,d,b,q);if(a.find("unpitched").length){p=this.curClef[this.curStf[c]];e=X(e,parseInt(h),p,this.tstep);
h=a.find("instrument");h=h.length?h.attr("id"):"dummyId";h=this.drumInst[h]||O(d);p=a.find("notehead");q=p.text().replace(" ","-");"x"==q&&(d="^"+d.replace(/\^/g,"").replace(/_/g,""));if("circle-x"==q||"diamond"==q||"triangle"==q)d="_"+d.replace(/\^/g,"").replace(/_/g,"");"yes"==p.attr("filled")&&(q+="+");"no"==p.attr("filled")&&(q+="-");this.drumNotes[c+";"+d]=[e,h,q]}e=a.find("tie").add(a.find("notations>tied")).get();e.some(function(a){return"start"==$(a).attr("type")})&&(d+="-");e=a.find("beam").map(function(){return $(this).text()}).get();
b.beam=-1<e.indexOf("continue")||-1<e.indexOf("end")||b.grace;e=a.find("lyric");for(h=p=0;h<e.length;++h)q=$(e[h]),k=parseInt((q.attr("number")||"1").replace(/^.*verse/,"")),0==k?k=p+1:p=k,b.lyrs[k]=ia(q);e=a.find("stem").text();!this.wstems||"up"!=e&&"down"!=e||e==this.stemDir[c]||(this.stemDir[c]=e,this.msc.appendElem(c,n("[I:stemdir %s]",[e])));g?this.msc.addChord(b,d):this.msc.appendNote(c,b,d);e=a.find("notations>slur");for(h=0;h<e.length;++h)a=$(e[h]),this.matchSlur(a.attr("type"),a.attr("number"),
c,this.msc.lastnote,b.grace,l)};w.prototype.doAttr=function(a){var b,c;var d={C1:"alto1",C2:"alto2",C3:"alto",C4:"tenor",F4:"bass",F3:"bass3",G2:"treble",TAB:"tab",percussion:"perc"};if(b=a.find("divisions").text())this.msr.divs=parseInt(b);b=parseInt(a.find("transpose>chromatic").text()||"0");var g=a.find("key>fifths").first().text();var e=a.find("key>key-step").first().text();var h=0==this.msc.tijd&&0==this.msr.ixm;if(g||e)(g?(g=Y(parseInt(g),a.find("key>mode").first().text()||"major"),e=$jscomp.makeIterator(g),
g=e.next().value,this.msralts=e.next().value):(e=$jscomp.makeIterator(Z(a,this)),g=e.next().value,this.msralts=e.next().value,this.altkey=1),!h||b%12||"none"!=v.key)?g==v.key&&h||(this.msr.attr+="[K:"+g+"]"):v.key=g;if(g=a.find("time>beats").text()){e=a.find("time>beat-type").text();var p=g+"/"+e;h?v.mtr=p:this.msr.attr+="[M:"+p+"]";this.msr.mtr=[parseInt(g),parseInt(e)]}this.msr.mdur=this.msr.divs*this.msr.mtr[0]*4/this.msr.mtr[1];var l=this;a.find("measure-style").each(function(){var a,b,c,d,f;
var e=parseInt($(this).attr("number")||"1");var g=l.stfMap[e];$(this).find("measure-repeat").each(function(){a=$(this).attr("type");"start"==a?(l.repeat_str[e]=[l.msr.ixm,$(this).text()],g.forEach(function(a){l.msc.insertElem(a,l.repeat_str[e])})):"stop"==a&&(b=l.repeat_str[e][0],d=l.repeat_str[e][1],c=l.msr.ixm-b,d?(f=d+" ",c/=parseInt(d)):f="",l.repeat_str[e][0]=n("[I:repeat %s%d]",[f,c]),delete l.repeat_str[e])})});(g=a.find("transpose>octave-change").text()||"")&&(b+=12*parseInt(g));g=a.find("clef");
e={};p=a.find("staff-details");for(a=0;a<p.length;a++){var k=p.eq(a);e[k.attr("number")||1]=k}for(a=0;a<g.length;a++){var m=$(g[a]);p=parseInt(m.attr("number")||"1");var r=m.find("sign").text();k="percussion"!=r&&"TAB"!=r?m.find("line").text()||"":"";k=d[r+k]||"";m=m.find("clef-octave-change").text()||"0";k+={"-2":"-15","-1":"-8",1:"+8",2:"+15"}[m]||"";this.clefOct[p]=-parseInt(m);b&&"TAB"!=r&&(k+=" transpose="+b);if(c=e[p]){if(m=c.find("staff-lines").text())r="3"==m&&"TAB"==r?"|||":m,k+=" stafflines="+
r,this.stafflines=parseInt(m);var t=[];c.find("staff-tuning").each(function(){t.push($(this).find("tuning-step").text()+$(this).find("tuning-octave").text())});t.length&&(k+=n(" strings=%s",[t.join(",")]));(r=c.find("capo").text())&&(k+=n(" capo=%s",[r]))}this.curClef[p]=k;if(h)this.clefMap[p]=k;else for(r=this.stfMap[p],c=0;c<r.length;++c){m=r[c];var w=new E("[K:"+k+"]",p);this.msc.appendObj(m,w,0)}}};w.prototype.findVoice=function(a,b){var c=b.eq(a);var d=parseInt(c.find("staff").text()||"1");var g=
this.stfMap[d];g=g.length?g[0]:1;if(this.dirtov1)return{sn:d,v:g,v1:g};for(a+=1;a<b.length;++a){c=b.eq(a);if("note"==c[0].tagName)return b=parseInt(c.find("staff").text()||"1"),d=parseInt(c.find("voice").text()||"1"),this.isSib&&(d+=100*b),b=this.vce2stf[d],{sn:b,v:d,v1:g};if("backup"==c[0].tagName)break}return{sn:d,v:g,v1:g}};w.prototype.doDirection=function(a,b,c){function d(a,b,c,d,f){b&&(c=0<=b.indexOf("!8v")?a.stfMap[f]:[c],c.forEach(function(c){null!=d?a.msc.appendElemT(c,b.replace("(",")").replace("ped",
"ped-up"),d):a.msc.appendElem(c,b)}))}function g(a,b,c,f){var g={down:"!8va(!",up:"!8vb(!",crescendo:"!<(!",diminuendo:"!>(!",start:"!ped!"};e=C.attr("type")||"";var h=b+(C.attr("number")||"1");if(e in g)if(g=g[e],h in a.dirStk){var l=a.dirStk[h];delete a.dirStk[h];"stop"==l.type?d(a,g,c,l.tijd,f):(k("%s direction %s has no stop in part %d, measure %d, voice %d",[b,l.type,a.msr.ixp+1,a.msr.ixm+1,c+1]),a.dirStk[h]={type:e,vs:c})}else a.dirStk[h]={type:e,vs:c};else if("stop"==e)h in a.dirStk?(l=a.dirStk[h],
delete a.dirStk[h],e=l.type,c=l.vs,"stop"==e?(k("%s direction %s has double stop in part %d, measure %d, voice %d",[b,e,a.msr.ixp+1,a.msr.ixm+1,c+1]),g=""):g=g[l.type].replace("(",")").replace("ped","ped-up")):(a.dirStk[h]={type:"stop",tijd:a.msc.tijd},g="");else throw"wrong direction type";d(a,g,c,null,f)}var e,h,p,l="";var q=a.attr("placement");var m=this.findVoice(b,c);var r=m.sn;var t=m.v;var w=m.v1;var z="",J={dacapo:"D.C.",dalsegno:"D.S.",tocoda:"dacoda",fine:"fine",coda:"O",segno:"S"};var C=
a.find("sound");if(C.length){var A=C.find("midi-instrument");if(A.length){var B=C.find("midi-instrument>midi-program").text();m=C.find("midi-instrument>midi-channel").text();for(p in this.vceInst)this.vceInst[p]==A.attr("id")&&(t=p);(p=(B?B-1:m)+"")&&0<v.volpan&&this.msc.appendElem(t,"[I:MIDI= "+(B?"program":"channel")+" "+p+"]")}B=C.find("instrument-change>score-instrument");B.length&&(B=B.attr("id"),p=$jscomp.makeIterator(this.instMid[this.msr.ixp][B]),m=p.next().value,B=p.next().value,p.next(),
p.next(),m=this.findVoice(b,c),b=$jscomp.makeIterator(["program",B-1]),B=b.next().value,p=b.next().value,0<v.volpan&&this.msc.appendElem(t,"[I:MIDI= "+B+" "+p+"]"));if(B=C.attr("tempo")){B=parseFloat(B).toFixed(0);var y=[1,4]}for(u in J)if(C.attr(u)){z=J[u];break}}J=a.children("direction-type");for(b=0;b<J.length;++b){a=$(J[b]);var u={whole:[1,1],half:[1,2],quarter:[1,4],eighth:[1,8]};c=a.find("metronome");c.length&&(C=c.find("beat-unit").text()||"",y=C in u?u[C]:u.quarter,c.find("beat-unit-dot").length&&
(y=I(3*y[0],2*y[1])),(u=c.find("per-minute").text().match(/[.\d]+/))&&(B=u[0]));C=a.find("wedge");C.length&&g(this,"wedge",t);u=a.find("words");0==u.length&&(u=a.find("rehearsal"));for(c=0;c<u.length;++c){if(z){this.msc.appendElem(t,n("!%s!",[z]),1);break}var D="below"==q?"_":"^";p=$(u[c]);0>parseFloat(p.attr("default-y")||"0")&&(D="_");l+=p.text().replace(/"/g,'\\"').replace(/\n/g,"\\n")}l=l.trim();for(h in U)u=U[h],a.find("dynamics>"+h).length&&this.msc.appendElem(t,u,1);a.find("coda").length&&
this.msc.appendElem(t,"O",1);a.find("segno").length&&this.msc.appendElem(t,"S",1);C=a.find("octave-shift");C.length&&g(this,"octave-shift",t,r);C=a.find("pedal");C.length&&this.ped&&(this.pedVce||(this.pedVce=t),g(this,"pedal",this.pedVce));"diatonic fretting"==a.find("other-direction").text()&&(this.diafret=1)}B&&(B=parseFloat(B).toFixed(0),0==this.msc.tijd&&0==this.msr.ixm?(v.tempo=B,v.tempo_units=y):this.msc.appendElem(w,n("[Q:%d/%d=%s]",[y[0],y[1],B])));l&&this.msc.appendElem(t,'"'+D+l+'"',1)};
w.prototype.doHarmony=function(a,b,c){c=this.findVoice(b,c).v;var d={major:"",minor:"m",augmented:"+",diminished:"dim",dominant:"7","half-diminished":"m7b5"};b={major:"maj",dominant:"",minor:"m",diminished:"dim",augmented:"+",suspended:"sus"};var g={second:"2",fourth:"4",seventh:"7",sixth:"6",ninth:"9","11th":"11","13th":"13"};var e={1:"#",0:"","-1":"b"};var h=a.find("root>root-step","").text();var k=e[a.find("root>root-alter").text()]||"";var l="";var q=a.find("kind").text();q in d?q=d[q]:-1<q.indexOf("-")?
(d=q.split("-"),q=d[0],d=d[1],q=(b[q]||"")+(g[d]||""),0==q.indexOf("sus")&&(l=q,q="")):"none"==q&&(q=a.find("kind").attr("text"));g=a.find("degree");for(b=0;b<g.length;++b)d=$(g[b]),q+=(e[d.find("degree-alter").text()]||"")+d.find("degree-value").text();q=q.replace("79","9").replace("713","13").replace("maj6","6");a=a.find("bass>bass-step").text()+(e[a.find("bass>bass-alter").text()]||"");this.msc.appendElem(c,'"'+h+k+q+l+(a&&"/"+a)+'"',1)};w.prototype.doBarline=function(a){var b=a.find("repeat"),
c=0;b.length&&(c=b.attr("direction"));if(this.unfold)return c?"forward"==c?1:2:0;"right"==(a.attr("location")||"right")&&(b=a.find("bar-style").text(),"light-light"==b?this.msr.rline="||":"light-heavy"==b&&(this.msr.rline="|]"));c&&("forward"==c?this.msr.lline=":":this.msr.rline=":|");a=a.find("ending");a.length&&("start"==a.attr("type")?(a=(a.attr("number")||"1").replace(/\./g,"").replace(/ /g,""),/^[\d,]+$/.test(a)||(a='"'+a.trim()+'"'),this.msr.lnum=a):"|"==this.msr.rline&&(this.msr.rline="||"));
return 0};w.prototype.doPrint=function(a){if("yes"==a.attr("new-system")||"yes"==a.attr("new-page"))return this.nolbrk?"":"$"};w.prototype.doPartList=function(a){var b,c;var d=a.find("part-list>score-part");for(b=0;b<d.length;++b){var g=d[b];var e={};var h=$(g).find("midi-instrument");for(g=0;g<h.length;++g){var k=$(h[g]);var l=["midi-channel","midi-program","volume","pan"];var q=[];for(c=0;c<l.length;++c){var m=l[c];q.push(k.find(m).text()||this.midDflt[c])}c=1*q[3];-90<=c&&90>=c&&(c=(c+90)/180*
127);e[k.attr("id")]=[parseInt(q[0]),parseInt(q[1]),1.27*parseFloat(q[2]),c];(q=k.find("midi-unpitched").text())&&(this.drumInst[k.attr("id")]=q-1)}this.instMid.push(e)}a=a.find("part-list");q=ea(a);return K(q,{},[])[0]};w.prototype.mkTitle=function(a){var b=[],c=[],d=[],g,e;var h=a.find("work>work-title").text().trim();var p=a.find("movement-title").text().trim();var l=a.find("identification>creator");for(g=0;g<l.length;++g){var m=$(l[g]);var n=m.text();m=m.attr("type");n&&(n=n.split("\n").map(function(a){return a.trim()}),
"composer"==m?b.push.apply(b,n):("lyricist"==m||"transcriber"==m)&&c.push.apply(c,n))}l=a.find("identification>rights");for(g=0;g<l.length;++g)if(n=$(l[g]).text())n=n.split("\n").map(function(a){return a.trim()}),c.push.apply(c,n);l=a.find("credit");for(g=0;g<l.length;++g){n="";m=$(l[g]).find("credit-words");for(e=0;e<m.length;++e)n+=$(m[e]).text();d.push(n.replace(/\s*[\r\n]\s*/g," "))}d=function(a){function f(a){return a&&-1<l.indexOf(a)}var e=[],g;for(g=0;g<d.length;++g){var l=d[g];6>a&&(l&&-1<
h.indexOf(l)||l&&-1<p.indexOf(l))||5>a&&(l&&-1<b.indexOf(l)||l&&-1<c.indexOf(l))||4>a&&(h&&-1<l.indexOf(h)||p&&-1<l.indexOf(p))||3>a&&(b.some(f)||c.some(f))||2>a&&/^[\d\W]*$/.test(l)||e.push(l)}0==a&&h+p&&(e="");return e}(this.ctf);h&&(h="T:"+h.replace(/\n/g,"\nT:")+"\n");p&&(h+="T:"+p.replace(/\n/g,"\nT:")+"\n");d.length&&(h+=d.map(function(a){return"T:"+a}).join("\n")+"\n");b.length&&(h+=b.map(function(a){return"C:"+a}).join("\n")+"\n");c.length&&(h+=c.map(function(a){return"Z:"+a}).join("\n")+
"\n");h&&(v.title=h.substr(0,h.length-1));(this.isSib=0<=a.find("identification>encoding>software").text().indexOf("Sibelius"))&&k("Sibelius MusicXMl is unreliable",[])};w.prototype.doDefaults=function(a){if(this.doPageFmt){var b=a.find("defaults");if(b.length){a=b.find("scaling>millimeters").text();var c=b.find("scaling>tenths").text();c=a/c/10;a=b.find("page-layout>page-width").text()*c;var d=b.find("page-layout>page-margins").first();b=d.find("left-margin").text();d=d.find("right-margin").text();
var g=10*c/.2117;!v.scale&&g&&(v.scale=g.toFixed(2));!v.pagewidth&&a&&(v.pagewidth=a.toFixed(2));v.leftmargin||""==b||(v.leftmargin=(b*c).toFixed(2));v.rightmargin||""==d||(v.rightmargin=(d*c).toFixed(2))}}};w.prototype.locStaffMap=function(a){var b={};this.vceInst={};this.msc.vnums={};this.hasStems={};this.stfMap={};this.clefMap={};a=a.find("measure>note");for(var c=0;c<a.length;c++){var d=$(a[c]),g=parseInt(d.find("voice").text()||"1");this.isSib&&(g+=100*(d.find("staff").text()||1));this.msc.vnums[g]=
1;var e=parseInt(d.find("staff").text()||"1");this.stfMap[e]=[];if(g in b){var h=b[g];h[e]=(h[e]||0)+1}else h={},h[e]=1,b[g]=h;h=d.find("instrument");h.length&&(this.vceInst[g]=$(h).attr("id"));h=d.find("stem");0!=d.find("rest").length||0!=h.length&&"none"==h.text()||(this.hasStems[g]=1)}for(g in b){a=[];c=b[g];for(e in c)a.push([c[e],e]);a.sort(function(a,b){return a[0]-b[0]});a=a[a.length-1][1];this.stfMap[a].push(g);this.vce2stf[g]=a;this.curStf[g]=a}};w.prototype.emptyStaves=function(a,b){var c=
this,d=a[0];if(this.vce2stf=={})return a;var g=Object.keys(this.vce2stf).reduce(function(a,b){return Math.max(+a,+b)},[]),e=Object.entries(this.stfMap);e=e.filter(function(a){a=$jscomp.makeIterator(a);a.next();return 0==a.next().value.length});e=e.map(function(a){a=$jscomp.makeIterator(a);var b=a.next().value;a.next();return b});if(0==e.length)return a;var h=$("<part></part>",d);h.attr("id",a.attr("id"));var k=$("<measure></measure>",d);e.forEach(function(f,e){var l=g+e+1,p=b.eq(0),m=a.find("divisions").text()||
"1";e=$("<backup></backup>",d);var n=$("<duration>"+m+"</duration>",d);e.append(n);var q=$("<note></note",d);q.attr("print-object","no");n=$("<rest></rest>",d);n.attr("measure","yes");m=$("<duration>"+m+"</duration>");l=$("<voice>"+l+"</voice>");f=$("<staff>"+f+"</staff>");q.append([n,m,l,f]);f=p.children();for(p=0;p<f.length&&"note"!=f[p].tagName;p++);f.splice(p,0,e[0]);f.splice(p,0,q[0]);k.append(f);h.append(k);h.append(b.slice(1));c.msc.wev=!0});this.locStaffMap(h);return h};w.prototype.addStaffMap=
function(a){var b,c,d=[],g=Object.keys(this.stfMap).sort(function(a,b){return a-b});for(c=0;c<g.length;++c){var e=g[c];var h=this.stfMap[e];var k=[];var l=[];for(b=0;b<h.length;++b){var m=h[b];m in a&&(k.push(a[m]),l.push(void 0==this.hasStems[m]))}if(k.length)for(d.push(k),h=(e in this.clefMap)?this.clefMap[e]:"treble",b=0;b<k.length;++b)m=k[b],e="",0==h.indexOf("tab")&&(l[b]&&0>h.indexOf("nostems")&&(e=" nostems"),this.diafret&&0>h.indexOf("diafret")&&(e+=" diafret")),v.clefs.set(m,h+e)}this.gStfMap.push(d)};
w.prototype.addMidiMap=function(a,b){var c=this.instMid[a],d=Object.keys(c);var g=d.length?c[d[0]]:this.midDflt;a=[];var e=this;for(m in b){d=Object.keys(this.drumNotes).sort().filter(function(a){return a.split(";")[0]==m});var h=d.map(function(a){return{nt:a.split(";")[1],step:e.drumNotes[a][0],midi:e.drumNotes[a][1],nhd:e.drumNotes[a][2]}});var k=b[m];d=this.vceInst[m]||"";d in c?a.push([k,c[d].concat(h)]):a.push([k,g.concat(h)])}a.sort(function(a,b){return a[0]-b[0]});a.forEach(function(a){e.midiMap.push(a[1])});
g="E G B d f a c' e'".split(" ");var l="0 1- 1 1+ 2 3 3 4 4 5 6 6+ 7 8- 8 8+ 9 10 10 11 11 12 13 13+ 14".split(" ");d=Object.keys(this.tabmap).sort();for(c=0;c<d.length;++c){k=d[c];a=k.match(/(\d+),(.*)/);var m=a[1];var t=a[2];h=this.tabmap[k][0];var r=this.tabmap[k][1];this.diafret&&(r=l[parseInt(r)]);k=b[m];h=this.stafflines-parseInt(h);a=this.tabVceMap[k]||[];a.push(n("%%map tab%d %s print=%s heads=kop%s\n",[k,t,g[h],r]));this.tabVceMap[k]=a;this.koppen[r]=1}};w.prototype.parse=function(a){var b=
{},c=$(a);this.scanEdo(c);this.mkTitle(c);this.doDefaults(c);a=this.doPartList(c);for(var d=c.find("part"),g=0;g<d.length;++g){var e=d.eq(g),h=e.find("measure");this.locStaffMap(e);e=this.emptyStaves(e,h);h=e.find("measure");this.drumNotes={};this.clefOct={};this.curClef={};this.stemDir={};this.tabmap={};this.diafret=0;this.stafflines=5;this.msc.initVoices(1);this.maatRecs=[];this.msr={};for(var m=e=0,l=0;l<h.length;){var q=h.eq(l),t=0,r="";this.msr=new z(g,l,this.msr);this.curalts={};for(var u=q.children(),
w=0;w<u.length;w++)switch(c=u.eq(w),c[0].tagName){case "note":this.doNote(c);break;case "attributes":this.doAttr(c);break;case "direction":this.doDirection(c,w,u);break;case "sound":this.doDirection(q,w,u);break;case "harmony":this.doHarmony(c,w,u);break;case "barline":t=this.doBarline(c);break;case "backup":c=parseInt(c.find("duration").text());L(c,this.msr)&&this.msc.incTime(-c);break;case "forward":c=parseInt(c.find("duration").text());L(c,this.msr)&&this.msc.incTime(c);break;case "print":r=this.doPrint(c)}this.msc.addBar(r,
this.msr,this.curStf,this.isSib);this.maatRecs.push(this.msr);1==t?(m=l,l+=1):2==t?1>e?(l=m,e+=1):(e=0,l+=1):l+=1}for(var y in this.repeat_str)h=this.repeat_str[y],h[0]=n("[I:repeat %s %d]",[h[1],1]);h=this.msc.outVoices(this.maatRecs,g);this.addStaffMap(h);this.addMidiMap(g,h);for(y in h)b[y]=h[y]}Object.keys(b).length?v.mkHeader(this.gStfMap,a,this.midiMap,this.tabVceMap,this.koppen,this.edo):k("nothing written, %s has no notes ...",[v.fnmext])};vertaal=function(a,b){var c={u:0,b:0,n:0,c:0,v:0,
d:0,m:0,x:0,t:0,v1:0,noped:0,stm:0,mnum:-1,temp:0,s:0,fin:-1,p:"f",rbm:0,nbr:0,wev:0},d;for(d in b)c[d]=b[d];c.p=c.p?c.p.split(","):[];v=new H(".abc","",0,c);b=new w(c);try{b.parse(a)}catch(g){k("** exception occurred: %s",[g])}return v.writeall()}})();"undefined"!=typeof exports&&(exports.vertaal=vertaal,exports.xml2abc_VERSION=xml2abc_VERSION);
