@dsebastien/music-notation 0.12.0 → 0.14.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.
@@ -1,4 +1,4 @@
1
- /*! @dsebastien/music-notation 0.12.0 tab bundle | MIT | loads alphaTab (MPL-2.0) from jsDelivr */
1
+ /*! @dsebastien/music-notation 0.14.0 tab bundle | MIT | loads alphaTab (MPL-2.0) from jsDelivr */
2
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
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
4
  `);let a=r?.join(" ")===j[6].join(" ");return[...r&&!a?[`\\tuning (${r.map((d)=>ae(d)).join(" ")})`]:[],...c,ge(m,l)].join(`
@@ -89,14 +89,38 @@
89
89
  stroke-width: 2;
90
90
  }
91
91
 
92
- /* Playback: a compact strip at the bottom of the diagram, shown on hover, keyboard focus or a
93
- tap. Host styles (Obsidian's buttons, selects and sliders) are reset inside it. */
92
+ /* Playback (#58): a playable diagram is a button (a click plays it); one bar below the block
93
+ plays its diagrams. Host styles (Obsidian's buttons, selects and sliders) are reset inside the
94
+ bars. */
94
95
  .mn-playable {
95
96
  position: relative;
96
97
  display: inline-block;
98
+ /* No line-box gap under the drawing, before the bar. */
99
+ vertical-align: top;
97
100
  max-width: 100%;
101
+ border-radius: 6px;
102
+ }
103
+
104
+ /* The selected diagram of a row (the one the bar plays and names) and the focused one: outlines
105
+ drawn inside the edge (the block's scroll box, overflow-x, never cuts them) and over the
106
+ drawing (keys and chips reach the edge), kept in forced-colors mode. */
107
+ .mn-playable.mn-selected {
108
+ outline: 2px solid color-mix(in srgb, var(--mn-accent) 45%, transparent);
109
+ outline-offset: -2px;
110
+ }
111
+
112
+ .mn-playable:focus-visible {
113
+ outline: 2px solid var(--mn-accent);
114
+ outline-offset: -2px;
98
115
  }
99
116
 
117
+ /* A mouse click focuses the diagram too: only the selection shows then. */
118
+ .mn-playable:focus:not(:focus-visible):not(.mn-selected) {
119
+ outline: none;
120
+ }
121
+
122
+ /* The tab and score bar (#82 gives it the block bar's look): a strip at the bottom of the score,
123
+ shown on hover, keyboard focus or a tap. */
100
124
  .mn-play {
101
125
  position: absolute;
102
126
  left: 2px;
@@ -119,13 +143,6 @@
119
143
  transition: opacity 120ms ease;
120
144
  }
121
145
 
122
- .mn-playable:hover .mn-play,
123
- .mn-playable:focus-within .mn-play,
124
- .mn-playable.mn-play-open .mn-play {
125
- opacity: 1;
126
- pointer-events: auto;
127
- }
128
-
129
146
  .mn-play button,
130
147
  .mn-play select {
131
148
  all: unset;
@@ -139,6 +156,22 @@
139
156
  font-size: 10px;
140
157
  color: inherit;
141
158
  border-radius: 4px;
159
+ }
160
+
161
+ /* The hand on everything that plays or sets something (#81), with a class in every selector so it
162
+ outranks host element rules such as Obsidian's \`button { cursor: var(--cursor) }\`, and again
163
+ under \`.mn-block\` for hosts with class rules; no !important. Without playback there is no
164
+ .mn-playable: diagrams and notes keep the arrow. */
165
+ .mn-playable,
166
+ .mn-playable *,
167
+ .mn-play button,
168
+ .mn-play select,
169
+ .mn-play input[type='range'],
170
+ .mn-block .mn-playable,
171
+ .mn-block .mn-playable *,
172
+ .mn-block .mn-play button,
173
+ .mn-block .mn-play select,
174
+ .mn-block .mn-play input[type='range'] {
142
175
  cursor: pointer;
143
176
  }
144
177
 
@@ -167,7 +200,7 @@
167
200
  }
168
201
 
169
202
  .mn-play-icon-loop,
