@dsebastien/music-notation 0.10.1 → 0.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +7 -4
- package/dist/blocks/properties.d.ts +2 -0
- package/dist/blocks/renderers.d.ts +11 -2
- package/dist/chord/generate.d.ts +13 -4
- package/dist/chords/chart.d.ts +51 -1
- package/dist/cli.js +3 -3
- package/dist/fretboard/exercise.d.ts +86 -0
- package/dist/index.d.ts +10 -4
- package/dist/index.js +5873 -3821
- package/dist/index.js.map +32 -23
- package/dist/music-notation.css +105 -0
- package/dist/music-notation.publish.min.js +134 -24
- package/dist/music-notation.tab.min.js +112 -7
- package/dist/picking/pattern.d.ts +59 -0
- package/dist/picking/play.d.ts +87 -0
- package/dist/picking/render.d.ts +17 -0
- package/dist/picking/voicing.d.ts +19 -0
- package/dist/playback/app-bar.d.ts +8 -0
- package/dist/playback/controls.d.ts +27 -0
- package/dist/playback/picking-bar.d.ts +10 -0
- package/dist/playback/progression-bar.d.ts +8 -0
- package/dist/playback/progression.d.ts +124 -0
- package/dist/playback/strum-bar.d.ts +28 -1
- package/dist/publish/index.js +6058 -4145
- package/dist/publish/index.js.map +32 -23
- package/dist/render/layout.d.ts +35 -0
- package/dist/strum/play.d.ts +18 -0
- package/dist/tab/index.d.ts +5 -0
- package/dist/tab/index.js +5 -1
- package/dist/tab/index.js.map +3 -3
- package/dist/voicings/index.js +202 -18
- package/dist/voicings/index.js.map +5 -5
- package/package.json +1 -1
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
/*! @dsebastien/music-notation 0.
|
|
2
|
-
(()=>{var He=(e,n)=>{for(let[t,r]of Object.entries(n))if(r!==void 0)e.setAttribute(t,String(r))};function W(e,n,t={},r=[]){let o=e.createElementNS("http://www.w3.org/2000/svg",n);He(o,t);for(let s of r)if(s)o.appendChild(s);return o}function A(e,n,t,r){let o=e.createElement(n);if(t)o.className=t;if(r!==void 0)o.textContent=r;return o}var rn=`mn-name-${Math.random().toString(36).slice(2,8)}-`;var Ve=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Ie=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],se={C:0,D:2,E:4,F:5,G:7,A:9,B:11};function R(e){let n=/^([A-Ga-g])([#♯b♭]*)$/.exec(e.trim());if(!n)return null;let t=se[n[1].toUpperCase()];for(let r of n[2])t+=r==="#"||r==="♯"?1:-1;return(t%12+12)%12}function q(e){let n=/^([A-Ga-g][#♯b♭]*)(-?\d)$/.exec(e.trim());if(!n)return null;let t=R(n[1]);if(t===null)return null;let r=se[n[1][0].toUpperCase()],o=Math.round((t-r)/12);return(Number(n[2])+1)*12+t-o*12}var ze=(e,n=!1)=>(n?Ie:Ve)[((Math.round(e)||0)%12+12)%12];var ae=(e,n=!1)=>`${ze(e,n)}${Math.floor(e/12)-1}`;var je=new Map(Object.entries({standard:"E2 A2 D3 G3 B3 E4","drop d":"D2 A2 D3 G3 B3 E4","drop c":"C2 G2 C3 F3 A3 D4","drop b":"B1 F#2 B2 E3 G#3 C#4","drop a":"A1 E2 A2 D3 F#3 B3","double drop d":"D2 A2 D3 G3 B3 D4",dadgad:"D2 A2 D3 G3 A3 D4","open g":"D2 G2 D3 G3 B3 D4","open d":"D2 A2 D3 F#3 A3 D4","open e":"E2 B2 E3 G#3 B3 E4","open c":"C2 G2 C3 G3 C4 E4","open a":"E2 A2 E3 A3 C#4 E4","half step down":"Eb2 Ab2 Db3 Gb3 Bb3 Eb4","whole step down":"D2 G2 C3 F3 A3 D4","modal c6":"C2 A2 C3 G3 C4 E4",c6:"C2 A2 C3 G3 C4 E4",bass:"E1 A1 D2 G2",ukulele:"G4 C4 E4 A4"}));function H(e){let n=e.trim(),t=je.get(n.toLowerCase().replace(/\s*\(.*\)$/,""));if(t)return H(t);let r=n.split(/[\s,]+/).filter(Boolean);if(r.length>1&&r.every((a)=>q(a)!==null))return r.map((a)=>q(a));let o=r.length>1?r:n.match(/[A-G][#♯b♭]?|[a-g][#♯♭]?/g)??[];if(o.length<2||o.join("")!==r.join(""))return null;let s=[];for(let a of o){let l=R(a);if(l===null)return null;let m=s[s.length-1];if(m===void 0){let u=[28,40,52].map((i)=>i-i%12+l);s.push(u.reduce((i,d)=>Math.abs(d-40)<Math.abs(i-40)?d:i))}else{let u=m-m%12+l;while(u<=m)u+=12;s.push(u)}}return s}var Ue=/^\s*([A-Ga-g][#b]?|[1-8](?=\s*[|:]))?\s*[|:]?/,_e=/^[-0-9xX|:hpbrsvt/\\~^().*<>\s]*$/,We=/^\s*([A-Za-z][A-Za-z0-9. -]{0,14}?)\s*[|:]([-xXoOgfdb#@*+|:\s]*)$/,qe=new Map(Object.entries({hihat:"h hh hat hihat hihats","hihat-open":"oh openhat openhihat","hihat-foot":"hf fh hp ph pedal hihatfoot hihatpedal",crash:"c c1 cc cr cy cym crash crash1 cymbal",crash2:"c2 cr2 crash2",ride:"r rd rc ride",splash:"sp spl splash",china:"ch cn chi china",cowbell:"cb cow cowbell",snare:"s sd sn sr snare snaredrum",tom1:"t t1 ht tom1 hightom hitom",tom2:"t2 mt tom2 midtom",tom3:"t3 lt tom3 lowtom",floor:"f ft fl t4 tom4 floor floortom",kick:"b bd bs k kd bass kick bassdrum kickdrum"}).flatMap(([e,n])=>n.split(" ").map((t)=>[t,e])));function Ke(e,n){let t=n==="#";switch(e){case"hihat":return n==="o"||n==="O"?"HiHatOpen":"HiHatClosed";case"hihat-open":return"HiHatOpen";case"hihat-foot":return"PedalHiHatHit";case"crash":return t?"CrashHighChoke":"CrashHighHit";case"crash2":return t?"CrashMediumChoke":"CrashMediumHit";case"ride":return t?"RideChoke":"RideMiddle";case"splash":return t?"SplashChoke":"SplashHit";case"china":return t?"ChinaChoke":"ChinaHit";case"cowbell":return"CowbellMediumHit";case"snare":return"SnareHit";case"tom1":return"HighTomHit";case"tom2":return"MidTomHit";case"tom3":return"LowTomHit";case"floor":return"VeryLowTomHit";case"kick":return"KickHit"}}var Xe=(e)=>e==="X"||e==="O"?["ac"]:e==="g"?["g"]:[],Ye=/[^-0-9xXoOgfdbhprsvt/\\~^().*<>#@+|:\s]|<(?!\d)/,Je=/^\s*(?:[xX]\s*\d{1,3}|\d{1,3}\s*[xX])\s*$/;function Ze(e){let n=e.lastIndexOf("|");if(n<0)return{line:e,text:null};let t=e.slice(n+1),r=t.trim();if(!r)return{line:e,text:null};return Ye.test(r)||Je.test(r)||/^\s/.test(t)&&!r.includes("--")?{line:e.slice(0,n+1),text:r}:{line:e,text:null}}function Qe(e){let{line:n,text:t}=Ze(e.trimEnd()),r=null,o=Ue.exec(n),s=n.slice(o[0].length);if(_e.test(s)&&(n.match(/-/g)?.length??0)>=4&&(n.includes("|")||/^\s*[A-Ga-g][#b]?\s*[-|:]/.test(n)))r={name:o[1]??null,body:s,offset:o[0].length,barred:/[|:]$/.test(o[0])};let a=null,l=We.exec(n),m=l?l[1].toLowerCase().replace(/[ .-]/g,""):"",u=qe.get(m);if(l&&u&&(l[2].match(/[^\s|:]/g)?.length??0)>=4)a={drum:u,name:m,body:l[2],lettered:/^[A-Ga-g]$/.test(l[1])};return r||a?{string:r,drum:a,text:t}:null}var be=(e)=>[...new Set(e.map((n)=>n.text).filter((n)=>n!==null))];function et(e){let n=[],t=0;for(let r=2;r<e.length-1;r++){let[o,s]=[e[t].string.name,e[t+1].string.name];if(o!==null&&e[r].string.name===o&&e[r+1].string.name===s&&r-t>=2)n.push(e.slice(t,r)),t=r}return n.push(e.slice(t)),n}function tt(e){let n=[],t=[];for(let r of e){if(t.some((o)=>o.drum.name===r.drum.name))n.push(t),t=[];t.push(r)}return n.push(t),n}var nt=/^[\sPpMm.\-_|=~]*$/,rt=/P\.?M/i;function ot(e){if(!nt.test(e)||!rt.test(e))return[];let n=[];for(let t=0;t<e.length;t++){let r=e[t];if((r==="P"||r==="p")&&/^\.?[Mm]/.test(e.slice(t+1,t+3)))n.push([t,t]);else if(r!==" "&&n.length)n[n.length-1][1]=t}return n}function ie(e,n=null){return et(e).flatMap((t,r)=>{let o=t.map((u)=>u.string.name);if(t.length<3&&o.some((u)=>u===null))return[];let s=t.map((u)=>u.string.body),a=t[0].string.offset,l=new Set;if(r===0&&n!==null)for(let[u,i]of ot(n))for(let d=Math.max(u,a);d<=i;d++)l.add(d-a);let m=t.some((u)=>!u.string.barred);return[{kind:"strings",names:o,lines:s,texts:be(t),muted:l,openStart:m}]})}function le(e,n){if(!e.length)return[];if(e.every((o)=>o.drum)&&e.some((o)=>!o.string||!o.drum.lettered||/[xXoOgfdb#@*+]/.test(o.drum.body)))return tt(e).map((o)=>({kind:"drums",drums:o.map((s)=>s.drum.drum),lines:o.map((s)=>s.drum.body),texts:be(o)}));if(e.every((o)=>o.string))return ie(e,n);let t=[],r=[];for(let o of[...e,null])if(o?.string)r.push(o);else{if(r.length)t.push(...ie(r,t.length?null:n));r=[]}return t}function st(e){let n=[],t=[],r=null,o=null;for(let s of e.split(/\r?\n/)){let a=Qe(s);if(a){if(!t.length)r=o;t.push(a)}else n.push(...le(t,r)),t=[];o=s}return n.push(...le(t,r)),n}function ce(e,n){let t=Math.max(...e.map((m)=>m.length)),r=e.map((m)=>m.padEnd(t,"-")),o=[],s=[],a=!1,l=0;for(let m=0;m<t;m++){if(r.every((c)=>c[m]==="|"||c[m]===":")){if(a)o.push({beats:s,start:l,end:m});s=[],a=!1,l=m+1;continue}if(r.some((c)=>c[m]!==" "))a=!0;let{beat:u,skip:i,at:d}=n(r,m);if(u.length)s.push({notes:u,col:d??m});m+=i}if(a)o.push({beats:s,start:l,end:t});return o}var G=(e)=>e!==void 0&&e>="0"&&e<="9",me=(e,n)=>(e==="1"||e==="2")&&G(n)&&Number(e+n)<=24;function at(e){let n=new Map,t=new Map,r=new Set,o=(s)=>{let a=s,l=e[a]==="(";if(l)a++;if(!G(e[a]))return{fret:null,next:s};let m=me(e[a],e[a+1])?2:1,u=Number(e.slice(a,a+m));for(let i=0;i<m;i++)r.add(a+i);if(a+=m,l&&e[a]===")")a++;return{fret:u,next:a}};for(let s=0;s<e.length;){if(!G(e[s])||r.has(s)){s++;continue}let a=me(e[s],e[s+1])?2:1,l=Number(e.slice(s,s+a));n.set(s,{fret:l,width:a});let m=[],u=e[s-1],i=s+a;if(u==="<"&&e[i]===">")m.push("nh"),i++;else if((u==="/"||u==="\\")&&!/[\d)>]/.test(e[s-2]??"-"))m.push(u==="/"?"sib":"sia");if(e[i]==="b"||e[i]==="^"){let p=o(i+1);i=p.next;let h=[0,(p.fret!==null&&p.fret>l?Math.min(p.fret-l,4):2)*2];if(e[i]==="r"){let f=o(i+1);i=f.next;let g=f.fret===null?0:(f.fret-l)*2;h.push(Math.min(h[1],Math.max(0,g)))}m.push(`b (${h.join(" ")})`)}if(e[i]==="~"||e[i]==="v"){m.push("v");while(e[i]==="~"||e[i]==="v")i++}let d=e[i],c=G(e[i+1])||e[i+1]==="("&&G(e[i+2]);if((d==="h"||d==="p")&&c)m.push("h");else if(d==="/"||d==="\\"||d==="s"){if(c)m.push("sl");else if(d!=="s")m.push(d==="/"?"sou":"sod")}if(m.length)t.set(s,m);s+=a}return{frets:n,effects:t}}var it=(e,n,t=[])=>(r,o)=>{let s=[],a=new Set,l=o,m=!1,u=(i,d)=>{let c=r[i][d],p=n.has(d)?["pm"]:[];if(c==="x"||c==="X"){s.push({tex:`x.${t[i]??i+1}`,effects:p}),a.add(i);return}let b=e[i].frets.get(d);if(!b)return;if(b.width===2&&d===o)m=!0;if(r[i][d-1]==="<")l=Math.min(l,d-1);s.push({tex:`${b.fret}.${t[i]??i+1}`,effects:[...e[i].effects.get(d)??[],...p],string:t[i]??i+1}),a.add(i)};if(r.forEach((i,d)=>u(d,o)),m)r.forEach((i,d)=>a.has(d)||u(d,o+1));return{beat:s,skip:m?1:0,at:l}},z={3:[64,59,55],4:[43,38,33,28],5:[43,38,33,28,23],6:[64,59,55,50,45,40],7:[64,59,55,50,45,40,35]},ue=[64,59,55,50,45,40,35,30],K={names:["E","A","D","G","B","E"],midis:[40,45,50,55,59,64]},lt=["E A D G","B E A D G"],X=(e)=>e[0].toUpperCase()+e.slice(1);function Y(e){let n=e.length;if(e.every((t)=>t!==null&&/^\d$/.test(t)))return e.every((t)=>ue[Number(t)-1])?e.map((t)=>ue[Number(t)-1]):null;if(e.every((t)=>t!==null&&/^[A-Ga-g]/.test(t))){let t=[...e].reverse(),r=t.map(X).join(" ");if(lt.includes(r))return H(r).map((a)=>a-12).reverse();let o=[...K.names.keys()].filter((a)=>t.every((l,m)=>K.names[a+m]===X(l)));if(o.length){let a=o.length>1&&t[0]==="e"?o.at(-1):o[0];return K.midis.slice(a,a+n).reverse()}if(n===1){let a=R(X(e[0]));return a===null?null:[48+(a-48+120)%12]}let s=H(r);if(s)return s.reverse()}return z[n]??null}function ct(e){let n=[...z[6]],t=n.indexOf(e);if(t<0)t=n.reduce((r,o,s)=>Math.abs(o-e)<Math.abs(n[r]-e)?s:r,0),n[t]=e;return{tuning:n,string:t+1}}function mt(e){if(e.length===1){let{tuning:r,string:o}=ct(e[0]);return{tuning:r,strings:[o]}}let n=z[6];if(e.length>5)return null;let t=e.map((r)=>n.indexOf(r));if(t[0]<0||t.some((r,o)=>r!==t[0]+o))return null;return{tuning:[...n],strings:t.map((r)=>r+1)}}var ut=(e)=>(n,t)=>{let r=[];return n.forEach((o,s)=>{let a=o[t];if(!/[xXoOgfdb#@*+]/.test(a))return;let l=Ke(e[s],a);if(!r.some((m)=>m.tex===l))r.push({tex:l,effects:Xe(a)})}),{beat:r,skip:0}},ye=[[24,1,!0],[16,1,!1],[12,2,!0],[8,2,!1],[6,4,!0],[4,4,!1],[3,8,!0],[2,8,!1],[1,16,!1]];function de(e){let n=[];for(let t=e;t>0;){let[r,o,s]=ye.find(([a])=>a<=t);n.push({duration:o,dotted:s}),t-=r}return n}var D={ts:[4,4],length:16,beat:4,grids:[1,2,4,8,16]},fe={ts:[3,4],length:12,beat:4,grids:[1,3,6,12]},dt={ts:[6,8],length:12,beat:6,grids:[1,2,6,12]},ft={ts:[12,8],length:24,beat:6,grids:[1,2,4,12,24]};function pt(e,n){let t=new Map;for(let o=1;o<e.length;o++){let s=e[o]-e[o-1],a=n[o]-n[o-1];if((t.get(s)??a)!==a)return!1;t.set(s,a)}let r=[...t].sort((o,s)=>o[0]-s[0]);return r.every(([,o],s)=>s===0||o>=r[s-1][1])}var ht=new Set(ye.map(([e])=>e));function gt(e,n,[t,r],o,s,a){let l=r/n;if(l<1||s&&!Number.isInteger(l))return null;let m=[],u=0;for(let i of e){let d=(i-t)/l,c=Math.round(d),p=Math.abs(d-c)*l;if(c<0||c>=n||p>o+0.000000001||m.length&&c*(a/n)<=m.at(-1))return null;u=Math.max(u,p),m.push(c*(a/n))}if(!s&&m.some((i,d)=>!ht.has((m[d+1]??a)-i)))return null;return pt(e,m)?{at:m,error:u}:null}function J(e,n,t,r=D){if(!e.length)return[];let o=[[t,n-t],[t,n]];for(let s=1;s<t;s++)o.push([s,n-s]);if(e[0]>t)o.push([0,n]);for(let[s,a]of[[0.4,!1],[1,!1],[0.4,!0]])for(let l of r.grids){let m=o.map((u)=>gt(e,l,u,s,a,r.length)).filter((u)=>u!==null);if(m.length)return m.reduce((u,i)=>i.error<u.error?i:u).at}return null}function I(e,n,t=n.length){let r=[],{beat:o,length:s}=n;for(let a=e;a<t;){let l=s===4*o&&a%(2*o)===0&&a<=s/2?[2*o]:[],u=(a%2?[1]:a%o?[2,1]:[...l,o,2,1]).find((i)=>i<=t-a);r.push({beat:-1,sixteenths:u}),a+=u}return r}function bt(e,n=D,t=[]){let r=e.slice(1).map((a,l)=>a-e[l]),o=new Map;for(let a of r)o.set(a,(o.get(a)??0)+1);let s=[...o].reduce((a,l)=>!a||l[1]>a[1]||l[1]===a[1]&&l[0]<a[0]?l:a,null)?.[0];for(let a of[2,1]){let l=e.map((u,i)=>a*(i<r.length?Math.max(1,Math.round(r[i]/s)):1)),m=l.reduce((u,i)=>u+i,0);if(a===2)for(let u of t){if(m<=n.length)break;if(u+1>=l.length||l[u]!==2)continue;let i=Math.max(1,l[u+1]-1);m-=1+l[u+1]-i,l[u]=1,l[u+1]=i}if(m>n.length)continue;return[...l.map((u,i)=>({beat:i,sixteenths:u})),...I(m,n)]}return e.map((a,l)=>({beat:l,sixteenths:1}))}var yt=new Set(["h","sl"]),vt=(e)=>e.flatMap((n,t)=>n.notes.some((r)=>r.effects.some((o)=>yt.has(o)))?[t]:[]);function xt(e,n,t){let r=t.length,o=e.part==="whole"?e.width:n,s=e.part==="end"?n-e.width:0,a=e.beats.map((i)=>i.col+s);if(e.part==="start"&&a.length){let i=J([...a,e.width],o,e.pad,t);if(i){let d=i.pop(),c=i[0]>0?[{beat:-1,sixteenths:i[0]}]:[];return i.forEach((p,b)=>c.push({beat:b,sixteenths:(i[b+1]??d)-p})),[...c,...I(d,t)]}}let l=J(a,o,e.pad,t);if(!l){let i=bt(e.beats.map((p)=>p.col),t,vt(e.beats));if(e.part!=="end")return i;let d=i.filter((p)=>p.beat>=0),c=d.reduce((p,b)=>p+b.sixteenths,0);return e.pickup?d:[...I(0,t,r-c),...d]}let m=l[0],u=m===0||e.pickup?[]:e.part==="end"?I(0,t,m):[{beat:-1,sixteenths:m}];return l.forEach((i,d)=>u.push({beat:d,sixteenths:(l[d+1]??r)-i})),u}var kt=(e)=>e.reduce((n,t)=>t.beats.length?Math.min(n,t.beats[0].col-t.start):n,3);function pe(e,n,t,r){let o=Math.max(...e.map((s)=>s.length));return{bars:n,pad:kt(n),texts:t,openStart:r&&n[0]?.start===0,openEnd:n.at(-1)?.end===o}}function wt(e){let n=[];for(let t of e)t.bars.forEach((r,o)=>{if((o>0||!t.openStart)&&(o<t.bars.length-1||!t.openEnd)&&r.beats.length)n.push(r.end-r.start)});if(n.length<2)return null;return n.sort((t,r)=>t-r),n[n.length>>1]}function ve(e){let n=new Map;for(let r of e)n.set(r,(n.get(r)??0)+1);let t;for(let[r,o]of n)if(!t||o>t.count||o===t.count&&r<t.value)t={value:r,count:o};return t}function Tt(e,n){if(n===null)return D;let t=[];for(let i of e)i.bars.forEach((d,c)=>{let p=(c>0||!i.openStart)&&(c<i.bars.length-1||!i.openEnd),b=d.end-d.start;if(p&&d.beats.length&&Math.abs(b-n)<=1)t.push({bar:d,pad:i.pad})});let r=new Map;for(let{bar:i}of t)for(let d=1;d<i.beats.length;d++){let c=i.beats[d].col-i.beats[d-1].col;r.set(c,(r.get(c)??0)+1)}let o=Math.max(0,...r.values()),s=Math.min(...[...r].filter(([,i])=>i*2>=o).map(([i])=>i));if(t.length<2||!Number.isFinite(s))return D;let a=[],l=0,m=0;for(let{bar:i,pad:d}of t){let c=i.beats.map((g)=>(g.col-i.start-d)/s);if(c.some((g)=>Math.abs(g-Math.round(g))*s>0.40000000100000005)){a.push(0);continue}let p=c.map(Math.round),b=Math.max(Math.ceil((i.end-i.start-d)/s-0.5),p.at(-1)+1);if(a.push(b),b!==6)continue;let h=i.beats.reduce((g,v)=>v.notes.reduce((T,L)=>Math.max(T,L.string??0),g),0),f=p.filter((g,v)=>i.beats[v].notes.some((T)=>T.string===h));for(let g of[p,f.length<p.length?f:[]])if(g.some((v)=>v!==0&&v%2===0)&&g.every((v)=>v%2===0))l++;else if(g.includes(3)&&g.every((v)=>v%3===0))m++}let u=ve(a);if(u.count*3<t.length*2)return D;if(u.value===3)return fe;if(u.value===6)return l>m?fe:dt;return u.value===12?ft:D}function At(e,n){let t=(s)=>n!==null&&s<=n*2/3,r=[],o=null;return e.forEach((s,a)=>{let l=r.length,m=e[a+1];s.bars.forEach((i,d)=>{let c=i.beats.map((f)=>({notes:f.notes,col:f.col-i.start})),p={beats:c,width:i.end-i.start,pad:s.pad,part:"whole",pickup:!1,text:null},b=d===0&&o!==null;if(o&&d===0){let f=o.width-s.pad;p={...o,beats:[...o.beats,...c.map((g)=>({notes:g.notes,col:g.col+f}))],width:o.width+p.width-s.pad},o=null}if(d===s.bars.length-1&&t(p.width)){let f=m?.bars[0],g=f?p.width+f.end-f.start-m.pad:0;if(f&&(s.openEnd||t(f.end-f.start)&&(m.openStart||g<=n*1.25))){if(p.beats.length||!s.openEnd)o=p;return}if(s.openEnd&&!b){if(!p.beats.length)return;p.part="start"}}let h=!r.length;if(d===0&&!b&&p.part==="whole"&&t(p.width)&&p.beats.length){if(h||s.openStart)p.part="end",p.pickup=h}r.push(p)});let u=o??(r.length>l?r.at(-1):null);if(s.texts.length&&u){let i=s.texts.join(" / ");u.text=u.text?`${u.text} / ${i}`:i}}),r}function Mt(e,n){return e.flatMap((t)=>{if(t.part!=="whole"||t.beats.length<2)return[t];let r=t.beats.map((d)=>d.col);if(J(r,t.width,t.pad,n))return[t];let o=r.slice(1).map((d,c)=>d-r[c]),s=ve(o).value,a=o.reduce((d,c)=>d+Math.max(1,Math.round(c/s)),1),l=n.length/2,m=s*l;if(a<=l||t.width-t.pad<m*1.5)return[t];let u=Math.floor((r.at(-1)-t.pad)/m)+1,i=Array.from({length:u},()=>[]);for(let d of t.beats){let c=Math.min(u-1,Math.max(0,Math.floor((d.col-t.pad)/m)));while(c<u-1&&d.col>=t.pad+(c+1)*m)c++;while(c>0&&d.col<t.pad+c*m)c--;i[c].push({notes:d.notes,col:d.col-c*m})}return i.map((d,c)=>({beats:d,width:t.pad+m,pad:t.pad,part:"whole",pickup:!1,text:c===u-1?t.text:null}))})}var St=(e)=>`"${e.replace(/[\\"]/g,(n)=>`\\${n}`)}"`,V=(e,n)=>n.length?`${e}{${n.join(" ")}}`:e;function Et(e,n){if(!e.length)return V("r",n);if(e.length===1)return V(e[0].tex,[...e[0].effects,...n]);return V(`(${e.map((t)=>V(t.tex,t.effects)).join(" ")})`,n)}var he=new Set(["h","sl","sou","sod"]);function Ct(e,n){if(n===1)return[e];let t=[e.map((r)=>({...r,effects:r.effects.filter((o)=>!he.has(o))}))];for(let r=1;r<n;r++)t.push(e.filter((o)=>o.string!==void 0).map((o)=>({tex:`-.${o.string}`,effects:o.effects.filter((s)=>s==="pm"||r===n-1&&he.has(s))})));return t}function ge(e,n){let t=0;return e.map(({beats:o,rhythm:s,text:a,pickup:l})=>{let m=[];if(!o.length)for(let d of n===D?[{duration:1,dotted:!1}]:de(n.length))m.push({notes:[],...d});for(let{beat:d,sixteenths:c}of s){let p=de(c),b=Ct(d>=0?o[d]:[],p.length);p.forEach((h,f)=>m.push({notes:b[f],...h}))}let u=m.length-1;while(u>0&&!m[u].notes.length)u--;if(!m[u].notes.length)u=m.length-1;let i=m.map((d,c)=>{let p=d.dotted?["d"]:[];if(a&&c===u)p.push(`txt ${St(a)}`);let b=d.duration===t?"":`:${d.duration} `;return t=d.duration,b+Et(d.notes,p)}).join(" ");return l?`\\ac ${i}`:i}).join(` |
|
|
3
|
-
`)}function xe(e){let n=st(e),t=n[0];if(!t)return null;let r=t.kind==="strings"?
|
|
4
|
-
`);let
|
|
5
|
-
`)}var Nt="1.8.4",
|
|
6
|
-
`).trimEnd(),!r.file&&!r.tex)throw Error("Write the music in alphaTex, or give a file: [[Song.gp]]");let s=r.file?null:xe(r.tex);if(s!==null)r.tex=s,r.fromText=!0;return r}function ke(e,n){let t=e?.cause??e;for(let r of["lexerDiagnostics","parserDiagnostics","semanticDiagnostics"]){let o=t?.[r]?.items;if(!Array.isArray(o))continue;let s=o.find((a)=>a.severity===2&&a.message);if(s)return`${s.start&&n!==null?`line ${s.start.line+n}, column ${s.start.col}: `:""}${s.message}`}return e instanceof Error?e.message:String(e)}var Dt=0;function we(e,n){for(let t of n.tracks)for(let r of t.staves){if(r.isPercussion)for(let s of r.bars??[])s.clef=Dt;let o=!r.isPercussion&&r.tuning.length>0;if(e==="both"){r.showStandardNotation=!0,r.showTablature=o;continue}r.showSlash=!1,r.showNumbered=!1,r.showTablature=e==="tab"&&o,r.showStandardNotation=!r.showTablature}}var Ot=5;function Pt(e,n){if(n!==null&&/\bdy\b|\\showdynamics/i.test(n))return;if(!e.tracks.some((r)=>r.staves.some((o)=>o.bars.some((s)=>s.voices.some((a)=>a.beats.some((l)=>!l.isRest&&l.dynamics!==Ot))))))e.stylesheet.hideDynamics=!0}var Rt="rendered by alphaTab";function $t(e,n){e.renderer?.partialRenderFinished?.on((r)=>{for(let o of n.querySelectorAll(".at-surface > div")){if(o.layoutResultId!==r.id)continue;let s=typeof r.renderResult==="string"&&r.renderResult.includes(Rt);o.style.visibility=s?"hidden":""}})}function Te(e,n,t=1){let r=e.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.fillStyle="#000",o.fillStyle=n,o.fillRect(0,0,1,1);let s=o.getImageData(0,0,1,1).data;if(s.length<4)return null;return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${(s[3]/255*t).toFixed(3)})`}function Gt(e){let n=e.ownerDocument,t=n.defaultView?.getComputedStyle(e).color||"",r=t&&Te(n,t)||(/^rgba?\(/.test(t)?t:"rgba(0, 0, 0, 1)"),o=t&&Te(n,t,0.6)||r;return{mainGlyphColor:r,secondaryGlyphColor:o,scoreInfoColor:r,staffLineColor:o,barSeparatorColor:r,barNumberColor:o}}var te=(e)=>{let n=e.defaultView??globalThis;return{map:(t)=>new n.Map(t),bytes:(t)=>{let r=new n.Uint8Array(t.length);return r.set(t),r}}},Bt={play:"M4 2.5v11l9-5.5z",pause:"M4 3h3v10H4zM9 3h3v10H9z",stop:"M4 4h8v8H4z",loop:"M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5",metronome:"M6 2h4l3 12H3zM8 11l3-7",countIn:"M3 13h10M5 13V9M8 13V6M11 13V3",volume:"M2 6h3l4-3v10l-4-3H2zM11 5.5a3.5 3.5 0 0 1 0 5"};function Z(e,n){let r=W(e,"svg",{class:`mn-play-icon${n==="play"||n==="pause"||n==="stop"?"":" mn-play-icon-loop"}`,viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"});return r.appendChild(W(e,"path",{d:Bt[n]})),r}var Ae=(e)=>{let n=Math.max(0,Math.round(e/1000));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`};function Ht(e,n,t,r){let o=A(e,"div","mn-play mn-tab-bar");o.addEventListener("mousedown",(h)=>h.stopPropagation()),o.setAttribute("role","group"),o.setAttribute("aria-label","Playback");let s={loop:!1,metronome:!1,countIn:!1,speed:1,volume:1},a=null,l=null,m=()=>(a??=new Promise((h)=>{if(n.playerReady.on(()=>h(!0)),l=()=>h(!1),n.settings.player.playerMode=t.PlayerMode.EnabledSynthesizer,n.settings.player.enableCursor=!0,typeof r.soundFont==="string")n.settings.player.soundFont=r.soundFont;if(n.updateSettings(),r.soundFont instanceof Uint8Array)n.loadSoundFont(te(e).bytes(r.soundFont),!1)}).then((h)=>{if(h)n.isLooping=s.loop,n.metronomeVolume=s.metronome?1:0,n.countInVolume=s.countIn?1:0,n.playbackSpeed=s.speed,n.masterVolume=s.volume;return h}),a),u=(h,f,g)=>{let v=A(e,"button");return v.type="button",v.title=f,v.setAttribute("aria-label",f),v.appendChild(Z(e,h)),v.addEventListener("click",g),o.appendChild(v),v},i=(h)=>{if(n.player)h()},d=(h,f,g)=>{let v=u(h,f,()=>{s[g]=!s[g],i(()=>{n.isLooping=s.loop,n.metronomeVolume=s.metronome?1:0,n.countInVolume=s.countIn?1:0}),v.classList.toggle("mn-on",s[g]),v.setAttribute("aria-pressed",String(s[g]))});v.setAttribute("aria-pressed","false")},c=u("play","Play",()=>{m().then((h)=>{if(h)n.playPause()})});u("stop","Stop",()=>i(()=>n.stop())),d("loop","Loop","loop"),d("metronome","Metronome","metronome"),d("countIn","Count-in","countIn");let p=(h,f,g,v,T,L,k="")=>{let N=A(e,"label","mn-play-field"),E=A(e,"span","mn-play-label");E.setAttribute("aria-hidden","true"),E.append(f);let w=A(e,"input");w.type="range",w.min=String(g),w.max=String(v),w.value=String(T),w.setAttribute("aria-label",h),N.title=`${h}: ${T}${k}`,w.addEventListener("input",()=>{L(Number(w.value)),N.title=`${h}: ${w.value}${k}`}),N.append(E,w),o.appendChild(N)};p("Speed","%",25,150,100,(h)=>{s.speed=h/100,i(()=>n.playbackSpeed=s.speed)},"%"),p("Volume",Z(e,"volume"),0,100,100,(h)=>{s.volume=h/100,i(()=>n.masterVolume=s.volume)});let b=A(e,"span","mn-tab-time","");return o.appendChild(b),n.playerStateChanged.on((h)=>{let f=Number(h.state)===Number(t.synth.PlayerState.Playing);c.replaceChildren(Z(e,f?"pause":"play")),c.title=f?"Pause":"Play",c.setAttribute("aria-label",c.title)}),n.playerPositionChanged.on((h)=>{b.textContent=`${Ae(h.currentTime)} / ${Ae(h.endTime)}`}),{bar:o,failed:(h)=>{l?.(),c.disabled=!0,c.title=`Can't play: ${h}`,c.setAttribute("aria-label",c.title)}}}function Vt(e,n){return e.tracks.some((t,r)=>(!n||n.includes(r+1))&&t.staves.some((o)=>!o.isPercussion&&o.tuning.length>0))}var It=[{staves:"tab",label:"Tab",what:"tablature"},{staves:"score",label:"Score",what:"standard notation"},{staves:"both",label:"Both",what:"standard notation and tablature"}];function zt(e,n,t,r){let o=A(e,"span","mn-tab-views");o.setAttribute("role","group"),o.setAttribute("aria-label","View");let s=n.staves,a=r?A(e,"button","mn-tab-keep","Keep this view"):null,l=It.map(({staves:u,label:i,what:d})=>{let c=A(e,"button","mn-tab-view",i);c.type="button",c.dataset.staves=u;let p=u!==n.staves?"":n.written?" (this block's staves: line)":" (the default: the block has no staves: line)";return c.title=`Draw as ${d}${p}`,c.addEventListener("click",()=>{if(u===s)return;s=u,m(),t(u)}),o.appendChild(c),c}),m=()=>{for(let u of l){let i=u.dataset.staves===s;u.classList.toggle("mn-on",i),u.setAttribute("aria-pressed",String(i))}if(a)a.hidden=s===n.staves,a.title=`Write staves: ${s} at the top of the block`};if(a&&r)a.type="button",a.addEventListener("click",()=>r(s)),o.appendChild(a);return m(),o}function Me(e,n,t,r){let o=t.ownerDocument,s=A(o,"div",`mn-block mn-block-${e} mn-tab`);t.appendChild(s);let a=null,l=!1,m=!1,u=()=>{},i=new Promise((c)=>{u=(p)=>{if(m)return;m=!0,c(p)}}),d=(c)=>{s.replaceChildren(A(o,"div","mn-error-message",`${e}: ${c}`)),s.classList.add("mn-error"),u({ok:!1,error:c})};if(!n.trim())s.classList.add("mn-empty"),u({ok:!0,error:null});else(async()=>{await Promise.resolve();let c=Ft(e,n),p={staves:c.stavesWritten?c.staves:r.defaultStaves??c.staves,written:c.stavesWritten},b=p.staves,h=!1,f=r.alphaTab;if(!f?.AlphaTabApi)throw Error("alphaTab isn't loaded");let g=A(o,"div","mn-tab-surface");s.appendChild(g);let{assets:v}=r,T=te(o),L={core:{useWorkers:Boolean(v.scriptFile),...v.scriptFile?{scriptFile:v.scriptFile}:{},smuflFontSources:T.map([[f.FontFileFormat.Woff2,v.font]]),logLevel:f.LogLevel.Warning,enableLazyLoading:!1},display:{staveProfile:"Default",resources:Gt(s)},player:{playerMode:f.PlayerMode.Disabled,enableUserInteraction:!0}},k=new f.AlphaTabApi(g,L);if(a=k,l){k.destroy();return}r.onApi?.(k);let N=[];k.scoreLoaded.on((y)=>{N=y.tracks.flatMap((x)=>x.staves.map((M)=>({showSlash:M.showSlash,showNumbered:M.showNumbered}))),we(b,y),h=Vt(y,c.tracks),Pt(y,c.file?null:c.tex)}),$t(k,g);let E=null;k.renderFinished.on(()=>{if(m||l)return;if(r.player!==!1){if(E=Ht(o,k,f,v),s.appendChild(E.bar),r.views!==!1&&h)E.bar.appendChild(zt(o,p,(y)=>{b=y;let x=k.score;if(l||!x)return;x.tracks.flatMap((S)=>S.staves).forEach((S,P)=>Object.assign(S,N[P])),we(y,x),k.render()},r.onKeepView));s.addEventListener("pointerdown",(y)=>{if(y.pointerType!=="touch"||E?.bar.contains(y.target))return;s.classList.toggle("mn-play-open")})}u({ok:!0,error:null})}),k.error.on((y)=>{let x=c.fromText?`Couldn't draw this text tab: ${ke(y,null)}`:ke(y,c.texLine);if(m)E?.failed(x);else d(x)});let w=c.tracks?.map((y)=>y-1);if(c.file){let y;try{y=r.resolveFile?await r.resolveFile(c.file):null}catch(M){throw Error(`Couldn't read "${c.file}": ${M instanceof Error?M.message:String(M)}`)}if(l)return;if(!y)throw Error(`Couldn't find the file "${c.file}"`);if(!k.load(T.bytes(y),w))throw Error(`Couldn't read "${c.file}": not a score file alphaTab knows`)}else k.tex(c.tex,w??"all")})().catch((c)=>{if(!l)d(c instanceof Error?c.message:String(c))});return{el:s,ready:i,get api(){return a},destroy(){l=!0;try{a?.destroy()}catch{}s.remove(),u({ok:!1,error:null})}}}var ee={guitar:25,piano:0},j={channel:1,program:28},Q={channel:9,key:33},jt=0.5;function Ut(e,n){return{reportsStart:!0,play(t,{sound:r,volume:o,onEnd:s,onStart:a}){let l=n(),m=l?.player;if(!l||!m)throw Error("The soundfont player is not ready");let u=new e.midi.MidiFile,i=new e.midi.AlphaSynthMidiFileHandler(u,!0),d=(f)=>Math.round(f*u.division);if(i.addTempo(0,60),i.addProgramChange(0,0,0,ee[r]),r==="guitar"&&t.some((f)=>f.kind==="muted"))i.addProgramChange(0,0,j.channel,j.program);if(t.some((f)=>f.kind==="click"))i.addProgramChange(0,0,Q.channel,0);let c=Number.isFinite(o)?Math.min(1,Math.max(0,o)):0.8;l.masterVolume=c;for(let f of t){let g=f.velocity===void 0||!Number.isFinite(f.velocity)?100:Math.round(Math.min(127,Math.max(1,f.velocity))),v=f.kind==="click"?Q.channel:f.kind==="muted"&&r==="guitar"?j.channel:0;i.addNote(0,d(f.time),Math.max(1,d(f.duration)),f.kind==="click"?Q.key:f.midi,g,v)}let p=Math.max(...t.map((f)=>f.time+f.duration),0);i.addControlChange(0,d(p+jt),0,e.midi.ControllerType.HoldPedal,0),l.playbackSpeed=1,m.playOneTimeMidiFile(u);let b=!1;queueMicrotask(()=>{if(!b)a?.()});let h=setTimeout(()=>s?.(),(p+0.2)*1000);return{stop(){b=!0,clearTimeout(h),m.stop()}}}}}function Se(e,n,t,r){let o=null,s=null,a=null,l=()=>{if(a)return a;s=A(t,"div","mn-tab-hidden"),s.setAttribute("aria-hidden","true"),t.body.appendChild(s);let u=te(t);o=new e.AlphaTabApi(s,{core:{useWorkers:Boolean(n.scriptFile),...n.scriptFile?{scriptFile:n.scriptFile}:{},smuflFontSources:u.map([[e.FontFileFormat.Woff2,n.font]])},player:{playerMode:e.PlayerMode.EnabledSynthesizer,...typeof n.soundFont==="string"?{soundFont:n.soundFont}:{}}});let i=o;if(a=new Promise((d)=>{let c=!1,p=!i.playerReady,b=()=>{if(c&&p)d(!0)};i.soundFontLoaded.on(()=>{c=!0,b(),setTimeout(()=>{p=!0,b()},4000)}),i.playerReady?.on(()=>{p=!0,b()}),i.error.on(()=>d(!1))}),n.soundFont instanceof Uint8Array)i.loadSoundFont(u.bytes(n.soundFont),!1);return i.tex(`\\track "Guitar" \\instrument ${ee.guitar} r \\track "Piano" \\instrument ${ee.piano} r \\track "Muted" \\instrument ${j.program} r`),a},m=Ut(e,()=>o);return{reportsStart:!0,play(u,i){let d=null,c=!1;return l().then((p)=>{if(c)return;try{if(p){d=m.play(u,i);return}}catch{}if(!r)return;if(d=r.play(u,i),!r.reportsStart)i.onStart?.()}),{stop(){c=!0,d?.stop()}}},destroy(){try{o?.destroy()}catch{}s?.remove(),o=null,a=null}}}function Ee(e=()=>U().script){let n=null;return(t)=>{let r=t.defaultView;if(r.alphaTab)return Promise.resolve(r.alphaTab);return n??=new Promise((o,s)=>{let a=t.createElement("script");a.src=e();let l=r.define?.amd?r.define:void 0;if(l)r.define=void 0;let m=(u)=>{if(l&&r.define===void 0)r.define=l;if(u===null&&r.alphaTab){o(r.alphaTab);return}n=null,a.remove(),s(Error(u??"alphaTab's script didn't define alphaTab"))};a.onload=()=>m(null),a.onerror=()=>m("Couldn't load alphaTab"),t.head.appendChild(a)}),n}}var Ce=`/* Music notation. Colors follow Obsidian's theme variables when present, with fallbacks for any page. */
|
|
1
|
+
/*! @dsebastien/music-notation 0.12.0 tab bundle | MIT | loads alphaTab (MPL-2.0) from jsDelivr */
|
|
2
|
+
(()=>{var He=(e,n)=>{for(let[t,r]of Object.entries(n))if(r!==void 0)e.setAttribute(t,String(r))};function q(e,n,t={},r=[]){let o=e.createElementNS("http://www.w3.org/2000/svg",n);He(o,t);for(let s of r)if(s)o.appendChild(s);return o}function S(e,n,t,r){let o=e.createElement(n);if(t)o.className=t;if(r!==void 0)o.textContent=r;return o}var rn=`mn-name-${Math.random().toString(36).slice(2,8)}-`;var Ve=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],Ie=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"],se={C:0,D:2,E:4,F:5,G:7,A:9,B:11};function R(e){let n=/^([A-Ga-g])([#♯b♭]*)$/.exec(e.trim());if(!n)return null;let t=se[n[1].toUpperCase()];for(let r of n[2])t+=r==="#"||r==="♯"?1:-1;return(t%12+12)%12}function K(e){let n=/^([A-Ga-g][#♯b♭]*)(-?\d)$/.exec(e.trim());if(!n)return null;let t=R(n[1]);if(t===null)return null;let r=se[n[1][0].toUpperCase()],o=Math.round((t-r)/12);return(Number(n[2])+1)*12+t-o*12}var ze=(e,n=!1)=>(n?Ie:Ve)[((Math.round(e)||0)%12+12)%12];var ae=(e,n=!1)=>`${ze(e,n)}${Math.floor(e/12)-1}`;var je=new Map(Object.entries({standard:"E2 A2 D3 G3 B3 E4","drop d":"D2 A2 D3 G3 B3 E4","drop c":"C2 G2 C3 F3 A3 D4","drop b":"B1 F#2 B2 E3 G#3 C#4","drop a":"A1 E2 A2 D3 F#3 B3","double drop d":"D2 A2 D3 G3 B3 D4",dadgad:"D2 A2 D3 G3 A3 D4","open g":"D2 G2 D3 G3 B3 D4","open d":"D2 A2 D3 F#3 A3 D4","open e":"E2 B2 E3 G#3 B3 E4","open c":"C2 G2 C3 G3 C4 E4","open a":"E2 A2 E3 A3 C#4 E4","half step down":"Eb2 Ab2 Db3 Gb3 Bb3 Eb4","whole step down":"D2 G2 C3 F3 A3 D4","modal c6":"C2 A2 C3 G3 C4 E4",c6:"C2 A2 C3 G3 C4 E4",bass:"E1 A1 D2 G2",ukulele:"G4 C4 E4 A4"}));function V(e){let n=e.trim(),t=je.get(n.toLowerCase().replace(/\s*\(.*\)$/,""));if(t)return V(t);let r=n.split(/[\s,]+/).filter(Boolean);if(r.length>1&&r.every((i)=>K(i)!==null))return r.map((i)=>K(i));let o=r.length>1?r:n.match(/[A-G][#♯b♭]?|[a-g][#♯♭]?/g)??[];if(o.length<2||o.join("")!==r.join(""))return null;let s=[];for(let i of o){let l=R(i);if(l===null)return null;let m=s[s.length-1];if(m===void 0){let c=[28,40,52].map((a)=>a-a%12+l);s.push(c.reduce((a,u)=>Math.abs(u-40)<Math.abs(a-40)?u:a))}else{let c=m-m%12+l;while(c<=m)c+=12;s.push(c)}}return s}var Ue=/^\s*([A-Ga-g][#b]?|[1-8](?=\s*[|:]))?\s*[|:]?/,_e=/^[-0-9xX|:hpbrsvt/\\~^().*<>\s]*$/,We=/^\s*([A-Za-z][A-Za-z0-9. -]{0,14}?)\s*[|:]([-xXoOgfdb#@*+|:\s]*)$/,qe=new Map(Object.entries({hihat:"h hh hat hihat hihats","hihat-open":"oh openhat openhihat","hihat-foot":"hf fh hp ph pedal hihatfoot hihatpedal",crash:"c c1 cc cr cy cym crash crash1 cymbal",crash2:"c2 cr2 crash2",ride:"r rd rc ride",splash:"sp spl splash",china:"ch cn chi china",cowbell:"cb cow cowbell",snare:"s sd sn sr snare snaredrum",tom1:"t t1 ht tom1 hightom hitom",tom2:"t2 mt tom2 midtom",tom3:"t3 lt tom3 lowtom",floor:"f ft fl t4 tom4 floor floortom",kick:"b bd bs k kd bass kick bassdrum kickdrum"}).flatMap(([e,n])=>n.split(" ").map((t)=>[t,e])));function Ke(e,n){let t=n==="#";switch(e){case"hihat":return n==="o"||n==="O"?"HiHatOpen":"HiHatClosed";case"hihat-open":return"HiHatOpen";case"hihat-foot":return"PedalHiHatHit";case"crash":return t?"CrashHighChoke":"CrashHighHit";case"crash2":return t?"CrashMediumChoke":"CrashMediumHit";case"ride":return t?"RideChoke":"RideMiddle";case"splash":return t?"SplashChoke":"SplashHit";case"china":return t?"ChinaChoke":"ChinaHit";case"cowbell":return"CowbellMediumHit";case"snare":return"SnareHit";case"tom1":return"HighTomHit";case"tom2":return"MidTomHit";case"tom3":return"LowTomHit";case"floor":return"VeryLowTomHit";case"kick":return"KickHit"}}var Xe=(e)=>e==="X"||e==="O"?["ac"]:e==="g"?["g"]:[],Ye=/[^-0-9xXoOgfdbhprsvt/\\~^().*<>#@+|:\s]|<(?!\d)/,Je=/^\s*(?:[xX]\s*\d{1,3}|\d{1,3}\s*[xX])\s*$/;function Ze(e){let n=e.lastIndexOf("|");if(n<0)return{line:e,text:null};let t=e.slice(n+1),r=t.trim();if(!r)return{line:e,text:null};return Ye.test(r)||Je.test(r)||/^\s/.test(t)&&!r.includes("--")?{line:e.slice(0,n+1),text:r}:{line:e,text:null}}function Qe(e){let{line:n,text:t}=Ze(e.trimEnd()),r=null,o=Ue.exec(n),s=n.slice(o[0].length);if(_e.test(s)&&(n.match(/-/g)?.length??0)>=4&&(n.includes("|")||/^\s*[A-Ga-g][#b]?\s*[-|:]/.test(n)))r={name:o[1]??null,body:s,offset:o[0].length,barred:/[|:]$/.test(o[0])};let i=null,l=We.exec(n),m=l?l[1].toLowerCase().replace(/[ .-]/g,""):"",c=qe.get(m);if(l&&c&&(l[2].match(/[^\s|:]/g)?.length??0)>=4)i={drum:c,name:m,body:l[2],lettered:/^[A-Ga-g]$/.test(l[1])};return r||i?{string:r,drum:i,text:t}:null}var be=(e)=>[...new Set(e.map((n)=>n.text).filter((n)=>n!==null))];function et(e){let n=[],t=0;for(let r=2;r<e.length-1;r++){let[o,s]=[e[t].string.name,e[t+1].string.name];if(o!==null&&e[r].string.name===o&&e[r+1].string.name===s&&r-t>=2)n.push(e.slice(t,r)),t=r}return n.push(e.slice(t)),n}function tt(e){let n=[],t=[];for(let r of e){if(t.some((o)=>o.drum.name===r.drum.name))n.push(t),t=[];t.push(r)}return n.push(t),n}var nt=/^[\sPpMm.\-_|=~]*$/,rt=/P\.?M/i;function ot(e){if(!nt.test(e)||!rt.test(e))return[];let n=[];for(let t=0;t<e.length;t++){let r=e[t];if((r==="P"||r==="p")&&/^\.?[Mm]/.test(e.slice(t+1,t+3)))n.push([t,t]);else if(r!==" "&&n.length)n[n.length-1][1]=t}return n}function ie(e,n=null){return et(e).flatMap((t,r)=>{let o=t.map((c)=>c.string.name);if(t.length<3&&o.some((c)=>c===null))return[];let s=t.map((c)=>c.string.body),i=t[0].string.offset,l=new Set;if(r===0&&n!==null)for(let[c,a]of ot(n))for(let u=Math.max(c,i);u<=a;u++)l.add(u-i);let m=t.some((c)=>!c.string.barred);return[{kind:"strings",names:o,lines:s,texts:be(t),muted:l,openStart:m}]})}function le(e,n){if(!e.length)return[];if(e.every((o)=>o.drum)&&e.some((o)=>!o.string||!o.drum.lettered||/[xXoOgfdb#@*+]/.test(o.drum.body)))return tt(e).map((o)=>({kind:"drums",drums:o.map((s)=>s.drum.drum),lines:o.map((s)=>s.drum.body),texts:be(o)}));if(e.every((o)=>o.string))return ie(e,n);let t=[],r=[];for(let o of[...e,null])if(o?.string)r.push(o);else{if(r.length)t.push(...ie(r,t.length?null:n));r=[]}return t}function st(e){let n=[],t=[],r=null,o=null;for(let s of e.split(/\r?\n/)){let i=Qe(s);if(i){if(!t.length)r=o;t.push(i)}else n.push(...le(t,r)),t=[];o=s}return n.push(...le(t,r)),n}function me(e,n){let t=Math.max(...e.map((m)=>m.length)),r=e.map((m)=>m.padEnd(t,"-")),o=[],s=[],i=!1,l=0;for(let m=0;m<t;m++){if(r.every((d)=>d[m]==="|"||d[m]===":")){if(i)o.push({beats:s,start:l,end:m});s=[],i=!1,l=m+1;continue}if(r.some((d)=>d[m]!==" "))i=!0;let{beat:c,skip:a,at:u}=n(r,m);if(c.length)s.push({notes:c,col:u??m});m+=a}if(i)o.push({beats:s,start:l,end:t});return o}var G=(e)=>e!==void 0&&e>="0"&&e<="9",ce=(e,n)=>(e==="1"||e==="2")&&G(n)&&Number(e+n)<=24;function at(e){let n=new Map,t=new Map,r=new Set,o=(s)=>{let i=s,l=e[i]==="(";if(l)i++;if(!G(e[i]))return{fret:null,next:s};let m=ce(e[i],e[i+1])?2:1,c=Number(e.slice(i,i+m));for(let a=0;a<m;a++)r.add(i+a);if(i+=m,l&&e[i]===")")i++;return{fret:c,next:i}};for(let s=0;s<e.length;){if(!G(e[s])||r.has(s)){s++;continue}let i=ce(e[s],e[s+1])?2:1,l=Number(e.slice(s,s+i));n.set(s,{fret:l,width:i});let m=[],c=e[s-1],a=s+i;if(c==="<"&&e[a]===">")m.push("nh"),a++;else if((c==="/"||c==="\\")&&!/[\d)>]/.test(e[s-2]??"-"))m.push(c==="/"?"sib":"sia");if(e[a]==="b"||e[a]==="^"){let p=o(a+1);a=p.next;let f=[0,(p.fret!==null&&p.fret>l?Math.min(p.fret-l,4):2)*2];if(e[a]==="r"){let h=o(a+1);a=h.next;let g=h.fret===null?0:(h.fret-l)*2;f.push(Math.min(f[1],Math.max(0,g)))}m.push(`b (${f.join(" ")})`)}if(e[a]==="~"||e[a]==="v"){m.push("v");while(e[a]==="~"||e[a]==="v")a++}let u=e[a],d=G(e[a+1])||e[a+1]==="("&&G(e[a+2]);if((u==="h"||u==="p")&&d)m.push("h");else if(u==="/"||u==="\\"||u==="s"){if(d)m.push("sl");else if(u!=="s")m.push(u==="/"?"sou":"sod")}if(m.length)t.set(s,m);s+=i}return{frets:n,effects:t}}var it=(e,n,t=[])=>(r,o)=>{let s=[],i=new Set,l=o,m=!1,c=(a,u)=>{let d=r[a][u],p=n.has(u)?["pm"]:[];if(d==="x"||d==="X"){s.push({tex:`x.${t[a]??a+1}`,effects:p}),i.add(a);return}let b=e[a].frets.get(u);if(!b)return;if(b.width===2&&u===o)m=!0;if(r[a][u-1]==="<")l=Math.min(l,u-1);s.push({tex:`${b.fret}.${t[a]??a+1}`,effects:[...e[a].effects.get(u)??[],...p],string:t[a]??a+1}),i.add(a)};if(r.forEach((a,u)=>c(u,o)),m)r.forEach((a,u)=>i.has(u)||c(u,o+1));return{beat:s,skip:m?1:0,at:l}},j={3:[64,59,55],4:[43,38,33,28],5:[43,38,33,28,23],6:[64,59,55,50,45,40],7:[64,59,55,50,45,40,35]},ue=[64,59,55,50,45,40,35,30],X={names:["E","A","D","G","B","E"],midis:[40,45,50,55,59,64]},lt=["E A D G","B E A D G"],Y=(e)=>e[0].toUpperCase()+e.slice(1);function J(e){let n=e.length;if(e.every((t)=>t!==null&&/^\d$/.test(t)))return e.every((t)=>ue[Number(t)-1])?e.map((t)=>ue[Number(t)-1]):null;if(e.every((t)=>t!==null&&/^[A-Ga-g]/.test(t))){let t=[...e].reverse(),r=t.map(Y).join(" ");if(lt.includes(r))return V(r).map((i)=>i-12).reverse();let o=[...X.names.keys()].filter((i)=>t.every((l,m)=>X.names[i+m]===Y(l)));if(o.length){let i=o.length>1&&t[0]==="e"?o.at(-1):o[0];return X.midis.slice(i,i+n).reverse()}if(n===1){let i=R(Y(e[0]));return i===null?null:[48+(i-48+120)%12]}let s=V(r);if(s)return s.reverse()}return j[n]??null}function mt(e){let n=[...j[6]],t=n.indexOf(e);if(t<0)t=n.reduce((r,o,s)=>Math.abs(o-e)<Math.abs(n[r]-e)?s:r,0),n[t]=e;return{tuning:n,string:t+1}}function ct(e){if(e.length===1){let{tuning:r,string:o}=mt(e[0]);return{tuning:r,strings:[o]}}let n=j[6];if(e.length>5)return null;let t=e.map((r)=>n.indexOf(r));if(t[0]<0||t.some((r,o)=>r!==t[0]+o))return null;return{tuning:[...n],strings:t.map((r)=>r+1)}}var ut=(e)=>(n,t)=>{let r=[];return n.forEach((o,s)=>{let i=o[t];if(!/[xXoOgfdb#@*+]/.test(i))return;let l=Ke(e[s],i);if(!r.some((m)=>m.tex===l))r.push({tex:l,effects:Xe(i)})}),{beat:r,skip:0}},ye=[[24,1,!0],[16,1,!1],[12,2,!0],[8,2,!1],[6,4,!0],[4,4,!1],[3,8,!0],[2,8,!1],[1,16,!1]];function de(e){let n=[];for(let t=e;t>0;){let[r,o,s]=ye.find(([i])=>i<=t);n.push({duration:o,dotted:s}),t-=r}return n}var F={ts:[4,4],length:16,beat:4,grids:[1,2,4,8,16]},pe={ts:[3,4],length:12,beat:4,grids:[1,3,6,12]},dt={ts:[6,8],length:12,beat:6,grids:[1,2,6,12]},pt={ts:[12,8],length:24,beat:6,grids:[1,2,4,12,24]};function ft(e,n){let t=new Map;for(let o=1;o<e.length;o++){let s=e[o]-e[o-1],i=n[o]-n[o-1];if((t.get(s)??i)!==i)return!1;t.set(s,i)}let r=[...t].sort((o,s)=>o[0]-s[0]);return r.every(([,o],s)=>s===0||o>=r[s-1][1])}var ht=new Set(ye.map(([e])=>e));function gt(e,n,[t,r],o,s,i){let l=r/n;if(l<1||s&&!Number.isInteger(l))return null;let m=[],c=0;for(let a of e){let u=(a-t)/l,d=Math.round(u),p=Math.abs(u-d)*l;if(d<0||d>=n||p>o+0.000000001||m.length&&d*(i/n)<=m.at(-1))return null;c=Math.max(c,p),m.push(d*(i/n))}if(!s&&m.some((a,u)=>!ht.has((m[u+1]??i)-a)))return null;return ft(e,m)?{at:m,error:c}:null}function Z(e,n,t,r=F){if(!e.length)return[];let o=[[t,n-t],[t,n]];for(let s=1;s<t;s++)o.push([s,n-s]);if(e[0]>t)o.push([0,n]);for(let[s,i]of[[0.4,!1],[1,!1],[0.4,!0]])for(let l of r.grids){let m=o.map((c)=>gt(e,l,c,s,i,r.length)).filter((c)=>c!==null);if(m.length)return m.reduce((c,a)=>a.error<c.error?a:c).at}return null}function z(e,n,t=n.length){let r=[],{beat:o,length:s}=n;for(let i=e;i<t;){let l=s===4*o&&i%(2*o)===0&&i<=s/2?[2*o]:[],c=(i%2?[1]:i%o?[2,1]:[...l,o,2,1]).find((a)=>a<=t-i);r.push({beat:-1,sixteenths:c}),i+=c}return r}function bt(e,n=F,t=[]){let r=e.slice(1).map((i,l)=>i-e[l]),o=new Map;for(let i of r)o.set(i,(o.get(i)??0)+1);let s=[...o].reduce((i,l)=>!i||l[1]>i[1]||l[1]===i[1]&&l[0]<i[0]?l:i,null)?.[0];for(let i of[2,1]){let l=e.map((c,a)=>i*(a<r.length?Math.max(1,Math.round(r[a]/s)):1)),m=l.reduce((c,a)=>c+a,0);if(i===2)for(let c of t){if(m<=n.length)break;if(c+1>=l.length||l[c]!==2)continue;let a=Math.max(1,l[c+1]-1);m-=1+l[c+1]-a,l[c]=1,l[c+1]=a}if(m>n.length)continue;return[...l.map((c,a)=>({beat:a,sixteenths:c})),...z(m,n)]}return e.map((i,l)=>({beat:l,sixteenths:1}))}var yt=new Set(["h","sl"]),vt=(e)=>e.flatMap((n,t)=>n.notes.some((r)=>r.effects.some((o)=>yt.has(o)))?[t]:[]);function xt(e,n,t){let r=t.length,o=e.part==="whole"?e.width:n,s=e.part==="end"?n-e.width:0,i=e.beats.map((a)=>a.col+s);if(e.part==="start"&&i.length){let a=Z([...i,e.width],o,e.pad,t);if(a){let u=a.pop(),d=a[0]>0?[{beat:-1,sixteenths:a[0]}]:[];return a.forEach((p,b)=>d.push({beat:b,sixteenths:(a[b+1]??u)-p})),[...d,...z(u,t)]}}let l=Z(i,o,e.pad,t);if(!l){let a=bt(e.beats.map((p)=>p.col),t,vt(e.beats));if(e.part!=="end")return a;let u=a.filter((p)=>p.beat>=0),d=u.reduce((p,b)=>p+b.sixteenths,0);return e.pickup?u:[...z(0,t,r-d),...u]}let m=l[0],c=m===0||e.pickup?[]:e.part==="end"?z(0,t,m):[{beat:-1,sixteenths:m}];return l.forEach((a,u)=>c.push({beat:u,sixteenths:(l[u+1]??r)-a})),c}var kt=(e)=>e.reduce((n,t)=>t.beats.length?Math.min(n,t.beats[0].col-t.start):n,3);function fe(e,n,t,r){let o=Math.max(...e.map((s)=>s.length));return{bars:n,pad:kt(n),texts:t,openStart:r&&n[0]?.start===0,openEnd:n.at(-1)?.end===o}}function wt(e){let n=[];for(let t of e)t.bars.forEach((r,o)=>{if((o>0||!t.openStart)&&(o<t.bars.length-1||!t.openEnd)&&r.beats.length)n.push(r.end-r.start)});if(n.length<2)return null;return n.sort((t,r)=>t-r),n[n.length>>1]}function ve(e){let n=new Map;for(let r of e)n.set(r,(n.get(r)??0)+1);let t;for(let[r,o]of n)if(!t||o>t.count||o===t.count&&r<t.value)t={value:r,count:o};return t}function Tt(e,n){if(n===null)return F;let t=[];for(let a of e)a.bars.forEach((u,d)=>{let p=(d>0||!a.openStart)&&(d<a.bars.length-1||!a.openEnd),b=u.end-u.start;if(p&&u.beats.length&&Math.abs(b-n)<=1)t.push({bar:u,pad:a.pad})});let r=new Map;for(let{bar:a}of t)for(let u=1;u<a.beats.length;u++){let d=a.beats[u].col-a.beats[u-1].col;r.set(d,(r.get(d)??0)+1)}let o=Math.max(0,...r.values()),s=Math.min(...[...r].filter(([,a])=>a*2>=o).map(([a])=>a));if(t.length<2||!Number.isFinite(s))return F;let i=[],l=0,m=0;for(let{bar:a,pad:u}of t){let d=a.beats.map((g)=>(g.col-a.start-u)/s);if(d.some((g)=>Math.abs(g-Math.round(g))*s>0.40000000100000005)){i.push(0);continue}let p=d.map(Math.round),b=Math.max(Math.ceil((a.end-a.start-u)/s-0.5),p.at(-1)+1);if(i.push(b),b!==6)continue;let f=a.beats.reduce((g,y)=>y.notes.reduce((T,C)=>Math.max(T,C.string??0),g),0),h=p.filter((g,y)=>a.beats[y].notes.some((T)=>T.string===f));for(let g of[p,h.length<p.length?h:[]])if(g.some((y)=>y!==0&&y%2===0)&&g.every((y)=>y%2===0))l++;else if(g.includes(3)&&g.every((y)=>y%3===0))m++}let c=ve(i);if(c.count*3<t.length*2)return F;if(c.value===3)return pe;if(c.value===6)return l>m?pe:dt;return c.value===12?pt:F}function At(e,n){let t=(s)=>n!==null&&s<=n*2/3,r=[],o=null;return e.forEach((s,i)=>{let l=r.length,m=e[i+1];s.bars.forEach((a,u)=>{let d=a.beats.map((h)=>({notes:h.notes,col:h.col-a.start})),p={beats:d,width:a.end-a.start,pad:s.pad,part:"whole",pickup:!1,text:null},b=u===0&&o!==null;if(o&&u===0){let h=o.width-s.pad;p={...o,beats:[...o.beats,...d.map((g)=>({notes:g.notes,col:g.col+h}))],width:o.width+p.width-s.pad},o=null}if(u===s.bars.length-1&&t(p.width)){let h=m?.bars[0],g=h?p.width+h.end-h.start-m.pad:0;if(h&&(s.openEnd||t(h.end-h.start)&&(m.openStart||g<=n*1.25))){if(p.beats.length||!s.openEnd)o=p;return}if(s.openEnd&&!b){if(!p.beats.length)return;p.part="start"}}let f=!r.length;if(u===0&&!b&&p.part==="whole"&&t(p.width)&&p.beats.length){if(f||s.openStart)p.part="end",p.pickup=f}r.push(p)});let c=o??(r.length>l?r.at(-1):null);if(s.texts.length&&c){let a=s.texts.join(" / ");c.text=c.text?`${c.text} / ${a}`:a}}),r}function Mt(e,n){return e.flatMap((t)=>{if(t.part!=="whole"||t.beats.length<2)return[t];let r=t.beats.map((u)=>u.col);if(Z(r,t.width,t.pad,n))return[t];let o=r.slice(1).map((u,d)=>u-r[d]),s=ve(o).value,i=o.reduce((u,d)=>u+Math.max(1,Math.round(d/s)),1),l=n.length/2,m=s*l;if(i<=l||t.width-t.pad<m*1.5)return[t];let c=Math.floor((r.at(-1)-t.pad)/m)+1,a=Array.from({length:c},()=>[]);for(let u of t.beats){let d=Math.min(c-1,Math.max(0,Math.floor((u.col-t.pad)/m)));while(d<c-1&&u.col>=t.pad+(d+1)*m)d++;while(d>0&&u.col<t.pad+d*m)d--;a[d].push({notes:u.notes,col:u.col-d*m})}return a.map((u,d)=>({beats:u,width:t.pad+m,pad:t.pad,part:"whole",pickup:!1,text:d===c-1?t.text:null}))})}var St=(e)=>`"${e.replace(/[\\"]/g,(n)=>`\\${n}`)}"`,I=(e,n)=>n.length?`${e}{${n.join(" ")}}`:e;function Et(e,n){if(!e.length)return I("r",n);if(e.length===1)return I(e[0].tex,[...e[0].effects,...n]);return I(`(${e.map((t)=>I(t.tex,t.effects)).join(" ")})`,n)}var he=new Set(["h","sl","sou","sod"]);function Ct(e,n){if(n===1)return[e];let t=[e.map((r)=>({...r,effects:r.effects.filter((o)=>!he.has(o))}))];for(let r=1;r<n;r++)t.push(e.filter((o)=>o.string!==void 0).map((o)=>({tex:`-.${o.string}`,effects:o.effects.filter((s)=>s==="pm"||r===n-1&&he.has(s))})));return t}function ge(e,n){let t=0;return e.map(({beats:o,rhythm:s,text:i,pickup:l})=>{let m=[];if(!o.length)for(let u of n===F?[{duration:1,dotted:!1}]:de(n.length))m.push({notes:[],...u});for(let{beat:u,sixteenths:d}of s){let p=de(d),b=Ct(u>=0?o[u]:[],p.length);p.forEach((f,h)=>m.push({notes:b[h],...f}))}let c=m.length-1;while(c>0&&!m[c].notes.length)c--;if(!m[c].notes.length)c=m.length-1;let a=m.map((u,d)=>{let p=u.dotted?["d"]:[];if(i&&d===c)p.push(`txt ${St(i)}`);let b=u.duration===t?"":`:${u.duration} `;return t=u.duration,b+Et(u.notes,p)}).join(" ");return l?`\\ac ${a}`:a}).join(` |
|
|
3
|
+
`)}function xe(e){let n=st(e),t=n[0];if(!t)return null;let r=t.kind==="strings"?J(t.names):null,o=r?ct(r):null;if(o)r=o.tuning;let s=[];if(t.kind==="drums"){for(let d of n)if(d.kind==="drums")s.push(fe(d.lines,me(d.lines,ut(d.drums)),d.texts,!1))}else{let d=JSON.stringify(J(t.names)),p=o?.strings??[];for(let b of n){if(b.kind!=="strings"||JSON.stringify(J(b.names))!==d)continue;let f=it(b.lines.map(at),b.muted,p);s.push(fe(b.lines,me(b.lines,f),b.texts,b.openStart))}}let i=wt(s),l=Tt(s,i),m=Mt(At(s,i),l).map((d)=>({beats:d.beats.map((p)=>p.notes),rhythm:xt(d,i??0,l),text:d.text,pickup:d.pickup}));if(!m.length)return null;let c=l===F?[]:[`\\ts ${l.ts.join(" ")}`];if(t.kind==="drums")return["\\instrument percussion","\\articulation defaults",...c,ge(m,l)].join(`
|
|
4
|
+
`);let a=r?.join(" ")===j[6].join(" ");return[...r&&!a?[`\\tuning (${r.map((d)=>ae(d)).join(" ")})`]:[],...c,ge(m,l)].join(`
|
|
5
|
+
`)}var Nt="1.8.4",_=(e=Nt)=>{let n=`https://cdn.jsdelivr.net/npm/@coderline/alphatab@${e}/dist`;return{script:`${n}/alphaTab.min.js`,font:`${n}/font/Bravura.woff2`,soundFont:`${n}/soundfont/sonivox.sf3`}},Lt=/^\s*(staves|file|tracks?)\s*:\s*(.*)$/i;function Ft(e,n){let t=n.split(/\r?\n/),r={staves:e,stavesWritten:!1,file:null,tracks:null,tex:"",texLine:0,fromText:!1},o=0;for(;o<t.length;o++){let i=t[o];if(!i.trim()||/^\s*\/\//.test(i))continue;let l=Lt.exec(i);if(!l)break;let m=l[1].toLowerCase(),c=l[2].trim();if(m==="staves"){let a=c.toLowerCase();if(a!=="tab"&&a!=="score"&&a!=="both")throw Error(`staves: use tab, score or both, got "${c}"`);r.staves=a,r.stavesWritten=!0}else if(m==="file")r.file=c.replace(/^!?\[\[|\]\]$/g,"").split(/[|#]/)[0].trim()||null;else{let a=c.split(/[\s,]+/).filter(Boolean).map(Number);if(!a.length||a.some((u)=>!Number.isInteger(u)||u<1))throw Error(`tracks: use track numbers from 1, got "${c}"`);r.tracks=a}}while(o<t.length&&!t[o].trim())o++;if(r.texLine=o,r.tex=t.slice(o).join(`
|
|
6
|
+
`).trimEnd(),!r.file&&!r.tex)throw Error("Write the music in alphaTex, or give a file: [[Song.gp]]");let s=r.file?null:xe(r.tex);if(s!==null)r.tex=s,r.fromText=!0;return r}function ke(e,n){let t=e?.cause??e;for(let r of["lexerDiagnostics","parserDiagnostics","semanticDiagnostics"]){let o=t?.[r]?.items;if(!Array.isArray(o))continue;let s=o.find((i)=>i.severity===2&&i.message);if(s)return`${s.start&&n!==null?`line ${s.start.line+n}, column ${s.start.col}: `:""}${s.message}`}return e instanceof Error?e.message:String(e)}var Ot=0;function we(e,n){for(let t of n.tracks)for(let r of t.staves){if(r.isPercussion)for(let s of r.bars??[])s.clef=Ot;let o=!r.isPercussion&&r.tuning.length>0;if(e==="both"){r.showStandardNotation=!0,r.showTablature=o;continue}r.showSlash=!1,r.showNumbered=!1,r.showTablature=e==="tab"&&o,r.showStandardNotation=!r.showTablature}}var Dt=5;function Pt(e,n){if(n!==null&&/\bdy\b|\\showdynamics/i.test(n))return;if(!e.tracks.some((r)=>r.staves.some((o)=>o.bars.some((s)=>s.voices.some((i)=>i.beats.some((l)=>!l.isRest&&l.dynamics!==Dt))))))e.stylesheet.hideDynamics=!0}var Rt="rendered by alphaTab";function $t(e,n){e.renderer?.partialRenderFinished?.on((r)=>{for(let o of n.querySelectorAll(".at-surface > div")){if(o.layoutResultId!==r.id)continue;let s=typeof r.renderResult==="string"&&r.renderResult.includes(Rt);o.style.visibility=s?"hidden":""}})}function Te(e,n,t=1){let r=e.createElement("canvas");r.width=1,r.height=1;let o=r.getContext("2d",{willReadFrequently:!0});if(!o)return null;o.fillStyle="#000",o.fillStyle=n,o.fillRect(0,0,1,1);let s=o.getImageData(0,0,1,1).data;if(s.length<4)return null;return`rgba(${s[0]}, ${s[1]}, ${s[2]}, ${(s[3]/255*t).toFixed(3)})`}function Gt(e){let n=e.ownerDocument,t=n.defaultView?.getComputedStyle(e).color||"",r=t&&Te(n,t)||(/^rgba?\(/.test(t)?t:"rgba(0, 0, 0, 1)"),o=t&&Te(n,t,0.6)||r;return{mainGlyphColor:r,secondaryGlyphColor:o,scoreInfoColor:r,staffLineColor:o,barSeparatorColor:r,barNumberColor:o}}var ne=(e)=>{let n=e.defaultView??globalThis;return{map:(t)=>new n.Map(t),bytes:(t)=>{let r=new n.Uint8Array(t.length);return r.set(t),r}}},Bt={play:"M4 2.5v11l9-5.5z",pause:"M4 3h3v10H4zM9 3h3v10H9z",stop:"M4 4h8v8H4z",loop:"M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5",metronome:"M6 2h4l3 12H3zM8 11l3-7",countIn:"M3 13h10M5 13V9M8 13V6M11 13V3",volume:"M2 6h3l4-3v10l-4-3H2zM11 5.5a3.5 3.5 0 0 1 0 5"};function Q(e,n){let r=q(e,"svg",{class:`mn-play-icon${n==="play"||n==="pause"||n==="stop"?"":" mn-play-icon-loop"}`,viewBox:"0 0 16 16",width:12,height:12,"aria-hidden":"true"});return r.appendChild(q(e,"path",{d:Bt[n]})),r}var Ae=(e)=>{let n=Math.max(0,Math.round(e/1000));return`${Math.floor(n/60)}:${String(n%60).padStart(2,"0")}`};function Ht(e,n,t,r){let o=S(e,"div","mn-play mn-tab-bar");o.addEventListener("mousedown",(f)=>f.stopPropagation()),o.setAttribute("role","group"),o.setAttribute("aria-label","Playback");let s={loop:!1,metronome:!1,countIn:!1,speed:1,volume:1},i=null,l=null,m=()=>(i??=new Promise((f)=>{if(n.playerReady.on(()=>f(!0)),l=()=>f(!1),n.settings.player.playerMode=t.PlayerMode.EnabledSynthesizer,n.settings.player.enableCursor=!0,typeof r.soundFont==="string")n.settings.player.soundFont=r.soundFont;if(n.updateSettings(),r.soundFont instanceof Uint8Array)n.loadSoundFont(ne(e).bytes(r.soundFont),!1)}).then((f)=>{if(f)n.isLooping=s.loop,n.metronomeVolume=s.metronome?1:0,n.countInVolume=s.countIn?1:0,n.playbackSpeed=s.speed,n.masterVolume=s.volume;return f}),i),c=(f,h,g)=>{let y=S(e,"button");return y.type="button",y.title=h,y.setAttribute("aria-label",h),y.appendChild(Q(e,f)),y.addEventListener("click",g),o.appendChild(y),y},a=(f)=>{if(n.player)f()},u=(f,h,g)=>{let y=c(f,h,()=>{s[g]=!s[g],a(()=>{n.isLooping=s.loop,n.metronomeVolume=s.metronome?1:0,n.countInVolume=s.countIn?1:0}),y.classList.toggle("mn-on",s[g]),y.setAttribute("aria-pressed",String(s[g]))});y.setAttribute("aria-pressed","false")},d=c("play","Play",()=>{m().then((f)=>{if(f)n.playPause()})});c("stop","Stop",()=>a(()=>n.stop())),u("loop","Loop","loop"),u("metronome","Metronome","metronome"),u("countIn","Count-in","countIn");let p=(f,h,g,y,T,C,O="")=>{let k=S(e,"label","mn-play-field"),N=S(e,"span","mn-play-label");N.setAttribute("aria-hidden","true"),N.append(h);let w=S(e,"input");w.type="range",w.min=String(g),w.max=String(y),w.value=String(T),w.setAttribute("aria-label",f),k.title=`${f}: ${T}${O}`,w.addEventListener("input",()=>{C(Number(w.value)),k.title=`${f}: ${w.value}${O}`}),k.append(N,w),o.appendChild(k)};p("Speed","%",25,150,100,(f)=>{s.speed=f/100,a(()=>n.playbackSpeed=s.speed)},"%"),p("Volume",Q(e,"volume"),0,100,100,(f)=>{s.volume=f/100,a(()=>n.masterVolume=s.volume)});let b=S(e,"span","mn-tab-time","");return o.appendChild(b),n.playerStateChanged.on((f)=>{let h=Number(f.state)===Number(t.synth.PlayerState.Playing);d.replaceChildren(Q(e,h?"pause":"play")),d.title=h?"Pause":"Play",d.setAttribute("aria-label",d.title)}),n.playerPositionChanged.on((f)=>{b.textContent=`${Ae(f.currentTime)} / ${Ae(f.endTime)}`}),{bar:o,speed:()=>s.speed,failed:(f)=>{l?.(),d.disabled=!0,d.title=`Can't play: ${f}`,d.setAttribute("aria-label",d.title)}}}function Vt(e,n){return e.tracks.some((t,r)=>(!n||n.includes(r+1))&&t.staves.some((o)=>!o.isPercussion&&o.tuning.length>0))}var It=[{staves:"tab",label:"Tab",what:"tablature"},{staves:"score",label:"Score",what:"standard notation"},{staves:"both",label:"Both",what:"standard notation and tablature"}];function zt(e,n,t,r){let o=S(e,"span","mn-tab-views");o.setAttribute("role","group"),o.setAttribute("aria-label","View");let s=n.staves,i=r?S(e,"button","mn-tab-keep","Keep this view"):null,l=It.map(({staves:c,label:a,what:u})=>{let d=S(e,"button","mn-tab-view",a);d.type="button",d.dataset.staves=c;let p=c!==n.staves?"":n.written?" (this block's staves: line)":" (the default: the block has no staves: line)";return d.title=`Draw as ${u}${p}`,d.addEventListener("click",()=>{if(c===s)return;s=c,m(),t(c)}),o.appendChild(d),d}),m=()=>{for(let c of l){let a=c.dataset.staves===s;c.classList.toggle("mn-on",a),c.setAttribute("aria-pressed",String(a))}if(i)i.hidden=s===n.staves,i.title=`Write staves: ${s} at the top of the block`};if(i&&r)i.type="button",i.addEventListener("click",()=>r(s)),o.appendChild(i);return m(),o}function Me(e,n,t,r){let o=t.ownerDocument,s=S(o,"div",`mn-block mn-block-${e} mn-tab`);t.appendChild(s);let i=null,l=()=>1,m=!1,c=!1,a=()=>{},u=new Promise((p)=>{a=(b)=>{if(c)return;c=!0,p(b)}}),d=(p)=>{s.replaceChildren(S(o,"div","mn-error-message",`${e}: ${p}`)),s.classList.add("mn-error"),a({ok:!1,error:p})};if(!n.trim())s.classList.add("mn-empty"),a({ok:!0,error:null});else(async()=>{await Promise.resolve();let p=Ft(e,n),b={staves:p.stavesWritten?p.staves:r.defaultStaves??p.staves,written:p.stavesWritten},f=b.staves,h=!1,g=r.alphaTab;if(!g?.AlphaTabApi)throw Error("alphaTab isn't loaded");let y=S(o,"div","mn-tab-surface");s.appendChild(y);let{assets:T}=r,C=ne(o),O={core:{useWorkers:Boolean(T.scriptFile),...T.scriptFile?{scriptFile:T.scriptFile}:{},smuflFontSources:C.map([[g.FontFileFormat.Woff2,T.font]]),logLevel:g.LogLevel.Warning,enableLazyLoading:!1},display:{staveProfile:"Default",resources:Gt(s)},player:{playerMode:g.PlayerMode.Disabled,enableUserInteraction:!0}},k=new g.AlphaTabApi(y,O);if(i=k,m){k.destroy();return}r.onApi?.(k);let N=[];k.scoreLoaded.on((v)=>{N=v.tracks.flatMap((M)=>M.staves.map((A)=>({showSlash:A.showSlash,showNumbered:A.showNumbered}))),we(f,v),h=Vt(v,p.tracks),Pt(v,p.file?null:p.tex)}),$t(k,y);let w=null;k.renderFinished.on(()=>{if(c||m)return;if(r.player!==!1){if(w=Ht(o,k,g,T),l=w.speed,s.appendChild(w.bar),r.views!==!1&&h)w.bar.appendChild(zt(o,b,(v)=>{f=v;let M=k.score;if(m||!M)return;M.tracks.flatMap((D)=>D.staves).forEach((D,H)=>Object.assign(D,N[H])),we(v,M),k.render()},r.onKeepView));s.addEventListener("pointerdown",(v)=>{if(v.pointerType!=="touch"||w?.bar.contains(v.target))return;s.classList.toggle("mn-play-open")})}a({ok:!0,error:null})}),k.error.on((v)=>{let M=p.fromText?`Couldn't draw this text tab: ${ke(v,null)}`:ke(v,p.texLine);if(c)w?.failed(M);else d(M)});let x=p.tracks?.map((v)=>v-1);if(p.file){let v;try{v=r.resolveFile?await r.resolveFile(p.file):null}catch(A){throw Error(`Couldn't read "${p.file}": ${A instanceof Error?A.message:String(A)}`)}if(m)return;if(!v)throw Error(`Couldn't find the file "${p.file}"`);if(!k.load(C.bytes(v),x))throw Error(`Couldn't read "${p.file}": not a score file alphaTab knows`)}else k.tex(p.tex,x??"all")})().catch((p)=>{if(!m)d(p instanceof Error?p.message:String(p))});return{el:s,ready:u,get api(){return i},speed:()=>l(),destroy(){m=!0;try{i?.destroy()}catch{}s.remove(),a({ok:!1,error:null})}}}var te={guitar:25,piano:0},U={channel:1,program:28},ee={channel:9,key:33},jt=0.5;function Ut(e,n){return{reportsStart:!0,play(t,{sound:r,volume:o,onEnd:s,onStart:i}){let l=n(),m=l?.player;if(!l||!m)throw Error("The soundfont player is not ready");let c=new e.midi.MidiFile,a=new e.midi.AlphaSynthMidiFileHandler(c,!0),u=(h)=>Math.round(h*c.division);if(a.addTempo(0,60),a.addProgramChange(0,0,0,te[r]),r==="guitar"&&t.some((h)=>h.kind==="muted"))a.addProgramChange(0,0,U.channel,U.program);if(t.some((h)=>h.kind==="click"))a.addProgramChange(0,0,ee.channel,0);let d=Number.isFinite(o)?Math.min(1,Math.max(0,o)):0.8;l.masterVolume=d;for(let h of t){let g=h.velocity===void 0||!Number.isFinite(h.velocity)?100:Math.round(Math.min(127,Math.max(1,h.velocity))),y=h.kind==="click"?ee.channel:h.kind==="muted"&&r==="guitar"?U.channel:0;a.addNote(0,u(h.time),Math.max(1,u(h.duration)),h.kind==="click"?ee.key:h.midi,g,y)}let p=Math.max(...t.map((h)=>h.time+h.duration),0);a.addControlChange(0,u(p+jt),0,e.midi.ControllerType.HoldPedal,0),l.playbackSpeed=1,m.playOneTimeMidiFile(c);let b=!1;queueMicrotask(()=>{if(!b)i?.()});let f=setTimeout(()=>s?.(),(p+0.2)*1000);return{stop(){b=!0,clearTimeout(f),m.stop()}}}}}function Se(e,n,t,r){let o=null,s=null,i=null,l=()=>{if(i)return i;s=S(t,"div","mn-tab-hidden"),s.setAttribute("aria-hidden","true"),t.body.appendChild(s);let c=ne(t);o=new e.AlphaTabApi(s,{core:{useWorkers:Boolean(n.scriptFile),...n.scriptFile?{scriptFile:n.scriptFile}:{},smuflFontSources:c.map([[e.FontFileFormat.Woff2,n.font]])},player:{playerMode:e.PlayerMode.EnabledSynthesizer,...typeof n.soundFont==="string"?{soundFont:n.soundFont}:{}}});let a=o;if(i=new Promise((u)=>{let d=!1,p=!a.playerReady,b=()=>{if(d&&p)u(!0)};a.soundFontLoaded.on(()=>{d=!0,b(),setTimeout(()=>{p=!0,b()},4000)}),a.playerReady?.on(()=>{p=!0,b()}),a.error.on(()=>u(!1))}),n.soundFont instanceof Uint8Array)a.loadSoundFont(c.bytes(n.soundFont),!1);return a.tex(`\\track "Guitar" \\instrument ${te.guitar} r \\track "Piano" \\instrument ${te.piano} r \\track "Muted" \\instrument ${U.program} r`),i},m=Ut(e,()=>o);return{reportsStart:!0,play(c,a){let u=null,d=!1;return l().then((p)=>{if(d)return;try{if(p){u=m.play(c,a);return}}catch{}if(!r)return;if(u=r.play(c,a),!r.reportsStart)a.onStart?.()}),{stop(){d=!0,u?.stop()}}},destroy(){try{o?.destroy()}catch{}s?.remove(),o=null,i=null}}}function Ee(e=()=>_().script){let n=null;return(t)=>{let r=t.defaultView;if(r.alphaTab)return Promise.resolve(r.alphaTab);return n??=new Promise((o,s)=>{let i=t.createElement("script");i.src=e();let l=r.define?.amd?r.define:void 0;if(l)r.define=void 0;let m=(c)=>{if(l&&r.define===void 0)r.define=l;if(c===null&&r.alphaTab){o(r.alphaTab);return}n=null,i.remove(),s(Error(c??"alphaTab's script didn't define alphaTab"))};i.onload=()=>m(null),i.onerror=()=>m("Couldn't load alphaTab"),t.head.appendChild(i)}),n}}var Ce=`/* Music notation. Colors follow Obsidian's theme variables when present, with fallbacks for any page. */
|
|
7
7
|
.mn-block,
|
|
8
8
|
.mn-svg,
|
|
9
9
|
.mn-chart {
|
|
@@ -42,6 +42,16 @@
|
|
|
42
42
|
height: auto;
|
|
43
43
|
}
|
|
44
44
|
|
|
45
|
+
/* Touch screens (#73): chord diagrams and fretboards a third larger, so each string's lane (the
|
|
46
|
+
hit area of its marks across, 18 and 20 units) is at least 24 px, the minimum target size of
|
|
47
|
+
WCAG 2.5.8. max-width still keeps them inside the page. */
|
|
48
|
+
@media (pointer: coarse) {
|
|
49
|
+
.mn-svg.mn-guitar-chord,
|
|
50
|
+
.mn-svg.mn-fretboard {
|
|
51
|
+
zoom: 1.34;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
|
|
45
55
|
.mn-svg text {
|
|
46
56
|
fill: var(--mn-fg);
|
|
47
57
|
font-size: 11px;
|
|
@@ -960,4 +970,99 @@
|
|
|
960
970
|
.mn-playable .mn-svg [data-midi].mn-playing + .mn-key-label {
|
|
961
971
|
fill: var(--mn-on-playing);
|
|
962
972
|
}
|
|
963
|
-
|
|
973
|
+
|
|
974
|
+
/* A fretboard exercise (#47): the run's tab under the diagram, as wide as the block. */
|
|
975
|
+
.mn-block .mn-exercise-block {
|
|
976
|
+
display: flex;
|
|
977
|
+
flex-direction: column;
|
|
978
|
+
align-items: flex-start;
|
|
979
|
+
gap: 0.5em;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
.mn-block .mn-exercise-block > .mn-exercise-tab,
|
|
983
|
+
.mn-block .mn-exercise-block > .mn-tab-holder {
|
|
984
|
+
align-self: stretch;
|
|
985
|
+
}
|
|
986
|
+
|
|
987
|
+
.mn-block pre.mn-exercise {
|
|
988
|
+
margin: 0;
|
|
989
|
+
white-space: pre-wrap;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
/* Progressions and charts in time (#46): the bar sits above the chords, always shown. */
|
|
993
|
+
.mn-play.mn-play-static {
|
|
994
|
+
position: static;
|
|
995
|
+
display: inline-flex;
|
|
996
|
+
justify-content: flex-start;
|
|
997
|
+
margin: 0 0 6px;
|
|
998
|
+
opacity: 1;
|
|
999
|
+
pointer-events: auto;
|
|
1000
|
+
}
|
|
1001
|
+
|
|
1002
|
+
.mn-progression-chord.mn-playing {
|
|
1003
|
+
border-radius: 6px;
|
|
1004
|
+
background: color-mix(in srgb, var(--mn-playing) 22%, transparent);
|
|
1005
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--mn-playing) 70%, transparent);
|
|
1006
|
+
}
|
|
1007
|
+
|
|
1008
|
+
.mn-chart .mn-chord.mn-playing {
|
|
1009
|
+
border-radius: 3px;
|
|
1010
|
+
background: color-mix(in srgb, var(--mn-playing) 45%, transparent);
|
|
1011
|
+
}
|
|
1012
|
+
|
|
1013
|
+
/* Picking patterns (#51): a small tab, the fingers and counts under it. */
|
|
1014
|
+
.mn-svg .mn-picking-string {
|
|
1015
|
+
stroke: var(--mn-muted);
|
|
1016
|
+
stroke-width: 1;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.mn-svg .mn-picking-bar {
|
|
1020
|
+
stroke: var(--mn-fg);
|
|
1021
|
+
stroke-width: 1.5;
|
|
1022
|
+
}
|
|
1023
|
+
|
|
1024
|
+
.mn-svg .mn-picking-gap {
|
|
1025
|
+
fill: var(--mn-bg);
|
|
1026
|
+
stroke: none;
|
|
1027
|
+
}
|
|
1028
|
+
|
|
1029
|
+
.mn-svg .mn-picking-fret {
|
|
1030
|
+
fill: var(--mn-fg);
|
|
1031
|
+
font-size: 11px;
|
|
1032
|
+
font-weight: 600;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
.mn-svg .mn-picking-finger {
|
|
1036
|
+
fill: var(--mn-accent);
|
|
1037
|
+
font-size: 11px;
|
|
1038
|
+
font-style: italic;
|
|
1039
|
+
}
|
|
1040
|
+
|
|
1041
|
+
.mn-svg .mn-picking-finger.mn-picking-thumb {
|
|
1042
|
+
font-weight: 700;
|
|
1043
|
+
}
|
|
1044
|
+
|
|
1045
|
+
.mn-svg .mn-picking-cell {
|
|
1046
|
+
fill: transparent;
|
|
1047
|
+
stroke: none;
|
|
1048
|
+
}
|
|
1049
|
+
|
|
1050
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
|
|
1051
|
+
fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
|
|
1052
|
+
}
|
|
1053
|
+
|
|
1054
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
|
|
1055
|
+
fill: var(--mn-playing);
|
|
1056
|
+
}
|
|
1057
|
+
|
|
1058
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
|
|
1059
|
+
fill: var(--mn-on-playing);
|
|
1060
|
+
}
|
|
1061
|
+
|
|
1062
|
+
/* App controls in a timed play bar (#77): after the bar's own, styled like them. */
|
|
1063
|
+
.mn-play .mn-play-app {
|
|
1064
|
+
display: inline-flex;
|
|
1065
|
+
align-items: center;
|
|
1066
|
+
gap: 2px 6px;
|
|
1067
|
+
}
|
|
1068
|
+
`;var Wt=Ce,Ne="music-notation-styles";function Le(e){if(e.getElementById(Ne))return;let n=e.createElement("style");n.id=Ne,n.textContent=Wt,e.head.appendChild(n)}var qt=(e)=>e.reduce((n,t)=>Math.max(n,t.time+t.duration),0),oe=(e)=>440*Math.pow(2,(e-69)/12);function Kt(e,n,t,r=Math.random,o={}){let s=new Float32Array(Math.round(n*t)),i=Math.max(2,Math.round(n/oe(e))),l=new Float32Array(i);for(let f=0;f<i;f++)l[f]=r()*2-1;let m=Math.min(1,Math.max(0,o.brightness??1));if(m<1){let f=0.2+0.8*m,h=l[i-1];for(let g=0;g<i;g++)l[g]=h+=f*(l[g]-h)}let c=Math.min(0.5,Math.max(0,o.pick??0)),a=Math.round(c*i);if(a>0){let f=Float32Array.from(l);for(let h=0;h<i;h++)l[h]=f[h]-f[(h-a+i)%i]}if(m<1||a>0){let f=l.reduce((g,y)=>g+y,0)/i,h=l.reduce((g,y)=>Math.max(g,Math.abs(y-f)),0)||1;for(let g=0;g<i;g++)l[g]=(l[g]-f)/h}let u=o.damping!==void 0&&Number.isFinite(o.damping)?o.damping:1,d=(0.004-Math.min(0.0035,0.00004*(90-e)))*u,p=1-Math.min(0.02,Math.max(0.0001,d)),b=0;for(let f=0;f<s.length;f++){let h=(b+1)%i,g=l[b];l[b]=p*0.5*(g+l[h]),s[f]=g*0.5,b=h}return s}var Fe=0.07,Oe=0.03,Xt=(e)=>e>=88?2800:e>=84?2100:1400;function Yt(e,n,t,r,o,s){let i=r+t.time,l=t.velocity===void 0||!Number.isFinite(t.velocity)?1:Math.min(127,Math.max(0,t.velocity))/100,m=e.createGain();m.connect(n);let c,a;if(t.kind==="click"){let u=e.createOscillator();u.type="triangle",u.frequency.value=Xt(t.midi),c=u,a=Oe,m.gain.setValueAtTime(0,i),m.gain.linearRampToValueAtTime(0.5*l||0.0001,i+0.001),m.gain.exponentialRampToValueAtTime(0.0001,i+Oe)}else{let u=e.createBiquadFilter();if(u.type="lowpass",u.frequency.value=o==="guitar"?1800:2500,u.connect(m),o==="guitar"){let d=e.createBufferSource();d.buffer=s(e,t.midi),c=d}else{let d=e.createOscillator();d.type="triangle",d.frequency.value=oe(t.midi),c=d}a=Fe,m.gain.setValueAtTime(1.2*l||0.0001,i),m.gain.exponentialRampToValueAtTime(0.0001,i+Fe),c.connect(u)}if(t.kind==="click")c.connect(m);return c.start(i),c.stop(i+a+0.02),c}var De=new WeakMap;function Jt(e){let n=De.get(e);if(n)return n;let t=e.AudioContext;if(!t)return null;let r=new t;return De.set(e,r),r}var Zt=4,Pe=[0,1,0.5,0.3,0.15,0.08,0.04],re=4,Qt={guitar:0.15,piano:0.3},Re=(e,n)=>Math.min(Qt[e],Math.max(0.03,n/2)),en=(e)=>Math.min(2.5,Math.max(0.35,Math.pow(2,(60-e)/24)));function $e(e,n=Math.random){let t=new Map,r=new WeakMap,o=(l,m)=>l+(m-l)*n(),s=(l,m,c)=>{let a=m*re+c,u=t.get(a);if(!u){let d=Kt(m,l.sampleRate,Zt,n,{brightness:o(0.55,0.95),pick:o(0.08,0.2),damping:o(0.85,1.15)});u=l.createBuffer(1,d.length,l.sampleRate),u.getChannelData(0).set(d),t.set(a,u)}return u},i=(l)=>{let m=r.get(l);if(!m){let c=new Float32Array(Pe.length);m=l.createPeriodicWave(c,Float32Array.from(Pe)),r.set(l,m)}return m};return{reportsStart:!0,play(l,{sound:m,volume:c,onEnd:a,onStart:u}){let d=Jt(e);if(!d||!l.length)return{stop(){}};let p=d.resume(),b=l.map(()=>({pluck:Math.min(re-1,Math.floor(n()*re)),cents:o(-4,4),level:o(0.93,1.07),decay:o(0.9,1.1)}));if(m==="guitar")l.forEach((x,v)=>{if(x.kind==="muted")s(d,x.midi,0);else if(!x.kind)s(d,x.midi,b[v].pluck)});let f=d.createGain();f.gain.value=Number.isFinite(c)?Math.min(1,Math.max(0,c)):0.8,f.connect(d.destination);let h=d.currentTime+0.05,g=l.map((x,v)=>{if(x.kind)return Yt(d,f,x,h,m,(E,Be)=>s(E,Be,0));let M=b[v],A=h+x.time,D=A+x.duration,H=Re(m,x.duration),L=d.createGain();L.connect(f);let W=(x.velocity===void 0||!Number.isFinite(x.velocity)?1:Math.min(127,Math.max(0,x.velocity))/100)*M.level,P;if(m==="guitar"){let E=d.createBufferSource();E.buffer=s(d,x.midi,M.pluck),E.playbackRate.value=Math.pow(2,M.cents/1200),P=E,L.gain.setValueAtTime(W,A),L.gain.setValueAtTime(W,D)}else{let E=d.createOscillator();E.setPeriodicWave(i(d)),E.frequency.value=oe(x.midi),E.detune.value=M.cents,P=E,L.gain.setValueAtTime(0,A),L.gain.linearRampToValueAtTime(0.35*W,A+0.005),L.gain.setTargetAtTime(0,A+0.005,en(x.midi)*M.decay)}return L.gain.setTargetAtTime(0,Math.max(A+0.006,D),H/4),P.connect(L),P.start(A),P.stop(Math.max(A+0.006,D)+H),P}),y=()=>f.disconnect(),T=!1,C,O=()=>{if(T||!u)return;let x=Number.isFinite(d.outputLatency)?d.outputLatency:0;C=e.setTimeout(()=>{if(!T)u()},Math.max(0,h-d.currentTime+x)*1000)};if(u)Promise.resolve(p).then(O,O);let k=e.setTimeout(()=>a?.(),(qt(l)+0.15)*1000),N=l.reduce((x,v)=>Math.max(x,v.time+v.duration+Re(m,v.duration)),0),w=e.setTimeout(y,(N+0.15)*1000);return{stop(){if(T)return;T=!0,e.clearTimeout(k),e.clearTimeout(C),e.clearTimeout(w);let x=d.currentTime;f.gain.setTargetAtTime(0,x,0.01);for(let v of g)try{v.stop(x+0.05)}catch{}w=e.setTimeout(y,80)}}}}}var tn="pre > code.language-tab, pre > code.language-score",B=new Map,nn=Ee();function Ge(e){for(let[t,{result:r,holder:o}]of B)if(!t.isConnected||!r.el.isConnected){if(r.destroy(),o.remove(),B.delete(t),t.isConnected)t.style.removeProperty("display")}let n=[...e.querySelectorAll(tn)].filter((t)=>{let r=t.parentElement,o=B.get(r);if(!o)return r.dataset.mpRendered!=="pending";if(o.source===(t.textContent??""))return!1;return o.result.destroy(),o.holder.remove(),B.delete(r),!0});if(!n.length)return;for(let t of n)t.parentElement.dataset.mpRendered="pending";nn(e).then((t)=>{let r=_(),o={scriptFile:null,font:r.font,soundFont:r.soundFont},s=e.defaultView;s.musicNotationSoundfontPlayer??=Se(t,o,e,$e(s));for(let i of n){let l=i.parentElement;if(!l.parentElement)continue;let m=i.classList.contains("language-score")?"score":"tab",c=i.textContent??"",a=e.createElement("div");a.className="mn-tab-holder",l.insertAdjacentElement("afterend",a);let u=Me(m,c,a,{alphaTab:t,assets:o});B.set(l,{result:u,source:c,holder:a}),u.ready.then(({ok:d})=>{if(l.dataset.mpRendered=d?"done":"error",d&&u.el.isConnected)l.style.display="none"})}}).catch(()=>{for(let t of n)t.parentElement.dataset.mpRendered="error"})}if(!window.musicNotationTabLoaded){window.musicNotationTabLoaded=!0;let e=()=>{Le(document),Ge(document);let n=!1;new MutationObserver(()=>{if(n)return;n=!0,requestAnimationFrame(()=>{n=!1,Ge(document)})}).observe(document.body,{childList:!0,subtree:!0,characterData:!0})};if(document.readyState==="loading")document.addEventListener("DOMContentLoaded",e);else e()}})();
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Fingerpicking patterns (#51, fence `picking`): `key: value` lines and pattern lines of one
|
|
3
|
+
* token a slot, PIMA letters (p the thumb on the bass, p' the thumb on the alternate bass, i m a
|
|
4
|
+
* the fingers on strings 3 2 1) or string numbers (1 the highest), `+` or glued letters for notes
|
|
5
|
+
* picked together (a pinch: `p+a`, `pa`), `-` `.` `_` rests, `|` bar lines. Named patterns:
|
|
6
|
+
* Travis, alternate bass, 1-2-3-4 (an arpeggio).
|
|
7
|
+
*/
|
|
8
|
+
import { type Subdivision } from '../strum/pattern.js';
|
|
9
|
+
/** The thumb on the bass or the alternate bass, a finger, or a string by number. */
|
|
10
|
+
export type Pluck = {
|
|
11
|
+
finger: 'p';
|
|
12
|
+
alternate: boolean;
|
|
13
|
+
} | {
|
|
14
|
+
finger: 'i' | 'm' | 'a';
|
|
15
|
+
} | {
|
|
16
|
+
string: number;
|
|
17
|
+
};
|
|
18
|
+
export interface PickingSlot {
|
|
19
|
+
/** What sounds in the slot, together; empty for a rest. */
|
|
20
|
+
plucks: Pluck[];
|
|
21
|
+
}
|
|
22
|
+
export interface PickingPattern {
|
|
23
|
+
slots: PickingSlot[];
|
|
24
|
+
beatsPerBar: number;
|
|
25
|
+
beatUnit: number;
|
|
26
|
+
subdivision: Subdivision;
|
|
27
|
+
slotsPerBeat: number;
|
|
28
|
+
compound: boolean;
|
|
29
|
+
/** Slots in one counted beat: `slotsPerBeat`, three times that in compound time. */
|
|
30
|
+
slotsPerPulse: number;
|
|
31
|
+
swing: number | null;
|
|
32
|
+
slotsPerBar: number;
|
|
33
|
+
/** The pattern's own bars (it repeats over every chord). */
|
|
34
|
+
bars: number;
|
|
35
|
+
/** The chord picked (`chord:`), or null. */
|
|
36
|
+
chord: string | null;
|
|
37
|
+
/** One chord a bar (`chords:` or `progression:`), the pattern repeating; empty when none. */
|
|
38
|
+
chords: string[];
|
|
39
|
+
tempo: number | null;
|
|
40
|
+
tuning: string | null;
|
|
41
|
+
title: string | null;
|
|
42
|
+
/** The named pattern written (`pattern: travis`), as named; null when written out. */
|
|
43
|
+
name: string | null;
|
|
44
|
+
}
|
|
45
|
+
/** Bounds that keep a pattern quick to draw and to hear. */
|
|
46
|
+
export declare const MAX_PICKING_BARS = 16;
|
|
47
|
+
/** The named patterns, in 8ths: each fills a bar, repeated, in the block's time. */
|
|
48
|
+
export declare const PICKING_PATTERNS: Readonly<Record<string, {
|
|
49
|
+
name: string;
|
|
50
|
+
slots: string;
|
|
51
|
+
}>>;
|
|
52
|
+
/** A named pattern's key ("travis"), from any case and the usual other names; null otherwise. */
|
|
53
|
+
export declare function namedPicking(text: string): string | null;
|
|
54
|
+
/** Reads a ```picking block. Throws a message for the user. */
|
|
55
|
+
export declare function parsePicking(source: string, strings?: number): PickingPattern;
|
|
56
|
+
/** A pluck as written: p, p', i, m, a, or the string's number. */
|
|
57
|
+
export declare const pluckText: (p: Pluck) => string;
|
|
58
|
+
/** A pattern as one line of tokens ("p m p' i p m p' i"), bars separated by `|`. */
|
|
59
|
+
export declare function formatPicking(pattern: PickingPattern): string;
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
import { type NotePlayer, type Sound } from '../playback/player.js';
|
|
3
|
+
import { type ProgressionHandle } from '../playback/progression.js';
|
|
4
|
+
import { type Pass } from '../strum/play.js';
|
|
5
|
+
import { type PickingPattern } from './pattern.js';
|
|
6
|
+
import { type PickedNote } from './voicing.js';
|
|
7
|
+
/** A pattern ready to play: each slot's notes, over its bar's chord. */
|
|
8
|
+
export interface PickingScore {
|
|
9
|
+
slots: {
|
|
10
|
+
notes: PickedNote[];
|
|
11
|
+
thumb: boolean[];
|
|
12
|
+
}[];
|
|
13
|
+
slotsPerBeat: number;
|
|
14
|
+
beatsPerBar: number;
|
|
15
|
+
slotsPerPulse: number;
|
|
16
|
+
swing: number | null;
|
|
17
|
+
/** Each bar's chord (as written), null for E minor or the open strings. */
|
|
18
|
+
chords: (string | null)[];
|
|
19
|
+
}
|
|
20
|
+
export interface PickingScoreOptions {
|
|
21
|
+
/** A chord to pick (wins over the pattern's `chord:`). */
|
|
22
|
+
chord?: string | null;
|
|
23
|
+
/** One chord a bar (wins over the pattern's `chords:`); the pattern repeats over them. */
|
|
24
|
+
chords?: readonly string[];
|
|
25
|
+
/** Open strings, lowest first; standard by default. */
|
|
26
|
+
tuning?: readonly number[];
|
|
27
|
+
voicings?: VoicingLookup;
|
|
28
|
+
}
|
|
29
|
+
/**
|
|
30
|
+
* The bars played: one a chord when chords are given (the pattern's bars in turn), else the
|
|
31
|
+
* pattern's bars over its one chord; each slot's notes on that bar's grip.
|
|
32
|
+
*/
|
|
33
|
+
export declare function pickingScore(pattern: PickingPattern, options?: PickingScoreOptions): PickingScore;
|
|
34
|
+
/** MIDI velocities: the thumb, a finger; the bar's first beat and the counted beats add. */
|
|
35
|
+
export declare const PICKING_VELOCITY: {
|
|
36
|
+
thumb: number;
|
|
37
|
+
finger: number;
|
|
38
|
+
first: number;
|
|
39
|
+
beat: number;
|
|
40
|
+
};
|
|
41
|
+
export interface PickingEventOptions {
|
|
42
|
+
/** Counted beats a minute (a dotted quarter in 6/8); 90 (60 in compound time). */
|
|
43
|
+
bpm?: number;
|
|
44
|
+
countIn?: boolean;
|
|
45
|
+
/** A metronome click on each counted beat; off by default. */
|
|
46
|
+
click?: boolean;
|
|
47
|
+
/** How long the last notes ring after the pattern, in seconds (0 when it loops). */
|
|
48
|
+
tail?: number;
|
|
49
|
+
seed?: number;
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* One pass of a picking score: its notes (with the count-in first when asked), its length, and
|
|
53
|
+
* when each slot is played (`strums`, one a slot with notes), to light it.
|
|
54
|
+
*/
|
|
55
|
+
export declare function pickingEvents(score: PickingScore, options?: PickingEventOptions): Pass;
|
|
56
|
+
export interface PlayPickingOptions {
|
|
57
|
+
/** A chord to pick (wins over the pattern's `chord:`). */
|
|
58
|
+
chord?: string | null;
|
|
59
|
+
/** One chord a bar (wins over the pattern's `chords:`); the pattern repeats over them. */
|
|
60
|
+
chords?: readonly string[];
|
|
61
|
+
/** Counted beats a minute: the pattern's `tempo:`, else 90 (60 in compound time). */
|
|
62
|
+
bpm?: number;
|
|
63
|
+
/** Open strings (MIDI, lowest first) or a tuning name; the pattern's, else standard. */
|
|
64
|
+
tuning?: readonly number[] | string;
|
|
65
|
+
/** Finds guitar voicings for chords (see `/voicings`); generated voicings otherwise. */
|
|
66
|
+
voicings?: VoicingLookup;
|
|
67
|
+
countIn?: boolean;
|
|
68
|
+
loop?: boolean;
|
|
69
|
+
/** A metronome click on each counted beat; off by default. */
|
|
70
|
+
click?: boolean;
|
|
71
|
+
/** The light synthesizer of `window` by default. */
|
|
72
|
+
player?: NotePlayer;
|
|
73
|
+
window?: Window;
|
|
74
|
+
sound?: Sound;
|
|
75
|
+
/** 0 to 1, 0.8 by default. */
|
|
76
|
+
volume?: number;
|
|
77
|
+
/** Called as each bar starts sounding: its index, its chord, the pass (from 1). */
|
|
78
|
+
onBar?: (bar: number, chord: string | null, pass: number) => void;
|
|
79
|
+
/** Called once the pattern is over (not after stop). */
|
|
80
|
+
onEnd?: () => void;
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Plays a picking pattern (a ```picking block's text, or a parsed pattern) over a chord or one
|
|
84
|
+
* chord a bar. Throws the block's message when the text has a mistake, or on an unknown chord or
|
|
85
|
+
* tuning. `update` changes the tempo, loop, click, volume or sound from the next pass.
|
|
86
|
+
*/
|
|
87
|
+
export declare function playPicking(pattern: string | PickingPattern, options?: PlayPickingOptions): ProgressionHandle;
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { RenderOptions } from '../blocks/renderers.js';
|
|
2
|
+
import { type PickingPattern } from './pattern.js';
|
|
3
|
+
export interface PickingOptions {
|
|
4
|
+
title?: string;
|
|
5
|
+
/** Open strings, lowest first; standard by default. */
|
|
6
|
+
tuning?: readonly number[];
|
|
7
|
+
/** Beats a minute playback starts at (the pattern's own tempo wins). */
|
|
8
|
+
bpm?: number;
|
|
9
|
+
voicings?: RenderOptions['voicings'];
|
|
10
|
+
}
|
|
11
|
+
/** The pattern's drawing over its chords, with what playback needs on its elements. */
|
|
12
|
+
export declare function renderPicking(doc: Document, pattern: PickingPattern, options?: PickingOptions): SVGElement;
|
|
13
|
+
/**
|
|
14
|
+
* A ```picking block: the pattern drawn over its chord or chords, with each slot's notes for
|
|
15
|
+
* playback. Throws a message for the user.
|
|
16
|
+
*/
|
|
17
|
+
export declare function renderPickingBlock(doc: Document, source: string, options: RenderOptions): Element;
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
import type { Pluck } from './pattern.js';
|
|
3
|
+
/** One note picked: its string (0 the lowest), fret and pitch. */
|
|
4
|
+
export interface PickedNote {
|
|
5
|
+
string: number;
|
|
6
|
+
fret: number;
|
|
7
|
+
midi: number;
|
|
8
|
+
}
|
|
9
|
+
/** The chord's grip, lowest string first (null a muted string). Throws on an unknown chord. */
|
|
10
|
+
export declare function pickingFrets(chord: string | null, tuning?: readonly number[], voicings?: VoicingLookup): (number | null)[];
|
|
11
|
+
/**
|
|
12
|
+
* The note a pluck sounds over a grip; null when nothing fits (a finger whose strings are all
|
|
13
|
+
* muted). The alternate bass: the chord's fifth on the string closest to the bass, a sounding
|
|
14
|
+
* one first (costs 1 a string away), else fretted on a muted string below the bass (1.5, plus
|
|
15
|
+
* 0.25 when fretted), on the strings below the fingers' (4 to 6 on a guitar): C x32010 alternates
|
|
16
|
+
* with G on string 6 (fret 3), G 320003 with D on string 4, D xx0232 with A on string 5, Am x02210
|
|
17
|
+
* with E on string 4.
|
|
18
|
+
*/
|
|
19
|
+
export declare function pluckNote(pluck: Pluck, frets: readonly (number | null)[], tuning: readonly number[], chord: string | null): PickedNote | null;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { PlayOptions, TimedBar } from './controls.js';
|
|
2
|
+
export interface AppBar {
|
|
3
|
+
/** To call when the bar's tempo changes. */
|
|
4
|
+
tempoChanged(bpm: number): void;
|
|
5
|
+
/** Frees what the app set up (its returned function). */
|
|
6
|
+
free(): void;
|
|
7
|
+
}
|
|
8
|
+
export declare function handToApp(options: PlayOptions, bar: HTMLElement, info: Pick<TimedBar, 'kind' | 'drawing' | 'compound' | 'tempo'>): AppBar;
|
|
@@ -26,6 +26,33 @@ export interface PlayOptions {
|
|
|
26
26
|
* has no hand (a keyboard, a piano chord) is drawn for it. Right by default (#60).
|
|
27
27
|
*/
|
|
28
28
|
hand?: Hand;
|
|
29
|
+
/**
|
|
30
|
+
* Called with each bar that plays a piece in time (strum, picking, progression, ChordPro chart;
|
|
31
|
+
* #77), once it's built, so the app can add its own controls (`bar.add`) and read the tempo set
|
|
32
|
+
* on it. What it returns (a function) is called when the block is destroyed. A hook that
|
|
33
|
+
* throws leaves the bar as it is.
|
|
34
|
+
*/
|
|
35
|
+
timedBar?: (bar: TimedBar) => void | (() => void);
|
|
36
|
+
}
|
|
37
|
+
/** A bar that plays a piece in time, as an app sees it (`PlayOptions.timedBar`, #77). */
|
|
38
|
+
export interface TimedBar {
|
|
39
|
+
/** What it plays: a strumming or picking pattern, a progression block or a ChordPro chart. */
|
|
40
|
+
kind: 'strum' | 'picking' | 'progression' | 'chart';
|
|
41
|
+
/** The bar itself (`.mn-play`, role group). */
|
|
42
|
+
element: HTMLElement;
|
|
43
|
+
/** The drawing it plays: the pattern's SVG, the `.mn-progression` or the `.mn-chart`. */
|
|
44
|
+
drawing: Element;
|
|
45
|
+
/** Counted in dotted beats (6/8, 9/8, 12/8): the tempo counts dotted quarters. */
|
|
46
|
+
compound: boolean;
|
|
47
|
+
/** The tempo set on the bar (20 to 240), in the beat it counts: what the next pass plays at. */
|
|
48
|
+
tempo(): number;
|
|
49
|
+
/** Calls `listener` with each new tempo set on the bar; returns a function that stops it. */
|
|
50
|
+
onTempo(listener: (bpm: number) => void): () => void;
|
|
51
|
+
/**
|
|
52
|
+
* Adds an app control at the end of the bar, after the bar's own (so they come last in the
|
|
53
|
+
* focus order), in its `.mn-play-app` slot. It shows and hides with the bar.
|
|
54
|
+
*/
|
|
55
|
+
add(control: HTMLElement): void;
|
|
29
56
|
}
|
|
30
57
|
/** A number within bounds; the fallback when it isn't a number at all. */
|
|
31
58
|
export declare const clamp: (n: number | undefined, lo: number, hi: number, fallback: number) => number;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The play bar of a picking pattern (#51): play / stop, loop, count-in, click, tempo, volume and
|
|
3
|
+
* sound, as on strumming patterns. What plays is read from the drawing (each slot's
|
|
4
|
+
* `data-mn-notes`, each bar's chord), so any page that drew the pattern can play it.
|
|
5
|
+
*/
|
|
6
|
+
import { type PickingScore } from '../picking/play.js';
|
|
7
|
+
import type { PlayOptions } from './controls.js';
|
|
8
|
+
/** The score of a drawn picking pattern; null when it has no slots. */
|
|
9
|
+
export declare function pickingScoreFromDrawing(drawing: Element): PickingScore | null;
|
|
10
|
+
export declare function pickingBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions): () => void;
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { type PlayOptions } from './controls.js';
|
|
2
|
+
import { type ProgressionBar } from './progression.js';
|
|
3
|
+
/** The bars of a drawn progression or chart, in order, each with the elements that show it. */
|
|
4
|
+
export declare function barsFromDrawing(drawing: Element): {
|
|
5
|
+
bars: ProgressionBar[];
|
|
6
|
+
marks: Element[][];
|
|
7
|
+
};
|
|
8
|
+
export declare function progressionBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions): () => void;
|