pianometer/tonal.min.js

3 lines
34 KiB
JavaScript
Raw Permalink Normal View History

"use strict";var Tonal=(()=>{var dt=Object.defineProperty;var Xn=Object.getOwnPropertyDescriptor;var Qn=Object.getOwnPropertyNames;var Jn=Object.prototype.hasOwnProperty;var pt=(t,n)=>{for(var e in n)dt(t,e,{get:n[e],enumerable:!0})},Yn=(t,n,e,r)=>{if(n&&typeof n=="object"||typeof n=="function")for(let o of Qn(n))!Jn.call(t,o)&&o!==e&&dt(t,o,{get:()=>n[o],enumerable:!(r=Xn(n,o))||r.enumerable});return t};var Wn=t=>Yn(dt({},"__esModule",{value:!0}),t);var fa={};pt(fa,{AbcNotation:()=>nn,Array:()=>bt,Chord:()=>fn,ChordDictionary:()=>ua,ChordType:()=>Nt,Collection:()=>an,Core:()=>tt,DurationValue:()=>dn,Interval:()=>Mn,Key:()=>wn,Midi:()=>bn,Mode:()=>$n,Note:()=>Tn,PcSet:()=>ca,Pcset:()=>It,Progression:()=>kn,Range:()=>Gn,RomanNumeral:()=>En,Scale:()=>Un,ScaleDictionary:()=>la,ScaleType:()=>jt,TimeSignature:()=>Kn,Tonal:()=>sa,accToAlt:()=>_,altToAcc:()=>E,coordToInterval:()=>G,coordToNote:()=>vt,decode:()=>Z,deprecate:()=>f,distance:()=>b,encode:()=>W,fillStr:()=>$,interval:()=>l,isNamed:()=>k,isPitch:()=>q,note:()=>s,stepToLetter:()=>ht,tokenizeInterval:()=>yt,tokenizeNote:()=>H,tonicIntervalsTransposer:()=>D,transpose:()=>u});var tt={};pt(tt,{accToAlt:()=>_,altToAcc:()=>E,coordToInterval:()=>G,coordToNote:()=>vt,decode:()=>Z,deprecate:()=>f,distance:()=>b,encode:()=>W,fillStr:()=>$,interval:()=>l,isNamed:()=>k,isPitch:()=>q,note:()=>s,stepToLetter:()=>ht,tokenizeInterval:()=>yt,tokenizeNote:()=>H,tonicIntervalsTransposer:()=>D,transpose:()=>u});var $=(t,n)=>Array(Math.abs(n)+1).join(t);function f(t,n,e){return function(...r){return console.warn(`${t} is deprecated. Use ${n}.`),e.apply(this,r)}}function k(t){return t!==null&&typeof t=="object"&&typeof t.name=="string"}function q(t){return t!==null&&typeof t=="object"&&typeof t.step=="number"&&typeof t.alt=="number"}var Xt=[0,2,4,-1,1,3,5],Qt=Xt.map(t=>Math.floor(t*7/12));function W(t){let{step:n,alt:e,oct:r,dir:o=1}=t,a=Xt[n]+7*e;if(r===void 0)return[o*a];let i=r-Qt[n]-4*e;return[o*a,o*i]}var Zn=[3,0,4,1,5,2,6];function Z(t){let[n,e,r]=t,o=Zn[te(n)],a=Math.floor((n+1)/7);if(e===void 0)return{step:o,alt:a,dir:r};let i=e+4*a+Qt[o];return{step:o,alt:a,oct:i,dir:r}}function te(t){let n=(t+1)%7;return n<0?7+n:n}var Jt={empty:!0,name:"",pc:"",acc:""},Ut=new Map,ht=t=>"CDEFGAB".charAt(t),E=t=>t<0?$("b",-t):$("#",t),_=t=>t[0]==="b"?-t.length:t.length;function s(t){let n=JSON.stringify(t),e=Ut.get(n);if(e)return e;let r=typeof t=="string"?re(t):q(t)?s(oe(t)):k(t)?s(t.name):Jt;return Ut.set(n,r),r}var ne=/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/;function H(t){let n=ne.exec(t);return[n[1].toUpperCase(),n[2].replace(/x/g,"##"),n[3],n[4]]}function vt(t){return s(Z(t))}var ee=(t,n)=>(t%n+n)%n,Pt=[0,2,4,5,7,9,11];function re(t){let n=H(t);if(n[0]===""||n[3]!=="")return Jt;let e=n[0],r=n[1],o=n[2],a=(e.charCodeAt(0)+3)%7,i=_(r),m=o.length?+o:void 0,c=W({step:a,alt:i,oct:m}),P=e+r+o,h=e+r,j=(Pt[a]+i+120)%12,d=m===void 0?ee(Pt[a]+i,12)-12*99:Pt[a]+i+12*(m+1),x=d>=0&&d<=127?d:null,C=m===void 0?null:Math.pow(2,(d-69)/12)*440;return{empty:!1,acc:r,alt:i,chroma:j,coord:c,freq:C,height:d,letter:e,midi:x,name:P,oct:m,pc:h,step:a}}function oe(t){let{step:n,alt:e,oct:r}=t,o=ht(n);if(!o)return"";let a=o+E(e);return r||r===0?a+r:a}var Mt={empty:!0,name:"",acc:""},ae="([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})",ie="(AA|A|P|M|m|d|dd)([-+]?\\d+)",me=new RegExp("^"+ae+"|"+ie+"$");function yt(t){let n=me.exec(`${t}`);return n===null?["",""]:n[1]?[n[1],n[2]]:[n[4],n[3]]}var Ht={};function l(t){return typeof t=="string"?Ht[t]||(Ht[t]=se(t)):q(t)?l(ue(t)):k(t)?l(t.name):Mt}var Kt=[0,2,4,5,7,9,11],Yt="PMMPPMM";function se(t){let n=yt(t);if(n[0]==="")return Mt;let e=+n[0],r=n[1],o=(Math.abs(e)-1)%7,a=Yt[o];if(a==="M"&&r==="P")return Mt;let i=a==="M"?"majorable":"perfectable",m=""+e+r,c=e<0?-1:1,P=e===8||e===-8?e:c*(o+1),h=ce(i,r),j=Math.floor((Math.abs(e)-1)/7),d=c*(Kt[o]+h+12*j),x=(c*(Kt[o]+h)%12+12)%12,C=W({step:o,alt:h,oct:j,dir:c});return{empty:!1,name:m,num:e,q:r,step:o,alt:h,dir:c,type:i,simple:P,semitones:d,chroma:x,coord:C,oct:j}}function G(t,n){let[e,r=0]=t,o=e*7+r*12<0,a=n||o?[-e,-r,-1]:[e,r,1];retur
//# sourceMappingURL=tonal.min.js.map