170
- .mn-play-icon-volume {
203
+ .mn-play-icon-line {
171
204
  fill: none;
172
205
  stroke: currentColor;
173
206
  stroke-width: 1.6;
@@ -181,11 +214,34 @@
181
214
  gap: 2px;
182
215
  }
183
216
 
217
+ .mn-play-field[hidden] {
218
+ display: none;
219
+ }
220
+
221
+ /* The tab bar's glyph before a slider. */
184
222
  .mn-play-label {
185
223
  display: inline-flex;
186
224
  opacity: 0.8;
187
225
  }
188
226
 
227
+ /* A slider's value after it ("90 BPM", "12 ms"), in digits of one width so the bar doesn't move
228
+ while it changes. */
229
+ .mn-play-value {
230
+ min-width: 7ch;
231
+ font-variant-numeric: tabular-nums;
232
+ white-space: nowrap;
233
+ opacity: 0.85;
234
+ }
235
+
236
+ /* The selected diagram's name on the bar of a row. */
237
+ .mn-play-name {
238
+ max-width: 16ch;
239
+ overflow: hidden;
240
+ text-overflow: ellipsis;
241
+ white-space: nowrap;
242
+ font-weight: 600;
243
+ }
244
+
189
245
  .mn-play input[type='range'] {
190
246
  all: unset;
191
247
  appearance: none;
@@ -195,7 +251,6 @@
195
251
  height: 9px;
196
252
  margin: 0;
197
253
  background: linear-gradient(var(--mn-faint), var(--mn-faint)) center / 100% 3px no-repeat;
198
- cursor: pointer;
199
254
  }
200
255
 
201
256
  .mn-play input[type='range']::-webkit-slider-runnable-track {
@@ -238,11 +293,6 @@
238
293
  background: var(--mn-accent);
239
294
  }
240
295
 
241
- .mn-playable [data-midi],
242
- .mn-playable .mn-hit {
243
- cursor: pointer;
244
- }
245
-
246
296
  /* A playable mark's hit area: invisible, but it takes clicks and taps (an open string's circle is
247
297
  only a ring), centered on the mark. */
248
298
  .mn-svg .mn-hit {
@@ -256,30 +306,6 @@
256
306
  pointer-events: none;
257
307
  }
258
308
 
259
- /* The bar's empty space lets clicks through to the dots under it; its controls take them. */
260
- .mn-playable:hover .mn-play,
261
- .mn-playable:focus-within .mn-play,
262
- .mn-playable.mn-play-open .mn-play {
263
- pointer-events: none;
264
- }
265
-
266
- .mn-playable:hover .mn-play > *,
267
- .mn-playable:focus-within .mn-play > *,
268
- .mn-playable.mn-play-open .mn-play > * {
269
- pointer-events: auto;
270
- }
271
-
272
- /* Touch screens: hover sticks after a tap, so only a tap opens the bar. */
273
- @media (hover: none) {
274
- .mn-playable:hover:not(.mn-play-open) .mn-play {
275
- opacity: 0;
276
- }
277
-
278
- .mn-playable:hover:not(.mn-play-open) .mn-play > * {
279
- pointer-events: none;
280
- }
281
- }
282
-
283
309
  /* Tabs and scores: the player bar stays at the bottom of the screen while the score scrolls. */
284
310
  .mn-tab {
285
311
  position: relative;
@@ -521,6 +547,31 @@
521
547
  stroke: var(--mn-fg);
522
548
  }
523
549
 
550
+ /* Fingering in words (#53): a short paragraph under the diagram, at most a little wider than a
551
+ chord diagram, so a row of captioned chords stays a row. */
552
+ .mn-block .mn-captioned {
553
+ display: flex;
554
+ flex-direction: column;
555
+ /* The diagram centered over its words, which can be wider than a chord diagram. */
556
+ align-items: center;
557
+ gap: 0.35em;
558
+ margin: 0;
559
+ }
560
+
561
+ .mn-block .mn-fingering[hidden] {
562
+ display: none;
563
+ }
564
+
565
+ .mn-block .mn-fingering {
566
+ max-width: 16em;
567
+ margin: 0;
568
+ font-size: 0.85em;
569
+ line-height: 1.4;
570
+ /* Obsidian's muted text; elsewhere the page's own text color, readable on any background
571
+ (the grey fallback of --mn-muted is too light for small text on white). */
572
+ color: var(--text-muted, currentColor);
573
+ }
574
+
524
575
  /* Several diagrams in one block: a row that wraps, or a grid of at most \`columns\` columns that
525
576
  also wraps on narrow screens rather than shrinking diagrams to nothing. */
526
577
  .mn-block .mn-row {
@@ -798,12 +849,12 @@
798
849
 
799
850
  /* Following a strumming pattern: the slot that plays gets a band and its strum the playing
800
851
  color (the band keeps it visible for a muted strum and in any theme). */
801
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-cell {
852
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-cell {
802
853
  fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
803
854
  }
804
855
 
805
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-arrow,
806
- .mn-playable .mn-svg .mn-strum-slot.mn-playing .mn-strum-mute {
856
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-arrow,
857
+ .mn-timed .mn-svg .mn-strum-slot.mn-playing .mn-strum-mute {
807
858
  stroke: var(--mn-fg);
808
859
  stroke-width: 3;
809
860
  }
@@ -867,6 +918,14 @@
867
918
  margin-bottom: 0.3em;
868
919
  }
869
920
 
921
+ /* Degrees a harmonized scale leaves out (#43). */
922
+ .mn-progression-note {
923
+ color: var(--mn-muted);
924
+ font-size: 0.8em;
925
+ font-style: italic;
926
+ margin-bottom: 0.3em;
927
+ }
928
+
870
929
  .mn-block .mn-progression-chord {
871
930
  display: flex;
872
931
  flex-direction: column;
@@ -989,16 +1048,33 @@
989
1048
  white-space: pre-wrap;
990
1049
  }
991
1050
 
992
- /* Progressions and charts in time (#46): the bar sits above the chords, always shown. */
1051
+ /* Every bar but the tab bar (#58): below what it plays, in the flow, always shown, at the left
1052
+ of the block even when a wide row scrolls. */
993
1053
  .mn-play.mn-play-static {
994
- position: static;
995
- display: inline-flex;
1054
+ position: sticky;
1055
+ left: 0;
1056
+ right: auto;
1057
+ bottom: auto;
1058
+ display: flex;
1059
+ width: fit-content;
1060
+ max-width: 100%;
1061
+ box-sizing: border-box;
996
1062
  justify-content: flex-start;
997
- margin: 0 0 6px;
1063
+ gap: 4px 8px;
1064
+ margin: 6px 0 0;
1065
+ padding: 3px 6px;
1066
+ font-size: 11px;
998
1067
  opacity: 1;
999
1068
  pointer-events: auto;
1000
1069
  }
1001
1070
 
1071
+ .mn-timed {
1072
+ display: inline-flex;
1073
+ flex-direction: column;
1074
+ align-items: flex-start;
1075
+ max-width: 100%;
1076
+ }
1077
+
1002
1078
  .mn-progression-chord.mn-playing {
1003
1079
  border-radius: 6px;
1004
1080
  background: color-mix(in srgb, var(--mn-playing) 22%, transparent);
@@ -1047,15 +1123,15 @@
1047
1123
  stroke: none;
1048
1124
  }
1049
1125
 
1050
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
1126
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-cell {
1051
1127
  fill: color-mix(in srgb, var(--mn-playing) 35%, transparent);
1052
1128
  }
1053
1129
 
1054
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
1130
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-gap {
1055
1131
  fill: var(--mn-playing);
1056
1132
  }
1057
1133
 
1058
- .mn-playable .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
1134
+ .mn-timed .mn-svg .mn-picking-slot.mn-playing .mn-picking-fret {
1059
1135
  fill: var(--mn-on-playing);
1060
1136
  }
1061
1137
 
@@ -0,0 +1,46 @@
1
+ /** Small icons, drawn on a 16 × 16 grid so they look the same in every font. */
2
+ export declare const ICONS: {
3
+ readonly play: "M4 2.5v11l9-5.5z";
4
+ readonly stop: "M4 4h8v8H4z";
5
+ /** Two triangles: every diagram of the block, one after the other. */
6
+ readonly all: "M1.5 2.5v11l6.5-5.5zM8 2.5v11l6.5-5.5z";
7
+ readonly loop: "M3 8a5 5 0 0 1 8.5-3.5L13 6V2.5M13 8a5 5 0 0 1-8.5 3.5L3 10v3.5";
8
+ /** A metronome, for the count-in. */
9
+ readonly count: "M5.5 14h5L9 2.5H7zM8 11.5l4.5-7";
10
+ /** Beats, for the click. */
11
+ readonly click: "M3 5v6M8 5v6M13 5v6";
12
+ };
13
+ export type IconName = keyof typeof ICONS;
14
+ export declare function icon(doc: Document, name: IconName): SVGElement;
15
+ /**
16
+ * A play bar: a group named `label`, always shown, below what it plays. A press in it is the
17
+ * bar's: an editor (Obsidian's live preview) must not take it as a click on the block, which
18
+ * opens its source.
19
+ */
20
+ export declare function playBar(doc: Document, cls: string, label: string): HTMLElement;
21
+ /** A button that shows an icon, named for screen readers and in its tooltip. */
22
+ export declare function iconButton(doc: Document, cls: string, label: string, name: IconName): HTMLButtonElement;
23
+ /** A button that stays pressed (loop, count-in, click); `set` hears each change. */
24
+ export declare function pressedButton(doc: Document, cls: string, label: string, name: IconName, on: boolean, set: (on: boolean) => void): HTMLButtonElement;
25
+ export interface Slider {
26
+ field: HTMLElement;
27
+ input: HTMLInputElement;
28
+ /** Shows a value set from outside (the strum of the other sound). */
29
+ show(n: number): void;
30
+ }
31
+ /**
32
+ * A slider with its value written after it ("90 BPM", "12 ms"): the readable label every bar
33
+ * shows instead of the glyphs it had (#58). The value is also the slider's `aria-valuetext`; a
34
+ * `hint` (a 6/8 tempo counts dotted quarters) goes to its tooltip and `aria-description`.
35
+ */
36
+ export declare function valueSlider(doc: Document, label: string, unit: string, min: number, max: number, value: number, set: (n: number) => void, hint?: string): Slider;
37
+ /** A select named `label`, with an option per value. */
38
+ export declare function choice<T extends string>(doc: Document, cls: string, label: string, values: readonly T[], chosen: T, names: Record<T, string>, set: (value: T) => void): HTMLSelectElement;
39
+ /** The volume when the app doesn't give one. */
40
+ export declare const DEFAULT_VOLUME = 0.8;
41
+ /**
42
+ * The app's volume, 0 to 1: a number, or a function read at each play so a setting changed in
43
+ * the app applies at once (#58: the volume left the bars). Out of range is clamped; anything else
44
+ * (a function that throws, NaN) is the default.
45
+ */
46
+ export declare function volumeOf(volume: number | (() => number) | undefined): number;
@@ -0,0 +1,80 @@
1
+ import { type Sound } from './player.js';
2
+ import { type DiagramData, type PlayOptions } from './controls.js';
3
+ /** One playable diagram of a block. */
4
+ interface Item {
5
+ diagram: Element;
6
+ data: DiagramData;
7
+ /** The diagram's button: the `.mn-playable` around it. */
8
+ wrap: HTMLElement;
9
+ /** The drawing on the page: the diagram, or its redrawing for the other instrument. */
10
+ shown: Element;
11
+ /** Its redrawing for the other instrument, once made (null: nothing to draw). */
12
+ other: Element | null | undefined;
13
+ /** A caption in words (caption: fingering), about the diagram's own instrument. */
14
+ caption: HTMLElement | undefined;
15
+ /** What the bar calls it. */
16
+ name: string;
17
+ /** What screen readers call it: its accessible name, else the bar's. */
18
+ spoken: string;
19
+ }
20
+ /** A block's diagrams as they play: the bar (when the block has one) drives it. */
21
+ export interface DiagramGroup {
22
+ /** Stops what plays. */
23
+ stop(): void;
24
+ /** Plays the diagrams on another sound (and redraws them for it, when a block bar plays it). */
25
+ setSound(sound: Sound): void;
26
+ /** Called each time something starts playing (so another bar of the block stops). */
27
+ onPlay: (() => void) | null;
28
+ /**
29
+ * Stops what another bar of the block plays (Escape on a diagram); true when something
30
+ * played. A progression's bar sets it.
31
+ */
32
+ stopOthers: (() => boolean) | null;
33
+ /** Frees the group: stops, and no timer stays. */
34
+ destroy(): void;
35
+ }
36
+ export interface GroupOptions {
37
+ /**
38
+ * A block bar plays the group: the sound redraws the diagrams for the other instrument, and
39
+ * the selected diagram (the one the bar plays) is marked. A progression's diagrams have none.
40
+ */
41
+ bar: boolean;
42
+ }
43
+ /**
44
+ * Makes `diagrams` (all of one block) playable together: one thing plays at a time; a click on a
45
+ * diagram plays it, a click on a note plays that note. With `bar`, the block's bar is built and
46
+ * placed below them.
47
+ */
48
+ export declare function diagramGroup(doc: Document, win: Window, diagrams: {
49
+ diagram: Element;
50
+ data: DiagramData;
51
+ }[], options: PlayOptions, how: GroupOptions): {
52
+ group: DiagramGroup;
53
+ items: readonly Item[];
54
+ api: GroupApi;
55
+ bind: (ui: GroupUi) => void;
56
+ };
57
+ /** What the bar reads and drives. */
58
+ export interface GroupApi {
59
+ readonly selected: Item;
60
+ readonly busy: boolean;
61
+ readonly inTurn: boolean;
62
+ readonly sound: Sound;
63
+ bpm: number;
64
+ strumOf(sound: Sound): number;
65
+ setStrum(sound: Sound, n: number): void;
66
+ loop: boolean;
67
+ playSelected(): void;
68
+ playAll(): void;
69
+ stop(): void;
70
+ }
71
+ /** The bar's side: told when something changed. */
72
+ export interface GroupUi {
73
+ changed(): void;
74
+ }
75
+ /** The bar of a block's diagrams. Returns a function that stops what plays and frees it. */
76
+ export declare function blockBarFor(doc: Document, win: Window, block: Element, diagrams: {
77
+ diagram: Element;
78
+ data: DiagramData;
79
+ }[], options: PlayOptions): () => void;
80
+ export {};
@@ -1,5 +1,5 @@
1
1
  import type { Hand } from '../render/layout.js';
2
- import { type NotePlayer, type Sound } from './player.js';
2
+ import { type NotePlayer, type PlayKind, type Sound } from './player.js';
3
3
  export interface PlayOptions {
4
4
  /**
5
5
  * Plays the notes: a player, or a function returning one at each play (null for the default),
@@ -9,8 +9,12 @@ export interface PlayOptions {
9
9
  player?: NotePlayer | ((win: Window) => NotePlayer | null | undefined);
10
10
  /** Guitar or piano; by default the diagram's (piano for keyboards and piano chords). */
11
11
  sound?: Sound;
12
- /** 0 to 1, 0.8 by default. */
13
- volume?: number;
12
+ /**
13
+ * 0 to 1, 0.8 by default. The bars have no volume (#58): it is the app's setting. A function
14
+ * is read at each play (and each pass of a loop), so a setting changed in the app applies at
15
+ * once.
16
+ */
17
+ volume?: number | (() => number);
14
18
  /** Scales: notes per minute, 90 by default; also strum patterns' tempo when they have none. */
15
19
  bpm?: number;
16
20
  /**
@@ -61,15 +65,34 @@ export declare const clamp: (n: number | undefined, lo: number, hi: number, fall
61
65
  * so piano chords stay a block unless `{ piano }` is given.
62
66
  */
63
67
  export declare function strumsOf(strum: PlayOptions['strum']): Record<Sound, number>;
64
- /** Small icons, drawn so they look the same in every font. */
65
- declare const ICONS: Record<'play' | 'stop' | 'loop' | 'volume', string>;
66
- export declare function icon(doc: Document, name: keyof typeof ICONS): SVGElement;
68
+ export { icon } from './bar-parts.js';
67
69
  export declare function lightFor(win: Window): NotePlayer;
68
70
  /** The player apps passed (read at each play), else the light synthesizer. */
69
71
  export declare function playerFor(win: Window, options: PlayOptions): NotePlayer;
72
+ /** The diagram's own playback data, set by its renderer. */
73
+ export interface DiagramData {
74
+ kind: PlayKind;
75
+ pitches: number[];
76
+ sound: Sound;
77
+ /** The tonic's pitch class, from the root mark (scales start on it); null without one. */
78
+ root: number | null;
79
+ }
80
+ /** The pitch classes of a chord drawn over a scale (its tones), or undefined. */
81
+ export declare function tonesOf(drawing: Element): number[] | undefined;
82
+ /** The pitch class of a drawing's root mark (a root dot or key), or null. */
83
+ export declare function rootOf(drawing: Element): number | null;
84
+ export declare function dataOf(diagram: Element): DiagramData | null;
85
+ /**
86
+ * The same notes drawn for the other instrument: a keyboard for a guitar diagram or a fretboard,
87
+ * a fretboard for a keyboard. The diagram's own chord or scale with its exact pitches, so notes
88
+ * keep their spelling (Gm's Bb) and labels their meaning (C9's 9); a list rebuilt from its notes
89
+ * and root otherwise. With the title, the labels and the orientation (between fretboards and
90
+ * keyboards); null when nothing can be drawn (no note within a guitar's range).
91
+ */
92
+ export declare function redrawFor(doc: Document, diagram: Element, data: DiagramData, pageHand?: Hand): Element | null;
70
93
  /**
71
- * Wraps each playable diagram in `el` (an SVG with notes to play) with its playback bar. Returns
72
- * a function that stops whatever plays.
94
+ * Makes what `el` draws playable: each block's diagrams (an SVG with notes to play) get one bar
95
+ * below them, strumming and picking patterns, progressions and ChordPro charts their bar in time.
96
+ * Returns a function that stops whatever plays.
73
97
  */
74
98
  export declare function attachPlayback(el: HTMLElement, options?: PlayOptions): () => void;
75
- export {};
@@ -1,8 +1,9 @@
1
- import { type PlayOptions } from './controls.js';
1
+ import type { PlayOptions } from './controls.js';
2
+ import type { DiagramGroup } from './block-bar.js';
2
3
  import { type ProgressionBar } from './progression.js';
3
4
  /** The bars of a drawn progression or chart, in order, each with the elements that show it. */
4
5
  export declare function barsFromDrawing(drawing: Element): {
5
6
  bars: ProgressionBar[];
6
7
  marks: Element[][];
7
8
  };
8
- export declare function progressionBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions): () => void;
9
+ export declare function progressionBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions, diagrams?: DiagramGroup | null): () => void;
@@ -14,19 +14,19 @@ export declare function strumBarFor(doc: Document, win: Window, drawing: Element
14
14
  export interface TimedPiece {
15
15
  /** What it plays, for the app (#77). */
16
16
  kind: 'strum' | 'picking';
17
- /** The wrapper's own class, beside `mn-playable`. */
17
+ /** The wrapper's own class, beside `mn-timed`. */
18
18
  cls: string;
19
19
  /** The bar's name for screen readers. */
20
20
  label: string;
21
- /** Counted in dotted beats (6/8): the tempo slider shows ♩. */
21
+ /** Counted in dotted beats (6/8): the tempo counts dotted quarters. */
22
22
  compound: boolean;
23
23
  make: PassMaker;
24
24
  /** Shows a click (metronome) button, on or off at the start; none when absent. */
25
25
  click?: boolean;
26
26
  }
27
27
  /**
28
- * The bar of a piece played in time over a drawing whose slots are `[data-mn-beat]` elements:
29
- * play / stop, loop, count-in, click when asked, tempo, volume, sound. Each pass's slots light
28
+ * The bar of a piece played in time over a drawing whose slots are `[data-mn-beat]` elements,
29
+ * below it: play / stop, loop, count-in, click when asked, tempo, sound. Each pass's slots light
30
30
  * as they sound.
31
31
  */
32
32
  export declare function timedBarFor(doc: Document, win: Window, drawing: Element, options: PlayOptions, piece: TimedPiece): () => void;