@dsebastien/music-notation 0.10.0 → 0.11.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 +16 -5
- package/dist/blocks/renderers.d.ts +11 -2
- package/dist/chord/generate.d.ts +13 -4
- package/dist/cli.js +3 -3
- package/dist/fretboard/exercise.d.ts +80 -0
- package/dist/index.d.ts +7 -1
- package/dist/index.js +5562 -3845
- package/dist/index.js.map +29 -21
- package/dist/music-notation.css +88 -0
- package/dist/music-notation.publish.min.js +117 -22
- package/dist/music-notation.tab.min.js +95 -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/picking-bar.d.ts +10 -0
- package/dist/playback/progression-bar.d.ts +8 -0
- package/dist/playback/progression.d.ts +111 -0
- package/dist/playback/strum-bar.d.ts +26 -1
- package/dist/publish/index.js +5929 -4335
- package/dist/publish/index.js.map +28 -20
- package/dist/strum/play.d.ts +18 -0
- package/dist/tab/index.d.ts +5 -0
- package/dist/tab/index.js +15 -4
- package/dist/tab/index.js.map +4 -4
- package/dist/voicings/index.js +96 -7
- package/dist/voicings/index.js.map +3 -3
- 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((i)=>q(i)!==null))return r.map((i)=>q(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,d)=>Math.abs(d-40)<Math.abs(a-40)?d:a))}else{let c=m-m%12+l;while(c<=m)c+=12;s.push(c)}}return s}var _e=/^\s*([A-Ga-g][#b]?|[1-8](?=\s*[|:]))?\s*[|:]?/,Ue=/^[-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=_e.exec(n),s=n.slice(o[0].length);if(Ue.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 d=Math.max(c,i);d<=a;d++)l.add(d-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((u)=>u[m]==="|"||u[m]===":")){if(i)o.push({beats:s,start:l,end:m});s=[],i=!1,l=m+1;continue}if(r.some((u)=>u[m]!==" "))i=!0;let{beat:c,skip:a,at:d}=n(r,m);if(c.length)s.push({notes:c,col:d??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 f=o(a+1);a=f.next;let h=[0,(f.fret!==null&&f.fret>l?Math.min(f.fret-l,4):2)*2];if(e[a]==="r"){let p=o(a+1);a=p.next;let b=p.fret===null?0:(p.fret-l)*2;h.push(Math.min(h[1],Math.max(0,b)))}m.push(`b (${h.join(" ")})`)}if(e[a]==="~"||e[a]==="v"){m.push("v");while(e[a]==="~"||e[a]==="v")a++}let d=e[a],u=G(e[a+1])||e[a+1]==="("&&G(e[a+2]);if((d==="h"||d==="p")&&u)m.push("h");else if(d==="/"||d==="\\"||d==="s"){if(u)m.push("sl");else if(d!=="s")m.push(d==="/"?"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,d)=>{let u=r[a][d],f=n.has(d)?["pm"]:[];if(u==="x"||u==="X"){s.push({tex:`x.${t[a]??a+1}`,effects:f}),i.add(a);return}let g=e[a].frets.get(d);if(!g)return;if(g.width===2&&d===o)m=!0;if(r[a][d-1]==="<")l=Math.min(l,d-1);s.push({tex:`${g.fret}.${t[a]??a+1}`,effects:[...e[a].effects.get(d)??[],...f],string:t[a]??a+1}),i.add(a)};if(r.forEach((a,d)=>c(d,o)),m)r.forEach((a,d)=>i.has(d)||c(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((i)=>i-12).reverse();let o=[...K.names.keys()].filter((i)=>t.every((l,m)=>K.names[i+m]===X(l)));if(o.length){let i=o.length>1&&t[0]==="e"?o.at(-1):o[0];return K.midis.slice(i,i+n).reverse()}if(n===1){let i=R(X(e[0]));return i===null?null:[48+(i-48+120)%12]}let s=H(r);if(s)return s.reverse()}return z[n]??null}function mt(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 ct(e){if(e.length===1){let{tuning:r,string:o}=mt(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 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 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],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 d=(a-t)/l,u=Math.round(d),f=Math.abs(d-u)*l;if(u<0||u>=n||f>o+0.000000001||m.length&&u*(i/n)<=m.at(-1))return null;c=Math.max(c,f),m.push(u*(i/n))}if(!s&&m.some((a,d)=>!ht.has((m[d+1]??i)-a)))return null;return pt(e,m)?{at:m,error:c}: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,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 I(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=D,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})),...I(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=J([...i,e.width],o,e.pad,t);if(a){let d=a.pop(),u=a[0]>0?[{beat:-1,sixteenths:a[0]}]:[];return a.forEach((f,g)=>u.push({beat:g,sixteenths:(a[g+1]??d)-f})),[...u,...I(d,t)]}}let l=J(i,o,e.pad,t);if(!l){let a=bt(e.beats.map((f)=>f.col),t,vt(e.beats));if(e.part!=="end")return a;let d=a.filter((f)=>f.beat>=0),u=d.reduce((f,g)=>f+g.sixteenths,0);return e.pickup?d:[...I(0,t,r-u),...d]}let m=l[0],c=m===0||e.pickup?[]:e.part==="end"?I(0,t,m):[{beat:-1,sixteenths:m}];return l.forEach((a,d)=>c.push({beat:d,sixteenths:(l[d+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 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 a of e)a.bars.forEach((d,u)=>{let f=(u>0||!a.openStart)&&(u<a.bars.length-1||!a.openEnd),g=d.end-d.start;if(f&&d.beats.length&&Math.abs(g-n)<=1)t.push({bar:d,pad:a.pad})});let r=new Map;for(let{bar:a}of t)for(let d=1;d<a.beats.length;d++){let u=a.beats[d].col-a.beats[d-1].col;r.set(u,(r.get(u)??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 D;let i=[],l=0,m=0;for(let{bar:a,pad:d}of t){let u=a.beats.map((b)=>(b.col-a.start-d)/s);if(u.some((b)=>Math.abs(b-Math.round(b))*s>0.40000000100000005)){i.push(0);continue}let f=u.map(Math.round),g=Math.max(Math.ceil((a.end-a.start-d)/s-0.5),f.at(-1)+1);if(i.push(g),g!==6)continue;let h=a.beats.reduce((b,v)=>v.notes.reduce((T,L)=>Math.max(T,L.string??0),b),0),p=f.filter((b,v)=>a.beats[v].notes.some((T)=>T.string===h));for(let b of[f,p.length<f.length?p:[]])if(b.some((v)=>v!==0&&v%2===0)&&b.every((v)=>v%2===0))l++;else if(b.includes(3)&&b.every((v)=>v%3===0))m++}let c=ve(i);if(c.count*3<t.length*2)return D;if(c.value===3)return fe;if(c.value===6)return l>m?fe:dt;return c.value===12?ft:D}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,d)=>{let u=a.beats.map((p)=>({notes:p.notes,col:p.col-a.start})),f={beats:u,width:a.end-a.start,pad:s.pad,part:"whole",pickup:!1,text:null},g=d===0&&o!==null;if(o&&d===0){let p=o.width-s.pad;f={...o,beats:[...o.beats,...u.map((b)=>({notes:b.notes,col:b.col+p}))],width:o.width+f.width-s.pad},o=null}if(d===s.bars.length-1&&t(f.width)){let p=m?.bars[0],b=p?f.width+p.end-p.start-m.pad:0;if(p&&(s.openEnd||t(p.end-p.start)&&(m.openStart||b<=n*1.25))){if(f.beats.length||!s.openEnd)o=f;return}if(s.openEnd&&!g){if(!f.beats.length)return;f.part="start"}}let h=!r.length;if(d===0&&!g&&f.part==="whole"&&t(f.width)&&f.beats.length){if(h||s.openStart)f.part="end",f.pickup=h}r.push(f)});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((a)=>a.col);if(J(r,t.width,t.pad,n))return[t];let o=r.slice(1).map((a,d)=>a-r[d]),s=ve(o).value,i=o.reduce((a,d)=>a+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;return Array.from({length:c},(a,d)=>{let u=t.pad+d*m;return{beats:t.beats.filter((g)=>(d===0||g.col>=u)&&(d===c-1||g.col<u+m)).map((g)=>({notes:g.notes,col:g.col-d*m})),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}`)}"`,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:i,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:u}of s){let f=de(u),g=Ct(d>=0?o[d]:[],f.length);f.forEach((h,p)=>m.push({notes:g[p],...h}))}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((d,u)=>{let f=d.dotted?["d"]:[];if(i&&u===c)f.push(`txt ${St(i)}`);let g=d.duration===t?"":`:${d.duration} `;return t=d.duration,g+Et(d.notes,f)}).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"?
|
|
4
|
-
`);let a=r?.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((
|
|
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 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((i)=>i.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},i=null,l=null,m=()=>(i??=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}),i),c=(h,p,b)=>{let v=A(e,"button");return v.type="button",v.title=p,v.setAttribute("aria-label",p),v.appendChild(Z(e,h)),v.addEventListener("click",b),o.appendChild(v),v},a=(h)=>{if(n.player)h()},d=(h,p,b)=>{let v=c(h,p,()=>{s[b]=!s[b],a(()=>{n.isLooping=s.loop,n.metronomeVolume=s.metronome?1:0,n.countInVolume=s.countIn?1:0}),v.classList.toggle("mn-on",s[b]),v.setAttribute("aria-pressed",String(s[b]))});v.setAttribute("aria-pressed","false")},u=c("play","Play",()=>{m().then((h)=>{if(h)n.playPause()})});c("stop","Stop",()=>a(()=>n.stop())),d("loop","Loop","loop"),d("metronome","Metronome","metronome"),d("countIn","Count-in","countIn");let f=(h,p,b,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(p);let w=A(e,"input");w.type="range",w.min=String(b),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)};f("Speed","%",25,150,100,(h)=>{s.speed=h/100,a(()=>n.playbackSpeed=s.speed)},"%"),f("Volume",Z(e,"volume"),0,100,100,(h)=>{s.volume=h/100,a(()=>n.masterVolume=s.volume)});let g=A(e,"span","mn-tab-time","");return o.appendChild(g),n.playerStateChanged.on((h)=>{let p=Number(h.state)===Number(t.synth.PlayerState.Playing);u.replaceChildren(Z(e,p?"pause":"play")),u.title=p?"Pause":"Play",u.setAttribute("aria-label",u.title)}),n.playerPositionChanged.on((h)=>{g.textContent=`${Ae(h.currentTime)} / ${Ae(h.endTime)}`}),{bar:o,failed:(h)=>{l?.(),u.disabled=!0,u.title=`Can't play: ${h}`,u.setAttribute("aria-label",u.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,i=r?A(e,"button","mn-tab-keep","Keep this view"):null,l=It.map(({staves:c,label:a,what:d})=>{let u=A(e,"button","mn-tab-view",a);u.type="button",u.dataset.staves=c;let f=c!==n.staves?"":n.written?" (this block's staves: line)":" (the default: the block has no staves: line)";return u.title=`Draw as ${d}${f}`,u.addEventListener("click",()=>{if(c===s)return;s=c,m(),t(c)}),o.appendChild(u),u}),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=A(o,"div",`mn-block mn-block-${e} mn-tab`);t.appendChild(s);let i=null,l=!1,m=!1,c=()=>{},a=new Promise((u)=>{c=(f)=>{if(m)return;m=!0,u(f)}}),d=(u)=>{s.replaceChildren(A(o,"div","mn-error-message",`${e}: ${u}`)),s.classList.add("mn-error"),c({ok:!1,error:u})};if(!n.trim())s.classList.add("mn-empty"),c({ok:!0,error:null});else(async()=>{await Promise.resolve();let u=Ft(e,n),f={staves:u.stavesWritten?u.staves:r.defaultStaves??u.staves,written:u.stavesWritten},g=f.staves,h=!1,p=r.alphaTab;if(!p?.AlphaTabApi)throw Error("alphaTab isn't loaded");let b=A(o,"div","mn-tab-surface");s.appendChild(b);let{assets:v}=r,T=te(o),L={core:{useWorkers:Boolean(v.scriptFile),...v.scriptFile?{scriptFile:v.scriptFile}:{},smuflFontSources:T.map([[p.FontFileFormat.Woff2,v.font]]),logLevel:p.LogLevel.Warning,enableLazyLoading:!1},display:{staveProfile:"Default",resources:Gt(s)},player:{playerMode:p.PlayerMode.Disabled,enableUserInteraction:!0}},k=new p.AlphaTabApi(b,L);if(i=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(g,y),h=Vt(y,u.tracks),Pt(y,u.file?null:u.tex)}),$t(k,b);let E=null;k.renderFinished.on(()=>{if(m||l)return;if(r.player!==!1){if(E=Ht(o,k,p,v),s.appendChild(E.bar),r.views!==!1&&h)E.bar.appendChild(zt(o,f,(y)=>{g=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")})}c({ok:!0,error:null})}),k.error.on((y)=>{let x=u.fromText?`Couldn't draw this text tab: ${ke(y,null)}`:ke(y,u.texLine);if(m)E?.failed(x);else d(x)});let w=u.tracks?.map((y)=>y-1);if(u.file){let y;try{y=r.resolveFile?await r.resolveFile(u.file):null}catch(M){throw Error(`Couldn't read "${u.file}": ${M instanceof Error?M.message:String(M)}`)}if(l)return;if(!y)throw Error(`Couldn't find the file "${u.file}"`);if(!k.load(T.bytes(y),w))throw Error(`Couldn't read "${u.file}": not a score file alphaTab knows`)}else k.tex(u.tex,w??"all")})().catch((u)=>{if(!l)d(u instanceof Error?u.message:String(u))});return{el:s,ready:a,get api(){return i},destroy(){l=!0;try{i?.destroy()}catch{}s.remove(),c({ok:!1,error:null})}}}var ee={guitar:25,piano:0},j={channel:1,program:28},Q={channel:9,key:33},jt=0.5;function _t(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),d=(p)=>Math.round(p*c.division);if(a.addTempo(0,60),a.addProgramChange(0,0,0,ee[r]),r==="guitar"&&t.some((p)=>p.kind==="muted"))a.addProgramChange(0,0,j.channel,j.program);if(t.some((p)=>p.kind==="click"))a.addProgramChange(0,0,Q.channel,0);let u=Number.isFinite(o)?Math.min(1,Math.max(0,o)):0.8;l.masterVolume=u;for(let p of t){let b=p.velocity===void 0||!Number.isFinite(p.velocity)?100:Math.round(Math.min(127,Math.max(1,p.velocity))),v=p.kind==="click"?Q.channel:p.kind==="muted"&&r==="guitar"?j.channel:0;a.addNote(0,d(p.time),Math.max(1,d(p.duration)),p.kind==="click"?Q.key:p.midi,b,v)}let f=Math.max(...t.map((p)=>p.time+p.duration),0);a.addControlChange(0,d(f+jt),0,e.midi.ControllerType.HoldPedal,0),l.playbackSpeed=1,m.playOneTimeMidiFile(c);let g=!1;queueMicrotask(()=>{if(!g)i?.()});let h=setTimeout(()=>s?.(),(f+0.2)*1000);return{stop(){g=!0,clearTimeout(h),m.stop()}}}}}function Se(e,n,t,r){let o=null,s=null,i=null,l=()=>{if(i)return i;s=A(t,"div","mn-tab-hidden"),s.setAttribute("aria-hidden","true"),t.body.appendChild(s);let c=te(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((d)=>{let u=!1,f=!a.playerReady,g=()=>{if(u&&f)d(!0)};a.soundFontLoaded.on(()=>{u=!0,g(),setTimeout(()=>{f=!0,g()},4000)}),a.playerReady?.on(()=>{f=!0,g()}),a.error.on(()=>d(!1))}),n.soundFont instanceof Uint8Array)a.loadSoundFont(c.bytes(n.soundFont),!1);return a.tex(`\\track "Guitar" \\instrument ${ee.guitar} r \\track "Piano" \\instrument ${ee.piano} r \\track "Muted" \\instrument ${j.program} r`),i},m=_t(e,()=>o);return{reportsStart:!0,play(c,a){let d=null,u=!1;return l().then((f)=>{if(u)return;try{if(f){d=m.play(c,a);return}}catch{}if(!r)return;if(d=r.play(c,a),!r.reportsStart)a.onStart?.()}),{stop(){u=!0,d?.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. */
|
|
1
|
+
/*! @dsebastien/music-notation 0.11.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 {
|
|
@@ -960,4 +960,92 @@
|
|
|
960
960
|
.mn-playable .mn-svg [data-midi].mn-playing + .mn-key-label {
|
|
961
961
|
fill: var(--mn-on-playing);
|
|
962
962
|
}
|
|
963
|
-
|
|
963
|
+
|
|
964
|
+
/* A fretboard exercise (#47): the run's tab under the diagram, as wide as the block. */
|
|
965
|
+
.mn-block .mn-exercise-block {
|
|
966
|
+
display: flex;
|
|
967
|
+
flex-direction: column;
|
|
968
|
+
align-items: flex-start;
|
|
969
|
+
gap: 0.5em;
|
|
970
|
+
}
|
|
971
|
+
|
|
972
|
+
.mn-block .mn-exercise-block > .mn-exercise-tab,
|
|
973
|
+
.mn-block .mn-exercise-block > .mn-tab-holder {
|
|
974
|
+
align-self: stretch;
|
|
975
|
+
}
|
|
976
|
+
|
|
977
|
+
.mn-block pre.mn-exercise {
|
|
978
|
+
margin: 0;
|
|
979
|
+
white-space: pre-wrap;
|
|
980
|
+
}
|
|
981
|
+
|
|
982
|
+
/* Progressions and charts in time (#46): the bar sits above the chords, always shown. */
|
|
983
|
+
.mn-play.mn-play-static {
|
|
984
|
+
position: static;
|
|
985
|
+
display: inline-flex;
|
|
986
|
+
justify-content: flex-start;
|
|
987
|
+
margin: 0 0 6px;
|
|
988
|
+
opacity: 1;
|
|
989
|
+
pointer-events: auto;
|
|
990
|
+
}
|
|
991
|
+
|
|
992
|
+
.mn-progression-chord.mn-playing {
|
|
993
|
+
border-radius: 6px;
|
|
994
|
+
background: color-mix(in srgb, var(--mn-playing) 22%, transparent);
|
|
995
|
+
box-shadow: 0 0 0 2px color-mix(in srgb, var(--mn-playing) 70%, transparent);
|
|
996
|
+
}
|
|
997
|
+
|
|
998
|
+
.mn-chart .mn-chord.mn-playing {
|
|
999
|
+
border-radius: 3px;
|
|
1000
|
+
background: color-mix(in srgb, var(--mn-playing) 45%, transparent);
|
|
1001
|
+
}
|
|
1002
|
+
|
|
1003
|
+
/* Picking patterns (#51): a small tab, the fingers and counts under it. */
|
|
1004
|
+
.mn-svg .mn-picking-string {
|
|
1005
|
+
stroke: var(--mn-muted);
|
|
1006
|
+
stroke-width: 1;
|
|
1007
|
+
}
|
|
1008
|
+
|
|
1009
|
+
.mn-svg .mn-picking-bar {
|
|
1010
|
+
stroke: var(--mn-fg);
|
|
1011
|
+
stroke-width: 1.5;
|
|
1012
|
+
}
|
|
1013
|
+
|
|
1014
|
+
.mn-svg .mn-picking-gap {
|
|
1015
|
+
fill: var(--mn-bg);
|
|
1016
|
+
stroke: none;
|
|
1017
|
+
}
|
|
1018
|
+
|
|
1019
|
+
.mn-svg .mn-picking-fret {
|
|
1020
|
+
fill: var(--mn-fg);
|
|
1021
|
+
font-size: 11px;
|
|
1022
|
+
font-weight: 600;
|
|
1023
|
+
}
|
|
1024
|
+
|
|
1025
|
+
.mn-svg .mn-picking-finger {
|
|
1026
|
+
fill: var(--mn-accent);
|
|
1027
|
+
font-size: 11px;
|
|
1028
|
+
font-style: italic;
|
|
1029
|
+
}
|
|
1030
|
+
|
|
1031
|
+
.mn-svg .mn-picking-finger.mn-picking-thumb {
|
|
1032
|
+
font-weight: 700;
|
|
1033
|
+
}
|
|
1034
|
+
|
|
1035
|
+
.mn-svg .mn-picking-cell {
|
|
1036
|
+
fill: transparent;
|
|
1037
|
+
stroke: none;
|
|
1038
|
+
}
|
|
1039
|
+
|
|
1040
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
|
|
1041
|
+
fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
|
|
1042
|
+
}
|
|
1043
|
+
|
|
1044
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
|
|
1045
|
+
fill: var(--mn-playing);
|
|
1046
|
+
}
|
|
1047
|
+
|
|
1048
|
+
.mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
|
|
1049
|
+
fill: var(--mn-on-playing);
|
|
1050
|
+
}
|
|
1051
|
+
`;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,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;
|
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
import type { VoicingLookup } from '../voicings/index.js';
|
|
2
|
+
import { type StrumPattern } from '../strum/pattern.js';
|
|
3
|
+
import { type Pass, type StrumFollower, type StrumSettings, type StrumTiming } from '../strum/play.js';
|
|
4
|
+
import { type NotePlayer, type PlayHandle, type Sound } from './player.js';
|
|
5
|
+
/** How each bar's chord is played. */
|
|
6
|
+
export type ProgressionStrum = 'beats' | 'bar' | 'arpeggio';
|
|
7
|
+
export declare const PROGRESSION_STRUMS: readonly ProgressionStrum[];
|
|
8
|
+
/** One bar: its chord (as shown, null when unnamed) and the notes it sounds, lowest first. */
|
|
9
|
+
export interface ProgressionBar {
|
|
10
|
+
chord: string | null;
|
|
11
|
+
pitches: readonly number[];
|
|
12
|
+
}
|
|
13
|
+
export interface ProgressionEventOptions {
|
|
14
|
+
/** Counted beats a minute (a quarter in 4/4; a dotted quarter with a 6/8 pattern); 90. */
|
|
15
|
+
bpm?: number;
|
|
16
|
+
/** Beats in a bar, 1 to 16; 4 by default. A pattern's own time signature wins. */
|
|
17
|
+
beatsPerBar?: number;
|
|
18
|
+
/** The note that counts as a beat (4 by default; 8 in 6/8, counted in dotted quarters). */
|
|
19
|
+
beatUnit?: number;
|
|
20
|
+
/** `beats` (a down strum on each beat, by default), `bar` (one strum a bar), `arpeggio`. */
|
|
21
|
+
strum?: ProgressionStrum;
|
|
22
|
+
/** A strumming pattern played in each bar instead (its bars in turn, its chords ignored). */
|
|
23
|
+
pattern?: StrumPattern | null;
|
|
24
|
+
/** The most time between the strings of a strum, in seconds: 0.012 by default, 0 a block. */
|
|
25
|
+
spread?: number;
|
|
26
|
+
/** A metronome click on every beat; on by default. */
|
|
27
|
+
click?: boolean;
|
|
28
|
+
/** A bar of clicks first. */
|
|
29
|
+
countIn?: boolean;
|
|
30
|
+
/** How long the last chord rings after the progression, in seconds (0 when it loops). */
|
|
31
|
+
tail?: number;
|
|
32
|
+
/** Varies the small differences between strums from pass to pass. */
|
|
33
|
+
seed?: number;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* The notes of one pass of a progression (the count-in first when asked), its length in seconds,
|
|
37
|
+
* and when each bar is played (`strums`, one a bar: `slot` is the bar's index), to light it.
|
|
38
|
+
*/
|
|
39
|
+
export declare function progressionEvents(bars: readonly ProgressionBar[], options?: ProgressionEventOptions): Pass;
|
|
40
|
+
/** A chord to play: a symbol (or words), or its notes (lowest first) with the name to show. */
|
|
41
|
+
export type ProgressionChordInput = string | {
|
|
42
|
+
chord?: string | null;
|
|
43
|
+
pitches: readonly number[];
|
|
44
|
+
};
|
|
45
|
+
export interface PlayProgressionOptions {
|
|
46
|
+
/** Counted beats a minute (a quarter in 4/4, a dotted quarter with a 6/8 pattern); 90. */
|
|
47
|
+
bpm?: number;
|
|
48
|
+
/** Beats in a bar, 1 to 16; 4 by default. A pattern's time signature wins. */
|
|
49
|
+
beatsPerBar?: number;
|
|
50
|
+
/** The note that counts as a beat: 4 by default; 8 in 6/8 (counted in dotted quarters). */
|
|
51
|
+
beatUnit?: number;
|
|
52
|
+
/** `beats` (by default), `bar` or `arpeggio`. */
|
|
53
|
+
strum?: ProgressionStrum;
|
|
54
|
+
/** A strumming pattern (a ```strum block's text, or parsed) played in every bar. */
|
|
55
|
+
pattern?: string | StrumPattern;
|
|
56
|
+
/** A metronome click on every beat; on by default. */
|
|
57
|
+
click?: boolean;
|
|
58
|
+
/** A bar of clicks first; off by default. */
|
|
59
|
+
countIn?: boolean;
|
|
60
|
+
loop?: boolean;
|
|
61
|
+
/** Open strings (MIDI, lowest first) or a tuning name, for chord symbols; standard. */
|
|
62
|
+
tuning?: readonly number[] | string;
|
|
63
|
+
/** Finds guitar voicings for chord symbols (see `/voicings`); generated ones otherwise. */
|
|
64
|
+
voicings?: VoicingLookup;
|
|
65
|
+
/** The light synthesizer of `window` by default. */
|
|
66
|
+
player?: NotePlayer;
|
|
67
|
+
/** The window to play in (popouts have their own); the global one by default. */
|
|
68
|
+
window?: Window;
|
|
69
|
+
/** Guitar by default; piano plays piano voicings of chord symbols, as blocks. */
|
|
70
|
+
sound?: Sound;
|
|
71
|
+
/** 0 to 1, 0.8 by default. */
|
|
72
|
+
volume?: number;
|
|
73
|
+
/** Called as each bar starts sounding: its index, its chord, the pass (from 1). */
|
|
74
|
+
onBar?: (bar: number, chord: string | null, pass: number) => void;
|
|
75
|
+
/** Called once the progression is over (not after stop). */
|
|
76
|
+
onEnd?: () => void;
|
|
77
|
+
}
|
|
78
|
+
/** What can change while a progression plays; it applies from the next pass. */
|
|
79
|
+
export interface ProgressionChanges {
|
|
80
|
+
bpm?: number;
|
|
81
|
+
loop?: boolean;
|
|
82
|
+
click?: boolean;
|
|
83
|
+
volume?: number;
|
|
84
|
+
sound?: Sound;
|
|
85
|
+
}
|
|
86
|
+
export interface ProgressionHandle extends PlayHandle {
|
|
87
|
+
/** Changes the tempo, loop, click, volume or sound from the next pass. */
|
|
88
|
+
update(changes: ProgressionChanges): void;
|
|
89
|
+
}
|
|
90
|
+
/** At most this many bars a progression (a long chart plays its first ones). */
|
|
91
|
+
export declare const MAX_PROGRESSION_BARS = 256;
|
|
92
|
+
/** The notes of a chord symbol: a guitar voicing (the strum's), or a piano voicing on piano. */
|
|
93
|
+
export declare function progressionPitches(chord: string, sound?: Sound, tuning?: readonly number[], voicings?: VoicingLookup): number[];
|
|
94
|
+
/** Calls `call(i)` as each timing starts, from `heard()` (or `wait` ms after it's made). */
|
|
95
|
+
export declare function followTimes(win: Pick<Window, 'setTimeout' | 'clearTimeout'>, times: readonly StrumTiming[], call: (timing: StrumTiming) => void, wait?: number): StrumFollower;
|
|
96
|
+
/** The settings of a progression player, read at each pass. */
|
|
97
|
+
export interface ProgressionSettings extends StrumSettings {
|
|
98
|
+
click: boolean;
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
* Plays `bars` pass after pass (see `runStrum` for the timing), from `settings()` read at each
|
|
102
|
+
* pass. `follow` gets each pass's bars (`slot` is the bar's index), to light them.
|
|
103
|
+
*/
|
|
104
|
+
export declare function runProgression(bars: readonly ProgressionBar[], options: Pick<ProgressionEventOptions, 'beatsPerBar' | 'beatUnit' | 'strum' | 'pattern'>, player: () => NotePlayer, settings: () => ProgressionSettings, timers: Pick<Window, 'setTimeout' | 'clearTimeout'>, onEnd?: () => void, follow?: (bars: StrumTiming[], player: NotePlayer, pass: number) => StrumFollower): PlayHandle;
|
|
105
|
+
/**
|
|
106
|
+
* Plays chords in time, one a bar (#46): strummed on the beats by default, with a metronome
|
|
107
|
+
* click, a count-in when asked, and a loop. Chord symbols take the strum's guitar voicing (a piano
|
|
108
|
+
* voicing with `sound: 'piano'`); given notes play as given. Throws on a chord it can't read, an
|
|
109
|
+
* unknown tuning, or a pattern with a mistake.
|
|
110
|
+
*/
|
|
111
|
+
export declare function playProgression(chords: readonly ProgressionChordInput[], options?: PlayProgressionOptions): ProgressionHandle;
|