diff --git a/assets/index-Cb8h-mHG.js b/assets/index-BLLwekxr.js similarity index 99% rename from assets/index-Cb8h-mHG.js rename to assets/index-BLLwekxr.js index 77a56c0..d6a7f21 100644 --- a/assets/index-Cb8h-mHG.js +++ b/assets/index-BLLwekxr.js @@ -1,4 +1,4 @@ -(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();const ne="%[a-f0-9]{2}",X=new RegExp("("+ne+")|([^%]+?)","gi"),Q=new RegExp("("+ne+")+","gi");function P(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;const t=r.slice(0,e),n=r.slice(e);return Array.prototype.concat.call([],P(t),P(n))}function be(r){try{return decodeURIComponent(r)}catch{let e=r.match(X)||[];for(let t=1;tr==null,xe=r=>encodeURIComponent(r).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),V=Symbol("encodeFragmentIdentifier");function Se(r){switch(r.arrayFormat){case"index":return e=>(t,n)=>{const s=t.length;return n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),"[",s,"]"].join("")]:[...t,[g(e,r),"[",g(s,r),"]=",g(n,r)].join("")]};case"bracket":return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),"[]"].join("")]:[...t,[g(e,r),"[]=",g(n,r)].join("")];case"colon-list-separator":return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),":list="].join("")]:[...t,[g(e,r),":list=",g(n,r)].join("")];case"comma":case"separator":case"bracket-separator":{const e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,s)=>s===void 0||r.skipNull&&s===null||r.skipEmptyString&&s===""?n:(s=s===null?"":s,n.length===0?[[g(t,r),e,g(s,r)].join("")]:[[n,g(s,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,g(e,r)]:[...t,[g(e,r),"=",g(n,r)].join("")]}}function Ee(r){let e;switch(r.arrayFormat){case"index":return(t,n,s)=>{if(e=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!e){s[t]=n;return}s[t]===void 0&&(s[t]={}),s[t][e[1]]=n};case"bracket":return(t,n,s)=>{if(e=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!e){s[t]=n;return}if(s[t]===void 0){s[t]=[n];return}s[t]=[...s[t],n]};case"colon-list-separator":return(t,n,s)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){s[t]=n;return}if(s[t]===void 0){s[t]=[n];return}s[t]=[...s[t],n]};case"comma":case"separator":return(t,n,s)=>{const i=typeof n=="string"&&n.includes(r.arrayFormatSeparator),o=typeof n=="string"&&!i&&M(n,r).includes(r.arrayFormatSeparator);n=o?M(n,r):n;const a=i||o?n.split(r.arrayFormatSeparator).map(c=>M(c,r)):n===null?n:M(n,r);s[t]=a};case"bracket-separator":return(t,n,s)=>{const i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!i){s[t]=n&&M(n,r);return}const o=n===null?[]:n.split(r.arrayFormatSeparator).map(a=>M(a,r));if(s[t]===void 0){s[t]=o;return}s[t]=[...s[t],...o]};default:return(t,n,s)=>{if(s[t]===void 0){s[t]=n;return}s[t]=[...[s[t]].flat(),n]}}}function re(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(r,e){return e.encode?e.strict?xe(r):encodeURIComponent(r):r}function M(r,e){return e.decode?ke(r):r}function ie(r){return Array.isArray(r)?r.sort():typeof r=="object"?ie(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function oe(r){const e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Me(r){let e="";const t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function K(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function H(r){r=oe(r);const e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Z(r,e){e={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...e},re(e.arrayFormatSeparator);const t=Ee(e),n=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return n;for(const s of r.split("&")){if(s==="")continue;const i=e.decode?s.replaceAll("+"," "):s;let[o,a]=se(i,"=");o===void 0&&(o=i),a=a===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?a:M(a,e),t(M(o,e),a,n)}for(const[s,i]of Object.entries(n))if(typeof i=="object"&&i!==null)for(const[o,a]of Object.entries(i))i[o]=K(a,e);else n[s]=K(i,e);return e.sort===!1?n:(e.sort===!0?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((s,i)=>{const o=n[i];return s[i]=o&&typeof o=="object"&&!Array.isArray(o)?ie(o):o,s},Object.create(null))}function ae(r,e){if(!r)return"";e={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...e},re(e.arrayFormatSeparator);const t=o=>e.skipNull&&ve(r[o])||e.skipEmptyString&&r[o]==="",n=Se(e),s={};for(const[o,a]of Object.entries(r))t(o)||(s[o]=a);const i=Object.keys(s);return e.sort!==!1&&i.sort(e.sort),i.map(o=>{const a=r[o];return a===void 0?"":a===null?g(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?g(o,e)+"[]":a.reduce(n(o),[]).join("&"):g(o,e)+"="+g(a,e)}).filter(o=>o.length>0).join("&")}function le(r,e){e={decode:!0,...e};let[t,n]=se(r,"#");return t===void 0&&(t=r),{url:t?.split("?")?.[0]??"",query:Z(H(r),e),...e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:M(n,e)}:{}}}function ce(r,e){e={encode:!0,strict:!0,[V]:!0,...e};const t=oe(r.url).split("?")[0]||"",n=H(r.url),s={...Z(n,{sort:!1}),...r.query};let i=ae(s,e);i&&=`?${i}`;let o=Me(r.url);if(typeof r.fragmentIdentifier=="string"){const a=new URL(t);a.hash=r.fragmentIdentifier,o=e[V]?a.hash:`#${r.fragmentIdentifier}`}return`${t}${i}${o}`}function he(r,e,t){t={parseFragmentIdentifier:!0,[V]:!1,...t};const{url:n,query:s,fragmentIdentifier:i}=le(r,t);return ce({url:n,query:we(s,e),fragmentIdentifier:i},t)}function Ce(r,e,t){const n=Array.isArray(e)?s=>!e.includes(s):(s,i)=>!e(s,i);return he(r,n,t)}const q=Object.freeze(Object.defineProperty({__proto__:null,exclude:Ce,extract:H,parse:Z,parseUrl:le,pick:he,stringify:ae,stringifyUrl:ce},Symbol.toStringTag,{value:"Module"})),W={version:"0.7.0",date:"2024-04-25T09:40:40.419Z"};class I{constructor(e,t={}){this.input=e,this.ip=t.index||0,this.length=t.length||e.byteLength-this.ip,this.chunkList=[],this.offset=this.ip,this.padding=t.padding!==void 0?t.padding:!0,this.bigEndian=t.bigEndian!==void 0?t.bigEndian:!1}parse(){const e=this.length+this.offset;for(this.chunkList=[];this.ip>>0:(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)>>>0,t)),t+=n,this.padding&&(t-this.offset&1)===1&&t++,this.ip=t}getChunk(e){const t=this.chunkList[e];return t!==void 0?t:null}getNumberOfChunks(){return this.chunkList.length}}class Ae{constructor(e,t,n){this.type=e,this.size=t,this.offset=n}}class G{constructor(e,t={}){this.input=e,this.parserOption=t.parserOption||{},this.sampleRate=t.sampleRate||22050,this.presetHeader=[],this.presetZone=[],this.presetZoneModulator=[],this.presetZoneGenerator=[],this.instrument=[],this.instrumentZone=[],this.instrumentZoneModulator=[],this.instrumentZoneGenerator=[],this.sampleHeader=[],this.GeneratorEnumeratorTable=Object.keys(G.getGeneratorTable())}static getGeneratorTable(){return Object.freeze({startAddrsOffset:0,endAddrsOffset:0,startloopAddrsOffset:0,endloopAddrsOffset:0,startAddrsCoarseOffset:0,modLfoToPitch:0,vibLfoToPitch:0,modEnvToPitch:0,initialFilterFc:13500,initialFilterQ:0,modLfoToFilterFc:0,modEnvToFilterFc:0,endAddrsCoarseOffset:0,modLfoToVolume:0,unused1:void 0,chorusEffectsSend:0,reverbEffectsSend:0,pan:0,unused2:void 0,unused3:void 0,unused4:void 0,delayModLFO:-12e3,freqModLFO:0,delayVibLFO:-12e3,freqVibLFO:0,delayModEnv:-12e3,attackModEnv:-12e3,holdModEnv:-12e3,decayModEnv:-12e3,sustainModEnv:0,releaseModEnv:-12e3,keynumToModEnvHold:0,keynumToModEnvDecay:0,delayVolEnv:-12e3,attackVolEnv:-12e3,holdVolEnv:-12e3,decayVolEnv:-12e3,sustainVolEnv:0,releaseVolEnv:-12e3,keynumToVolEnvHold:0,keynumToVolEnvDecay:0,instrument:null,reserved1:void 0,keyRange:null,velRange:null,startloopAddrsCoarseOffset:0,keynum:null,velocity:null,initialAttenuation:0,reserved2:void 0,endloopAddrsCoarseOffset:0,coarseTune:0,fineTune:0,sampleID:null,sampleModes:0,reserved3:void 0,scaleTuning:100,exclusiveClass:null,overridingRootKey:null,unuded5:void 0,endOper:void 0})}parse(){const e=new I(this.input,this.parserOption);if(e.parse(),e.chunkList.length!==1)throw new Error("wrong chunk length");const t=e.getChunk(0);if(t===null)throw new Error("chunk not found");this.parseRiffChunk(t),this.input=null}parseRiffChunk(e){const t=this.input;let n=e.offset;if(e.type!=="RIFF")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="sfbk")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.getNumberOfChunks()!==3)throw new Error("invalid sfbk structure");this.parseInfoList(i.getChunk(0)),this.parseSdtaList(i.getChunk(1)),this.parsePdtaList(i.getChunk(2))}parseInfoList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="INFO")throw new Error("invalid signature:"+s);new I(t,{index:n,length:e.size-4}).parse()}parseSdtaList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="sdta")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.chunkList.length!==1)throw new Error("TODO");this.samplingData=i.getChunk(0)}parsePdtaList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="pdta")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.getNumberOfChunks()!==9)throw new Error("invalid pdta chunk");this.parsePhdr(i.getChunk(0)),this.parsePbag(i.getChunk(1)),this.parsePmod(i.getChunk(2)),this.parsePgen(i.getChunk(3)),this.parseInst(i.getChunk(4)),this.parseIbag(i.getChunk(5)),this.parseImod(i.getChunk(6)),this.parseIgen(i.getChunk(7)),this.parseShdr(i.getChunk(8))}parsePhdr(e){const t=this.input;let n=e.offset;const s=this.presetHeader=[],i=e.offset+e.size;if(e.type!=="phdr")throw new Error("invalid chunk type:"+e.type);for(;n>>0,genre:(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,morphology:(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0})}parsePbag(e){const t=this.input;let n=e.offset;const s=this.presetZone=[],i=e.offset+e.size;if(e.type!=="pbag")throw new Error("invalid chunk type:"+e.type);for(;n>>0,l=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,d=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,u=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,f=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,h=t[n++],m=t[n++]<<24>>24,b=t[n++]|t[n++]<<8,p=t[n++]|t[n++]<<8;let y=new Int16Array(new Uint8Array(t.subarray(this.samplingData.offset+c*2,this.samplingData.offset+l*2)).buffer);if(d-=c,u-=c,f>0){const w=this.adjustSampleData(y,f);y=w.sample,f*=w.multiply,d*=w.multiply,u*=w.multiply}s.push(y),i.push({sampleName:a,start:c,end:l,startLoop:d,endLoop:u,sampleRate:f,originalPitch:h,pitchCorrection:m,sampleLink:b,sampleType:p})}}adjustSampleData(e,t){let n,s,i,o,a=1;for(;t>16,lo:t[n++],hi:t[n++]}});else switch(o){case"keyRange":case"velRange":case"keynum":case"velocity":a.push({type:o,value:{amount:null,lo:t[n++],hi:t[n++]}});break;default:a.push({type:o,value:{amount:t[n++]|t[n++]<<8<<16>>16}});break}n+=2,n+=2}return a}parseGenerator(e){const t=this.input;let n=e.offset;const s=e.offset+e.size;let i,o;const a=[];for(;n>16,lo:t[n++],hi:t[n++]}});continue}switch(o){case"keynum":case"keyRange":case"velRange":case"velocity":a.push({type:o,value:{amount:null,lo:t[n++],hi:t[n++]}});break;default:a.push({type:o,value:{amount:t[n++]|t[n++]<<8<<16>>16}});break}}return a}createInstrument(){const e=this.instrument,t=this.instrumentZone,n=[];let s,i,o,a,c,l,d,u,f;for(l=0,d=e.length;l{this.alert.className="alert alert-danger",this.message.innerText="An error occurred while loading SoundFont. See the console log for details. In addition, it may be cured by deleting the cache of the browser.",this.progressOuter.style.display="none"})}async fetch(){const e=await window.caches.open(z.CACHE_NAME),t=await e.match(this.url);if(this.cache&&t){this.onComplete(await t.arrayBuffer());return}const n=await fetch(this.url,{method:"GET"}).catch(u=>this.onError(u));if(!n||n&&!n.ok)return;const s=n.clone(),i=parseInt(n.headers.get("Content-Length")),o=s.body.getReader();let a=0;const c=[];for(;;){const{done:u,value:f}=await o.read();if(u)break;c.push(f),a+=f.length,this.message.innerText=`Now Loading... (${a} of ${i} byte)`,this.onProgress(a,i)}const l=new Uint8Array(a);let d=0;for(const u of c)l.set(u,d),d+=u.length;await e.put(this.url,n),this.onComplete(l)}}const Y=1/2**32;class Oe{float(e=1){return this.int()*Y*e}probability(e){return this.float()>>=0;const n=(t>>>0)-e;return n?e+this.int()%n:e}}const B=Math.random;class Te extends Oe{int(){return B()*4294967296>>>0}float(e=1){return B()*e}norm(e=1){return(B()-.5)*2*e}}const de=new Te,F={bins:2,scale:1,rnd:de},U=(r,e,t)=>{const n=new Array(r);for(let s=0;sr.reduce((e,t)=>e+t,0);function*ue(r,e){const t=[r[Symbol.iterator](),e[Symbol.iterator]()];for(let n=0;;n^=1){const s=t[n].next();if(s.done)return;yield s.value}}function*D(r){const{bins:e,scale:t,rnd:n}={...F,...r},s=U(e,t,n);s.forEach((a,c)=>s[c]=c&1?a:-a);const i=1/e;let o=_(s);for(let a=0,c=-1;;++a>=e&&(a=0))o-=s[a],o+=s[a]=c*n.norm(t),c^=4294967294,yield c*o*i}const Ne=r=>ue(D(r),D(r)),Ie=r=>{let e=32;return r&=-r,r&&e--,r&65535&&(e-=16),r&16711935&&(e-=8),r&252645135&&(e-=4),r&858993459&&(e-=2),r&1431655765&&(e-=1),e};function*Ge(r){const{bins:e=8,scale:t,rnd:n}={...F,...r},s=U(e,t,n),i=1/e;let o=_(s);for(let a=0;;a=a+1>>>0){const c=Ie(a)%e;o-=s[c],o+=s[c]=n.norm(t),yield o*i}}function*j(r){const{bins:e,scale:t,rnd:n}={...F,...r},s=U(e,t,n),i=1/e;let o=_(s);for(let a=0;;++a>=e&&(a=0))o-=s[a],o+=s[a]=n.norm(t),yield o*i}const Re=r=>ue(j(r),j(r));function*J(r){const{scale:e,rnd:t}={...F,...r};for(;;)yield t.norm(e)}const Fe=(r,e)=>r!=null&&typeof r[e]=="function",Le=r=>Fe(r,"xform")?r.xform():r,Be=r=>r!=null&&typeof r[Symbol.iterator]=="function",Pe=r=>r;class R{value;constructor(e){this.value=e}deref(){return this.value}}const Ve=r=>new R(r),qe=r=>r instanceof R,De=r=>r instanceof R?r:new R(r),ee=r=>r instanceof R?r.deref():r,je=(r,e)=>[r,Pe,e];function $e(r){return r?[...r]:je(()=>[],(e,t)=>(e.push(t),e))}function*He(r,e){const t=Le(r)($e()),n=t[1],s=t[2];for(let i of e){const o=s([],i);if(qe(o)){yield*ee(n(o.deref()));return}o.length&&(yield*o)}yield*ee(n([]))}const Ze=(r,e)=>[r[0],r[1],e];function fe(r,e){return Be(e)?He(fe(r),e):t=>{const n=t[2];let s=r;return Ze(t,(i,o)=>--s>0?n(i,o):s===0?De(n(i,o)):Ve(i))}}/** +(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const s of document.querySelectorAll('link[rel="modulepreload"]'))n(s);new MutationObserver(s=>{for(const i of s)if(i.type==="childList")for(const o of i.addedNodes)o.tagName==="LINK"&&o.rel==="modulepreload"&&n(o)}).observe(document,{childList:!0,subtree:!0});function t(s){const i={};return s.integrity&&(i.integrity=s.integrity),s.referrerPolicy&&(i.referrerPolicy=s.referrerPolicy),s.crossOrigin==="use-credentials"?i.credentials="include":s.crossOrigin==="anonymous"?i.credentials="omit":i.credentials="same-origin",i}function n(s){if(s.ep)return;s.ep=!0;const i=t(s);fetch(s.href,i)}})();const ne="%[a-f0-9]{2}",X=new RegExp("("+ne+")|([^%]+?)","gi"),Q=new RegExp("("+ne+")+","gi");function P(r,e){try{return[decodeURIComponent(r.join(""))]}catch{}if(r.length===1)return r;e=e||1;const t=r.slice(0,e),n=r.slice(e);return Array.prototype.concat.call([],P(t),P(n))}function be(r){try{return decodeURIComponent(r)}catch{let e=r.match(X)||[];for(let t=1;tr==null,xe=r=>encodeURIComponent(r).replaceAll(/[!'()*]/g,e=>`%${e.charCodeAt(0).toString(16).toUpperCase()}`),V=Symbol("encodeFragmentIdentifier");function Se(r){switch(r.arrayFormat){case"index":return e=>(t,n)=>{const s=t.length;return n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),"[",s,"]"].join("")]:[...t,[g(e,r),"[",g(s,r),"]=",g(n,r)].join("")]};case"bracket":return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),"[]"].join("")]:[...t,[g(e,r),"[]=",g(n,r)].join("")];case"colon-list-separator":return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,[g(e,r),":list="].join("")]:[...t,[g(e,r),":list=",g(n,r)].join("")];case"comma":case"separator":case"bracket-separator":{const e=r.arrayFormat==="bracket-separator"?"[]=":"=";return t=>(n,s)=>s===void 0||r.skipNull&&s===null||r.skipEmptyString&&s===""?n:(s=s===null?"":s,n.length===0?[[g(t,r),e,g(s,r)].join("")]:[[n,g(s,r)].join(r.arrayFormatSeparator)])}default:return e=>(t,n)=>n===void 0||r.skipNull&&n===null||r.skipEmptyString&&n===""?t:n===null?[...t,g(e,r)]:[...t,[g(e,r),"=",g(n,r)].join("")]}}function Ee(r){let e;switch(r.arrayFormat){case"index":return(t,n,s)=>{if(e=/\[(\d*)]$/.exec(t),t=t.replace(/\[\d*]$/,""),!e){s[t]=n;return}s[t]===void 0&&(s[t]={}),s[t][e[1]]=n};case"bracket":return(t,n,s)=>{if(e=/(\[])$/.exec(t),t=t.replace(/\[]$/,""),!e){s[t]=n;return}if(s[t]===void 0){s[t]=[n];return}s[t]=[...s[t],n]};case"colon-list-separator":return(t,n,s)=>{if(e=/(:list)$/.exec(t),t=t.replace(/:list$/,""),!e){s[t]=n;return}if(s[t]===void 0){s[t]=[n];return}s[t]=[...s[t],n]};case"comma":case"separator":return(t,n,s)=>{const i=typeof n=="string"&&n.includes(r.arrayFormatSeparator),o=typeof n=="string"&&!i&&M(n,r).includes(r.arrayFormatSeparator);n=o?M(n,r):n;const a=i||o?n.split(r.arrayFormatSeparator).map(c=>M(c,r)):n===null?n:M(n,r);s[t]=a};case"bracket-separator":return(t,n,s)=>{const i=/(\[])$/.test(t);if(t=t.replace(/\[]$/,""),!i){s[t]=n&&M(n,r);return}const o=n===null?[]:n.split(r.arrayFormatSeparator).map(a=>M(a,r));if(s[t]===void 0){s[t]=o;return}s[t]=[...s[t],...o]};default:return(t,n,s)=>{if(s[t]===void 0){s[t]=n;return}s[t]=[...[s[t]].flat(),n]}}}function re(r){if(typeof r!="string"||r.length!==1)throw new TypeError("arrayFormatSeparator must be single character string")}function g(r,e){return e.encode?e.strict?xe(r):encodeURIComponent(r):r}function M(r,e){return e.decode?ke(r):r}function ie(r){return Array.isArray(r)?r.sort():typeof r=="object"?ie(Object.keys(r)).sort((e,t)=>Number(e)-Number(t)).map(e=>r[e]):r}function oe(r){const e=r.indexOf("#");return e!==-1&&(r=r.slice(0,e)),r}function Me(r){let e="";const t=r.indexOf("#");return t!==-1&&(e=r.slice(t)),e}function K(r,e){return e.parseNumbers&&!Number.isNaN(Number(r))&&typeof r=="string"&&r.trim()!==""?r=Number(r):e.parseBooleans&&r!==null&&(r.toLowerCase()==="true"||r.toLowerCase()==="false")&&(r=r.toLowerCase()==="true"),r}function H(r){r=oe(r);const e=r.indexOf("?");return e===-1?"":r.slice(e+1)}function Z(r,e){e={decode:!0,sort:!0,arrayFormat:"none",arrayFormatSeparator:",",parseNumbers:!1,parseBooleans:!1,...e},re(e.arrayFormatSeparator);const t=Ee(e),n=Object.create(null);if(typeof r!="string"||(r=r.trim().replace(/^[?#&]/,""),!r))return n;for(const s of r.split("&")){if(s==="")continue;const i=e.decode?s.replaceAll("+"," "):s;let[o,a]=se(i,"=");o===void 0&&(o=i),a=a===void 0?null:["comma","separator","bracket-separator"].includes(e.arrayFormat)?a:M(a,e),t(M(o,e),a,n)}for(const[s,i]of Object.entries(n))if(typeof i=="object"&&i!==null)for(const[o,a]of Object.entries(i))i[o]=K(a,e);else n[s]=K(i,e);return e.sort===!1?n:(e.sort===!0?Object.keys(n).sort():Object.keys(n).sort(e.sort)).reduce((s,i)=>{const o=n[i];return s[i]=o&&typeof o=="object"&&!Array.isArray(o)?ie(o):o,s},Object.create(null))}function ae(r,e){if(!r)return"";e={encode:!0,strict:!0,arrayFormat:"none",arrayFormatSeparator:",",...e},re(e.arrayFormatSeparator);const t=o=>e.skipNull&&ve(r[o])||e.skipEmptyString&&r[o]==="",n=Se(e),s={};for(const[o,a]of Object.entries(r))t(o)||(s[o]=a);const i=Object.keys(s);return e.sort!==!1&&i.sort(e.sort),i.map(o=>{const a=r[o];return a===void 0?"":a===null?g(o,e):Array.isArray(a)?a.length===0&&e.arrayFormat==="bracket-separator"?g(o,e)+"[]":a.reduce(n(o),[]).join("&"):g(o,e)+"="+g(a,e)}).filter(o=>o.length>0).join("&")}function le(r,e){e={decode:!0,...e};let[t,n]=se(r,"#");return t===void 0&&(t=r),{url:t?.split("?")?.[0]??"",query:Z(H(r),e),...e&&e.parseFragmentIdentifier&&n?{fragmentIdentifier:M(n,e)}:{}}}function ce(r,e){e={encode:!0,strict:!0,[V]:!0,...e};const t=oe(r.url).split("?")[0]||"",n=H(r.url),s={...Z(n,{sort:!1}),...r.query};let i=ae(s,e);i&&=`?${i}`;let o=Me(r.url);if(typeof r.fragmentIdentifier=="string"){const a=new URL(t);a.hash=r.fragmentIdentifier,o=e[V]?a.hash:`#${r.fragmentIdentifier}`}return`${t}${i}${o}`}function he(r,e,t){t={parseFragmentIdentifier:!0,[V]:!1,...t};const{url:n,query:s,fragmentIdentifier:i}=le(r,t);return ce({url:n,query:we(s,e),fragmentIdentifier:i},t)}function Ce(r,e,t){const n=Array.isArray(e)?s=>!e.includes(s):(s,i)=>!e(s,i);return he(r,n,t)}const q=Object.freeze(Object.defineProperty({__proto__:null,exclude:Ce,extract:H,parse:Z,parseUrl:le,pick:he,stringify:ae,stringifyUrl:ce},Symbol.toStringTag,{value:"Module"})),W={version:"0.7.0",date:"2024-04-25T09:42:07.235Z"};class I{constructor(e,t={}){this.input=e,this.ip=t.index||0,this.length=t.length||e.byteLength-this.ip,this.chunkList=[],this.offset=this.ip,this.padding=t.padding!==void 0?t.padding:!0,this.bigEndian=t.bigEndian!==void 0?t.bigEndian:!1}parse(){const e=this.length+this.offset;for(this.chunkList=[];this.ip>>0:(e[t++]|e[t++]<<8|e[t++]<<16|e[t++]<<24)>>>0,t)),t+=n,this.padding&&(t-this.offset&1)===1&&t++,this.ip=t}getChunk(e){const t=this.chunkList[e];return t!==void 0?t:null}getNumberOfChunks(){return this.chunkList.length}}class Ae{constructor(e,t,n){this.type=e,this.size=t,this.offset=n}}class G{constructor(e,t={}){this.input=e,this.parserOption=t.parserOption||{},this.sampleRate=t.sampleRate||22050,this.presetHeader=[],this.presetZone=[],this.presetZoneModulator=[],this.presetZoneGenerator=[],this.instrument=[],this.instrumentZone=[],this.instrumentZoneModulator=[],this.instrumentZoneGenerator=[],this.sampleHeader=[],this.GeneratorEnumeratorTable=Object.keys(G.getGeneratorTable())}static getGeneratorTable(){return Object.freeze({startAddrsOffset:0,endAddrsOffset:0,startloopAddrsOffset:0,endloopAddrsOffset:0,startAddrsCoarseOffset:0,modLfoToPitch:0,vibLfoToPitch:0,modEnvToPitch:0,initialFilterFc:13500,initialFilterQ:0,modLfoToFilterFc:0,modEnvToFilterFc:0,endAddrsCoarseOffset:0,modLfoToVolume:0,unused1:void 0,chorusEffectsSend:0,reverbEffectsSend:0,pan:0,unused2:void 0,unused3:void 0,unused4:void 0,delayModLFO:-12e3,freqModLFO:0,delayVibLFO:-12e3,freqVibLFO:0,delayModEnv:-12e3,attackModEnv:-12e3,holdModEnv:-12e3,decayModEnv:-12e3,sustainModEnv:0,releaseModEnv:-12e3,keynumToModEnvHold:0,keynumToModEnvDecay:0,delayVolEnv:-12e3,attackVolEnv:-12e3,holdVolEnv:-12e3,decayVolEnv:-12e3,sustainVolEnv:0,releaseVolEnv:-12e3,keynumToVolEnvHold:0,keynumToVolEnvDecay:0,instrument:null,reserved1:void 0,keyRange:null,velRange:null,startloopAddrsCoarseOffset:0,keynum:null,velocity:null,initialAttenuation:0,reserved2:void 0,endloopAddrsCoarseOffset:0,coarseTune:0,fineTune:0,sampleID:null,sampleModes:0,reserved3:void 0,scaleTuning:100,exclusiveClass:null,overridingRootKey:null,unuded5:void 0,endOper:void 0})}parse(){const e=new I(this.input,this.parserOption);if(e.parse(),e.chunkList.length!==1)throw new Error("wrong chunk length");const t=e.getChunk(0);if(t===null)throw new Error("chunk not found");this.parseRiffChunk(t),this.input=null}parseRiffChunk(e){const t=this.input;let n=e.offset;if(e.type!=="RIFF")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="sfbk")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.getNumberOfChunks()!==3)throw new Error("invalid sfbk structure");this.parseInfoList(i.getChunk(0)),this.parseSdtaList(i.getChunk(1)),this.parsePdtaList(i.getChunk(2))}parseInfoList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="INFO")throw new Error("invalid signature:"+s);new I(t,{index:n,length:e.size-4}).parse()}parseSdtaList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="sdta")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.chunkList.length!==1)throw new Error("TODO");this.samplingData=i.getChunk(0)}parsePdtaList(e){const t=this.input;let n=e.offset;if(e.type!=="LIST")throw new Error("invalid chunk type:"+e.type);const s=String.fromCharCode(t[n++],t[n++],t[n++],t[n++]);if(s!=="pdta")throw new Error("invalid signature:"+s);const i=new I(t,{index:n,length:e.size-4});if(i.parse(),i.getNumberOfChunks()!==9)throw new Error("invalid pdta chunk");this.parsePhdr(i.getChunk(0)),this.parsePbag(i.getChunk(1)),this.parsePmod(i.getChunk(2)),this.parsePgen(i.getChunk(3)),this.parseInst(i.getChunk(4)),this.parseIbag(i.getChunk(5)),this.parseImod(i.getChunk(6)),this.parseIgen(i.getChunk(7)),this.parseShdr(i.getChunk(8))}parsePhdr(e){const t=this.input;let n=e.offset;const s=this.presetHeader=[],i=e.offset+e.size;if(e.type!=="phdr")throw new Error("invalid chunk type:"+e.type);for(;n>>0,genre:(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,morphology:(t[n++]|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0})}parsePbag(e){const t=this.input;let n=e.offset;const s=this.presetZone=[],i=e.offset+e.size;if(e.type!=="pbag")throw new Error("invalid chunk type:"+e.type);for(;n>>0,l=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,d=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,u=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,f=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,h=t[n++],m=t[n++]<<24>>24,b=t[n++]|t[n++]<<8,p=t[n++]|t[n++]<<8;let y=new Int16Array(new Uint8Array(t.subarray(this.samplingData.offset+c*2,this.samplingData.offset+l*2)).buffer);if(d-=c,u-=c,f>0){const w=this.adjustSampleData(y,f);y=w.sample,f*=w.multiply,d*=w.multiply,u*=w.multiply}s.push(y),i.push({sampleName:a,start:c,end:l,startLoop:d,endLoop:u,sampleRate:f,originalPitch:h,pitchCorrection:m,sampleLink:b,sampleType:p})}}adjustSampleData(e,t){let n,s,i,o,a=1;for(;t>16,lo:t[n++],hi:t[n++]}});else switch(o){case"keyRange":case"velRange":case"keynum":case"velocity":a.push({type:o,value:{amount:null,lo:t[n++],hi:t[n++]}});break;default:a.push({type:o,value:{amount:t[n++]|t[n++]<<8<<16>>16}});break}n+=2,n+=2}return a}parseGenerator(e){const t=this.input;let n=e.offset;const s=e.offset+e.size;let i,o;const a=[];for(;n>16,lo:t[n++],hi:t[n++]}});continue}switch(o){case"keynum":case"keyRange":case"velRange":case"velocity":a.push({type:o,value:{amount:null,lo:t[n++],hi:t[n++]}});break;default:a.push({type:o,value:{amount:t[n++]|t[n++]<<8<<16>>16}});break}}return a}createInstrument(){const e=this.instrument,t=this.instrumentZone,n=[];let s,i,o,a,c,l,d,u,f;for(l=0,d=e.length;l{this.alert.className="alert alert-danger",this.message.innerText="An error occurred while loading SoundFont. See the console log for details. In addition, it may be cured by deleting the cache of the browser.",this.progressOuter.style.display="none"})}async fetch(){const e=await window.caches.open(z.CACHE_NAME),t=await e.match(this.url);if(this.cache&&t){this.onComplete(await t.arrayBuffer());return}const n=await fetch(this.url,{method:"GET"}).catch(u=>this.onError(u));if(!n||n&&!n.ok)return;const s=n.clone(),i=parseInt(n.headers.get("Content-Length")),o=s.body.getReader();let a=0;const c=[];for(;;){const{done:u,value:f}=await o.read();if(u)break;c.push(f),a+=f.length,this.message.innerText=`Now Loading... (${a} of ${i} byte)`,this.onProgress(a,i)}const l=new Uint8Array(a);let d=0;for(const u of c)l.set(u,d),d+=u.length;await e.put(this.url,n),this.onComplete(l)}}const Y=1/2**32;class Oe{float(e=1){return this.int()*Y*e}probability(e){return this.float()>>=0;const n=(t>>>0)-e;return n?e+this.int()%n:e}}const B=Math.random;class Te extends Oe{int(){return B()*4294967296>>>0}float(e=1){return B()*e}norm(e=1){return(B()-.5)*2*e}}const de=new Te,F={bins:2,scale:1,rnd:de},U=(r,e,t)=>{const n=new Array(r);for(let s=0;sr.reduce((e,t)=>e+t,0);function*ue(r,e){const t=[r[Symbol.iterator](),e[Symbol.iterator]()];for(let n=0;;n^=1){const s=t[n].next();if(s.done)return;yield s.value}}function*D(r){const{bins:e,scale:t,rnd:n}={...F,...r},s=U(e,t,n);s.forEach((a,c)=>s[c]=c&1?a:-a);const i=1/e;let o=_(s);for(let a=0,c=-1;;++a>=e&&(a=0))o-=s[a],o+=s[a]=c*n.norm(t),c^=4294967294,yield c*o*i}const Ne=r=>ue(D(r),D(r)),Ie=r=>{let e=32;return r&=-r,r&&e--,r&65535&&(e-=16),r&16711935&&(e-=8),r&252645135&&(e-=4),r&858993459&&(e-=2),r&1431655765&&(e-=1),e};function*Ge(r){const{bins:e=8,scale:t,rnd:n}={...F,...r},s=U(e,t,n),i=1/e;let o=_(s);for(let a=0;;a=a+1>>>0){const c=Ie(a)%e;o-=s[c],o+=s[c]=n.norm(t),yield o*i}}function*j(r){const{bins:e,scale:t,rnd:n}={...F,...r},s=U(e,t,n),i=1/e;let o=_(s);for(let a=0;;++a>=e&&(a=0))o-=s[a],o+=s[a]=n.norm(t),yield o*i}const Re=r=>ue(j(r),j(r));function*J(r){const{scale:e,rnd:t}={...F,...r};for(;;)yield t.norm(e)}const Fe=(r,e)=>r!=null&&typeof r[e]=="function",Le=r=>Fe(r,"xform")?r.xform():r,Be=r=>r!=null&&typeof r[Symbol.iterator]=="function",Pe=r=>r;class R{value;constructor(e){this.value=e}deref(){return this.value}}const Ve=r=>new R(r),qe=r=>r instanceof R,De=r=>r instanceof R?r:new R(r),ee=r=>r instanceof R?r.deref():r,je=(r,e)=>[r,Pe,e];function $e(r){return r?[...r]:je(()=>[],(e,t)=>(e.push(t),e))}function*He(r,e){const t=Le(r)($e()),n=t[1],s=t[2];for(let i of e){const o=s([],i);if(qe(o)){yield*ee(n(o.deref()));return}o.length&&(yield*o)}yield*ee(n([]))}const Ze=(r,e)=>[r[0],r[1],e];function fe(r,e){return Be(e)?He(fe(r),e):t=>{const n=t[2];let s=r;return Ze(t,(i,o)=>--s>0?n(i,o):s===0?De(n(i,o)):Ve(i))}}/** * @logue/reverb * * @description JavaScript Reverb effect class @@ -8,4 +8,4 @@ * @version 1.3.9 * @see {@link https://github.com/logue/Reverb.js} */const te={version:"1.3.9",date:"2024-04-24T08:29:36.615Z"},N={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},ze={noise:"white",scale:1,peaks:2,randomAlgorithm:de,decay:2,delay:0,reverse:!1,time:2,filterType:"allpass",filterFreq:2200,filterQ:1,mix:.5,once:!1};class A{static version=te.version;static build=te.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=J;constructor(e,t){this.ctx=e,this.options=Object.assign(ze,t),this.wetGainNode=this.ctx.createGain(),this.dryGainNode=this.ctx.createGain(),this.filterNode=this.ctx.createBiquadFilter(),this.convolverNode=this.ctx.createConvolver(),this.outputNode=this.ctx.createGain(),this.isConnected=!1,this.filterType(this.options.filterType),this.setNoise(this.options.noise),this.buildImpulse(),this.mix(this.options.mix)}connect(e){return this.isConnected&&this.options.once?(this.isConnected=!1,this.outputNode):(this.convolverNode.connect(this.filterNode),this.filterNode.connect(this.wetGainNode),e.connect(this.convolverNode),e.connect(this.dryGainNode).connect(this.outputNode),e.connect(this.wetGainNode).connect(this.outputNode),this.isConnected=!0,this.outputNode)}disconnect(e){return this.isConnected&&(this.convolverNode.disconnect(this.filterNode),this.filterNode.disconnect(this.wetGainNode)),this.isConnected=!1,e}mix(e){if(!A.inRange(e,0,1))throw new RangeError("[Reverb.js] Dry/Wet ratio must be between 0 to 1.");this.options.mix=e,this.dryGainNode.gain.value=1-this.options.mix,this.wetGainNode.gain.value=this.options.mix}time(e){if(!A.inRange(e,1,50))throw new RangeError("[Reverb.js] Time length of inpulse response must be less than 50sec.");this.options.time=e,this.buildImpulse()}decay(e){if(!A.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response decay level must be less than 100.");this.options.decay=e,this.buildImpulse()}delay(e){if(!A.inRange(e,0,100))throw new RangeError("[Reverb.js] Inpulse Response delay time must be less than 100.");this.options.delay=e,this.buildImpulse()}reverse(e){this.options.reverse=e,this.buildImpulse()}filterType(e="allpass"){this.filterNode.type=this.options.filterType=e}filterFreq(e){if(!A.inRange(e,20,2e4))throw new RangeError("[Reverb.js] Filter frequrncy must be between 20 and 20000.");this.options.filterFreq=e,this.filterNode.frequency.value=this.options.filterFreq}filterQ(e){if(!A.inRange(e,0,10))throw new RangeError("[Reverb.js] Filter Q value must be between 0 and 10.");this.options.filterQ=e,this.filterNode.Q.value=this.options.filterQ}peaks(e){this.options.peaks=e,this.buildImpulse()}scale(e){this.options.scale=e,this.buildImpulse()}randomAlgorithm(e){this.options.randomAlgorithm=e,this.buildImpulse()}setNoise(e){switch(this.options.noise=e,e){case N.blue:this.noise=D;break;case N.green:this.noise=Ne;break;case N.pink:this.noise=Ge;break;case N.red:case N.brown:this.noise=j;break;case N.violet:this.noise=Re;break;default:this.noise=J}this.buildImpulse()}setRandomAlgorythm(e){this.options.randomAlgorithm=e,this.buildImpulse()}static inRange(e,t,n){return(e-t)*(e-n)<=0}buildImpulse(){const e=this.ctx.sampleRate,t=Math.max(e*this.options.time,1),n=e*this.options.delay,s=this.ctx.createBuffer(2,t,e),i=new Float32Array(t),o=new Float32Array(t),a=this.getNoise(t),c=this.getNoise(t);for(let l=0;ln.forEach(s=>{s.target.dataset.isIntersecting=s.isIntersecting}),{}),this.timer=void 0,this.drag=!1}getAudioContext(){const e=new AudioContext,t=()=>{document.removeEventListener("touchstart",t);const n=e.createBufferSource();n.start(),n.stop()};return document.addEventListener("touchstart",t),e}init(e="GM"){this.gainMaster.disconnect(),this.refreshInstruments(this.input),this.mode=e;for(let t=0;t<16;++t)this.setPercussionPart(t,t===9),this.programChange(t,0),this.volumeChange(t,100),this.panpotChange(t,64),this.pitchBend(t,0,64),this.pitchBendSensitivity(t,2),this.hold(t,0),this.expression(t,127),this.bankSelectMsb(t,t===9?127:0),this.bankSelectLsb(t,t===9?127:0),this.attackTime(t,64),this.decayTime(t,64),this.sustinTime(t,64),this.releaseTime(t,64),this.harmonicContent(t,64),this.cutOffFrequency(t,64),this.reverbDepth(t,40),this.modulationDepth(t,0),this.updateBankSelect(t),this.updateProgramSelect(t);this.setPercussionPart(9,!0);for(let t=0;t<128;++t)this.percussionVolume[t]=127;if(this.setMasterVolume(8192),this.gainMaster.connect(this.ctx.destination),this.element){const t=this.element.querySelector(".header .keys div");t.innerText=e+" Mode",this.element.querySelectorAll(".instrument .bank > select").forEach(s=>s.disabled=e==="GM"),this.element.dataset.mode=e}}async close(){await this.ctx.close()}refreshInstruments(e){this.input=e,this.parser=new G(e,{sampleRate:this.ctx.sampleRate}),this.bankSet=this.createAllInstruments()}createAllInstruments(){const e=this.parser;e.parse();const t=e.createPreset(),n=e.createInstrument(),s=[];let i,o,a,c,l;const d=[];return t.forEach(u=>{c=u.header.preset,o=u.header.bank,l=u.name.replace(/\0*$/,""),typeof u.instrument=="number"&&(a=n[u.instrument],a.name.replace(/\0*$/,"")!=="EOI"&&(s[o]=s[o]??[],i=s[o],i[c]={},i[c].name=l,a.info.forEach(f=>this.createNoteInfo(e,f,i[c])),d[o]||(d[o]=[]),d[o][c]=l))}),this.programSet=d,s}createNoteInfo(e,t,n){const s=t.generator;if(!s.keyRange||!s.sampleID)return;const i=this.getModGenAmount(s,"delayVolEnv"),o=this.getModGenAmount(s,"attackVolEnv"),a=this.getModGenAmount(s,"holdVolEnv"),c=this.getModGenAmount(s,"decayVolEnv"),l=this.getModGenAmount(s,"sustainVolEnv"),d=this.getModGenAmount(s,"releaseVolEnv"),u=this.getModGenAmount(s,"delayModEnv"),f=this.getModGenAmount(s,"attackModEnv"),h=this.getModGenAmount(s,"holdModEnv"),m=this.getModGenAmount(s,"decayModEnv"),b=this.getModGenAmount(s,"sustainModEnv"),p=this.getModGenAmount(s,"releaseModEnv"),y=this.getModGenAmount(s,"scaleTuning")/100,w=this.getModGenAmount(s,"coarseTune")+this.getModGenAmount(s,"fineTune")/100,k=this.getModGenAmount(s,"sampleModes");for(let v=s.keyRange.lo,E=s.keyRange.hi;v<=E;++v){if(n[v])continue;const C=this.getModGenAmount(s,"sampleID"),S=e.sampleHeader[C];n[v]={sample:e.sample[C],sampleRate:S.sampleRate,sampleModes:k,basePlaybackRate:1.0594630943592953**((v-this.getModGenAmount(s,"overridingRootKey")+w+S.pitchCorrection/100)*y),modEnvToPitch:this.getModGenAmount(s,"modEnvToPitch")/100,scaleTuning:y,start:this.getModGenAmount(s,"startAddrsCoarseOffset")*32768+this.getModGenAmount(s,"startAddrsOffset"),end:this.getModGenAmount(s,"endAddrsCoarseOffset")*32768+this.getModGenAmount(s,"endAddrsOffset"),loopStart:S.startLoop+this.getModGenAmount(s,"startloopAddrsCoarseOffset")*32768+this.getModGenAmount(s,"startloopAddrsOffset"),loopEnd:S.endLoop+this.getModGenAmount(s,"endloopAddrsCoarseOffset")*32768+this.getModGenAmount(s,"endloopAddrsOffset"),volDelay:2**(i/1200),volAttack:2**(o/1200),volHold:2**(a/1200)*2**((60-v)*this.getModGenAmount(s,"keynumToVolEnvHold")/1200),volDecay:2**(c/1200)*2**((60-v)*this.getModGenAmount(s,"keynumToVolEnvDecay")/1200),volSustain:l/1e3,volRelease:2**(d/1200),modDelay:2**(u/1200),modAttack:2**(f/1200),modHold:2**(h/1200)*2**((60-v)*this.getModGenAmount(s,"keynumToModEnvHold")/1200),modDecay:2**(m/1200)*2**((60-v)*this.getModGenAmount(s,"keynumToModEnvDecay")/1200),modSustain:b/1e3,modRelease:2**(p/1200),initialFilterFc:8.176*Math.pow(2,this.getModGenAmount(s,"initialFilterFc")/1200),modEnvToFilterFc:this.getModGenAmount(s,"modEnvToFilterFc")/100,initialFilterQ:this.getModGenAmount(s,"initialFilterQ")/10,reverbEffectSend:this.getModGenAmount(s,"reverbEffectSend")/10,initialAttenuation:this.getModGenAmount(s,"initialAttenuation")/10,freqVibLFO:8.176*Math.pow(2,this.getModGenAmount(s,"freqVibLFO")/1200),pan:this.getModGenAmount(s,"pan")/1200}}}getModGenAmount(e,t){return e[t]?e[t].amount:G.getGeneratorTable()[t]}start(){this.connect(),this.bufSrc.start(0),this.setMasterVolume(16383)}setMasterVolume(e){this.masterVolume=e,this.gainMaster.gain.value=this.baseVolume*(e/16384)}connect(){this.bufSrc.connect(this.gainMaster)}disconnect(){this.bufSrc.disconnect(this.gainMaster),this.bufSrc.buffer=null}drawSynth(){const e=window.document,t=this.element=e.createElement("div");t.className="synthesizer";const n=e.createElement("div");n.className="instrument",this.items=["mute","bank","program","volume","expression","panpot","pitchBend","pitchBendSensitivity","reverbDepth","keys"];const s="ontouchstart"in window?"touchstart":"mousedown",i="ontouchend"in window?"touchend":"mouseup";for(let l=0;l<16;l++){const d=e.createElement("div");d.className="channel",d.addEventListener(s,()=>{this.hold(l,0)});for(const u in this.items){if(!Object.hasOwn(this.items,u))continue;const f=e.createElement("div");switch(f.className=this.items[u],this.items[u]){case"mute":{const h=e.createElement("div");h.className="form-check form-check-inline";const m=e.createElement("input");m.ariaLabel=`Ch.${l+1} Mute`,m.setAttribute("type","checkbox"),m.className="form-check-input",m.id="mute"+l+"ch",m.value=l.toString(),m.addEventListener("change",p=>{this.mute(l,p.target.checked)},!1),h.appendChild(m);const b=e.createElement("label");b.className="form-check-label",b.textContent=(l+1).toString(),b.setAttribute("for","mute"+l+"ch"),h.appendChild(b),f.appendChild(h);break}case"bank":{const h=e.createElement("select");h.ariaLabel=`Ch.${l+1} Bank Select`,h.className="form-select form-select-sm bank-select",h.addEventListener("change",((m,b)=>p=>{const y=d.querySelector(".program select");m.bankChange(b,p.target.value),m.programChange(b,parseInt(y.value))})(this,l),!1),f.appendChild(h);break}case"program":{const h=e.createElement("select");h.className="form-select form-select-sm",h.ariaLabel=`Ch.${l+1} Program Change`,h.addEventListener("change",((m,b)=>p=>{m.programChange(b,p.target.value)})(this,l),!1),f.appendChild(h);break}case"volume":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Volume`,h.innerText="100",f.appendChild(h);break}case"expression":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Expression`,h.innerText="127",f.appendChild(h);break}case"pitchBendSensitivity":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Pitch Bend Sensitivity`,h.innerText="2",f.appendChild(h);break}case"reverbDepth":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Reverb Depth`,h.innerText="40",f.appendChild(h);break}case"panpot":{const h=e.createElement("div");h.role="progressbar",h.ariaLabel=`Ch.${l+1} Panpod`,h.ariaValueMin="0",h.ariaValueNow="64",h.ariaValueMax="127",h.className="progress";const m=e.createElement("div");m.className="progress-bar",h.appendChild(m),f.appendChild(h);break}case"pitchBend":{const h=e.createElement("div");h.className="progress",h.role="progressbar",h.ariaLabel=`Ch.${l+1} Pitch Bend`,h.ariaValueMin="-8192",h.ariaValueNow="0",h.ariaValueMax="8192",h.className="progress";const m=e.createElement("div");m.className="progress-bar progress-bar-animated",h.appendChild(m),f.appendChild(h);break}case"keys":{for(let h=0;h<127;h++){const m=e.createElement("div"),b=h%12;m.className="key "+([1,3,6,8,10].includes(b)?"semitone":"tone"),f.appendChild(m),m.addEventListener(s,((p,y,w)=>k=>{k.preventDefault(),p.drag=!0,p.noteOn(y,w,127)})(this,l,h)),m.addEventListener("mouseover",((p,y,w)=>k=>{k.preventDefault(),p.drag&&p.noteOn(y,w,127)})(this,l,h)),m.addEventListener("mouseout",((p,y,w)=>k=>{k.preventDefault(),p.noteOff(y,w)})(this,l,h)),m.addEventListener(i,((p,y,w)=>k=>{k.preventDefault(),p.drag=!1,p.noteOff(y,w)})(this,l,h))}break}}d.appendChild(f)}n.appendChild(d),this.intersection.observe(d)}const o=["Ch.","Bank","Program","Vol.","Exp.","Panpot","Pitch Bend","","Rev.",""],a=e.createElement("div");a.className="header";for(const l in this.items){if(!Object.hasOwn(this.items,l))continue;const d=e.createElement("div");d.className=this.items[l],d.textContent=o[l],this.items[l]==="keys"&&(d.appendChild(document.createElement("code")),d.appendChild(document.createElement("div"))),a.appendChild(d)}return n.prepend(a),t.appendChild(n),new ResizeObserver(l=>{this.items.forEach(u=>{const f=t.querySelector(`.header .${u}`),h=t.querySelector(`.channel .${u}`);f.style.width=h.offsetWidth+"px"});const d=t.querySelector(".header .keys");d.style.display=document.documentElement.clientWidth<=680?"none":"flex"}).observe(t),t}updateSynthElement(e,t,n){if(!this.element)return;const s=this.element.querySelectorAll(".instrument > .channel");if(s[e].dataset.isIntersecting){const i=s[e].querySelector(`.key:nth-child(${t+1})`);n===0?(i.classList.contains("note-on")&&i.classList.remove("note-on"),i.style.opacity="1"):(i.classList.add("note-on"),i.style.opacity=(n/127).toFixed(2))}}updateBankSelect(e){if(!this.element)return;const t=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".bank > select");for(;t.firstChild;)t.removeChild(t.firstChild);for(const n in this.programSet){if(!Object.hasOwn(this.programSet,n))continue;const s=document.createElement("option");s.value=n,s.textContent=("000"+parseInt(n)).slice(-3),parseInt(n)===this.channelBank[e]&&(s.selected=!0),t.appendChild(s)}}updateProgramSelect(e){if(!this.element)return;const t=this.element.querySelectorAll(".instrument > .channel")[e],n=this.channelBank[e],s=t.querySelector(".bank > select"),i=t.querySelector(".program > select");for(s.value=this.channelBank[e].toString();i.firstChild;)i.removeChild(i.firstChild);for(const o in this.programSet[n]){if(!Object.hasOwn(this.programSet[n],o))continue;const a=document.createElement("option");a.value=o,a.textContent=`${("000"+(parseInt(o)+1)).slice(-3)}:${this.programSet[n][o]}`,parseInt(o)===this.channelInstrument[e]&&(a.selected=!0),i.appendChild(a)}}noteOn(e,t,n=100){const s=this.channelBank[e],i=typeof this.bankSet[s]=="object"?this.bankSet[s]:this.bankSet[0];let o;if(typeof i[this.channelInstrument[e]]=="object"?o=i[this.channelInstrument[e]]:this.percussionPart[e]?o=this.bankSet[this.mode==="XG"?127:128][0]:o=this.bankSet[0][this.channelInstrument[e]],!o[t]){console.warn("instrument not found: bank=%s instrument=%s channel=%s key=%s",s,this.channelInstrument[e],e,t);return}const a=o[t];let c=this.channelPanpot[e]===0?Math.floor(Math.random()*127):this.channelPanpot[e]-64;c/=c<0?64:63,a.channel=e,a.key=t,a.velocity=n,a.panpot=c,a.volume=this.channelVolume[e]/127,a.pitchBend=this.channelPitchBend[e]-8192,a.expression=this.channelExpression[e],a.pitchBendSensitivity=Math.round(this.channelPitchBendSensitivity[e]),a.mute=this.channelMute[e],a.releaseTime=this.channelRelease[e],a.cutOffFrequency=this.cutOffFrequency[e],a.harmonicContent=this.harmonicContent[e],a.reverb=this.reverb[e],a.modulation=this.modulation[e],s>=127&&((t===42||t===44)&&this.noteOff(e,46),t===80&&this.noteOff(e,81),o.volume*=this.percussionVolume[t]/127);const l=new Ue(this.ctx,this.gainMaster,a);l.noteOn(),this.currentNoteOn[e].push(l),this.updateSynthElement(e,t,n)}noteOff(e,t){let n,s;const i=this.currentNoteOn[e];let o;const a=this.channelHold[e];for(n=0,s=i.length;n64;let i,o,a;if(!s)for(o=0,a=n.length;o .channel");if(!c[e])return;this.channelHold[e]?c[e].classList.add("hold"):c[e].classList.contains("hold")&&c[e].classList.remove("hold")}}bankSelectMsb(e,t){this.percussionPart[e]=t>=125,this.channelBank[e]=e===9?128:0,this.mode!=="GM"&&(this.mode==="XG"?t===64?this.channelBank[e]=125:t===126||t===127?this.channelBank[e]=t:t===128&&(this.channelBank[e]=127):(this.channelBank[e]=e===9?128:t,this.percussionPart[e]=t===128),this.updateBankSelect(e))}bankSelectLsb(e,t){this.mode==="XG"&&(this.percussionPart[e]||(this.channelBank[e]=t),this.updateBankSelect(e))}programChange(e,t){if(this.channelInstrument[e]=t,this.bankChange(e,this.channelBank[e]),this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".program > select");n.value=t.toString()}}bankChange(e,t){const n=this.mode==="XG"||this.mode==="GM"?127:128;if(this.mode==="GM"&&(t=0),e===9&&(t=n),this.bankSet[t]?this.channelBank[e]=t:this.channelBank[e]=this.percussionPart[e]?n:0,this.element){const s=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".bank > select");s.value=t.toString()}this.updateProgramSelect(e)}volumeChange(e,t){if(this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".volume var");n.innerText=t.toString()}this.channelVolume[e]=t}expression(e,t){let n,s;const i=this.currentNoteOn[e];for(n=0,s=i.length;n .channel")[e].querySelector(".expression var");o.innerText=t.toString()}this.channelExpression[e]=t}panpotChange(e,t){if(this.channelPanpot[e]=t,this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".panpot");n.ariaValueNow=t.toString();const s=n.querySelector(".progress-bar"),i=t/127*100;if(s.style.width=`${i}%`,s.classList.remove("left","right"),s.title=t.toString(),t===64)return;n.classList.add(t<63?"left":"right")}}pitchBend(e,t,n){const s=t&127|(n&127)<<7;let i,o;const a=this.currentNoteOn[e],c=s-8192;for(i=0,o=a.length;i .channel")[e].querySelector(".pitchBend");l.ariaValueNow=s.toString();const d=l.querySelector(".progress-bar");if(d.style.width=`${Math.floor(s/16384*100)}%`,d.title=c.toString(),d.classList.remove("high","low"),c===0)return;d.classList.add(c<0?"low":"high")}}pitchBendSensitivity(e,t){if(this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".pitchBendSensitivity > var");n.innerText=t.toString()}this.channelPitchBendSensitivity[e]=t}attackTime(e,t){this.channelAttack[e]=t}decayTime(e,t){this.channelDecay[e]=t}sustinTime(e,t){this.channelSustin[e]=t}releaseTime(e,t){this.channelRelease[e]=t}harmonicContent(e,t){this.channelHarmonicContent[e]=t}cutOffFrequency(e,t){this.channelCutOffFrequency[e]=t}reverbDepth(e,t){if(this.reverb[e].mix(t/127),this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".reverbDepth var");n.innerText=t.toString()}}modulationDepth(e,t){if(this.element){const n=this.element.querySelectorAll(".instrument > .channel")[e].querySelector(".pitchBend .progress-bar");t!==0?n.classList.add("progress-bar-striped"):n.classList.remove("progress-bar-striped")}this.modulation[e]=t}getPitchBendSensitivity(e){return this.channelPitchBendSensitivity[e]}drumInstrumentLevel(e,t){this.percussionVolume[e]=t}allNoteOff(e){const t=this.currentNoteOn[e];for(this.hold(e,0);t.length>0;)this.noteOff(e,t[0].key)}allSoundOff(e){const t=this.currentNoteOn[e];let n;for(;t.length>0;)n=t.shift(),this.noteOff(e,n.key),n.release(),n.disconnect();this.hold(e,0)}resetAllControl(e){this.allNoteOff(e),this.expression(e,127),this.pitchBend(e,0,64)}mute(e,t){const n=this.currentNoteOn[e];let s,i;if(this.channelMute[e]=t,t)for(s=0,i=n.length;sString.fromCharCode(n)).join(""),this.timer=setTimeout(()=>{t.innerText=""},5e4)}}class me{constructor(e={}){this.NrpnMsb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.NrpnLsb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.RpnMsb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.RpnLsb=[0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0],this.ready=!1,this.synth=void 0,this.messageHandler=this.onMessage.bind(this),this.rpnMode=!0,this.option={},this.option.drawSynth=e.drawSynth!=="false",this.option.cache=e.cache??!0,this.option.targetOrigin=e.targetOrigin??"*",this.option.colorMode=e.colorMode??"auto",this.url=e.url??"https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2",this.placeholder=e.placeholder?document.getElementById(e.placeholder):window.document.body,this.setColorMode(this.option.colorMode),this.window=null,window.opener?this.window=window.opener:window.parent!==window?this.window=window.parent:this.window=window}async setup(e=void 0){for(;this.placeholder.firstChild;)this.placeholder.removeChild(this.placeholder.firstChild);e&&(this.url=e),await new z(this.url,this.placeholder,this.option.cache,n=>this.setupByBuffer(n)).fetch()}getUrl(){return this.url}setupByBuffer(e){for(;this.placeholder.firstChild;)this.placeholder.removeChild(this.placeholder.firstChild);if(this.synth?this.synth.refreshInstruments(e):(this.synth=new _e(e),this.synth.start()),this.option.drawSynth)this.placeholder.appendChild(this.synth.drawSynth());else{const t=document.createElement("div");t.className="alert alert-success",t.role="alert",t.innerText="Ready.",this.placeholder.appendChild(t)}this.synth.init(),this.onReady()}callback(){}onReady(){window.removeEventListener("message",this.messageHandler),this.callback(),window.addEventListener("message",this.messageHandler,!1),this.window.postMessage("link,ready",this.option.targetOrigin)}onMessage(e){const t=typeof e.data.split=="function"?e.data.split(","):[],n=t.length!==0?t.shift():"";let s;switch(n){case"midi":this.processMidiMessage(t.map(i=>parseInt(i,16)));break;case"link":if(!this.window)return;switch(s=t.shift(),s){case"reqpatch":this.window.postMessage("link,patch",this.option.targetOrigin);break;case"setpatch":case"ready":this.window.postMessage("link,ready",this.option.targetOrigin);break;case"progress":this.window.postMessage("link,progress",this.option.targetOrigin);break;default:console.error("unknown link message:",s);break}break;default:console.error("unknown message type")}}setLoadCallback(e){this.callback=e}processMidiMessage(e){const t=e[0]&15,n=this.synth;switch(e[0]&240){case 128:n.noteOff(t,e[1],e[2]);break;case 144:e[2]>0?n.noteOn(t,e[1],e[2]):n.noteOff(t,e[1],0);break;case 176:{const s=e[2];switch(e[1]){case 0:n.bankSelectMsb(t,s);break;case 1:n.modulationDepth(t,s);break;case 5:break;case 6:if(this.rpnMode)switch(this.RpnMsb[t]){case 0:switch(this.RpnLsb[t]){case 0:n.pitchBendSensitivity(t,s);break}break}else switch(this.NrpnMsb[t]){case 26:n.drumInstrumentLevel(this.NrpnLsb[t],s);break}break;case 38:if(this.rpnMode)switch(this.RpnMsb[t]){case 0:switch(this.RpnLsb[t]){case 0:n.pitchBendSensitivity(t,n.getPitchBendSensitivity(t)+s/100);break}break}break;case 7:n.volumeChange(t,s);break;case 10:n.panpotChange(t,s);break;case 120:n.allSoundOff(t);break;case 121:n.resetAllControl(t);break;case 32:n.bankSelectLsb(t,s);break;case 71:n.harmonicContent(t,s);break;case 96:break;case 97:break;case 98:this.rpnMode=!1,this.NrpnLsb[t]=s;break;case 99:this.rpnMode=!1,this.NrpnMsb[t]=s;break;case 100:this.rpnMode=!0,this.RpnLsb[t]=s;break;case 101:this.rpnMode=!0,this.RpnMsb[t]=s;break;case 64:n.hold(t,s);break;case 11:n.expression(t,s);break;case 72:n.decayTime(t,s);break;case 73:n.releaseTime(t,s);break;case 74:n.attackTime(t,s);break;case 75:n.cutOffFrequency(t,s);break;case 91:n.reverbDepth(t,s);break}break}case 192:n.programChange(t,e[1]);break;case 224:n.pitchBend(t,e[1],e[2]);break;case 240:{e.splice(1,1);const s=e[1],i=e[2],o=e[3];if(s===126||i===9)switch(o){case 1:n.init("GM"),console.info("\x1B[34mGM System On\x1B[0m");break;case 2:console.info("\x1B[34mGM System Off\x1B[0m");break;case 3:console.info("\x1B[34mGM (v2) System On\x1B[0m"),n.init("GM2");break;default:console.log("\x1B[34mGM\x1B[0m: "+this.dumpMessage(e))}else s===127?o===1?n.setMasterVolume(e[4]+(e[5]<<7)):console.log("\x1B[34mRealtime\x1B[0m: "+this.dumpMessage(e)):s===125&&e[4]===1&&(e[5]===1?this.setColorMode("light"):e[5]===2?this.setColorMode("dark"):this.setColorMode("auto"));if(o===66){const a=e[6]-15,c=e[7],l=e[8];switch(c){case 0:if(a===0){const d=e.splice(8);d.pop(),d.pop(),n.processMidiMessage(d)}else console.log("\x1B[31mGS Bitmap message\x1B[0m:"+this.dumpMessage(e));break;case 4:n.setMasterVolume(l*64);break;case 21:{a===0?n.setPercussionPart(9,l!==0):a>=10?n.setPercussionPart(a-1,l!==0):n.setPercussionPart(a,l!==0);break}case 25:console.info("\x1B[31mGS Volume On/Off\x1B[0m: "+a,l);break;case 48:console.info("\x1B[31mGS Reverb\x1B[0m: "+this.dumpMessage(e));break;case 56:console.info("\x1B[31mGS Chorus\x1B[0m: "+this.dumpMessage(e));break;case 69:console.info("\x1B[31mGS Bitmap\x1B[0m: "+this.dumpMessage(e));break;case 127:n.init("GS"),console.info("\x1B[31mGS Reset\x1B[0m");break;default:console.log("\x1B[31mGS\x1B[0m: "+this.dumpMessage(e))}}else if(o===76){const a=e[4],c=e[5];switch(a){case 0:e[6]===126&&(n.init("XG"),console.info("\x1B[32mXG Reset\x1B[0m"));break;case 2:console.log("\x1B[32mXG Effect\x1B[0m: "+this.dumpMessage(e));break;case 3:console.log("\x1B[32mXG Insertion Effect\x1B[0m: "+this.dumpMessage(e));break;case 4:n.setMasterVolume(e[9]*64);break;case 6:{const l=e.splice(8);l.pop(),n.processMidiMessage(l);break}case 7:console.log("\x1B[32mXG Bitmap\x1B[0m: "+this.dumpMessage(e));break;case 8:n.setPercussionPart(c,e[8]!==0);break;default:console.log("\x1B[32mXG\x1B[0m: ",this.dumpMessage(e))}}break}default:n.setPercussionPart(9,!0);break}}dumpMessage(e){const t=[];let n=0;for(const s of e){let i="";switch(n){case 0:i="\x1B[35m";break;case 1:case 2:case 3:i="\x1B[33m";break;default:i=e.length-1===n?"\x1B[35m":"\x1B[36m";break}t.push(i+s.toString(16).toUpperCase().padStart(2,"0")),n++}return t.join(" ")+"\x1B[0m"}setColorMode(e){e?(e==="auto"&&(e=window.matchMedia("(prefers-color-scheme: dark)").matches?"dark":"light"),document.documentElement.setAttribute("data-bs-theme",e)):(document.documentElement.setAttribute("data-bs-theme","auto"),document.documentElement.removeAttribute("data-bs-theme"))}}class Xe extends me{constructor(e={}){super(e),this.midi=void 0}async setup(e){this.midi=await window.navigator.requestMIDIAccess({sysex:!0}),await super.setup(e)}onReady(){super.callback(),this.midi.inputs.forEach(e=>e.onmidimessage=t=>super.processMidiMessage(Array.from(t.data)))}}const $={version:W.version,build:W.date,WebMidiLink:me,WebMidiApi:Xe,Parser:G};let pe={drawSynth:!0,placeholder:"placeholder",colorMode:"auto",...q.parse(window.location.search),...q.parse(window.location.hash)};const O=new $.WebMidiLink(pe);document.addEventListener("DOMContentLoaded",r=>{const e=document.getElementById("file"),t=document.getElementById("drag"),n=document.getElementById("build"),s=document.getElementById("toggleDarkMode");O.setLoadCallback(()=>{t.classList.remove("bg-info"),document.getElementById("soundfont").innerText=decodeURIComponent(O.getUrl()).match(".+/(.+?)([?#;].*)?$")[1]}),n.dateTime=$.build,n.innerText=new Date($.build).toLocaleString(),O.setup();const i=window.matchMedia("(prefers-color-scheme: dark)");i.addListener(()=>{document.documentElement.getAttribute("data-bs-theme")||(O.setColorMode(pe.colorMode),s.checked=i.matches)});const o=a=>{const c=new FileReader;c.readAsArrayBuffer(a),c.onload=l=>{document.getElementById("soundfont").innerText=a.name;const d=new Uint8Array(l.target.result);O.setupByBuffer(d)}};e.addEventListener("change",a=>{a.preventDefault(),o(e.files[0]),e.value=""},!1),t.addEventListener("drop",a=>{const c=a.dataTransfer;c.files.length&&(a.preventDefault(),a.stopPropagation(),o(c.files[0])),t.classList.remove("bg-info")},!1),t.addEventListener("dragover",a=>{a.preventDefault(),a.stopPropagation(),t.classList.add("bg-info")},!1),t.addEventListener("dragleave",a=>{a.preventDefault(),a.stopPropagation(),t.classList.remove("bg-info")},!1),s.addEventListener("change",a=>{O.setColorMode(a.target.checked?"dark":"light")})},!1);window.addEventListener("hashchange",()=>{const r=q.parse(window.location.hash);r&&O.setup(r)},!1); -//# sourceMappingURL=index-Cb8h-mHG.js.map +//# sourceMappingURL=index-BLLwekxr.js.map diff --git a/assets/index-Cb8h-mHG.js.map b/assets/index-BLLwekxr.js.map similarity index 99% rename from assets/index-Cb8h-mHG.js.map rename to assets/index-BLLwekxr.js.map index 9e594a6..e33bf13 100644 --- a/assets/index-Cb8h-mHG.js.map +++ b/assets/index-BLLwekxr.js.map @@ -1 +1 @@ -{"version":3,"file":"index-Cb8h-mHG.js","sources":["../../node_modules/decode-uri-component/index.js","../../node_modules/split-on-first/index.js","../../node_modules/filter-obj/index.js","../../node_modules/query-string/base.js","../../src/meta.js","../../src/riff.js","../../src/sf2.js","../../src/loader.js","../../node_modules/@thi.ng/random/arandom.js","../../node_modules/@thi.ng/random/system.js","../../node_modules/@thi.ng/colored-noise/api.js","../../node_modules/@thi.ng/colored-noise/utils.js","../../node_modules/@thi.ng/colored-noise/blue.js","../../node_modules/@thi.ng/colored-noise/green.js","../../node_modules/@thi.ng/binary/count.js","../../node_modules/@thi.ng/colored-noise/pink.js","../../node_modules/@thi.ng/colored-noise/red.js","../../node_modules/@thi.ng/colored-noise/violet.js","../../node_modules/@thi.ng/colored-noise/white.js","../../node_modules/@thi.ng/checks/implements-function.js","../../node_modules/@thi.ng/transducers/ensure.js","../../node_modules/@thi.ng/checks/is-iterable.js","../../node_modules/@thi.ng/api/fn.js","../../node_modules/@thi.ng/transducers/reduced.js","../../node_modules/@thi.ng/transducers/reduce.js","../../node_modules/@thi.ng/transducers/push.js","../../node_modules/@thi.ng/transducers/iterator.js","../../node_modules/@thi.ng/transducers/compr.js","../../node_modules/@thi.ng/transducers/take.js","../../node_modules/@logue/reverb/dist/Reverb.es.js","../../src/sound_font_synth_note.js","../../src/sound_font_synth.js","../../src/wml.js","../../src/web_midi_api.js","../../src/index.js","../../index.html?html-proxy&index=0.js"],"sourcesContent":["const token = '%[a-f0-9]{2}';\nconst singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');\nconst multiMatcher = new RegExp('(' + token + ')+', 'gi');\n\nfunction decodeComponents(components, split) {\n\ttry {\n\t\t// Try to decode the entire string first\n\t\treturn [decodeURIComponent(components.join(''))];\n\t} catch {\n\t\t// Do nothing\n\t}\n\n\tif (components.length === 1) {\n\t\treturn components;\n\t}\n\n\tsplit = split || 1;\n\n\t// Split the array in 2 parts\n\tconst left = components.slice(0, split);\n\tconst right = components.slice(split);\n\n\treturn Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));\n}\n\nfunction decode(input) {\n\ttry {\n\t\treturn decodeURIComponent(input);\n\t} catch {\n\t\tlet tokens = input.match(singleMatcher) || [];\n\n\t\tfor (let i = 1; i < tokens.length; i++) {\n\t\t\tinput = decodeComponents(tokens, i).join('');\n\n\t\t\ttokens = input.match(singleMatcher) || [];\n\t\t}\n\n\t\treturn input;\n\t}\n}\n\nfunction customDecodeURIComponent(input) {\n\t// Keep track of all the replacements and prefill the map with the `BOM`\n\tconst replaceMap = {\n\t\t'%FE%FF': '\\uFFFD\\uFFFD',\n\t\t'%FF%FE': '\\uFFFD\\uFFFD',\n\t};\n\n\tlet match = multiMatcher.exec(input);\n\twhile (match) {\n\t\ttry {\n\t\t\t// Decode as big chunks as possible\n\t\t\treplaceMap[match[0]] = decodeURIComponent(match[0]);\n\t\t} catch {\n\t\t\tconst result = decode(match[0]);\n\n\t\t\tif (result !== match[0]) {\n\t\t\t\treplaceMap[match[0]] = result;\n\t\t\t}\n\t\t}\n\n\t\tmatch = multiMatcher.exec(input);\n\t}\n\n\t// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else\n\treplaceMap['%C2'] = '\\uFFFD';\n\n\tconst entries = Object.keys(replaceMap);\n\n\tfor (const key of entries) {\n\t\t// Replace all decoded components\n\t\tinput = input.replace(new RegExp(key, 'g'), replaceMap[key]);\n\t}\n\n\treturn input;\n}\n\nexport default function decodeUriComponent(encodedURI) {\n\tif (typeof encodedURI !== 'string') {\n\t\tthrow new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');\n\t}\n\n\ttry {\n\t\t// Try the built in decoder first\n\t\treturn decodeURIComponent(encodedURI);\n\t} catch {\n\t\t// Fallback to a more advanced decoder\n\t\treturn customDecodeURIComponent(encodedURI);\n\t}\n}\n","export default function splitOnFirst(string, separator) {\n\tif (!(typeof string === 'string' && typeof separator === 'string')) {\n\t\tthrow new TypeError('Expected the arguments to be of type `string`');\n\t}\n\n\tif (string === '' || separator === '') {\n\t\treturn [];\n\t}\n\n\tconst separatorIndex = string.indexOf(separator);\n\n\tif (separatorIndex === -1) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\tstring.slice(0, separatorIndex),\n\t\tstring.slice(separatorIndex + separator.length)\n\t];\n}\n","export function includeKeys(object, predicate) {\n\tconst result = {};\n\n\tif (Array.isArray(predicate)) {\n\t\tfor (const key of predicate) {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (descriptor?.enumerable) {\n\t\t\t\tObject.defineProperty(result, key, descriptor);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// `Reflect.ownKeys()` is required to retrieve symbol properties\n\t\tfor (const key of Reflect.ownKeys(object)) {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (descriptor.enumerable) {\n\t\t\t\tconst value = object[key];\n\t\t\t\tif (predicate(key, value, object)) {\n\t\t\t\t\tObject.defineProperty(result, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function excludeKeys(object, predicate) {\n\tif (Array.isArray(predicate)) {\n\t\tconst set = new Set(predicate);\n\t\treturn includeKeys(object, key => !set.has(key));\n\t}\n\n\treturn includeKeys(object, (key, value, object) => !predicate(key, value, object));\n}\n","import decodeComponent from 'decode-uri-component';\nimport splitOnFirst from 'split-on-first';\nimport {includeKeys} from 'filter-obj';\n\nconst isNullOrUndefined = value => value === null || value === undefined;\n\n// eslint-disable-next-line unicorn/prefer-code-point\nconst strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);\n\nconst encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');\n\nfunction encoderForArrayFormat(options) {\n\tswitch (options.arrayFormat) {\n\t\tcase 'index': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tconst index = result.length;\n\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result, [encode(key, options), '[', index, ']'].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\t[encode(key, options), '[]'].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '[]=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'colon-list-separator': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\t[encode(key, options), ':list='].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), ':list=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'comma':\n\t\tcase 'separator':\n\t\tcase 'bracket-separator': {\n\t\t\tconst keyValueSeparator = options.arrayFormat === 'bracket-separator'\n\t\t\t\t? '[]='\n\t\t\t\t: '=';\n\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\t// Translate null to an empty string so that it doesn't serialize as 'null'\n\t\t\t\tvalue = value === null ? '' : value;\n\n\t\t\t\tif (result.length === 0) {\n\t\t\t\t\treturn [[encode(key, options), keyValueSeparator, encode(value, options)].join('')];\n\t\t\t\t}\n\n\t\t\t\treturn [[result, encode(value, options)].join(options.arrayFormatSeparator)];\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tencode(key, options),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction parserForArrayFormat(options) {\n\tlet result;\n\n\tswitch (options.arrayFormat) {\n\t\tcase 'index': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /\\[(\\d*)]$/.exec(key);\n\n\t\t\t\tkey = key.replace(/\\[\\d*]$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = {};\n\t\t\t\t}\n\n\t\t\t\taccumulator[key][result[1]] = value;\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /(\\[])$/.exec(key);\n\t\t\t\tkey = key.replace(/\\[]$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = [value];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], value];\n\t\t\t};\n\t\t}\n\n\t\tcase 'colon-list-separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /(:list)$/.exec(key);\n\t\t\t\tkey = key.replace(/:list$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = [value];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], value];\n\t\t\t};\n\t\t}\n\n\t\tcase 'comma':\n\t\tcase 'separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tconst isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);\n\t\t\t\tconst isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));\n\t\t\t\tvalue = isEncodedArray ? decode(value, options) : value;\n\t\t\t\tconst newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : (value === null ? value : decode(value, options));\n\t\t\t\taccumulator[key] = newValue;\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket-separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tconst isArray = /(\\[])$/.test(key);\n\t\t\t\tkey = key.replace(/\\[]$/, '');\n\n\t\t\t\tif (!isArray) {\n\t\t\t\t\taccumulator[key] = value ? decode(value, options) : value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst arrayValue = value === null\n\t\t\t\t\t? []\n\t\t\t\t\t: value.split(options.arrayFormatSeparator).map(item => decode(item, options));\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = arrayValue;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], ...arrayValue];\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...[accumulator[key]].flat(), value];\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction validateArrayFormatSeparator(value) {\n\tif (typeof value !== 'string' || value.length !== 1) {\n\t\tthrow new TypeError('arrayFormatSeparator must be single character string');\n\t}\n}\n\nfunction encode(value, options) {\n\tif (options.encode) {\n\t\treturn options.strict ? strictUriEncode(value) : encodeURIComponent(value);\n\t}\n\n\treturn value;\n}\n\nfunction decode(value, options) {\n\tif (options.decode) {\n\t\treturn decodeComponent(value);\n\t}\n\n\treturn value;\n}\n\nfunction keysSorter(input) {\n\tif (Array.isArray(input)) {\n\t\treturn input.sort();\n\t}\n\n\tif (typeof input === 'object') {\n\t\treturn keysSorter(Object.keys(input))\n\t\t\t.sort((a, b) => Number(a) - Number(b))\n\t\t\t.map(key => input[key]);\n\t}\n\n\treturn input;\n}\n\nfunction removeHash(input) {\n\tconst hashStart = input.indexOf('#');\n\tif (hashStart !== -1) {\n\t\tinput = input.slice(0, hashStart);\n\t}\n\n\treturn input;\n}\n\nfunction getHash(url) {\n\tlet hash = '';\n\tconst hashStart = url.indexOf('#');\n\tif (hashStart !== -1) {\n\t\thash = url.slice(hashStart);\n\t}\n\n\treturn hash;\n}\n\nfunction parseValue(value, options) {\n\tif (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {\n\t\tvalue = Number(value);\n\t} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {\n\t\tvalue = value.toLowerCase() === 'true';\n\t}\n\n\treturn value;\n}\n\nexport function extract(input) {\n\tinput = removeHash(input);\n\tconst queryStart = input.indexOf('?');\n\tif (queryStart === -1) {\n\t\treturn '';\n\t}\n\n\treturn input.slice(queryStart + 1);\n}\n\nexport function parse(query, options) {\n\toptions = {\n\t\tdecode: true,\n\t\tsort: true,\n\t\tarrayFormat: 'none',\n\t\tarrayFormatSeparator: ',',\n\t\tparseNumbers: false,\n\t\tparseBooleans: false,\n\t\t...options,\n\t};\n\n\tvalidateArrayFormatSeparator(options.arrayFormatSeparator);\n\n\tconst formatter = parserForArrayFormat(options);\n\n\t// Create an object with no prototype\n\tconst returnValue = Object.create(null);\n\n\tif (typeof query !== 'string') {\n\t\treturn returnValue;\n\t}\n\n\tquery = query.trim().replace(/^[?#&]/, '');\n\n\tif (!query) {\n\t\treturn returnValue;\n\t}\n\n\tfor (const parameter of query.split('&')) {\n\t\tif (parameter === '') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst parameter_ = options.decode ? parameter.replaceAll('+', ' ') : parameter;\n\n\t\tlet [key, value] = splitOnFirst(parameter_, '=');\n\n\t\tif (key === undefined) {\n\t\t\tkey = parameter_;\n\t\t}\n\n\t\t// Missing `=` should be `null`:\n\t\t// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters\n\t\tvalue = value === undefined ? null : (['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options));\n\t\tformatter(decode(key, options), value, returnValue);\n\t}\n\n\tfor (const [key, value] of Object.entries(returnValue)) {\n\t\tif (typeof value === 'object' && value !== null) {\n\t\t\tfor (const [key2, value2] of Object.entries(value)) {\n\t\t\t\tvalue[key2] = parseValue(value2, options);\n\t\t\t}\n\t\t} else {\n\t\t\treturnValue[key] = parseValue(value, options);\n\t\t}\n\t}\n\n\tif (options.sort === false) {\n\t\treturn returnValue;\n\t}\n\n\t// TODO: Remove the use of `reduce`.\n\t// eslint-disable-next-line unicorn/no-array-reduce\n\treturn (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {\n\t\tconst value = returnValue[key];\n\t\tresult[key] = Boolean(value) && typeof value === 'object' && !Array.isArray(value) ? keysSorter(value) : value;\n\t\treturn result;\n\t}, Object.create(null));\n}\n\nexport function stringify(object, options) {\n\tif (!object) {\n\t\treturn '';\n\t}\n\n\toptions = {\n\t\tencode: true,\n\t\tstrict: true,\n\t\tarrayFormat: 'none',\n\t\tarrayFormatSeparator: ',',\n\t\t...options,\n\t};\n\n\tvalidateArrayFormatSeparator(options.arrayFormatSeparator);\n\n\tconst shouldFilter = key => (\n\t\t(options.skipNull && isNullOrUndefined(object[key]))\n\t\t|| (options.skipEmptyString && object[key] === '')\n\t);\n\n\tconst formatter = encoderForArrayFormat(options);\n\n\tconst objectCopy = {};\n\n\tfor (const [key, value] of Object.entries(object)) {\n\t\tif (!shouldFilter(key)) {\n\t\t\tobjectCopy[key] = value;\n\t\t}\n\t}\n\n\tconst keys = Object.keys(objectCopy);\n\n\tif (options.sort !== false) {\n\t\tkeys.sort(options.sort);\n\t}\n\n\treturn keys.map(key => {\n\t\tconst value = object[key];\n\n\t\tif (value === undefined) {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (value === null) {\n\t\t\treturn encode(key, options);\n\t\t}\n\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length === 0 && options.arrayFormat === 'bracket-separator') {\n\t\t\t\treturn encode(key, options) + '[]';\n\t\t\t}\n\n\t\t\treturn value\n\t\t\t\t.reduce(formatter(key), [])\n\t\t\t\t.join('&');\n\t\t}\n\n\t\treturn encode(key, options) + '=' + encode(value, options);\n\t}).filter(x => x.length > 0).join('&');\n}\n\nexport function parseUrl(url, options) {\n\toptions = {\n\t\tdecode: true,\n\t\t...options,\n\t};\n\n\tlet [url_, hash] = splitOnFirst(url, '#');\n\n\tif (url_ === undefined) {\n\t\turl_ = url;\n\t}\n\n\treturn {\n\t\turl: url_?.split('?')?.[0] ?? '',\n\t\tquery: parse(extract(url), options),\n\t\t...(options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}),\n\t};\n}\n\nexport function stringifyUrl(object, options) {\n\toptions = {\n\t\tencode: true,\n\t\tstrict: true,\n\t\t[encodeFragmentIdentifier]: true,\n\t\t...options,\n\t};\n\n\tconst url = removeHash(object.url).split('?')[0] || '';\n\tconst queryFromUrl = extract(object.url);\n\n\tconst query = {\n\t\t...parse(queryFromUrl, {sort: false}),\n\t\t...object.query,\n\t};\n\n\tlet queryString = stringify(query, options);\n\tqueryString &&= `?${queryString}`;\n\n\tlet hash = getHash(object.url);\n\tif (typeof object.fragmentIdentifier === 'string') {\n\t\tconst urlObjectForFragmentEncode = new URL(url);\n\t\turlObjectForFragmentEncode.hash = object.fragmentIdentifier;\n\t\thash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;\n\t}\n\n\treturn `${url}${queryString}${hash}`;\n}\n\nexport function pick(input, filter, options) {\n\toptions = {\n\t\tparseFragmentIdentifier: true,\n\t\t[encodeFragmentIdentifier]: false,\n\t\t...options,\n\t};\n\n\tconst {url, query, fragmentIdentifier} = parseUrl(input, options);\n\n\treturn stringifyUrl({\n\t\turl,\n\t\tquery: includeKeys(query, filter),\n\t\tfragmentIdentifier,\n\t}, options);\n}\n\nexport function exclude(input, filter, options) {\n\tconst exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);\n\n\treturn pick(input, exclusionFilter, options);\n}\n","// This file is auto-generated by the build system.\nconst meta = {\n version: '0.7.0',\n date: '2024-04-25T09:40:40.419Z',\n};\nexport default meta;\n","/**\n * Riff Parser class\n *\n * @author imaya\n */\nexport class Riff {\n /**\n * @param {ArrayBuffer} input Input buffer.\n * @param {Object} [optParams] Option parameters.\n */\n constructor(input, optParams = {}) {\n /** @type {ArrayBuffer} */\n this.input = input;\n /** @type {number} */\n this.ip = optParams.index || 0;\n /** @type {number} */\n this.length = optParams.length || input.byteLength - this.ip;\n /** @type {RiffChunk[]} */\n this.chunkList = [];\n /** @type {number} */\n this.offset = this.ip;\n /** @type {boolean} */\n this.padding = optParams.padding !== undefined ? optParams.padding : true;\n /** @type {boolean} */\n this.bigEndian =\n optParams.bigEndian !== undefined ? optParams.bigEndian : false;\n }\n\n /** @returns {void} */\n parse() {\n /** @type {number} */\n const length = this.length + this.offset;\n\n this.chunkList = [];\n\n while (this.ip < length) {\n this.parseChunk();\n }\n }\n\n /** @returns {void} */\n parseChunk() {\n /** @type {ArrayBuffer} */\n const input = this.input;\n /** @type {number} */\n let ip = this.ip;\n /** @type {number} */\n let size;\n\n this.chunkList.push(\n new RiffChunk(\n String.fromCharCode(input[ip++], input[ip++], input[ip++], input[ip++]),\n (size = this.bigEndian\n ? ((input[ip++] << 24) |\n (input[ip++] << 16) |\n (input[ip++] << 8) |\n input[ip++]) >>>\n 0\n : (input[ip++] |\n (input[ip++] << 8) |\n (input[ip++] << 16) |\n (input[ip++] << 24)) >>>\n 0),\n ip\n )\n );\n\n ip += size;\n\n // padding\n if (this.padding && ((ip - this.offset) & 1) === 1) {\n ip++;\n }\n\n this.ip = ip;\n }\n\n /**\n * @param {number} index Chunk index.\n * @returns {RiffChunk | null}\n */\n getChunk(index) {\n /** @type {RiffChunk} */\n const chunk = this.chunkList[index];\n\n return chunk !== undefined ? chunk : null;\n }\n\n /** @returns {number} */\n getNumberOfChunks() {\n return this.chunkList.length;\n }\n}\n\n/**\n * Riff Chunk Structure\n *\n * @interface\n */\nexport class RiffChunk {\n /**\n * @param {string} type\n * @param {number} size\n * @param {number} offset\n */\n constructor(type, size, offset) {\n /** @type {string} */\n this.type = type;\n /** @type {number} */\n this.size = size;\n /** @type {number} */\n this.offset = offset;\n }\n}\n","import { Riff } from './riff.js';\n\n/**\n * SoundFont Parser Class\n *\n * @author imaya\n */\nexport default class Parser {\n /**\n * @param {Uint8Array} input\n * @param {Object} [optParams]\n */\n constructor(input, optParams = {}) {\n /** @type {Uint8Array} */\n this.input = input;\n /** @type {object} */\n this.parserOption = optParams.parserOption || {};\n /** @type {number} */\n this.sampleRate = optParams.sampleRate || 22050; // よくわからんが、OSで指定されているサンプルレートを入れないと音が切れ切れになる。\n\n /** @type {object[]} */\n this.presetHeader = [];\n /** @type {object[]} */\n this.presetZone = [];\n /** @type {object[]} */\n this.presetZoneModulator = [];\n /** @type {object[]} */\n this.presetZoneGenerator = [];\n /** @type {object[]} */\n this.instrument = [];\n /** @type {object[]} */\n this.instrumentZone = [];\n /** @type {object[]} */\n this.instrumentZoneModulator = [];\n /** @type {object[]} */\n this.instrumentZoneGenerator = [];\n /** @type {object[]} */\n this.sampleHeader = [];\n /** @type {string[]} */\n this.GeneratorEnumeratorTable = Object.keys(Parser.getGeneratorTable());\n }\n\n /** @return {Record} ジェネレータとデフォルト値 */\n static getGeneratorTable() {\n return Object.freeze({\n /** @type {number} サンプルヘッダの音声波形データ開始位置に加算されるオフセット(下位16bit) */\n startAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データ終了位置に加算されるオフセット(下位16bit) */\n endAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(下位16bit) */\n startloopAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(下位16bit) */\n endloopAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データ開始位置に加算されるオフセット(上位16bit) */\n startAddrsCoarseOffset: 0,\n /** @type {number} LFOによるピッチの揺れ幅 */\n modLfoToPitch: 0,\n /** @type {number} モジュレーションホイール用LFOからピッチに対しての影響量 */\n vibLfoToPitch: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープからピッチに対しての影響量 */\n modEnvToPitch: 0,\n /** @type {number} フィルタのカットオフ周波数 */\n initialFilterFc: 13500,\n /** @type {number} フィルターのQ値(レゾナンス) */\n initialFilterQ: 0,\n /** @type {number} LFOによるフィルターカットオフ周波数の揺れ幅 */\n modLfoToFilterFc: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープからフィルターカットオフに対しての影響量 */\n modEnvToFilterFc: 0,\n /** @type {number} サンプルヘッダの音声波形データ終了位置に加算されるオフセット(上位16bit) */\n endAddrsCoarseOffset: 0,\n /** @type {number} LFOによるボリュームの揺れ幅 */\n modLfoToVolume: 0,\n /** @type {undefined} 未使用1 */\n unused1: undefined, // 14\n /** @type {number} コーラスエフェクトのセンドレベル */\n chorusEffectsSend: 0,\n /** @type {number} リバーブエフェクトのセンドレベル */\n reverbEffectsSend: 0,\n /** @type {number} パンの位置 */\n pan: 0,\n /** @type {undefined} 未使用2 */\n unused2: undefined,\n /** @type {undefined} 未使用3 */\n unused3: undefined,\n /** @type {undefined} 未使用4 */\n unused4: undefined,\n /** @type {number} LFOの揺れが始まるまでの時間 */\n delayModLFO: -12000,\n /** @type {number} LFOの揺れの周期 */\n freqModLFO: 0,\n /** @type {number} ホイールの揺れが始まるまでの時間 */\n delayVibLFO: -12000,\n /** @type {number} ホイールの揺れの周期 */\n freqVibLFO: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープのディレイ(アタックが始まるまでの時間) */\n delayModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのアタック時間 */\n attackModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのホールド時間(アタックが終わってからディケイが始まるまでの時間) */\n holdModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのディケイ時間 */\n decayModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのサステイン量 */\n sustainModEnv: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープのリリース時間 */\n releaseModEnv: -12000,\n /** @type {number} キー(ノートNo)によるフィルタ・ピッチ用エンベロープのホールド時間への影響 */\n keynumToModEnvHold: 0,\n /** @type {number} キー(ノートNo)によるフィルタ・ピッチ用エンベロープのディケイ時間への影響 */\n keynumToModEnvDecay: 0,\n /** @type {number} アンプ用エンベロープのディレイ(アタックが始まるまでの時間) */\n delayVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのアタック時間 */\n attackVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのホールド時間(アタックが終わってからディケイが始まるまでの時間) */\n holdVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのディケイ時間 */\n decayVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのサステイン量 */\n sustainVolEnv: 0,\n /** @type {number} アンプ用エンベロープのリリース時間 */\n releaseVolEnv: -12000,\n /** @type {number} キー(ノートNo)によるアンプ用エンベロープのホールド時間への影響 */\n keynumToVolEnvHold: 0,\n /** @type {number} キー(ノートNo)によるアンプ用エンベロープのディケイ時間への影響 */\n keynumToVolEnvDecay: 0,\n /** @type {number} 割り当てるインストルメント(楽器) */\n instrument: null,\n /** @type {undefined} 予約済み1 */\n reserved1: undefined, // 42\n /** @type {number} マッピングするキー(ノートNo)の範囲 */\n keyRange: null,\n /** @type {number} マッピングするベロシティの範囲 */\n velRange: null,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(上位16bit) */\n startloopAddrsCoarseOffset: 0,\n /** @type {number} どのキー(ノートNo)でも強制的に指定したキー(ノートNo)に変更する */\n keynum: null,\n /** @type {number} どのベロシティでも強制的に指定したベロシティに変更する */\n velocity: null,\n /** @type {number} 調整する音量 */\n initialAttenuation: 0,\n /** @type {undefined} 予約済み2 */\n reserved2: undefined, // 49\n /** @type {number} サンプルヘッダの音声波形データループ終了位置に加算されるオフセット(上位16bit) */\n endloopAddrsCoarseOffset: 0,\n /** @type {number} 半音単位での音程の調整 */\n coarseTune: 0,\n /** @type {number} cent単位での音程の調整 */\n fineTune: 0,\n /** @type {number} 割り当てるサンプル(音声波形) */\n sampleID: null,\n /** @type {number} サンプル(音声波形)をループさせるか等のフラグ */\n sampleModes: 0,\n /** @type {undefined} 予約済み3 */\n reserved3: undefined, // 55\n /** @type {number} キー(ノートNo)が+1されるごとに音程を何centあげるかの音階情報 */\n scaleTuning: 100,\n /** @type {number} 同時に音を鳴らさないようにするための排他ID(ハイハットのOpen、Close等に使用) */\n exclusiveClass: null,\n /** @type {number} サンプル(音声波形)の音程の上書き情報 */\n overridingRootKey: null,\n /** @type {undefined} 未使用5 */\n unuded5: undefined, // 59\n /** @type {undefined} 最後を示すオペレータ */\n endOper: undefined,\n });\n }\n\n /** @export */\n parse() {\n /** @type {Riff} */\n const parser = new Riff(this.input, this.parserOption);\n\n // parse RIFF chunk\n parser.parse();\n if (parser.chunkList.length !== 1) {\n throw new Error('wrong chunk length');\n }\n\n /** @type {import('./riff.js').RiffChunk | null} */\n const chunk = parser.getChunk(0);\n if (chunk === null) {\n throw new Error('chunk not found');\n }\n\n this.parseRiffChunk(chunk);\n this.input = null;\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseRiffChunk(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'RIFF') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'sfbk') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n if (parser.getNumberOfChunks() !== 3) {\n throw new Error('invalid sfbk structure');\n }\n\n // INFO-list\n this.parseInfoList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(0))\n );\n\n // sdta-list\n this.parseSdtaList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(1))\n );\n\n // pdta-list\n this.parsePdtaList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(2))\n );\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseInfoList(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'INFO') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseSdtaList(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'sdta') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n if (parser.chunkList.length !== 1) {\n throw new Error('TODO');\n }\n this.samplingData =\n /** @type {{ type: string; size: number; offset: number }} */\n (parser.getChunk(0));\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePdtaList(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'pdta') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n\n // check number of chunks\n if (parser.getNumberOfChunks() !== 9) {\n throw new Error('invalid pdta chunk');\n }\n\n this.parsePhdr(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(0))\n );\n this.parsePbag(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(1))\n );\n this.parsePmod(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(2))\n );\n this.parsePgen(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(3))\n );\n this.parseInst(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(4))\n );\n this.parseIbag(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(5))\n );\n this.parseImod(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(6))\n );\n this.parseIgen(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(7))\n );\n this.parseShdr(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(8))\n );\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePhdr(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const presetHeader = (this.presetHeader = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'phdr') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n presetHeader.push({\n presetName: String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n ),\n preset: data[ip++] | (data[ip++] << 8),\n bank: data[ip++] | (data[ip++] << 8),\n presetBagIndex: data[ip++] | (data[ip++] << 8),\n library:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n genre:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n morphology:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePbag(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const presetZone = (this.presetZone = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'pbag') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n presetZone.push({\n presetGeneratorIndex: data[ip++] | (data[ip++] << 8),\n presetModulatorIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePmod(chunk) {\n // check parse target\n if (chunk.type !== 'pmod') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.presetZoneModulator = this.parseModulator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePgen(chunk) {\n // check parse target\n if (chunk.type !== 'pgen') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n this.presetZoneGenerator = this.parseGenerator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseInst(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const instrument = (this.instrument = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'inst') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n instrument.push({\n instrumentName: String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n ),\n instrumentBagIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseIbag(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const instrumentZone = (this.instrumentZone = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'ibag') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n instrumentZone.push({\n instrumentGeneratorIndex: data[ip++] | (data[ip++] << 8),\n instrumentModulatorIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseImod(chunk) {\n // check parse target\n if (chunk.type !== 'imod') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.instrumentZoneModulator = this.parseModulator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseIgen(chunk) {\n // check parse target\n if (chunk.type !== 'igen') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.instrumentZoneGenerator = this.parseGenerator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseShdr(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const samples = (this.sample = []);\n /** @type {Object[]} */\n const sampleHeader = (this.sampleHeader = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {string} */\n let sampleName;\n /** @type {number} */\n let start;\n /** @type {number} */\n let end;\n /** @type {number} */\n let startLoop;\n /** @type {number} */\n let endLoop;\n /** @type {number} */\n let sampleRate;\n /** @type {number} */\n let originalPitch;\n /** @type {number} */\n let pitchCorrection;\n /** @type {number} */\n let sampleLink;\n /** @type {number} */\n let sampleType;\n\n // check parse target\n if (chunk.type !== 'shdr') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n sampleName = String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n );\n start =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n end =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n startLoop =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n endLoop =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n sampleRate =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n originalPitch = data[ip++];\n pitchCorrection = (data[ip++] << 24) >> 24;\n sampleLink = data[ip++] | (data[ip++] << 8);\n sampleType = data[ip++] | (data[ip++] << 8);\n\n let sample = new Int16Array(\n new Uint8Array(\n data.subarray(\n this.samplingData.offset + start * 2,\n this.samplingData.offset + end * 2\n )\n ).buffer\n );\n\n startLoop -= start;\n endLoop -= start;\n\n if (sampleRate > 0) {\n const adjust = this.adjustSampleData(sample, sampleRate);\n sample = adjust.sample;\n sampleRate *= adjust.multiply;\n startLoop *= adjust.multiply;\n endLoop *= adjust.multiply;\n }\n\n samples.push(sample);\n\n sampleHeader.push({\n sampleName,\n start,\n end,\n startLoop,\n endLoop,\n sampleRate,\n originalPitch,\n pitchCorrection,\n sampleLink,\n sampleType,\n });\n }\n }\n\n /**\n * @param {Int16Array} sample\n * @param {number} sampleRate\n * @return {object}\n */\n adjustSampleData(sample, sampleRate) {\n /** @type {Int16Array} */\n let newSample;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let multiply = 1;\n\n // buffer\n while (sampleRate < this.sampleRate) {\n // AudioContextのサンプルレートに変更\n newSample = new Int16Array(sample.length * 2);\n for (i = j = 0, il = sample.length; i < il; ++i) {\n newSample[j++] = sample[i];\n newSample[j++] = sample[i];\n }\n sample = newSample;\n multiply *= 2;\n sampleRate *= 2;\n }\n\n return {\n sample,\n multiply,\n };\n }\n\n /**\n * @param {import('./riff.js').RiffChunk} chunk\n * @return {Object[]}\n */\n parseModulator(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {number} */\n let code;\n /** @type {string} */\n let key;\n /** @type {Object[]} */\n const output = [];\n\n while (ip < size) {\n // Src Oper\n // TODO\n ip += 2;\n\n // Dest Oper\n code = data[ip++] | (data[ip++] << 8);\n key = this.GeneratorEnumeratorTable[code];\n if (!key) {\n // Amount\n output.push({\n type: key,\n value: {\n code,\n amount: data[ip] | (((data[ip + 1] << 8) << 16) >> 16),\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n } else {\n // Amount\n switch (key) {\n case 'keyRange':\n /* FALLTHROUGH */\n case 'velRange':\n /* FALLTHROUGH */\n case 'keynum':\n /* FALLTHROUGH */\n case 'velocity':\n output.push({\n type: key,\n value: {\n amount: null,\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n break;\n default:\n output.push({\n type: key,\n value: {\n amount: data[ip++] | (((data[ip++] << 8) << 16) >> 16),\n },\n });\n break;\n }\n }\n\n // AmtSrcOper\n // TODO\n ip += 2;\n\n // Trans Oper\n // TODO\n ip += 2;\n }\n\n return output;\n }\n\n /**\n * @param {import('./riff.js').RiffChunk} chunk\n * @return {Object[]}\n */\n parseGenerator(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {number} */\n let code;\n /** @type {string} */\n let key;\n /** @type {Object[]} */\n const output = [];\n\n while (ip < size) {\n code = data[ip++] | (data[ip++] << 8);\n key = this.GeneratorEnumeratorTable[code];\n if (!key) {\n output.push({\n type: key,\n value: {\n code,\n amount: data[ip] | (((data[ip + 1] << 8) << 16) >> 16),\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n continue;\n }\n\n switch (key) {\n case 'keynum':\n /* FALLTHROUGH */\n case 'keyRange':\n /* FALLTHROUGH */\n case 'velRange':\n /* FALLTHROUGH */\n case 'velocity':\n output.push({\n type: key,\n value: {\n amount: null,\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n break;\n default:\n output.push({\n type: key,\n value: {\n amount: data[ip++] | (((data[ip++] << 8) << 16) >> 16),\n },\n });\n break;\n }\n }\n\n return output;\n }\n\n /** @return {object[]} */\n createInstrument() {\n /** @type {Object[]} */\n const instrument = this.instrument;\n /** @type {Object[]} */\n const zone = this.instrumentZone;\n /** @type {Object[]} */\n const output = [];\n /** @type {number} */\n let bagIndex;\n /** @type {number} */\n let bagIndexEnd;\n /** @type {Object[]} */\n let zoneInfo;\n /** @type {{ generator: Object; generatorInfo: Object[] }} */\n let instrumentGenerator;\n /** @type {{ modulator: Object; modulatorInfo: Object[] }} */\n let instrumentModulator;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let jl;\n\n // instrument -> instrument bag -> generator / modulator\n for (i = 0, il = instrument.length; i < il; ++i) {\n bagIndex = instrument[i].instrumentBagIndex;\n bagIndexEnd = instrument[i + 1]\n ? instrument[i + 1].instrumentBagIndex\n : zone.length;\n zoneInfo = [];\n\n // instrument bag\n for (j = bagIndex, jl = bagIndexEnd; j < jl; ++j) {\n instrumentGenerator = this.createInstrumentGenerator_(zone, j);\n instrumentModulator = this.createInstrumentModulator_(zone, j);\n\n zoneInfo.push({\n generator: instrumentGenerator.generator,\n generatorSequence: instrumentGenerator.generatorInfo,\n modulator: instrumentModulator.modulator,\n modulatorSequence: instrumentModulator.modulatorInfo,\n });\n }\n\n output.push({\n name: instrument[i].instrumentName,\n info: zoneInfo,\n });\n }\n\n return output;\n }\n\n /** @return {object[]} */\n createPreset() {\n /** @type {Object[]} */\n const preset = this.presetHeader;\n /** @type {Object[]} */\n const zone = this.presetZone;\n /** @type {Object[]} */\n const output = [];\n /** @type {number} */\n let bagIndex;\n /** @type {number} */\n let bagIndexEnd;\n /** @type {Object[]} */\n let zoneInfo;\n /** @type {number} */\n let instrument;\n /** @type {{ generator: Object; generatorInfo: Object[] }} */\n let presetGenerator;\n /** @type {{ modulator: Object; modulatorInfo: Object[] }} */\n let presetModulator;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let jl;\n\n // preset -> preset bag -> generator / modulator\n for (i = 0, il = preset.length; i < il; ++i) {\n bagIndex = preset[i].presetBagIndex;\n bagIndexEnd = preset[i + 1] ? preset[i + 1].presetBagIndex : zone.length;\n zoneInfo = [];\n\n // preset bag\n for (j = bagIndex, jl = bagIndexEnd; j < jl; ++j) {\n presetGenerator = this.createPresetGenerator_(zone, j);\n presetModulator = this.createPresetModulator_(zone, j);\n\n zoneInfo.push({\n generator: presetGenerator.generator,\n generatorSequence: presetGenerator.generatorInfo,\n modulator: presetModulator.modulator,\n modulatorSequence: presetModulator.modulatorInfo,\n });\n\n instrument =\n presetGenerator.generator.instrument !== undefined\n ? presetGenerator.generator.instrument.amount\n : presetModulator.modulator.instrument !== undefined\n ? presetModulator.modulator.instrument.amount\n : null;\n }\n\n output.push({\n name: preset[i].presetName,\n info: zoneInfo,\n header: preset[i],\n instrument,\n });\n }\n\n return output;\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ generator: Object; generatorInfo: Object[] }}\n */\n createInstrumentGenerator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].instrumentGeneratorIndex,\n zone[index + 1]\n ? zone[index + 1].instrumentGeneratorIndex\n : this.instrumentZoneGenerator.length,\n this.instrumentZoneGenerator\n );\n\n return {\n generator: modgen.modgen,\n generatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ modulator: Object; modulatorInfo: Object[] }}\n */\n createInstrumentModulator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetModulatorIndex,\n zone[index + 1]\n ? zone[index + 1].instrumentModulatorIndex\n : this.instrumentZoneModulator.length,\n this.instrumentZoneModulator\n );\n\n return {\n modulator: modgen.modgen,\n modulatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ generator: Object; generatorInfo: Object[] }}\n */\n createPresetGenerator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetGeneratorIndex,\n zone[index + 1]\n ? zone[index + 1].presetGeneratorIndex\n : this.presetZoneGenerator.length,\n this.presetZoneGenerator\n );\n\n return {\n generator: modgen.modgen,\n generatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ modulator: Object; modulatorInfo: Object[] }}\n */\n createPresetModulator_(zone, index) {\n /** @type {{ modgen: Object; modgenInfo: Object[] }} */\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetModulatorIndex,\n zone[index + 1]\n ? zone[index + 1].presetModulatorIndex\n : this.presetZoneModulator.length,\n this.presetZoneModulator\n );\n\n return {\n modulator: modgen.modgen,\n modulatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} _zone\n * @param {number} indexStart\n * @param {number} indexEnd\n * @param {Array} zoneModGen\n * @returns {{ modgen: Object; modgenInfo: Object[] }}\n */\n createBagModGen_(_zone, indexStart, indexEnd, zoneModGen) {\n /** @type {Object[]} */\n const modgenInfo = [];\n /** @type {Object} */\n const modgen = {\n unknown: [],\n keyRange: {\n amount: null,\n hi: 127,\n lo: 0,\n },\n }; // TODO\n /** @type {Object} */\n let info;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n for (i = indexStart, il = indexEnd; i < il; ++i) {\n info = zoneModGen[i];\n modgenInfo.push(info);\n\n if (info.type === 'unknown') {\n modgen.unknown.push(info.value);\n } else {\n modgen[info.type] = info.value;\n }\n }\n\n return {\n modgen,\n modgenInfo,\n };\n }\n}\n","/**\n * @classdesc File Loader Class\n * @private\n * @author Logue \n */\nexport default class Loader {\n /** キャッシュの名前空間 */\n static CACHE_NAME = 'wml';\n /**\n * コンストラクタ\n *\n * @constructor\n * @param {string} url\n * @param {HTMLDivElement} placeholder\n * @param {boolean} cache\n * @param {Function} callback\n */\n constructor(url, placeholder, cache, callback) {\n this.url = url;\n this.cache = cache;\n this.callback = callback;\n\n /** @type {HTMLDivElement} */\n this.alert = document.createElement('div');\n this.alert.className = 'alert alert-warning';\n\n /** @type {HTMLParagraphElement} */\n this.message = document.createElement('p');\n this.message.innerText = 'Now Loading...';\n\n /** @type {HTMLDivElement} */\n this.progressOuter = document.createElement('div');\n this.progressOuter.className = 'progress';\n this.progressOuter.role = 'progressbar';\n this.progressOuter.ariaLabel = 'Loading Progress';\n this.progressOuter.ariaValueMin = '0';\n this.progressOuter.ariaValueNow = '0';\n this.progressOuter.ariaValueMax = '100';\n\n /** @type {HTMLDivElement} */\n this.progress = document.createElement('div');\n this.progress.className = 'progress-bar';\n\n this.progressOuter.appendChild(this.progress);\n this.alert.appendChild(this.message);\n this.alert.appendChild(this.progressOuter);\n\n placeholder.appendChild(this.alert);\n }\n\n /**\n * ダウンロード中のハンドラ\n * @param {number} current\n * @param {number} total\n * @private\n */\n onProgress(current, total) {\n const percentCompleted = Math.floor((current / total) * 100);\n this.progress.style.width = `${percentCompleted}%`;\n this.progress.innerText = `${percentCompleted}%`;\n }\n\n /**\n * ロード完了時のハンドラ\n *\n * @param {ArrayBuffer} buffer\n * @private\n */\n onComplete(buffer) {\n this.alert.className = 'alert alert-info';\n this.message.innerText = 'Initializing...';\n this.progress.className =\n 'progress-bar progress-bar-striped progress-bar-animated';\n this.progress.style.width = '100%';\n // コールバック実行\n this.callback(new Uint8Array(buffer));\n }\n\n /**\n * エラー時のハンドラ\n *\n * @param {Error | undefined} error エラー内容\n * @private\n */\n onError(error = undefined) {\n requestAnimationFrame(() => {\n this.alert.className = 'alert alert-danger';\n this.message.innerText =\n 'An error occurred while loading SoundFont. See the console log for details. In addition, it may be cured by deleting the cache of the browser.';\n this.progressOuter.style.display = 'none';\n });\n }\n\n /**\n * データ取得\n * @public\n */\n async fetch() {\n /** @type {Cache} */\n const cache = await window.caches.open(Loader.CACHE_NAME);\n /** @type {Response} */\n const cached = await cache.match(this.url);\n\n if (this.cache && cached) {\n // キャッシュが存在する場合、キャッシュの値を返す\n this.onComplete(await cached.arrayBuffer());\n return;\n }\n\n /** @type {void | Response} キャッシュがない場合Fetchで取得 */\n const response = await fetch(this.url, {\n method: 'GET',\n }).catch(e => this.onError(e));\n\n if (!response || (response && !response.ok)) {\n return;\n }\n\n /** @type {Response} キャッシュ用レスポンス */\n const cloned = response.clone();\n\n /** @type {number} ファイルの容量 */\n const contentLength = parseInt(response.headers.get('Content-Length'));\n\n /** @type {ReadableStreamDefaultReader} ファイルリーダー */\n const reader = cloned.body.getReader();\n\n /** @type {number} 読み込まれたチャンクの長さ */\n let receivedLength = 0;\n\n /** @type {Uint8Array[]} 受信したバイナリチャンクの配列(本文を構成します) */\n const chunks = [];\n\n // eslint-disable-next-line\n while (true) {\n // 最後のチャンクも場合、done は true。\n // value はチャンクバイトの Uint8Array\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n receivedLength += value.length;\n\n this.message.innerText = `Now Loading... (${receivedLength} of ${contentLength} byte)`;\n\n // Content lengthヘッダーが出力されている場合プログレスバーを表示\n this.onProgress(receivedLength, contentLength);\n }\n\n /** @type {Uint8Array} 全チャンク */\n const chunksAll = new Uint8Array(receivedLength);\n /** @type {number} 現在の読み込んだチャンク位置 */\n let position = 0;\n for (const chunk of chunks) {\n chunksAll.set(chunk, position);\n position += chunk.length;\n }\n\n // キャッシュへ保存\n await cache.put(this.url, response);\n // 完了時のイベントを実行\n this.onComplete(chunksAll);\n }\n}\n","const INV_MAX = 1 / 2 ** 32;\nclass ARandom {\n float(norm = 1) {\n return this.int() * INV_MAX * norm;\n }\n probability(p) {\n return this.float() < p;\n }\n norm(norm = 1) {\n return (this.int() * INV_MAX - 0.5) * 2 * norm;\n }\n normMinMax(min, max) {\n const x = this.minmax(min, max);\n return this.float() < 0.5 ? x : -x;\n }\n minmax(min, max) {\n return this.float() * (max - min) + min;\n }\n minmaxInt(min, max) {\n min |= 0;\n const range = (max | 0) - min;\n return range ? min + this.int() % range : min;\n }\n minmaxUint(min, max) {\n min >>>= 0;\n const range = (max >>> 0) - min;\n return range ? min + this.int() % range : min;\n }\n}\nexport {\n ARandom\n};\n","import { ARandom } from \"./arandom.js\";\nconst random = Math.random;\nclass SystemRandom extends ARandom {\n int() {\n return random() * 4294967296 >>> 0;\n }\n float(norm = 1) {\n return random() * norm;\n }\n norm(norm = 1) {\n return (random() - 0.5) * 2 * norm;\n }\n}\nconst SYSTEM = new SystemRandom();\nexport {\n SYSTEM,\n SystemRandom\n};\n","import { SYSTEM } from \"@thi.ng/random/system\";\nconst DEFAULT_OPTS = {\n bins: 2,\n scale: 1,\n rnd: SYSTEM\n};\nexport {\n DEFAULT_OPTS\n};\n","const preseed = (n, scale, rnd) => {\n const state = new Array(n);\n for (let i = 0; i < n; i++) {\n state[i] = rnd.norm(scale);\n }\n return state;\n};\nconst sum = (src) => src.reduce((sum2, x) => sum2 + x, 0);\nfunction* interleave(a, b) {\n const src = [a[Symbol.iterator](), b[Symbol.iterator]()];\n for (let i = 0; true; i ^= 1) {\n const next = src[i].next();\n if (next.done)\n return;\n yield next.value;\n }\n}\nexport {\n interleave,\n preseed,\n sum\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* blue(opts) {\n const { bins, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n state.forEach((x, i) => state[i] = i & 1 ? x : -x);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0, sign = -1; true; ++i >= bins && (i = 0)) {\n acc -= state[i];\n acc += state[i] = sign * rnd.norm(scale);\n sign ^= 4294967294;\n yield sign * acc * invN;\n }\n}\nexport {\n blue\n};\n","import { blue } from \"./blue.js\";\nimport { interleave } from \"./utils.js\";\nconst green = (opts) => interleave(blue(opts), blue(opts));\nexport {\n green\n};\n","const popCount = (x) => (x = x - (x >>> 1 & 1431655765), x = (x & 858993459) + (x >>> 2 & 858993459), (x + (x >>> 4) & 252645135) * 16843009 >>> 24);\nconst popCountArray = (data, start = 0, n = data.length) => {\n let num = 0;\n for (let end = start + n; start < end; start++) {\n const x = data[start];\n x > 0 && (num += popCount(x));\n }\n return num;\n};\nconst hammingDist = (x, y) => popCount(x ^ y);\nconst clz32 = (x) => x !== 0 ? 31 - (Math.log(x >>> 0) / Math.LN2 | 0) : 32;\nconst ctz32 = (x) => {\n let c = 32;\n x &= -x;\n x && c--;\n x & 65535 && (c -= 16);\n x & 16711935 && (c -= 8);\n x & 252645135 && (c -= 4);\n x & 858993459 && (c -= 2);\n x & 1431655765 && (c -= 1);\n return c;\n};\nconst bitSize = (x) => x > 1 ? Math.ceil(Math.log2(x)) : 0;\nexport {\n bitSize,\n clz32,\n ctz32,\n hammingDist,\n popCount,\n popCountArray\n};\n","import { ctz32 } from \"@thi.ng/binary/count\";\nimport { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* pink(opts) {\n const { bins = 8, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0; true; i = i + 1 >>> 0) {\n const id = ctz32(i) % bins;\n acc -= state[id];\n acc += state[id] = rnd.norm(scale);\n yield acc * invN;\n }\n}\nexport {\n pink\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* red(opts) {\n const { bins, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0; true; ++i >= bins && (i = 0)) {\n acc -= state[i];\n acc += state[i] = rnd.norm(scale);\n yield acc * invN;\n }\n}\nexport {\n red\n};\n","import { red } from \"./red.js\";\nimport { interleave } from \"./utils.js\";\nconst violet = (opts) => interleave(red(opts), red(opts));\nexport {\n violet\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nfunction* white(opts) {\n const { scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n while (true) {\n yield rnd.norm(scale);\n }\n}\nexport {\n white\n};\n","const implementsFunction = (x, fn) => x != null && typeof x[fn] === \"function\";\nexport {\n implementsFunction\n};\n","import { implementsFunction } from \"@thi.ng/checks/implements-function\";\nconst ensureTransducer = (x) => implementsFunction(x, \"xform\") ? x.xform() : x;\nexport {\n ensureTransducer\n};\n","const isIterable = (x) => x != null && typeof x[Symbol.iterator] === \"function\";\nexport {\n isIterable\n};\n","const identity = (x) => x;\nconst always = () => true;\nconst never = () => false;\nexport {\n always,\n identity,\n never\n};\n","class Reduced {\n value;\n constructor(val) {\n this.value = val;\n }\n deref() {\n return this.value;\n }\n}\nconst reduced = (x) => new Reduced(x);\nconst isReduced = (x) => x instanceof Reduced;\nconst ensureReduced = (x) => x instanceof Reduced ? x : new Reduced(x);\nconst unreduced = (x) => x instanceof Reduced ? x.deref() : x;\nexport {\n Reduced,\n ensureReduced,\n isReduced,\n reduced,\n unreduced\n};\n","import { identity } from \"@thi.ng/api/fn\";\nimport { implementsFunction } from \"@thi.ng/checks/implements-function\";\nimport { isArrayLike } from \"@thi.ng/checks/is-arraylike\";\nimport { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { illegalArity } from \"@thi.ng/errors/illegal-arity\";\nimport { isReduced, unreduced } from \"./reduced.js\";\nconst parseArgs = (args) => args.length === 2 ? [void 0, args[1]] : args.length === 3 ? [args[1], args[2]] : illegalArity(args.length);\nfunction reduce(...args) {\n const rfn = args[0];\n const init = rfn[0];\n const complete = rfn[1];\n const reduce2 = rfn[2];\n args = parseArgs(args);\n const acc = args[0] == null ? init() : args[0];\n const xs = args[1];\n return unreduced(\n complete(\n implementsFunction(xs, \"$reduce\") ? xs.$reduce(reduce2, acc) : isArrayLike(xs) ? reduceArray(reduce2, acc, xs) : reduceIterable(reduce2, acc, xs)\n )\n );\n}\nfunction reduceRight(...args) {\n const [init, complete, reduce2] = args[0];\n args = parseArgs(args);\n let acc = args[0] == null ? init() : args[0];\n const xs = args[1];\n for (let i = xs.length; i-- > 0; ) {\n acc = reduce2(acc, xs[i]);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return unreduced(complete(acc));\n}\nconst reduceArray = (rfn, acc, xs) => {\n for (let i = 0, n = xs.length; i < n; i++) {\n acc = rfn(acc, xs[i]);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return acc;\n};\nconst reduceIterable = (rfn, acc, xs) => {\n for (let x of xs) {\n acc = rfn(acc, x);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return acc;\n};\nconst reducer = (init, rfn) => [init, identity, rfn];\nconst $$reduce = (rfn, args) => {\n const n = args.length - 1;\n return isIterable(args[n]) ? args.length > 1 ? reduce(rfn.apply(null, args.slice(0, n)), args[n]) : reduce(rfn(), args[0]) : void 0;\n};\nexport {\n $$reduce,\n reduce,\n reduceRight,\n reducer\n};\n","import { reducer } from \"./reduce.js\";\nfunction push(xs) {\n return xs ? [...xs] : reducer(\n () => [],\n (acc, x) => (acc.push(x), acc)\n );\n}\nexport {\n push\n};\n","import { NO_OP, SEMAPHORE } from \"@thi.ng/api/api\";\nimport { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { ensureTransducer } from \"./ensure.js\";\nimport { push } from \"./push.js\";\nimport { isReduced, unreduced } from \"./reduced.js\";\nfunction* iterator(xform, xs) {\n const rfn = ensureTransducer(xform)(push());\n const complete = rfn[1];\n const reduce = rfn[2];\n for (let x of xs) {\n const y = reduce([], x);\n if (isReduced(y)) {\n yield* unreduced(complete(y.deref()));\n return;\n }\n if (y.length) {\n yield* y;\n }\n }\n yield* unreduced(complete([]));\n}\nfunction* iterator1(xform, xs) {\n const reduce = ensureTransducer(xform)([NO_OP, NO_OP, (_, x) => x])[2];\n for (let x of xs) {\n let y = reduce(SEMAPHORE, x);\n if (isReduced(y)) {\n y = unreduced(y.deref());\n if (y !== SEMAPHORE) {\n yield y;\n }\n return;\n }\n if (y !== SEMAPHORE) {\n yield y;\n }\n }\n}\nconst __iter = (xform, args, impl = iterator1) => {\n const n = args.length - 1;\n return isIterable(args[n]) ? args.length > 1 ? impl(xform.apply(null, args.slice(0, n)), args[n]) : impl(xform(), args[0]) : void 0;\n};\nexport {\n __iter,\n iterator,\n iterator1\n};\n","const compR = (rfn, fn) => [rfn[0], rfn[1], fn];\nexport {\n compR\n};\n","import { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { compR } from \"./compr.js\";\nimport { iterator } from \"./iterator.js\";\nimport { ensureReduced, reduced } from \"./reduced.js\";\nfunction take(n, src) {\n return isIterable(src) ? iterator(take(n), src) : (rfn) => {\n const r = rfn[2];\n let m = n;\n return compR(\n rfn,\n (acc, x) => --m > 0 ? r(acc, x) : m === 0 ? ensureReduced(r(acc, x)) : reduced(acc)\n );\n };\n}\nexport {\n take\n};\n","/**\n * @logue/reverb\n *\n * @description JavaScript Reverb effect class\n * @author Logue \n * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.\n * @license MIT\n * @version 1.3.9\n * @see {@link https://github.com/logue/Reverb.js}\n */\n\nimport { white as c, violet as m, red as f, pink as b, green as N, blue as g } from \"@thi.ng/colored-noise\";\nimport { take as v } from \"@thi.ng/transducers\";\nimport { SYSTEM as w } from \"@thi.ng/random\";\nconst d = {\n version: \"1.3.9\",\n date: \"2024-04-24T08:29:36.615Z\"\n}, o = {\n /** Blue noise */\n blue: \"blue\",\n /** Brown noise (same as red noise) */\n brown: \"red\",\n /** Green noise */\n green: \"green\",\n /** Pink noise */\n pink: \"pink\",\n /** Red noise */\n red: \"red\",\n /** Violet noise */\n violet: \"violet\",\n /** White noise */\n white: \"white\"\n}, y = {\n noise: \"white\",\n scale: 1,\n peaks: 2,\n randomAlgorithm: w,\n decay: 2,\n delay: 0,\n reverse: !1,\n time: 2,\n filterType: \"allpass\",\n filterFreq: 2200,\n filterQ: 1,\n mix: 0.5,\n once: !1\n};\nclass s {\n /** Version strings */\n static version = d.version;\n /** Build date */\n static build = d.date;\n /** AudioContext */\n ctx;\n /** Wet Level (Reverberated node) */\n wetGainNode;\n /** Dry Level (Original sound node) */\n dryGainNode;\n /** Impulse response filter */\n filterNode;\n /** Convolution node for applying impulse response */\n convolverNode;\n /** Output gain node */\n outputNode;\n /** Option */\n options;\n /** Connected flag */\n isConnected;\n /** Noise Generator */\n noise = c;\n /**\n * Constructor\n *\n * @param ctx - Root AudioContext\n * @param options - Configure\n */\n constructor(e, t) {\n this.ctx = e, this.options = Object.assign(y, t), this.wetGainNode = this.ctx.createGain(), this.dryGainNode = this.ctx.createGain(), this.filterNode = this.ctx.createBiquadFilter(), this.convolverNode = this.ctx.createConvolver(), this.outputNode = this.ctx.createGain(), this.isConnected = !1, this.filterType(this.options.filterType), this.setNoise(this.options.noise), this.buildImpulse(), this.mix(this.options.mix);\n }\n /**\n * Connect the node for the reverb effect to the original sound node.\n *\n * @param sourceNode - Input source node\n */\n connect(e) {\n return this.isConnected && this.options.once ? (this.isConnected = !1, this.outputNode) : (this.convolverNode.connect(this.filterNode), this.filterNode.connect(this.wetGainNode), e.connect(this.convolverNode), e.connect(this.dryGainNode).connect(this.outputNode), e.connect(this.wetGainNode).connect(this.outputNode), this.isConnected = !0, this.outputNode);\n }\n /**\n * Disconnect the reverb node\n *\n * @param sourceNode - Input source node\n */\n disconnect(e) {\n return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;\n }\n /**\n * Dry/Wet ratio\n *\n * @param mix - Ratio (0~1)\n */\n mix(e) {\n if (!s.inRange(e, 0, 1))\n throw new RangeError(\"[Reverb.js] Dry/Wet ratio must be between 0 to 1.\");\n this.options.mix = e, this.dryGainNode.gain.value = 1 - this.options.mix, this.wetGainNode.gain.value = this.options.mix;\n }\n /**\n * Set Impulse Response time length (second)\n *\n * @param value - IR length\n */\n time(e) {\n if (!s.inRange(e, 1, 50))\n throw new RangeError(\n \"[Reverb.js] Time length of inpulse response must be less than 50sec.\"\n );\n this.options.time = e, this.buildImpulse();\n }\n /**\n * Impulse response decay rate.\n *\n * @param value - Decay value\n */\n decay(e) {\n if (!s.inRange(e, 0, 100))\n throw new RangeError(\n \"[Reverb.js] Inpulse Response decay level must be less than 100.\"\n );\n this.options.decay = e, this.buildImpulse();\n }\n /**\n * Delay before reverberation starts\n *\n * @param value - Time[ms]\n */\n delay(e) {\n if (!s.inRange(e, 0, 100))\n throw new RangeError(\n \"[Reverb.js] Inpulse Response delay time must be less than 100.\"\n );\n this.options.delay = e, this.buildImpulse();\n }\n /**\n * Reverse the impulse response.\n *\n * @param reverse - Reverse IR\n */\n reverse(e) {\n this.options.reverse = e, this.buildImpulse();\n }\n /**\n * Filter for impulse response\n *\n * @param type - Filiter Type\n */\n filterType(e = \"allpass\") {\n this.filterNode.type = this.options.filterType = e;\n }\n /**\n * Filter frequency applied to impulse response\n *\n * @param freq - Frequency\n */\n filterFreq(e) {\n if (!s.inRange(e, 20, 2e4))\n throw new RangeError(\n \"[Reverb.js] Filter frequrncy must be between 20 and 20000.\"\n );\n this.options.filterFreq = e, this.filterNode.frequency.value = this.options.filterFreq;\n }\n /**\n * Filter quality.\n *\n * @param q - Quality\n */\n filterQ(e) {\n if (!s.inRange(e, 0, 10))\n throw new RangeError(\n \"[Reverb.js] Filter Q value must be between 0 and 10.\"\n );\n this.options.filterQ = e, this.filterNode.Q.value = this.options.filterQ;\n }\n /**\n * set IR source noise peaks\n *\n * @param p - Peaks\n */\n peaks(e) {\n this.options.peaks = e, this.buildImpulse();\n }\n /**\n * set IR source noise scale.\n *\n * @param s - Scale\n */\n scale(e) {\n this.options.scale = e, this.buildImpulse();\n }\n /**\n * set IR source noise generator.\n *\n * @param a - Algorithm\n */\n randomAlgorithm(e) {\n this.options.randomAlgorithm = e, this.buildImpulse();\n }\n /**\n * Inpulse Response Noise algorithm.\n *\n * @param type - IR noise algorithm type.\n */\n setNoise(e) {\n switch (this.options.noise = e, e) {\n case o.blue:\n this.noise = g;\n break;\n case o.green:\n this.noise = N;\n break;\n case o.pink:\n this.noise = b;\n break;\n case o.red:\n case o.brown:\n this.noise = f;\n break;\n case o.violet:\n this.noise = m;\n break;\n default:\n this.noise = c;\n }\n this.buildImpulse();\n }\n /**\n * Set Random Algorythm\n *\n * @param algorithm - Algorythm\n */\n setRandomAlgorythm(e) {\n this.options.randomAlgorithm = e, this.buildImpulse();\n }\n /**\n * Return true if in range, otherwise false\n *\n * @param x - Target value\n * @param min - Minimum value\n * @param max - Maximum value\n */\n static inRange(e, t, n) {\n return (e - t) * (e - n) <= 0;\n }\n /** Utility function for building an impulse response from the module parameters. */\n buildImpulse() {\n const e = this.ctx.sampleRate, t = Math.max(e * this.options.time, 1), n = e * this.options.delay, a = this.ctx.createBuffer(2, t, e), h = new Float32Array(t), l = new Float32Array(t), p = this.getNoise(t), u = this.getNoise(t);\n for (let i = 0; i < t; i++) {\n let r = 0;\n i < n ? (h[i] = 0, l[i] = 0, r = this.options.reverse ?? !1 ? t - (i - n) : i - n) : r = this.options.reverse ?? !1 ? t - i : i, h[i] = (p[i] ?? 0) * (1 - r / t) ** this.options.decay, l[i] = (u[i] ?? 0) * (1 - r / t) ** this.options.decay;\n }\n a.getChannelData(0).set(h), a.getChannelData(1).set(l), this.convolverNode.buffer = a;\n }\n /**\n * Noise source\n *\n * @param duration - length of IR.\n */\n getNoise(e) {\n return [\n ...v(\n e,\n this.noise({\n bins: this.options.peaks,\n scale: this.options.scale,\n rnd: this.options.randomAlgorithm\n })\n )\n ];\n }\n}\nexport {\n s as default\n};\n","/**\n * SynthesizerNote Class\n *\n * @author imaya\n * @private\n */\nexport default class SynthesizerNote {\n /**\n * @param {AudioContext} ctx\n * @param {AudioNode} destination\n * @param {{\n * channel: number;\n * key: number;\n * velocity:number;\n * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * sampleRate: number;\n * volume: number;\n * panpot: number;\n * pitchBend: number;\n * pitchBendSensitivity: number;\n * modEnvToPitch: number;\n * expression: number;\n * modulation: number;\n * cutOffFrequency: number;\n * hermonicContent: number;\n * reverb: import('@logue/reverb').default;\n * volDelay: number;\n * modDelay: number;\n * volAttack: number;\n * modAttack: number;\n * volHold: number;\n * modHold: number;\n * volDecay: number;\n * modDecay: number;\n * releaseTime: number;\n * volRelease: number;\n * modRelease: number;\n * start: number;\n * end: number;\n * pan: number;\n * sampleModes: number;\n * initialAttenuation: number;\n * volSustain:number;\n * modSustain:number;\n * initialFilterFc :number;\n * modEnvToFilterFc:number;\n * initialFilterQ: number;\n * mute: number;\n * scaleTuning: number;\n * }} instrument\n */\n constructor(ctx, destination, instrument) {\n /** @type {AudioContext} */\n this.ctx = ctx;\n /** @type {AudioNode} */\n this.destination = destination;\n\n this.instrument = instrument;\n /** @type {number} */\n this.channel = instrument.channel;\n /** @type {number} */\n this.key = instrument.key;\n /** @type {number} */\n this.velocity = instrument.velocity;\n /** @type {Uint8Array} */\n this.buffer = instrument.sample;\n /** @type {number} */\n this.playbackRate = instrument.basePlaybackRate;\n /** @type {number} */\n this.loopStart = instrument.loopStart;\n /** @type {number} */\n this.loopEnd = instrument.loopEnd;\n /** @type {number} */\n this.sampleRate = instrument.sampleRate;\n /** @type {number} */\n this.volume = instrument.volume;\n /** @type {number} */\n this.panpot = instrument.panpot;\n /** @type {number} */\n this.pitchBend = instrument.pitchBend;\n /** @type {number} */\n this.pitchBendSensitivity = instrument.pitchBendSensitivity;\n /** @type {number} */\n this.modEnvToPitch = instrument.modEnvToPitch;\n /** @type {number} */\n this.expression = instrument.expression;\n /** @type {number} */\n this.modulation = instrument.modulation;\n /** @type {number} */\n this.cutOffFrequency = instrument.cutOffFrequency;\n /** @type {number} */\n this.hermonicContent = instrument.hermonicContent;\n\n /** @type {import('@logue/reverb').default} */\n this.reverb = instrument.reverb;\n\n // state\n /** @type {number} */\n this.startTime = ctx.currentTime;\n /** @type {number} */\n this.computedPlaybackRate = this.playbackRate | 0;\n /** @type {boolean} */\n this.noteOffState = false;\n\n // ---------------------------------------------------------------------------\n // audio node\n // ---------------------------------------------------------------------------\n\n /** @type {AudioBuffer} */\n this.audioBuffer = null;\n /** @type {AudioBufferSourceNode} */\n this.bufferSource = ctx.createBufferSource();\n /** @type {PannerNode} */\n this.panner = ctx.createPanner();\n /** @type {GainNode} */\n this.outputGainNode = ctx.createGain();\n /** @type {GainNode} */\n this.expressionGainNode = ctx.createGain();\n /** @type {BiquadFilterNode} */\n this.filter = ctx.createBiquadFilter();\n /** @type {BiquadFilterNode} */\n this.modulator = ctx.createBiquadFilter();\n }\n\n /** Note on */\n noteOn() {\n /** @type {AudioContext} */\n const ctx = this.ctx;\n const instrument = this.instrument;\n /** @type {number} */\n const now = this.ctx.currentTime || 0;\n /** @type {number} */\n const volDelay = now + instrument.volDelay;\n /** @type {number} */\n const modDelay = now + instrument.modDelay;\n /** @type {number} */\n const volAttack = volDelay + instrument.volAttack;\n /** @type {number} */\n const modAttack = volDelay + instrument.modAttack;\n /** @type {number} */\n const volHold = volAttack + instrument.volHold;\n /** @type {number} */\n const modHold = modAttack + instrument.modHold;\n /** @type {number} */\n const volDecay = volHold + instrument.volDecay;\n /** @type {number} */\n const modDecay = modHold + instrument.modDecay;\n /** @type {number} */\n const loopStart = instrument.loopStart / this.sampleRate;\n /** @type {number} */\n const loopEnd = instrument.loopEnd / this.sampleRate;\n /** @type {number} */\n const startTime = instrument.start / this.sampleRate;\n // TODO: ドラムパートのPanが変化した場合、その計算をしなければならない\n // http://cpansearch.perl.org/src/PJB/MIDI-SoundFont-1.08/doc/sfspec21.html#8.4.6\n /** @type {number} */\n const pan = instrument.pan !== 0 ? instrument.pan : this.panpot;\n\n const sample = this.buffer.subarray(0, this.buffer.length + instrument.end);\n /** @type {AudioBuffer} */\n const buffer = (this.audioBuffer = ctx.createBuffer(\n 1,\n sample.length,\n this.sampleRate\n ));\n /** @type {Float32Array} */\n const channelData = buffer.getChannelData(0);\n channelData.set(sample);\n\n // buffer source\n /** @type {AudioBufferSourceNode} */\n const bufferSource = this.bufferSource;\n bufferSource.buffer = buffer;\n bufferSource.loop = instrument.sampleModes !== 0;\n bufferSource.loopStart = loopStart;\n bufferSource.loopEnd = loopEnd;\n this.updatePitchBend(this.pitchBend);\n\n // Output\n /** @type {GainNode} */\n const output = this.outputGainNode;\n\n // expression\n this.expressionGainNode.gain.value = this.expression / 127;\n\n // panpot\n /** @type {PannerNode} */\n const panner = this.panner;\n panner.panningModel = 'equalpower';\n panner.distanceModel = 'inverse';\n panner.positionX.setValueAtTime(Math.sin((pan * Math.PI) / 2), 0);\n panner.positionY.setValueAtTime(0, 0);\n panner.positionZ.setValueAtTime(Math.cos((pan * Math.PI) / 2), 0);\n\n // ---------------------------------------------------------------------------\n // Delay, Attack, Hold, Decay, Sustain\n // ---------------------------------------------------------------------------\n\n /** @type {number} */\n let volume =\n this.volume *\n (this.velocity / 127) *\n (1 - instrument.initialAttenuation / 1000);\n if (volume < 0) {\n volume = 0;\n }\n\n /** @type {AudioParam} volume envelope */\n const outputGain = output.gain;\n outputGain.setValueAtTime(0, now);\n outputGain.setValueAtTime(0, volDelay);\n outputGain.setTargetAtTime(volume, volDelay, instrument.volAttack);\n outputGain.setValueAtTime(volume, volHold);\n outputGain.linearRampToValueAtTime(\n volume * (1 - instrument.volSustain),\n volDecay\n );\n\n // modulation envelope\n /** @type {number} */\n const baseFreq = instrument.initialFilterFc;\n /** @type {number} */\n const peekFreq = instrument.initialFilterFc + instrument.modEnvToFilterFc;\n /** @type {number} */\n const sustainFreq =\n baseFreq + (peekFreq - baseFreq) * (1 - instrument.modSustain);\n\n /** @type {BiquadFilterNode} */\n const modulator = this.modulator;\n modulator.Q.setValueAtTime(10 ** (instrument.initialFilterQ / 200), now);\n modulator.frequency.value = baseFreq;\n modulator.type = 'lowpass';\n modulator.frequency.setTargetAtTime(\n baseFreq / 127,\n this.ctx.currentTime,\n 0.5\n );\n modulator.frequency.setValueAtTime(baseFreq, now);\n modulator.frequency.setValueAtTime(baseFreq, modDelay);\n modulator.frequency.setTargetAtTime(\n peekFreq,\n modDelay,\n instrument.modAttack\n );\n modulator.frequency.setValueAtTime(peekFreq, modHold);\n modulator.frequency.exponentialRampToValueAtTime(sustainFreq, modDecay);\n\n // Vibrato\n /* * @type {GainNode} LFO Depth * /\n const lfoDepth = this.ctx.createGain();\n /* * @type {OscillatorNode} LFO Oscillator * /\n const lfo = this.ctx.createOscillator();\n // Set parameters for LFO\n lfo.type = 'sine';\n lfoDepth.gain.value = 1;\n lfo.frequency.value = this.instrument['freqVibLFO'];\n\n if (this.modulation) {\n // Effector (Vibrato) ON\n lfo.start(0);\n } else {\n // Effector (Vibrato) Off\n lfo.stop(0);\n }\n // OscillatorNode (LFO) -> GainNode (Depth) -> frequency (AudioParam)\n lfo.connect(lfoDepth);\n\n // connect\n bufferSource.connect(lfoDepth);\n lfoDepth.connect(modulator);\n modulator.connect(panner);\n panner.connect(this.expressionGainNode);\n */\n bufferSource.connect(modulator);\n modulator.connect(panner);\n panner.connect(this.expressionGainNode);\n\n if (!instrument.mute) {\n this.connect();\n }\n\n this.expressionGainNode.connect(output);\n\n // fire\n bufferSource.start(0, startTime);\n }\n\n /**\n * @param {number} val\n * @return {number}\n */\n amountToFreq(val) {\n return 2 ** ((val - 6900) / 1200) * 440;\n }\n\n /** Note off */\n noteOff() {\n this.noteOffState = true;\n }\n\n /** @return {boolean} */\n isNoteOff() {\n return this.noteOffState;\n }\n\n /** @return {void} */\n release() {\n const instrument = this.instrument;\n /** @type {AudioBufferSourceNode} */\n const bufferSource = this.bufferSource;\n /** @type {GainNode} */\n const output = this.outputGainNode;\n /** @type {number} */\n const now = this.ctx.currentTime;\n /** @type {number} */\n const release = instrument.releaseTime - 64;\n\n // ---------------------------------------------------------------------------\n // volume release time\n // ---------------------------------------------------------------------------\n /** @type {number} */\n const volEndTimeTmp = instrument.volRelease * output.gain.value;\n /** @type {number} */\n const volEndTime =\n now + volEndTimeTmp * (1 + release / (release < 0 ? 64 : 63));\n // now + instrument['volRelease'] * (1 - instrument['volSustain']);\n\n // ---------------------------------------------------------------------------\n // modulation release time\n // ---------------------------------------------------------------------------\n /** @type {BiquadFilterNode} */\n const modulator = this.modulator;\n /** @type {number} */\n const baseFreq = instrument.initialFilterFc;\n /** @type {number} */\n const peekFreq = instrument.initialFilterFc + instrument.modEnvToFilterFc;\n /** @type {number} */\n const modEndTime =\n now +\n instrument.modRelease *\n (baseFreq === peekFreq\n ? 1\n : (modulator.frequency.value - baseFreq) / (peekFreq - baseFreq));\n\n // const modEndTime =\n // now + instrument['modRelease'] * (1 - instrument['modSustain']);\n\n if (!this.audioBuffer) {\n return;\n }\n\n // ---------------------------------------------------------------------------\n // Release\n // ---------------------------------------------------------------------------\n\n switch (instrument.sampleModes) {\n case 0:\n // ループしない\n bufferSource.loop = false;\n break;\n case 1:\n // ループさせる\n output.gain.cancelScheduledValues(0);\n output.gain.setValueAtTime(output.gain.value, now);\n output.gain.linearRampToValueAtTime(0, volEndTime);\n\n modulator.frequency.cancelScheduledValues(0);\n modulator.frequency.setValueAtTime(modulator.frequency.value, now);\n modulator.frequency.exponentialRampToValueAtTime(baseFreq, modEndTime);\n\n bufferSource.playbackRate.cancelScheduledValues(0);\n bufferSource.playbackRate.setValueAtTime(\n bufferSource.playbackRate.value,\n now\n );\n bufferSource.playbackRate.exponentialRampToValueAtTime(\n this.computedPlaybackRate,\n modEndTime\n );\n\n bufferSource.stop(volEndTime);\n break;\n case 2:\n // 未定義\n throw Error('[SynthesizerNote] Detect unused sampleModes');\n case 3:\n // ノートオフまでループさせる\n output.gain.cancelScheduledValues(0);\n output.gain.setValueAtTime(output.gain.value, now);\n output.gain.linearRampToValueAtTime(0, volEndTime);\n\n modulator.frequency.cancelScheduledValues(0);\n modulator.frequency.setValueAtTime(modulator.frequency.value, now);\n modulator.frequency.exponentialRampToValueAtTime(baseFreq, modEndTime);\n\n bufferSource.playbackRate.cancelScheduledValues(0);\n bufferSource.playbackRate.setValueAtTime(\n bufferSource.playbackRate.value,\n now\n );\n bufferSource.playbackRate.exponentialRampToValueAtTime(\n this.computedPlaybackRate,\n modEndTime\n );\n bufferSource.loop = false;\n bufferSource.buffer = null;\n break;\n default:\n throw Error(\n `[SynthesizerNote] ${instrument.sampleModes} is undefined sampleModes.`\n );\n }\n }\n\n /** Connect AudioContext */\n connect() {\n this.reverb.connect(this.outputGainNode).connect(this.destination);\n }\n\n /** Disconnect AudioContext */\n disconnect() {\n this.outputGainNode.disconnect(0);\n }\n\n /** Caluclate playback rate */\n schedulePlaybackRate() {\n /** @type {AudioParam} */\n const playbackRate = this.bufferSource.playbackRate;\n /** @type {number} */\n const computed = this.computedPlaybackRate;\n /** @type {number} */\n const start = this.startTime;\n /** @type {Object} */\n const instrument = this.instrument;\n /** @type {number} */\n const modAttack = start + instrument.modAttack;\n /** @type {number} */\n const modDecay = modAttack + instrument.modDecay;\n /** @type {number} */\n const peekPitch =\n computed *\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n (this.modEnvToPitch * this.instrument.scaleTuning);\n\n playbackRate.cancelScheduledValues(0);\n playbackRate.setValueAtTime(computed, start);\n playbackRate.linearRampToValueAtTime(peekPitch, modAttack);\n playbackRate.linearRampToValueAtTime(\n computed + (peekPitch - computed) * (1 - instrument.modSustain),\n modDecay\n );\n }\n\n /** @param {number} expression */\n updateExpression(expression) {\n this.expressionGainNode.gain.value = (this.expression = expression) / 127;\n }\n\n /** @param {number} pitchBend */\n updatePitchBend(pitchBend) {\n this.computedPlaybackRate =\n this.playbackRate *\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n ((pitchBend / (pitchBend < 0 ? 8192 : 8191)) *\n this.pitchBendSensitivity *\n this.instrument.scaleTuning);\n this.schedulePlaybackRate();\n }\n}\n","import Reverb from '@logue/reverb';\n\nimport Parser from './sf2.js';\nimport SynthesizerNote from './sound_font_synth_note.js';\n\n/**\n * Synthesizer Class\n *\n * @author imaya\n */\nexport default class Synthesizer {\n /** @param {Uint8Array} input */\n constructor(input) {\n /** @type {number} */\n let i;\n /** @type {Uint8Array} */\n this.input = input;\n /** @type {Parser} */\n this.parser = undefined;\n /** @type {number} */\n this.bank = 0;\n /** @type {Object} */\n this.bankSet = {};\n /** @type {number} */\n this.bufferSize = 2048;\n /** @type {AudioContext} */\n this.ctx = this.getAudioContext();\n /** @type {GainNode} */\n this.gainMaster = this.ctx.createGain();\n /** @type {AudioBufferSourceNode} */\n this.bufSrc = this.ctx.createBufferSource();\n /** @type {number[]} */\n this.channelInstrument = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelBank = [0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelVolume = [\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100,\n ];\n /** @type {number[]} */\n this.channelPanpot = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelPitchBend = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelPitchBendSensitivity = [\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n ];\n /** @type {number[]} */\n this.channelExpression = [\n 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,\n 127,\n ];\n /** @type {number[]} */\n this.channelAttack = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelDecay = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelSustin = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelRelease = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n\n /** @type {boolean[]} */\n this.channelHold = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n /** @type {number[]} */\n this.channelHarmonicContent = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelCutOffFrequency = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n\n /** @type {'GM'|'GM2'|'XG'|'GS'} */\n this.mode = 'GM2';\n\n /** @type {string[][]} */\n this.programSet = [];\n\n /** @type {boolean[]} */\n this.channelMute = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n /** @type {SynthesizerNote[][]} */\n this.currentNoteOn = [\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n ];\n /** @type {number} @const */\n this.baseVolume = 1 / 0xffff;\n /** @type {number} */\n this.masterVolume = 16384;\n\n /** @type {boolean[]} */\n this.percussionPart = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n true,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n\n /** @type {number[]} */\n this.percussionVolume = [];\n while (i === 127) {\n this.percussionVolume[i] = 127;\n i++;\n }\n\n /** @type {string[][]} */\n this.programSet = [];\n\n /** @type {Reverb[]} リバーブエフェクト(チャンネル毎に用意する) */\n this.reverb = [];\n\n /** @type {number[]} モジュレーション(ビブラート) */\n this.modulation = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n /** @type {BiquadFilterNode[]} フィルタ */\n this.filter = [];\n\n for (i = 0; i < 16; ++i) {\n // @ts-ignore\n this.reverb[i] = new Reverb(this.ctx, { noise: 'violet' });\n // フィルタを定義\n this.filter[i] = this.ctx.createBiquadFilter();\n }\n\n /** 表示項目 */\n this.items = [];\n\n /** @type {IntersectionObserver} 交差していない */\n this.intersection = new IntersectionObserver(\n entries =>\n entries.forEach(entry => {\n // @ts-ignore\n entry.target.dataset.isIntersecting = entry.isIntersecting;\n }),\n {}\n );\n\n /** @type {NodeJS.Timeout} タイマーのスレッド */\n this.timer = undefined;\n /** @type {boolean} */\n this.drag = false;\n }\n\n /** @return {AudioContext} */\n getAudioContext() {\n /** @type {AudioContext} */\n const ctx = new AudioContext();\n\n // Defreeze AudioContext for iOS.\n const initAudioContext = () => {\n document.removeEventListener('touchstart', initAudioContext);\n /** @type {AudioBufferSourceNode} wake up AudioContext */\n const emptySource = ctx.createBufferSource();\n emptySource.start();\n emptySource.stop();\n };\n\n document.addEventListener('touchstart', initAudioContext);\n\n return ctx;\n }\n\n /**\n * System Reset\n *\n * @param {'GM'|'GM2'|'XG'|'GS'} mode 音源モード\n */\n init(mode = 'GM') {\n this.gainMaster.disconnect();\n\n this.refreshInstruments(this.input);\n\n this.mode = mode;\n\n for (let i = 0; i < 16; ++i) {\n this.setPercussionPart(i, i === 9);\n this.programChange(i, 0);\n this.volumeChange(i, 100);\n this.panpotChange(i, 64);\n this.pitchBend(i, 0x00, 0x40); // 8192\n this.pitchBendSensitivity(i, 2);\n this.hold(i, 0);\n this.expression(i, 127);\n this.bankSelectMsb(i, i === 9 ? 127 : 0);\n this.bankSelectLsb(i, i === 9 ? 127 : 0);\n this.attackTime(i, 64);\n this.decayTime(i, 64);\n this.sustinTime(i, 64);\n this.releaseTime(i, 64);\n this.harmonicContent(i, 64);\n this.cutOffFrequency(i, 64);\n this.reverbDepth(i, 40);\n this.modulationDepth(i, 0);\n\n this.updateBankSelect(i);\n this.updateProgramSelect(i);\n }\n\n this.setPercussionPart(9, true);\n\n for (let i = 0; i < 128; ++i) {\n this.percussionVolume[i] = 127;\n }\n\n this.setMasterVolume(8192);\n\n this.gainMaster.connect(this.ctx.destination);\n\n if (this.element) {\n /** @type {HTMLDivElement} */\n const modeElement = this.element.querySelector('.header .keys div');\n modeElement.innerText = mode + ' Mode';\n /** @type {NodeListOf} */\n const bankSelectElement = this.element.querySelectorAll(\n '.instrument .bank > select'\n );\n\n bankSelectElement.forEach(element => (element.disabled = mode === 'GM'));\n this.element.dataset.mode = mode;\n }\n }\n\n /** Close AudioContext */\n async close() {\n await this.ctx.close();\n }\n\n /** @param {Uint8Array} input */\n refreshInstruments(input) {\n this.input = input;\n this.parser = new Parser(input, {\n sampleRate: this.ctx.sampleRate,\n });\n this.bankSet = this.createAllInstruments();\n }\n\n /** @returns {Object[][]} */\n createAllInstruments() {\n /** @type {Parser} */\n const parser = this.parser;\n parser.parse();\n /** @type {Array} TODO */\n const presets = parser.createPreset();\n /** @type {Array} TODO */\n const instruments = parser.createInstrument();\n /** @type {Array} */\n const banks = [];\n /** @type {Record} */\n let bank;\n /** @type {number} */\n let bankNumber;\n /** @type {Object} */\n let instrument;\n /** @type {number} */\n let presetNumber;\n /** @type {string} */\n let presetName;\n\n const programSet = [];\n\n presets.forEach(preset => {\n presetNumber = preset.header.preset;\n bankNumber = preset.header.bank;\n presetName = preset.name.replace(/\\0*$/, '');\n\n if (typeof preset.instrument !== 'number') {\n return;\n }\n\n instrument = instruments[preset.instrument];\n if (instrument.name.replace(/\\0*$/, '') === 'EOI') {\n return;\n }\n\n // select bank\n banks[bankNumber] = banks[bankNumber] ?? [];\n bank = banks[bankNumber];\n bank[presetNumber] = {};\n bank[presetNumber].name = presetName;\n\n instrument.info.forEach(info =>\n this.createNoteInfo(parser, info, bank[presetNumber])\n );\n\n if (!programSet[bankNumber]) {\n programSet[bankNumber] = [];\n }\n programSet[bankNumber][presetNumber] = presetName;\n });\n\n this.programSet = programSet;\n\n return banks;\n }\n\n /**\n * @param {Parser} parser\n * @param {any} info\n * @param {any} preset\n */\n createNoteInfo(parser, info, preset) {\n /** @type {*} */\n const generator = info.generator;\n\n if (!generator.keyRange || !generator.sampleID) {\n return;\n }\n\n // デフォルト値\n // https://www.utsbox.com/?p=2390\n\n /** @type {number} 33: DelayVolEnv */\n const volDelay = this.getModGenAmount(generator, 'delayVolEnv');\n /** @type {number} 34: AttackVolEnv */\n const volAttack = this.getModGenAmount(generator, 'attackVolEnv');\n /** @type {number} 35: HoldVolEnv */\n const volHold = this.getModGenAmount(generator, 'holdVolEnv');\n /** @type {number} 36: DecayVolEnv */\n const volDecay = this.getModGenAmount(generator, 'decayVolEnv');\n /** @type {number} 37: SustainVolEnv */\n const volSustain = this.getModGenAmount(generator, 'sustainVolEnv');\n /** @type {number} 38: ReleaseVolEnv */\n const volRelease = this.getModGenAmount(generator, 'releaseVolEnv');\n /** @type {number} 25: DelayModEnv */\n const modDelay = this.getModGenAmount(generator, 'delayModEnv');\n /** @type {number} 26: AttackModEnv */\n const modAttack = this.getModGenAmount(generator, 'attackModEnv');\n /** @type {number} 27: HoldModEnv */\n const modHold = this.getModGenAmount(generator, 'holdModEnv');\n /** @type {number} 28: DecayModEnv */\n const modDecay = this.getModGenAmount(generator, 'decayModEnv');\n /** @type {number} 29: SustainModEnv */\n const modSustain = this.getModGenAmount(generator, 'sustainModEnv');\n /** @type {number} 30: ReleaseModEnv */\n const modRelease = this.getModGenAmount(generator, 'releaseModEnv');\n /** @type {number} 56: ScaleTuning */\n const scale = this.getModGenAmount(generator, 'scaleTuning') / 100;\n /** @type {number} */\n const tune =\n this.getModGenAmount(generator, 'coarseTune') +\n this.getModGenAmount(generator, 'fineTune') / 100;\n /** @type {number} */\n const sampleModes = this.getModGenAmount(generator, 'sampleModes');\n\n for (\n let i = generator.keyRange.lo, il = generator.keyRange.hi;\n i <= il;\n ++i\n ) {\n if (preset[i]) {\n continue;\n }\n /** @type {number} */\n const sampleId = this.getModGenAmount(generator, 'sampleID');\n /** @type {object} */\n const sampleHeader = parser.sampleHeader[sampleId];\n\n preset[i] = {\n sample: parser.sample[sampleId],\n sampleRate: sampleHeader.sampleRate,\n // 54\n sampleModes,\n basePlaybackRate:\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n ((i -\n this.getModGenAmount(generator, 'overridingRootKey') +\n tune +\n sampleHeader.pitchCorrection / 100) *\n scale),\n modEnvToPitch: this.getModGenAmount(generator, 'modEnvToPitch') / 100,\n scaleTuning: scale,\n start:\n this.getModGenAmount(generator, 'startAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'startAddrsOffset'),\n end:\n this.getModGenAmount(generator, 'endAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'endAddrsOffset'),\n loopStart:\n // (sampleHeader.startLoop - sampleHeader.start) +\n sampleHeader.startLoop +\n this.getModGenAmount(generator, 'startloopAddrsCoarseOffset') *\n 32768 +\n this.getModGenAmount(generator, 'startloopAddrsOffset'),\n loopEnd:\n // (sampleHeader.endLoop - sampleHeader.start) +\n sampleHeader.endLoop +\n this.getModGenAmount(generator, 'endloopAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'endloopAddrsOffset'),\n volDelay: 2 ** (volDelay / 1200),\n volAttack: 2 ** (volAttack / 1200),\n volHold:\n 2 ** (volHold / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToVolEnvHold')) /\n 1200),\n volDecay:\n 2 ** (volDecay / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToVolEnvDecay')) /\n 1200),\n volSustain: volSustain / 1000,\n volRelease: 2 ** (volRelease / 1200),\n modDelay: 2 ** (modDelay / 1200),\n modAttack: 2 ** (modAttack / 1200),\n modHold:\n 2 ** (modHold / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToModEnvHold')) /\n 1200),\n modDecay:\n 2 ** (modDecay / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToModEnvDecay')) /\n 1200),\n modSustain: modSustain / 1000,\n modRelease: 2 ** (modRelease / 1200),\n initialFilterFc:\n 8.176 *\n Math.pow(\n 2,\n this.getModGenAmount(generator, 'initialFilterFc') / 1200\n ),\n modEnvToFilterFc:\n this.getModGenAmount(generator, 'modEnvToFilterFc') / 100,\n initialFilterQ: this.getModGenAmount(generator, 'initialFilterQ') / 10,\n reverbEffectSend:\n this.getModGenAmount(generator, 'reverbEffectSend') / 10,\n initialAttenuation:\n this.getModGenAmount(generator, 'initialAttenuation') / 10,\n freqVibLFO:\n 8.176 *\n Math.pow(2, this.getModGenAmount(generator, 'freqVibLFO') / 1200),\n pan: this.getModGenAmount(generator, 'pan') / 1200,\n };\n }\n }\n\n /**\n * @param {Object} generator\n * @param {string} enumeratorType\n * @return {number}\n */\n getModGenAmount(generator, enumeratorType) {\n return generator[enumeratorType]\n ? generator[enumeratorType].amount\n : Parser.getGeneratorTable()[enumeratorType];\n }\n\n /**\n * Start Tone Generator\n */\n start() {\n this.connect();\n this.bufSrc.start(0);\n this.setMasterVolume(16383);\n }\n\n /** @param {number} volume */\n setMasterVolume(volume) {\n this.masterVolume = volume;\n this.gainMaster.gain.value = this.baseVolume * (volume / 16384);\n }\n\n /** Connect root AudioContext */\n connect() {\n this.bufSrc.connect(this.gainMaster);\n }\n\n /** Disconnect root AudioContext */\n disconnect() {\n this.bufSrc.disconnect(this.gainMaster);\n this.bufSrc.buffer = null;\n }\n\n /** @return {HTMLDivElement} */\n drawSynth() {\n /** @type {Document} */\n const doc = window.document;\n /** @type {HTMLDivElement} */\n const wrapper = (this.element = doc.createElement('div'));\n wrapper.className = 'synthesizer';\n /** @type {HTMLDivElement} */\n const instElem = doc.createElement('div');\n instElem.className = 'instrument';\n /** @type {string[]} */\n this.items = [\n 'mute',\n 'bank',\n 'program',\n 'volume',\n 'expression',\n 'panpot',\n 'pitchBend',\n 'pitchBendSensitivity',\n 'reverbDepth',\n 'keys',\n ];\n /** @type {string} */\n const eventStart = 'ontouchstart' in window ? 'touchstart' : 'mousedown';\n /** @type {string} */\n const eventEnd = 'ontouchend' in window ? 'touchend' : 'mouseup';\n\n for (let channel = 0; channel < 16; channel++) {\n /** @type {HTMLDivElement} */\n const channelElem = doc.createElement('div');\n channelElem.className = 'channel';\n // ホールドを無効化する処理\n channelElem.addEventListener(eventStart, () => {\n this.hold(channel, 0);\n });\n for (const item in this.items) {\n if (!Object.hasOwn(this.items, item)) {\n continue;\n }\n /** @type {HTMLDivElement} */\n const itemElem = doc.createElement('div');\n itemElem.className = this.items[item];\n\n switch (this.items[item]) {\n case 'mute': {\n /** @type {HTMLDivElement | null} */\n const checkboxElement = doc.createElement('div');\n checkboxElement.className = 'form-check form-check-inline';\n /** @type {HTMLInputElement | null} */\n const checkbox = doc.createElement('input');\n checkbox.ariaLabel = `Ch.${channel + 1} Mute`;\n checkbox.setAttribute('type', 'checkbox');\n checkbox.className = 'form-check-input';\n checkbox.id = 'mute' + channel + 'ch';\n checkbox.value = channel.toString();\n checkbox.addEventListener(\n 'change',\n event => {\n // @ts-ignore\n this.mute(channel, event.target.checked);\n },\n false\n );\n checkboxElement.appendChild(checkbox);\n /** @type {HTMLLabelElement} */\n const labelElem = doc.createElement('label');\n\n labelElem.className = 'form-check-label';\n labelElem.textContent = (channel + 1).toString();\n labelElem.setAttribute('for', 'mute' + channel + 'ch');\n checkboxElement.appendChild(labelElem);\n itemElem.appendChild(checkboxElement);\n break;\n }\n case 'bank': {\n /** @type {HTMLSelectElement} Bank select */\n const bankSelect = doc.createElement('select');\n bankSelect.ariaLabel = `Ch.${channel + 1} Bank Select`;\n bankSelect.className = 'form-select form-select-sm bank-select';\n bankSelect.addEventListener(\n 'change',\n ((synth, ch) => event => {\n /** @type {HTMLSelectElement} */\n const program = channelElem.querySelector('.program select');\n // console.log(ch, event.target.value, program);\n // @ts-ignore\n synth.bankChange(ch, event.target.value);\n synth.programChange(ch, parseInt(program.value));\n })(this, channel),\n false\n );\n itemElem.appendChild(bankSelect);\n break;\n }\n case 'program': {\n /** @type {HTMLSelectElement} Program change */\n const select = doc.createElement('select');\n select.className = 'form-select form-select-sm';\n select.ariaLabel = `Ch.${channel + 1} Program Change`;\n select.addEventListener(\n 'change',\n ((synth, ch) => event => {\n // @ts-ignore\n synth.programChange(ch, event.target.value);\n })(this, channel),\n false\n );\n itemElem.appendChild(select);\n break;\n }\n case 'volume': {\n /** @type {HTMLElement} */\n const volumeElem = document.createElement('var');\n volumeElem.ariaLabel = `Ch.${channel + 1} Volume`;\n volumeElem.innerText = '100';\n itemElem.appendChild(volumeElem);\n break;\n }\n case 'expression': {\n /** @type {HTMLElement} */\n const expressionElem = document.createElement('var');\n expressionElem.ariaLabel = `Ch.${channel + 1} Expression`;\n expressionElem.innerText = '127';\n itemElem.appendChild(expressionElem);\n break;\n }\n case 'pitchBendSensitivity': {\n /** @type {HTMLElement} */\n const pitchSensElem = document.createElement('var');\n pitchSensElem.ariaLabel = `Ch.${\n channel + 1\n } Pitch Bend Sensitivity`;\n pitchSensElem.innerText = '2';\n itemElem.appendChild(pitchSensElem);\n break;\n }\n case 'reverbDepth': {\n /** @type {HTMLElement} */\n const reverbDepthElem = document.createElement('var');\n reverbDepthElem.ariaLabel = `Ch.${channel + 1} Reverb Depth`;\n reverbDepthElem.innerText = '40';\n itemElem.appendChild(reverbDepthElem);\n break;\n }\n case 'panpot': {\n /** @type {HTMLDivElement} */\n const panpotOuter = doc.createElement('div');\n panpotOuter.role = 'progressbar';\n panpotOuter.ariaLabel = `Ch.${channel + 1} Panpod`;\n panpotOuter.ariaValueMin = '0';\n panpotOuter.ariaValueNow = '64';\n panpotOuter.ariaValueMax = '127';\n panpotOuter.className = 'progress';\n const panpot = doc.createElement('div');\n // 緑色\n panpot.className = 'progress-bar';\n panpotOuter.appendChild(panpot);\n itemElem.appendChild(panpotOuter);\n break;\n }\n case 'pitchBend': {\n /** @type {HTMLDivElement} */\n const pitchOuter = doc.createElement('div');\n pitchOuter.className = 'progress';\n pitchOuter.role = 'progressbar';\n pitchOuter.ariaLabel = `Ch.${channel + 1} Pitch Bend`;\n pitchOuter.ariaValueMin = '-8192';\n pitchOuter.ariaValueNow = '0';\n pitchOuter.ariaValueMax = '8192';\n pitchOuter.className = 'progress';\n /** @type {HTMLDivElement} */\n const pitch = doc.createElement('div');\n // 黄色\n pitch.className = 'progress-bar progress-bar-animated';\n pitchOuter.appendChild(pitch);\n itemElem.appendChild(pitchOuter);\n break;\n }\n case 'keys': {\n // 鍵盤の描画\n for (let key = 0; key < 127; key++) {\n /** @type {HTMLDivElement} */\n const keyElem = doc.createElement('div');\n /** @type {number} */\n const n = key % 12;\n // 白鍵と黒鍵の色分け\n keyElem.className =\n 'key ' + ([1, 3, 6, 8, 10].includes(n) ? 'semitone' : 'tone');\n itemElem.appendChild(keyElem);\n\n // イベント割当\n keyElem.addEventListener(\n eventStart,\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.drag = true;\n synth.noteOn(ch, k, 127);\n })(this, channel, key)\n );\n keyElem.addEventListener(\n 'mouseover',\n ((synth, ch, k) => event => {\n event.preventDefault();\n if (synth.drag) {\n synth.noteOn(ch, k, 127);\n }\n })(this, channel, key)\n );\n keyElem.addEventListener(\n 'mouseout',\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.noteOff(ch, k);\n })(this, channel, key)\n );\n keyElem.addEventListener(\n eventEnd,\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.drag = false;\n synth.noteOff(ch, k);\n })(this, channel, key)\n );\n }\n break;\n }\n }\n channelElem.appendChild(itemElem);\n }\n instElem.appendChild(channelElem);\n this.intersection.observe(channelElem);\n }\n // ヘッダー行の描画\n const itemName = [\n 'Ch.',\n 'Bank',\n 'Program',\n 'Vol.',\n 'Exp.',\n 'Panpot',\n 'Pitch Bend',\n '',\n 'Rev.',\n '',\n ];\n /** @type {HTMLDivElement} */\n const headerElem = doc.createElement('div');\n headerElem.className = 'header';\n for (const item in this.items) {\n if (!Object.hasOwn(this.items, item)) {\n continue;\n }\n /** @type {HTMLDivElement} */\n const itemElem = doc.createElement('div');\n itemElem.className = this.items[item];\n itemElem.textContent = itemName[item];\n if (this.items[item] === 'keys') {\n // MIDI音源のLCDのテキスト領域エミュレーター\n itemElem.appendChild(document.createElement('code'));\n // GM / GS / XG表記\n itemElem.appendChild(document.createElement('div'));\n }\n headerElem.appendChild(itemElem);\n }\n instElem.prepend(headerElem);\n wrapper.appendChild(instElem);\n\n // ヘッダー行のリサイズ\n const ro = new ResizeObserver(_entries => {\n this.items.forEach(item => {\n /** @type {HTMLElement} */\n const headerItem = wrapper.querySelector(`.header .${item}`);\n /** @type {HTMLElement} */\n const channelItem = wrapper.querySelector(`.channel .${item}`);\n\n headerItem.style.width = channelItem.offsetWidth + 'px';\n });\n /** @type {HTMLElement} */\n const keysItem = wrapper.querySelector('.header .keys');\n\n keysItem.style.display =\n document.documentElement.clientWidth <= 680 ? 'none' : 'flex';\n });\n ro.observe(wrapper);\n\n return wrapper;\n }\n\n /**\n * シンセサイザーのDOMの更新\n *\n * @param {number} channel\n * @param {number} key\n * @param {number} velocity\n */\n updateSynthElement(channel, key, velocity) {\n if (!this.element) {\n return;\n }\n /** @type {NodeListOf} */\n const channelElems = this.element.querySelectorAll(\n '.instrument > .channel'\n );\n\n if (channelElems[channel].dataset.isIntersecting) {\n /** @type {HTMLDivElement} */\n const keyElem = channelElems[channel].querySelector(\n `.key:nth-child(${key + 1})`\n );\n if (velocity === 0) {\n if (keyElem.classList.contains('note-on')) {\n keyElem.classList.remove('note-on');\n }\n keyElem.style.opacity = '1';\n } else {\n keyElem.classList.add('note-on');\n // ベロシティに応じて透過度を調整\n keyElem.style.opacity = (velocity / 127).toFixed(2);\n }\n }\n }\n\n /**\n * バンクセレクタの選択ボックスの処理\n *\n * @param {number} channel\n */\n updateBankSelect(channel) {\n if (!this.element) {\n return;\n }\n /** @type {HTMLElement} */\n const bankElement = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.bank > select');\n\n while (bankElement.firstChild) {\n bankElement.removeChild(bankElement.firstChild);\n }\n\n for (const bankNo in this.programSet) {\n if (!Object.hasOwn(this.programSet, bankNo)) {\n continue;\n }\n const option = document.createElement('option');\n option.value = bankNo;\n option.textContent = ('000' + parseInt(bankNo)).slice(-3);\n if (parseInt(bankNo) === this.channelBank[channel]) {\n option.selected = true;\n }\n bankElement.appendChild(option);\n }\n }\n\n /**\n * プログラムチェンジの選択ボックスの処理\n *\n * @param {number} channel\n */\n updateProgramSelect(channel) {\n if (!this.element) {\n return;\n }\n const dom = this.element.querySelectorAll('.instrument > .channel')[\n channel\n ];\n\n /** @type {number} */\n const bankIndex = this.channelBank[channel];\n /** @type {HTMLSelectElement} */\n const bankElement = dom.querySelector('.bank > select');\n /** @type {HTMLSelectElement} */\n const programElement = dom.querySelector('.program > select');\n\n bankElement.value = this.channelBank[channel].toString();\n while (programElement.firstChild) {\n programElement.removeChild(programElement.firstChild);\n }\n\n for (const programNo in this.programSet[bankIndex]) {\n if (!Object.hasOwn(this.programSet[bankIndex], programNo)) {\n continue;\n }\n // TODO: 存在しないプログラムの場合、現状では空白になってしまう\n /** @type {HTMLOptionElement} */\n const option = document.createElement('option');\n option.value = programNo;\n option.textContent = `${('000' + (parseInt(programNo) + 1)).slice(-3)}:${\n this.programSet[bankIndex][programNo]\n }`;\n if (parseInt(programNo) === this.channelInstrument[channel]) {\n option.selected = true;\n }\n programElement.appendChild(option);\n }\n }\n\n /**\n * ノートオン\n *\n * @param {number} channel NoteOn するチャンネル.\n * @param {number} key NoteOn するキー.\n * @param {number} velocity 強さ.\n */\n noteOn(channel, key, velocity = 100) {\n /** @type {number} */\n const bankIndex = this.channelBank[channel];\n // バンクに楽器が存在しない場合は、原則的にバンク0の楽器を選択する。\n // ただし、SFX(Bank 64)は発音しない、\n // パーカッション(Bank127~128) の場合、0のStandard Kitの音を鳴らさなければならない)\n /** @type {Object} */\n const bank =\n typeof this.bankSet[bankIndex] === 'object'\n ? this.bankSet[bankIndex]\n : this.bankSet[0];\n\n /** @type {Object} */\n let instrument;\n\n if (typeof bank[this.channelInstrument[channel]] === 'object') {\n // 音色が存在する場合\n instrument = bank[this.channelInstrument[channel]];\n } else if (this.percussionPart[channel]) {\n // パーカッションバンクが選択されている場合で音色が存在しない場合Standard Kitを選択\n instrument = this.bankSet[this.mode === 'XG' ? 127 : 128][0];\n } else {\n // 通常の音色が選択されている状態で音色が存在しない場合バンク0を選択\n instrument = this.bankSet[0][this.channelInstrument[channel]];\n }\n\n if (!instrument[key]) {\n // TODO\n console.warn(\n 'instrument not found: bank=%s instrument=%s channel=%s key=%s',\n bankIndex,\n this.channelInstrument[channel],\n channel,\n key\n );\n return;\n }\n /** @type {Object} */\n const instrumentKey = instrument[key];\n /** @type {number} */\n let panpot =\n this.channelPanpot[channel] === 0\n ? Math.floor(Math.random() * 127) // パンが0の場合ランダムとなる。\n : this.channelPanpot[channel] - 64;\n panpot /= panpot < 0 ? 64 : 63;\n\n // create note information\n instrumentKey.channel = channel;\n instrumentKey.key = key;\n instrumentKey.velocity = velocity;\n instrumentKey.panpot = panpot;\n instrumentKey.volume = this.channelVolume[channel] / 127;\n instrumentKey.pitchBend = this.channelPitchBend[channel] - 8192;\n instrumentKey.expression = this.channelExpression[channel];\n instrumentKey.pitchBendSensitivity = Math.round(\n this.channelPitchBendSensitivity[channel]\n );\n instrumentKey.mute = this.channelMute[channel];\n instrumentKey.releaseTime = this.channelRelease[channel];\n instrumentKey.cutOffFrequency = this.cutOffFrequency[channel];\n instrumentKey.harmonicContent = this.harmonicContent[channel];\n instrumentKey.reverb = this.reverb[channel];\n instrumentKey.modulation = this.modulation[channel];\n\n // percussion\n if (bankIndex >= 127) {\n // ドラムパートのハイハットクローズはここで定義するべきではない。\n if (key === 42 || key === 44) {\n // 42: Closed Hi-Hat\n // 44: Pedal Hi-Hat\n // 46: Open Hi-Hat\n this.noteOff(channel, 46);\n }\n if (key === 80) {\n // 80: Mute Triangle\n // 81: Open Triangle\n this.noteOff(channel, 81);\n }\n instrument.volume *= this.percussionVolume[key] / 127;\n }\n\n // note on\n /** @type {SynthesizerNote} */\n const note = new SynthesizerNote(this.ctx, this.gainMaster, instrumentKey);\n // TODO: 本来パンポットはここで指定する\n note.noteOn();\n this.currentNoteOn[channel].push(note);\n\n this.updateSynthElement(channel, key, velocity);\n }\n\n /**\n * ノートオフ\n *\n * @param {number} channel NoteOff するチャンネル.\n * @param {number} key NoteOff するキー.\n */\n noteOff(channel, key) {\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {SynthesizerNote} */\n let note;\n /** @type {boolean} */\n const hold = this.channelHold[channel];\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n note = currentNoteOn[i];\n if (note.key === key) {\n note.noteOff();\n // hold している時は NoteOff にはするがリリースはしない\n if (!hold) {\n note.release();\n currentNoteOn.splice(i, 1);\n --i;\n --il;\n }\n }\n }\n this.updateSynthElement(channel, key, 0);\n }\n\n /**\n * ホールド(ダンパーペダル)\n *\n * @param {number} channel ホールドするチャンネル\n * @param {number} value 値\n */\n hold(channel, value) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {boolean} 0以外はonである。 */\n const hold = (this.channelHold[channel] = value > 64);\n /** @type {SynthesizerNote} */\n let note;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n if (!hold) {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n note = currentNoteOn[i];\n if (note.isNoteOff()) {\n note.release();\n currentNoteOn.splice(i, 1);\n --i;\n --il;\n }\n }\n }\n\n if (this.element) {\n /** @type {NodeListOf} */\n const channelElements = this.element.querySelectorAll(\n '.instrument > .channel'\n );\n\n if (!channelElements[channel]) {\n return;\n }\n if (this.channelHold[channel]) {\n channelElements[channel].classList.add('hold');\n } else if (channelElements[channel].classList.contains('hold')) {\n channelElements[channel].classList.remove('hold');\n }\n }\n }\n\n /**\n * バンクセレクトMSB(GS音源/GM Level2用)\n *\n * @param {number} channel チャンネルのバンクセレクトMSB\n * @param {number} value 値\n */\n bankSelectMsb(channel, value) {\n // 125より値が大きい場合、パーカッションとして処理\n this.percussionPart[channel] = value >= 125;\n // 念の為バンクを0にリセット\n this.channelBank[channel] = channel === 9 ? 128 : 0;\n\n if (this.mode === 'GM') {\n // GM音源モードのときはバンク・セレクトを無視\n return;\n } else if (this.mode === 'XG') {\n // XG音源は、MSB→LSBの優先順でバンクセレクトをする。\n if (value === 64) {\n // Bank Select MSB #64 (Voice Type: SFX)\n this.channelBank[channel] = 125;\n } else if (value === 126 || value === 127) {\n // Bank Select MSB #126 (Voice Type: Drum)\n // Bank Select MSB #127 (Voice Type: Drum)\n this.channelBank[channel] = value;\n } else if (value === 128) {\n this.channelBank[channel] = 127;\n }\n } else {\n // GS音源\n // ※チャンネル10のバンク・セレクト命令は無視する。\n this.channelBank[channel] = channel === 9 ? 128 : value;\n this.percussionPart[channel] = value === 128;\n }\n this.updateBankSelect(channel);\n }\n\n /**\n * バンクセレクトLSB(XG音源)\n *\n * @param {number} channel チャンネルのバンクセレクトLSB\n * @param {number} value 値\n */\n bankSelectLsb(channel, value) {\n // XG音源以外は処理しない\n if (this.mode !== 'XG') {\n return;\n }\n\n if (!this.percussionPart[channel]) {\n // ドラムパートではバンクセレクトLSB命令を無視する。\n this.channelBank[channel] = value;\n }\n\n this.updateBankSelect(channel);\n }\n\n /**\n * プログラムチェンジ\n *\n * @param {number} channel 音色を変更するチャンネル.\n * @param {number} instrument 音色番号.\n */\n programChange(channel, instrument) {\n this.channelInstrument[channel] = instrument;\n\n this.bankChange(channel, this.channelBank[channel]);\n if (this.element) {\n /** @type {HTMLSelectElement} */\n const select = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.program > select');\n\n select.value = instrument.toString();\n }\n }\n\n /**\n * バンクセレクト\n *\n * @param {number} channel 音色を変更するチャンネル.\n * @param {number} bank バンク・セレクト.\n */\n bankChange(channel, bank) {\n /** パーカッションバンク */\n const percussionBank = this.mode === 'XG' || this.mode === 'GM' ? 127 : 128;\n if (this.mode === 'GM') {\n // GMの場合バンクセレクトを無効化\n bank = 0;\n }\n if (channel === 9) {\n // GS、XGフラグが立っていない(拡張音源ではない)場合は、ch10はドラム固定、それ以外は0とする。\n bank = percussionBank;\n }\n if (this.bankSet[bank]) {\n this.channelBank[channel] = bank;\n } else {\n // 存在しない場合0を選択\n this.channelBank[channel] = this.percussionPart[channel]\n ? percussionBank\n : 0;\n }\n // }\n\n if (this.element) {\n /** @type {HTMLSelectElement} バンクセレクトの値 */\n const bankSelect = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.bank > select');\n bankSelect.value = bank.toString();\n }\n // TODO: 厳密にはMIDI音源はプログラムチェンジがあったときに、バンク・セレクトの値が反映されるのでこの実装は正しくない。\n this.updateProgramSelect(channel);\n }\n\n /**\n * ボリューム\n *\n * @param {number} channel 音量を変更するチャンネル.\n * @param {number} volume 音量(0-127).\n */\n volumeChange(channel, volume) {\n if (this.element) {\n /** @type {HTMLElement} */\n const volumeVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.volume var');\n volumeVariable.innerText = volume.toString();\n }\n\n this.channelVolume[channel] = volume;\n }\n\n /**\n * エクスプレッション\n *\n * @param {number} channel 音量を変更するチャンネル.\n * @param {number} expression 音量(0-127).\n */\n expression(channel, expression) {\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].updateExpression(expression);\n }\n\n if (this.element) {\n /** @type {HTMLElement} */\n const expressionVariabe = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.expression var');\n\n expressionVariabe.innerText = expression.toString();\n }\n\n this.channelExpression[channel] = expression;\n }\n\n /**\n * パンポット\n *\n * @param {number} channel Panpot を変更するチャンネル.\n * @param {number} panpot Panpot(0-127).\n */\n panpotChange(channel, panpot) {\n this.channelPanpot[channel] = panpot;\n if (this.element) {\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.panpot');\n dom.ariaValueNow = panpot.toString();\n /** @type {HTMLDivElement} */\n const progressBar = dom.querySelector('.progress-bar');\n const percentage = (panpot / 127) * 100;\n progressBar.style.width = `${percentage}%`;\n progressBar.classList.remove('left', 'right');\n progressBar.title = panpot.toString();\n if (panpot === 64) {\n return;\n }\n dom.classList.add(panpot < 63 ? 'left' : 'right');\n }\n }\n\n /**\n * ピッチベンド\n *\n * @param {number} channel ピッチベンドを変更するチャンネル.\n * @param {number} lowerByte\n * @param {number} higherByte\n */\n pitchBend(channel, lowerByte, higherByte) {\n /** @type {number} */\n const bend = (lowerByte & 0x7f) | ((higherByte & 0x7f) << 7);\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {import('./sound_font_synth_note.js').default[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {number} */\n const calculated = bend - 8192;\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].updatePitchBend(calculated);\n }\n\n this.channelPitchBend[channel] = bend;\n\n if (this.element) {\n /** @type {HTMLDivElement} */\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBend');\n dom.ariaValueNow = bend.toString();\n /** @type {HTMLDivElement} */\n const progressBar = dom.querySelector('.progress-bar');\n progressBar.style.width = `${Math.floor((bend / 16384) * 100)}%`;\n progressBar.title = calculated.toString();\n progressBar.classList.remove('high', 'low');\n if (calculated === 0) {\n return;\n }\n progressBar.classList.add(calculated < 0 ? 'low' : 'high');\n }\n }\n\n /**\n * ピッチベンド・センシビリティ\n *\n * @param {number} channel Pitch bend sensitivity を変更するチャンネル.\n * @param {number} sensitivity\n */\n pitchBendSensitivity(channel, sensitivity) {\n if (this.element) {\n /** @type {HTMLElement} */\n const pitchBendSensitivityVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBendSensitivity > var');\n pitchBendSensitivityVariable.innerText = sensitivity.toString();\n }\n this.channelPitchBendSensitivity[channel] = sensitivity;\n }\n\n /**\n * アタックタイム\n *\n * @param {number} channel\n * @param {number} attackTime\n */\n attackTime(channel, attackTime) {\n this.channelAttack[channel] = attackTime;\n }\n\n /**\n * ディケイタイム\n *\n * @param {number} channel\n * @param {number} decayTime\n */\n decayTime(channel, decayTime) {\n this.channelDecay[channel] = decayTime;\n }\n\n /**\n * サスティンタイム\n *\n * @param {number} channel\n * @param {number} sustinTime\n */\n sustinTime(channel, sustinTime) {\n this.channelSustin[channel] = sustinTime;\n }\n\n /**\n * リリースタイム\n *\n * @param {number} channel\n * @param {number} releaseTime\n */\n releaseTime(channel, releaseTime) {\n this.channelRelease[channel] = releaseTime;\n }\n\n /**\n * ハーモニックコンテント(ブライトネス)\n *\n * @param {number} channel\n * @param {number} value\n */\n harmonicContent(channel, value) {\n this.channelHarmonicContent[channel] = value;\n }\n\n /**\n * カットオフフリクエンシー\n *\n * @param {number} channel\n * @param {number} value\n */\n cutOffFrequency(channel, value) {\n this.channelCutOffFrequency[channel] = value;\n }\n\n /**\n * リバーブエフェクト\n *\n * @param {number} channel\n * @param {number} depth\n */\n reverbDepth(channel, depth) {\n // リバーブ深度は、ドライ/ウェット比とする。\n this.reverb[channel].mix(depth / 127);\n\n if (this.element) {\n /** @type {HTMLElement} */\n const reverbVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.reverbDepth var');\n reverbVariable.innerText = depth.toString();\n }\n }\n\n /**\n * モジュレーション(ビブラート)デプス\n *\n * @param {number} channel\n * @param {number} depth\n */\n modulationDepth(channel, depth) {\n if (this.element) {\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBend .progress-bar');\n\n // モデレーターが0でないときは、ピッチに斜め線を入れる\n if (depth !== 0) {\n dom.classList.add('progress-bar-striped');\n } else {\n dom.classList.remove('progress-bar-striped');\n }\n }\n this.modulation[channel] = depth;\n }\n\n /**\n * @param {number} channel Pitch bend sensitivity を取得するチャンネル.\n * @return {number}\n */\n getPitchBendSensitivity(channel) {\n return this.channelPitchBendSensitivity[channel];\n }\n\n /**\n * @param {number} key\n * @param {number} volume\n */\n drumInstrumentLevel(key, volume) {\n this.percussionVolume[key] = volume;\n }\n\n /**\n * オールノートオフ\n *\n * @param {number} channel NoteOff するチャンネル.\n */\n allNoteOff(channel) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n\n // ホールドを解除\n this.hold(channel, 0);\n\n // 再生中の音をすべて止める\n while (currentNoteOn.length > 0) {\n this.noteOff(channel, currentNoteOn[0].key);\n }\n }\n\n /**\n * オールサウンドオフ\n *\n * @param {number} channel 音を消すチャンネル.\n */\n allSoundOff(channel) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {SynthesizerNote} */\n let note;\n\n while (currentNoteOn.length > 0) {\n note = currentNoteOn.shift();\n this.noteOff(channel, note.key);\n note.release();\n note.disconnect();\n }\n\n // ホールドを解除\n this.hold(channel, 0);\n }\n\n /**\n * リセットオールコントロール\n *\n * @param {number} channel リセットするチャンネル\n */\n resetAllControl(channel) {\n // 実装不十分では?\n this.allNoteOff(channel);\n this.expression(channel, 127);\n this.pitchBend(channel, 0x00, 0x40);\n }\n\n /**\n * ミュート\n *\n * @param {number} channel ミュートの設定を変更するチャンネル.\n * @param {boolean} mute ミュートにするなら true.\n */\n mute(channel, mute) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n this.channelMute[channel] = mute;\n\n if (mute) {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].disconnect();\n }\n } else {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].connect();\n }\n }\n }\n\n /**\n * パーカッションチャネルにする\n *\n * @param {number} channel パーカッションチャネルとしてセットするチャンネル\n * @param {boolean} sw パーカッションチャネルか通常かのスイッチ\n */\n setPercussionPart(channel, sw) {\n this.channelBank[channel] =\n this.mode === 'GS' || this.mode === 'GM2' ? 128 : 127;\n\n this.percussionPart[channel] = sw;\n this.updateBankSelect(channel);\n }\n\n /**\n * MIDI音源のメッセージ欄に送られるsysExを解析\n *\n * @param {number[]} message\n */\n processMidiMessage(message) {\n clearTimeout(this.timer);\n /** @type {HTMLElement} */\n const dom = this.element.querySelector('.header .keys code');\n dom.innerText = message.map(e => String.fromCharCode(e)).join('');\n\n // 10秒後に削除\n this.timer = setTimeout(() => {\n dom.innerText = '';\n }, 50000);\n }\n}\n","import Loader from './loader.js';\nimport Synthesizer from './sound_font_synth.js';\n\n/**\n * WebMidiLink Class\n *\n * @author imaya\n */\nexport default class WebMidiLink {\n /** @param {object} option */\n constructor(option = {}) {\n /** @type {number[]} */\n this.NrpnMsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.NrpnLsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.RpnMsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.RpnLsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {boolean} */\n this.ready = false;\n /** @type {Synthesizer} */\n this.synth = undefined;\n /** @type {Function} */\n this.messageHandler = this.onMessage.bind(this);\n /** @type {boolean} */\n this.rpnMode = true;\n /** @type {object} */\n this.option = {};\n /** @type {boolean} Display synthsizer Web UI */\n this.option.drawSynth = option.drawSynth !== 'false';\n /** @type {boolean} Use Cache API */\n this.option.cache = option.cache ?? true;\n /** @type {string} CORS */\n this.option.targetOrigin = option.targetOrigin ?? '*';\n /** @type {'dark'|'light'|'auto'|undefined} Color mode */\n this.option.colorMode = option.colorMode ?? 'auto';\n /** @type {string} SoundFont URL */\n this.url =\n option.url ??\n 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2';\n\n /** @type {HTMLDivElement} */\n // @ts-ignore\n this.placeholder = option.placeholder\n ? document.getElementById(option.placeholder)\n : window.document.body;\n this.setColorMode(this.option.colorMode);\n /** @type {Window} */\n this.window = null;\n\n if (window.opener) {\n this.window = window.opener;\n } else if (window.parent !== window) {\n this.window = window.parent;\n } else {\n this.window = window;\n }\n }\n\n /**\n * Setup Soundfont by URL.\n *\n * @param {string?} url SoundFont URL\n * @public\n */\n async setup(url = undefined) {\n // DOMをクリア\n while (this.placeholder.firstChild) {\n this.placeholder.removeChild(this.placeholder.firstChild);\n }\n if (url) {\n // URLが明示的に指定されていた場合\n this.url = url;\n }\n\n /** 読み込み */\n const loader = new Loader(\n this.url,\n this.placeholder,\n this.option.cache,\n (/** @type {ArrayBuffer} */ buffer) => this.setupByBuffer(buffer)\n );\n await loader.fetch();\n }\n\n /**\n * Get SoundFont URL.\n *\n * @return {string}\n */\n getUrl() {\n return this.url;\n }\n\n /**\n * Setup SoundFont by ArrayBuffer.\n *\n * @param {ArrayBuffer} buffer\n */\n setupByBuffer(buffer) {\n // DOMをクリア\n while (this.placeholder.firstChild) {\n this.placeholder.removeChild(this.placeholder.firstChild);\n }\n\n if (!this.synth) {\n // 読み込まれていないときシンセサイザをセットアップ\n // @ts-ignore\n this.synth = new Synthesizer(buffer);\n // 待受開始\n this.synth.start();\n } else {\n // 別のSoundFontが読み込まれたときリロード\n // @ts-ignore\n this.synth.refreshInstruments(buffer);\n }\n if (this.option.drawSynth) {\n // キーボードなどを描画\n this.placeholder.appendChild(this.synth.drawSynth());\n } else {\n /** @type {HTMLDivElement} キーボードを描画しないときはReadyだけを表示する。 */\n const readyElem = document.createElement('div');\n readyElem.className = 'alert alert-success';\n readyElem.role = 'alert';\n readyElem.innerText = 'Ready.';\n this.placeholder.appendChild(readyElem);\n }\n // シンセサイザを初期化\n this.synth.init();\n\n this.onReady();\n }\n\n /**\n * Callback\n *\n * @protected\n */\n callback() {}\n\n /**\n * SoundFont Load Ready\n *\n * @protected\n */\n onReady() {\n // 一旦MIDI Link待受を解除\n // @ts-ignore\n window.removeEventListener('message', this.messageHandler);\n // コールバック実行\n this.callback();\n // MIDI Link待ち受け開始\n // @ts-ignore\n window.addEventListener('message', this.messageHandler, false);\n // ホスト側に準備完了通知を送信\n this.window.postMessage('link,ready', this.option.targetOrigin);\n }\n\n /**\n * WebMidiLink信号をパース\n *\n * @param {Event} ev\n * @private\n */\n onMessage(ev) {\n /** @type {Array} */\n // @ts-ignore\n const msg = typeof ev.data.split === 'function' ? ev.data.split(',') : [];\n /** @type {string} */\n // @ts-ignore\n const type = msg.length !== 0 ? msg.shift() : '';\n /** @type {string} */\n let command;\n\n switch (type) {\n case 'midi':\n this.processMidiMessage(msg.map(hex => parseInt(hex, 16)));\n break;\n case 'link':\n if (!this.window) {\n return;\n }\n command = msg.shift();\n switch (command) {\n case 'reqpatch':\n // TODO: dummy data\n this.window.postMessage('link,patch', this.option.targetOrigin);\n break;\n case 'setpatch':\n case 'ready':\n this.window.postMessage('link,ready', this.option.targetOrigin);\n // TODO: NOP\n break;\n case 'progress':\n // ※この命令は、WebMidiLinkの仕様に含まれていません。\n this.window.postMessage('link,progress', this.option.targetOrigin);\n break;\n default:\n console.error('unknown link message:', command);\n break;\n }\n break;\n default:\n console.error('unknown message type');\n }\n }\n\n /**\n * MIDI準備完了時のコールバック処理を登録する\n *\n * @param {()=>{}} callback コールバック関数\n * @public\n */\n setLoadCallback(callback) {\n this.callback = callback;\n }\n\n /**\n * MIDI信号を解析し、シンセサイザーを操作する\n *\n * @param {number[]} message\n * @protected\n */\n processMidiMessage(message) {\n /** @type {number} */\n const channel = message[0] & 0x0f;\n /** @type {Synthesizer} */\n const synth = this.synth;\n\n // http://amei.or.jp/midistandardcommittee/MIDI1.0.pdf\n switch (message[0] & 0xf0) {\n case 0x80: // NoteOff: 8n kk vv\n // @ts-ignore\n synth.noteOff(channel, message[1], message[2]);\n break;\n case 0x90: // NoteOn: 9n kk vv\n if (message[2] > 0) {\n synth.noteOn(channel, message[1], message[2]);\n } else {\n // @ts-ignore\n synth.noteOff(channel, message[1], 0);\n }\n break;\n case 0xb0: {\n // Control Change: Bn cc dd\n /** @type {number} */\n const value = message[2];\n switch (message[1]) {\n case 0x00: // Bank Select MSB: Bn 00 dd\n synth.bankSelectMsb(channel, value);\n break;\n case 0x01: // Modulation Depth\n synth.modulationDepth(channel, value);\n break;\n case 0x05: // Portament Time\n break;\n case 0x06: // Data Entry(MSB): Bn 06 dd\n if (this.rpnMode) {\n // RPN\n switch (this.RpnMsb[channel]) {\n case 0:\n switch (this.RpnLsb[channel]) {\n case 0: // Pitch Bend Sensitivity\n synth.pitchBendSensitivity(channel, value);\n break;\n case 1:\n // console.log(\"fine\");\n break;\n case 2:\n // console.log(\"coarse\");\n break;\n default:\n // console.log(\"default\");\n break;\n }\n break;\n default:\n // console.log(\"default:\", this.RpnMsb[channel], this.RpnLsb[channel]);\n break;\n }\n } else {\n // NRPN\n switch (this.NrpnMsb[channel]) {\n case 26: // Drum Instrument Level\n synth.drumInstrumentLevel(this.NrpnLsb[channel], value);\n break;\n default:\n // console.log(\"default:\", this.RpnMsb[channel], this.RpnLsb[channel]);\n break;\n }\n }\n break;\n case 0x26: // Data Entry(LSB): Bn 26 dd\n if (this.rpnMode) {\n // RPN\n switch (this.RpnMsb[channel]) {\n case 0:\n switch (this.RpnLsb[channel]) {\n case 0: // Pitch Bend Sensitivity\n synth.pitchBendSensitivity(\n channel,\n synth.getPitchBendSensitivity(channel) + value / 100\n );\n break;\n case 1:\n // console.log(\"fine\");\n break;\n case 2:\n // console.log(\"coarse\");\n break;\n }\n break;\n }\n }\n\n // NRPN で LSB が必要なものは今のところない\n break;\n\n case 0x07: // Volume Change: Bn 07 dd\n synth.volumeChange(channel, value);\n break;\n case 0x0a: // Panpot Change: Bn 0A dd\n synth.panpotChange(channel, value);\n break;\n case 0x78: // All Sound Off: Bn 78 00]\n synth.allSoundOff(channel);\n break;\n case 0x79: // Reset All Control: Bn 79 00\n synth.resetAllControl(channel);\n break;\n case 0x20: // BankSelect LSB: Bn 00 dd\n synth.bankSelectLsb(channel, value);\n break;\n case 0x47: // Harmonic Content\n synth.harmonicContent(channel, value);\n break;\n case 0x60: //\n // console.log(60);\n break;\n case 0x61: //\n // console.log(61);\n break;\n case 0x62: // NRPN LSB\n this.rpnMode = false;\n this.NrpnLsb[channel] = value;\n break;\n case 0x63: // NRPN MSB\n this.rpnMode = false;\n this.NrpnMsb[channel] = value;\n break;\n case 0x64: // RPN LSB\n this.rpnMode = true;\n this.RpnLsb[channel] = value;\n break;\n case 0x65: // RPN MSB\n this.rpnMode = true;\n this.RpnMsb[channel] = value;\n break;\n case 0x40: // Hold\n synth.hold(channel, value);\n break;\n case 0x0b: // Expression\n synth.expression(channel, value);\n break;\n case 0x48: // DecayTyme\n synth.decayTime(channel, value);\n break;\n case 0x49: // ReleaseTime\n synth.releaseTime(channel, value);\n break;\n case 0x4a: // Attack time\n synth.attackTime(channel, value);\n break;\n case 0x4b: // Brightness\n synth.cutOffFrequency(channel, value);\n break;\n case 0x5b: // Effect1 Depth(Reverb Send Level)\n synth.reverbDepth(channel, value);\n break;\n default:\n // not supported\n break;\n }\n break;\n }\n case 0xc0: // Program Change: Cn pp\n synth.programChange(channel, message[1]);\n break;\n case 0xe0: // Pitch Bend\n synth.pitchBend(channel, message[1], message[2]);\n break;\n case 0xf0: {\n // delete checksum\n message.splice(1, 1);\n\n // System Exclusive Message\n // [1] F0\n // [2] https://www.amei.or.jp/report/report6.html\n // [3] \n // [4] \n // [5] \n // [6] \n // [7] \n // [8] \n // [9] \n // [10] \n // [11] [IGNORE]\n // [12] F7 EOX [IGNORE]\n // console.log(this.dumpMessage(message));\n\n /**\n * @type {number} System Exclusive Manufacture's ID Number\n * @see {@link https://electronicmusic.fandom.com/wiki/List_of_MIDI_Manufacturer_IDs}\n */\n const manufacturerId = message[1];\n /** @type {number} Device ID (GM extended=0x10 / ポケミク=0x79 / Any=0x7F) */\n const device = message[2];\n /** @type {number} Model ID: (GM=0x09 / GS=0x42 / XG=0x4C) */\n const model = message[3];\n\n if (manufacturerId === 0x7e || device === 0x09) {\n // Gneral MIDI\n // http://amei.or.jp/midistandardcommittee/Recommended_Practice/GM2_japanese.pdf\n // console.log('GM:', this.dumpMessage(message));\n // Non Realtime\n switch (model) {\n case 0x01:\n // GM System On\n synth.init('GM');\n console.info('\\x1b[34mGM System On\\x1b[0m');\n break;\n case 0x02:\n // GM System Off\n console.info('\\x1b[34mGM System Off\\x1b[0m');\n // Throuh\n break;\n case 0x03:\n // GM2 System On\n console.info('\\x1b[34mGM (v2) System On\\x1b[0m');\n synth.init('GM2');\n break;\n default:\n // @ts-ignore\n console.log('\\x1b[34mGM\\x1b[0m: ' + this.dumpMessage(message));\n }\n } else if (manufacturerId === 0x7f) {\n // Realtime\n if (model === 0x01) {\n // master volume: F0 7F 7F 04 01 [value] [value] F7\n synth.setMasterVolume(message[4] + (message[5] << 7));\n } else {\n // @ts-ignore\n console.log(\n '\\x1b[34mRealtime\\x1b[0m: ' + this.dumpMessage(message)\n );\n }\n } else if (manufacturerId === 0x7d) {\n // smfplayer / sf2synth固有命令は、プライベート/非営利用途用のManufacturer IDである0x7Dを使用する。\n // プログラム上意味はないが、GM互換であるため、deviceID:0x10、ModelID:0x00とする。\n // よって、F0 7D 10 00 [...] 7Fで定義\n\n if (message[4] === 0x01) {\n // カラーモード切替\n // F0 7D 10 00 01 [value]\n if (message[5] === 0x01) {\n // 明示的にライトモード\n this.setColorMode('light');\n } else if (message[5] === 0x02) {\n // 明示的にダークモード\n this.setColorMode('dark');\n } else {\n // OSの設定に合わせる\n this.setColorMode('auto');\n }\n }\n }\n\n if (model === 0x42) {\n // Roland GS\n // http://lib.roland.co.jp/support/jp/manuals/res/1809974/SC-88VL_j.pdf\n // deviceは10、modelIDは42固定。\n // F0 41 10 42 12 [addr] [part] [key] [value] [checksum] F7\n // (DeviceID = 10, ModelID = 42, CommandID = 12)\n\n // QuickTime音源や、WindowsMIDI音源は、GS互換音源なのでmanufacturerIdが41とは限らない\n\n /* * @param {number} GsAddress GSアドレス(未使用)\n const GsAddress = message[6];\n */\n /** @type {number} GSパート番号 */\n const GsPart = message[6] - 0x0f;\n /** @type {number} GSのキーパラメータ */\n const GsKey = message[7];\n /** @type {number} GSの値 */\n const GsValue = message[8];\n // TODO\n switch (GsKey) {\n case 0x00:\n // TEXT INSERT FOR SC (ASCI code)\n // http://kurizill.g1.xrea.com/memorandum/midi2.htm\n // F0 41 10 45 12 10 [page] 00 [...value] [checksum] F7\n // ex. F0 41 10 45 12 10 00 00 [48 65 6C 6C 6F] 21 F7 = Hello\n\n // device IDの値は0x45固定だがその判定処理は省略\n\n if (GsPart === 0x00) {\n // ページが0x00の場合、LCDに表示するメッセージとする\n // @ts-ignore\n const msg = message.splice(8);\n // Remove F7\n msg.pop();\n // Remove Checksum\n msg.pop();\n synth.processMidiMessage(msg);\n } else {\n // GS音源のLCDの16x16のビットマップ画像\n // @ts-ignore\n console.log(\n '\\x1b[31mGS Bitmap message\\x1b[0m:' +\n this.dumpMessage(message)\n );\n }\n break;\n case 0x04:\n // GS Master Volume:\n // F0 41 10 42 12 40 00 04 [value] [checksum] F7\n // console.log('GS Volume:', this.dumpMessage(message));\n synth.setMasterVolume(GsValue * 64);\n break;\n\n case 0x15: {\n // GS Dram part: F0 41 10 42 12 40 1[part no] [Map] [checksum] F7\n // Notice: [sum] is ignroe in this program.\n\n if (GsPart === 0) {\n // 10 Ch.\n synth.setPercussionPart(9, GsValue !== 0x00);\n } else if (GsPart >= 10) {\n // 1~9 Ch.\n synth.setPercussionPart(GsPart - 1, GsValue !== 0x00);\n } else {\n // 11~16 Ch.\n synth.setPercussionPart(GsPart, GsValue !== 0x00);\n }\n break;\n }\n case 0x19:\n // VOLUME ON/OFF (PART LEVEL)\n // F0 41 10 42 12 40 1[part no] 19 [value] [checksum] F7\n console.info(\n '\\x1b[31mGS Volume On/Off\\x1b[0m: ' + GsPart,\n GsValue\n );\n break;\n case 0x30:\n // Reverb Effect\n console.info(\n '\\x1b[31mGS Reverb\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x38:\n // Chorus Effect\n console.info(\n '\\x1b[31mGS Chorus\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x45:\n // Bitmap icon 16x16 ?\n console.info(\n '\\x1b[31mGS Bitmap\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x7f:\n // GS Reset: F0 41 10 42 12 40 00 7F 00 [checksum] F7\n synth.init('GS');\n console.info('\\x1b[31mGS Reset\\x1b[0m');\n break;\n default:\n // @ts-ignore\n console.log('\\x1b[31mGS\\x1b[0m: ' + this.dumpMessage(message));\n }\n } else if (model === 0x4c) {\n // YAMAHA XG\n // F0 43 10 4C [...] F7\n // https://jp.yamaha.com/files/download/other_assets/9/321739/read_aoyama.pdf\n // https://jp.yamaha.com/files/download/other_assets/1/316861/MU100J1.pdf\n\n // カシオとKORGはXG互換音源を作っていたためmanufacturerIdが43とは限らない\n\n /** @type {number} Xg音源のキー */\n const XgKey = message[4];\n /** @type {number} Xg音源のパート */\n const XgPart = message[5];\n\n switch (XgKey) {\n case 0x00:\n // XG Reset:\n // F0 43 1n 4C 00 00 7E 00 F7\n if (message[6] === 0x7e) {\n synth.init('XG');\n console.info('\\x1b[32mXG Reset\\x1b[0m');\n }\n break;\n case 0x02:\n // Effect\n // https://jp.yamaha.com/files/download/other_assets/5/321745/efctparamlist.pdf\n // F0 43 10 4C 02 01 [type] [value] F7\n //\n // type\n // 02: Reverb\n // リバーブエフェクトのインパルス応答を選択する\n // 40: Variation\n // F0 43 10 4C 02 01 40 [type] 00 F7\n // インサーションエフェクトとして使用するモードと全チャンネルにかけるシステムエフェクトモード場合がある。\n // アンプシミュレーターやディストーション、フェイザー、ディレイなど飛び道具的なエフェクトはここに入っていた。\n // 41: バリエーションエフェクトの種類\n // [value]にエフェクトの種類\n // 5B: バリエーションエフェクトをかけるパート\n // F0 43 10 4C 02 01 5B [part] F7\n // [value]が0でインサーションエフェクト、1でシステムエフェクトモードに切り替える。\n // インサーションエフェクトが実装される前(MU100よりも前の機種)は、ディレイ・エフェクトで使う場合が多かった。\n console.log(\n '\\x1b[32mXG Effect\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x03:\n // Insertion Effect\n // F0 43 10 4C 03 [type] [value] F7\n // MU100以降の機種で実装されている。最大2系統。1チャンネルのみ指定可能。\n console.log(\n '\\x1b[32mXG Insertion Effect\\x1b[0m: ' +\n this.dumpMessage(message)\n );\n break;\n case 0x04:\n // XG Master Volume:\n // F0 43 1n 4C 00 00 04 [value] F7\n synth.setMasterVolume(message[9] * 64);\n break;\n case 0x06: {\n // Text:\n // F0 43 1n 4C 06 00 00 [text] F7\n // ex. F0 43 1n 4C 06 00 00 48 65 6C 6C 6F 21 F7 = Hello\n // @ts-ignore\n const msg = message.splice(8);\n // Remove F7\n msg.pop();\n synth.processMidiMessage(msg);\n break;\n }\n case 0x07:\n // Bitmap Window\n // F0 43 10 4C 07 00 00 [bitmap] F7\n // 音源のアイコン描画領域に描画する16x16のビットマップ画像。\n // 7bitごとに左上から描画する。仕様がややこしいので処理しない\n console.log(\n '\\x1b[32mXG Bitmap\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x08:\n // XG Dram Part:\n // F0 43 10 4C 08 [partNum] 07 [map] F7\n // 厳密には[map]は1以上の値が入り、3+1系統までしか使えない(MU2000の場合)が、本プログラムでは制限しない。\n synth.setPercussionPart(XgPart, message[8] !== 0x00);\n break;\n\n default:\n // @ts-ignore\n console.log('\\x1b[32mXG\\x1b[0m: ', this.dumpMessage(message));\n }\n }\n break;\n }\n default:\n // not supported\n synth.setPercussionPart(9, true);\n break;\n }\n }\n\n /**\n * Dump System Exclusive Message\n *\n * @private\n * @param {number[]} messages\n * @return {string}\n */\n dumpMessage(messages) {\n const ret = [];\n let i = 0;\n for (const msg of messages) {\n let str = '';\n switch (i) {\n case 0:\n // 青\n str = '\\x1b[35m';\n break;\n case 1:\n case 2:\n case 3:\n // 黄色\n str = '\\x1b[33m';\n break;\n default:\n // 末尾の場合は青、それ以外はシアン\n str = messages.length - 1 === i ? '\\x1b[35m' : '\\x1b[36m';\n break;\n }\n\n ret.push(str + msg.toString(16).toUpperCase().padStart(2, '0'));\n i++;\n }\n return ret.join(' ') + '\\x1b[0m';\n }\n\n /**\n * Change Color mode\n *\n * @param {'dark'|'light'|'auto'|undefined} mode Color Mode\n * @public\n */\n setColorMode(mode) {\n // Mode was given\n if (mode) {\n if (mode === 'auto') {\n mode = window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n }\n // Update data-* attr on html\n document.documentElement.setAttribute('data-bs-theme', mode);\n }\n // No mode given (e.g. reset)\n else {\n document.documentElement.setAttribute('data-bs-theme', 'auto');\n // Remove data-* attr from html\n document.documentElement.removeAttribute('data-bs-theme');\n }\n }\n}\n","import WebMidiLink from './wml';\n\n/**\n * Web MIDI API Reciever Class.\n *\n * @author Logue \n */\nexport default class WebMidiApi extends WebMidiLink {\n /**\n * @inheritdoc\n */\n constructor(option = {}) {\n super(option);\n /** @type {WebMidi.MIDIAccess | undefined} */\n this.midi = undefined;\n }\n\n /**\n * @inheritdoc\n * @param {string} url\n */\n async setup(url) {\n this.midi = await window.navigator.requestMIDIAccess({ sysex: true });\n await super.setup(url);\n }\n\n /**\n * @inheritdoc\n */\n onReady() {\n // コールバック実行\n super.callback();\n // Web MIDI APIを待ち受け\n this.midi.inputs.forEach(\n (\n /** @type {{ onmidimessage: (msg: WebMidi.MIDIMessageEvent) => void; }} */ input\n ) =>\n (input.onmidimessage = msg =>\n super.processMidiMessage(Array.from(msg.data)))\n );\n }\n}\n","import Meta from './meta.js';\nimport Parser from './sf2.js';\nimport WebMidiApi from './web_midi_api.js';\nimport WebMidiLink from './wml.js';\nimport './wml.scss';\n\nconst SoundFont = {\n version: Meta.version,\n build: Meta.date,\n WebMidiLink,\n WebMidiApi,\n Parser,\n};\n\nexport default SoundFont;\n","\n import qs from 'query-string';\n import SoundFont from '/src/index';\n\n /** sf2synth.js Option */\n let options = {\n ...{\n // URL to SoundFont File\n // url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2',\n // Show Keyboard\n drawSynth: true,\n // Target dom id\n placeholder: 'placeholder',\n // Color Mode (auto, dark, light)\n colorMode: 'auto',\n },\n ...qs.parse(window.location.search),\n ...qs.parse(window.location.hash),\n };\n\n /** @type {typeof import(\"./src/wml\").WebMidiLink } WebMidiLink */\n const wml = new SoundFont.WebMidiLink(options);\n\n document.addEventListener(\n 'DOMContentLoaded',\n event => {\n /** @type {HTMLInputElement} File Input Form */\n const fileInput = document.getElementById('file');\n /** @type {HTMLDivElement} drag area */\n const dragArea = document.getElementById('drag');\n /** @type {HTMLTimeElement} Build Date */\n const build = document.getElementById('build');\n /** @type {HTMLInputElement} */\n const toggleDarkMode = document.getElementById('toggleDarkMode');\n /** @type {HTMLSelectElement} */\n // const selector = document.getElementById('selector');\n\n wml.setLoadCallback(() => {\n dragArea.classList.remove('bg-info');\n document.getElementById('soundfont').innerText = decodeURIComponent(\n wml.getUrl()\n ).match('.+/(.+?)([?#;].*)?$')[1];\n });\n\n // Apply build time\n build.dateTime = SoundFont.build;\n build.innerText = new Date(SoundFont.build).toLocaleString();\n\n wml.setup();\n\n // Keep an eye out for System Light/Dark Mode Changes\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addListener(() => {\n // Ignore change if there's an override set\n if (document.documentElement.getAttribute('data-bs-theme')) {\n return;\n }\n\n // Apply color mode.\n wml.setColorMode(options.colorMode);\n\n // Make sure the checkbox is up-to-date\n toggleDarkMode.checked = mediaQuery.matches;\n });\n\n /**\n * Load sound font\n *\n * @param {File} file\n */\n const handleSoundFont = file => {\n const reader = new FileReader();\n reader.readAsArrayBuffer(file);\n\n reader.onload = e => {\n document.getElementById('soundfont').innerText = file.name;\n const data = new Uint8Array(e.target.result);\n wml.setupByBuffer(data);\n };\n };\n\n // When select SoundFont file\n fileInput.addEventListener(\n 'change',\n event => {\n event.preventDefault();\n handleSoundFont(fileInput.files[0]);\n fileInput.value = '';\n },\n false\n );\n\n // When SoundFont Drag and Drop.\n dragArea.addEventListener(\n 'drop',\n event => {\n const dt = event.dataTransfer;\n if (dt.files.length) {\n event.preventDefault();\n event.stopPropagation();\n handleSoundFont(dt.files[0]);\n }\n dragArea.classList.remove('bg-info');\n },\n false\n );\n dragArea.addEventListener(\n 'dragover',\n event => {\n event.preventDefault();\n event.stopPropagation();\n dragArea.classList.add('bg-info');\n },\n false\n );\n dragArea.addEventListener(\n 'dragleave',\n event => {\n event.preventDefault();\n event.stopPropagation();\n dragArea.classList.remove('bg-info');\n },\n false\n );\n\n // Toggle Dark mode\n toggleDarkMode.addEventListener('change', e => {\n wml.setColorMode(e.target.checked ? 'dark' : 'light');\n });\n\n /*\n selector.addEventListener('change', () => {\n console.log(selector.value);\n wml.setup(\n `https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/${selector.value}`\n );\n });\n */\n },\n false\n );\n\n window.addEventListener(\n 'hashchange',\n () => {\n const url = qs.parse(window.location.hash);\n if (url) {\n wml.setup(url);\n }\n },\n false\n );\n "],"names":["token","singleMatcher","multiMatcher","decodeComponents","components","split","left","right","decode","input","tokens","i","customDecodeURIComponent","replaceMap","match","result","entries","key","decodeUriComponent","encodedURI","splitOnFirst","string","separator","separatorIndex","includeKeys","object","predicate","descriptor","value","isNullOrUndefined","strictUriEncode","x","encodeFragmentIdentifier","encoderForArrayFormat","options","index","encode","keyValueSeparator","parserForArrayFormat","accumulator","isArray","isEncodedArray","newValue","item","arrayValue","validateArrayFormatSeparator","decodeComponent","keysSorter","a","b","removeHash","hashStart","getHash","url","hash","parseValue","extract","queryStart","parse","query","formatter","returnValue","parameter","parameter_","key2","value2","stringify","shouldFilter","objectCopy","keys","parseUrl","url_","stringifyUrl","queryFromUrl","queryString","urlObjectForFragmentEncode","pick","filter","fragmentIdentifier","exclude","exclusionFilter","meta","Riff","optParams","length","ip","size","RiffChunk","chunk","type","offset","Parser","parser","data","signature","presetHeader","presetZone","instrument","instrumentZone","samples","sampleHeader","sampleName","start","end","startLoop","endLoop","sampleRate","originalPitch","pitchCorrection","sampleLink","sampleType","sample","adjust","newSample","il","j","multiply","code","output","zone","bagIndex","bagIndexEnd","zoneInfo","instrumentGenerator","instrumentModulator","jl","preset","presetGenerator","presetModulator","modgen","_zone","indexStart","indexEnd","zoneModGen","modgenInfo","info","Loader","placeholder","cache","callback","current","total","percentCompleted","buffer","error","cached","response","e","cloned","contentLength","reader","receivedLength","chunks","done","chunksAll","position","INV_MAX","ARandom","norm","p","min","max","range","random","SystemRandom","SYSTEM","DEFAULT_OPTS","preseed","n","scale","rnd","state","sum","src","sum2","interleave","next","blue","opts","bins","invN","acc","sign","green","ctz32","c","pink","id","red","violet","white","implementsFunction","fn","ensureTransducer","isIterable","identity","Reduced","val","reduced","isReduced","ensureReduced","unreduced","reducer","init","rfn","push","xs","iterator","xform","complete","reduce","y","compR","take","r","m","d","o","w","s","g","N","f","h","l","u","v","SynthesizerNote","ctx","destination","now","volDelay","modDelay","volAttack","modAttack","volHold","modHold","volDecay","modDecay","loopStart","loopEnd","startTime","pan","bufferSource","panner","volume","outputGain","baseFreq","peekFreq","sustainFreq","modulator","release","volEndTimeTmp","volEndTime","modEndTime","playbackRate","computed","peekPitch","expression","pitchBend","Synthesizer","Reverb","entry","initAudioContext","emptySource","mode","modeElement","element","presets","instruments","banks","bank","bankNumber","presetNumber","presetName","programSet","generator","volSustain","volRelease","modSustain","modRelease","tune","sampleModes","sampleId","enumeratorType","doc","wrapper","instElem","eventStart","eventEnd","channel","channelElem","itemElem","checkboxElement","checkbox","event","labelElem","bankSelect","synth","ch","program","select","volumeElem","expressionElem","pitchSensElem","reverbDepthElem","panpotOuter","panpot","pitchOuter","pitch","keyElem","k","itemName","headerElem","_entries","headerItem","channelItem","keysItem","velocity","channelElems","bankElement","bankNo","option","dom","bankIndex","programElement","programNo","instrumentKey","note","currentNoteOn","hold","channelElements","percussionBank","volumeVariable","expressionVariabe","progressBar","percentage","lowerByte","higherByte","bend","calculated","sensitivity","pitchBendSensitivityVariable","attackTime","decayTime","sustinTime","releaseTime","depth","reverbVariable","mute","sw","message","WebMidiLink","readyElem","ev","msg","command","hex","manufacturerId","device","model","GsPart","GsKey","GsValue","XgKey","XgPart","messages","ret","str","WebMidiApi","SoundFont","Meta","qs","wml","fileInput","dragArea","build","toggleDarkMode","mediaQuery","handleSoundFont","file","dt"],"mappings":"ssBAAA,MAAMA,GAAQ,eACRC,EAAgB,IAAI,OAAO,IAAMD,GAAQ,aAAc,IAAI,EAC3DE,EAAe,IAAI,OAAO,IAAMF,GAAQ,KAAM,IAAI,EAExD,SAASG,EAAiBC,EAAYC,EAAO,CAC5C,GAAI,CAEH,MAAO,CAAC,mBAAmBD,EAAW,KAAK,EAAE,CAAC,CAAC,CACjD,MAAS,CAEP,CAED,GAAIA,EAAW,SAAW,EACzB,OAAOA,EAGRC,EAAQA,GAAS,EAGjB,MAAMC,EAAOF,EAAW,MAAM,EAAGC,CAAK,EAChCE,EAAQH,EAAW,MAAMC,CAAK,EAEpC,OAAO,MAAM,UAAU,OAAO,KAAK,CAAA,EAAIF,EAAiBG,CAAI,EAAGH,EAAiBI,CAAK,CAAC,CACvF,CAEA,SAASC,GAAOC,EAAO,CACtB,GAAI,CACH,OAAO,mBAAmBA,CAAK,CACjC,MAAS,CACP,IAAIC,EAASD,EAAM,MAAMR,CAAa,GAAK,CAAA,EAE3C,QAASU,EAAI,EAAGA,EAAID,EAAO,OAAQC,IAClCF,EAAQN,EAAiBO,EAAQC,CAAC,EA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YyO,EAAK,KACtD,MAAM/R,EAAO,IAAI,WAAWsD,EAAE,OAAO,MAAM,EAC3CkO,EAAI,cAAcxR,CAAI,CACpC,CACA,EAGUyR,EAAU,iBACR,SACA/E,GAAS,CACPA,EAAM,eAAc,EACpBoF,EAAgBL,EAAU,MAAM,CAAC,CAAC,EAClCA,EAAU,MAAQ,EACnB,EACD,EACZ,EAGUC,EAAS,iBACP,OACAhF,GAAS,CACP,MAAMsF,EAAKtF,EAAM,aACbsF,EAAG,MAAM,SACXtF,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBoF,EAAgBE,EAAG,MAAM,CAAC,CAAC,GAE7BN,EAAS,UAAU,OAAO,SAAS,CACpC,EACD,EACZ,EACUA,EAAS,iBACP,WACAhF,GAAS,CACPA,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBgF,EAAS,UAAU,IAAI,SAAS,CACjC,EACD,EACZ,EACUA,EAAS,iBACP,YACAhF,GAAS,CACPA,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBgF,EAAS,UAAU,OAAO,SAAS,CACpC,EACD,EACZ,EAGUE,EAAe,iBAAiB,SAAUtO,GAAK,CAC7CkO,EAAI,aAAalO,EAAE,OAAO,QAAU,OAAS,OAAO,CAChE,CAAW,CAUF,EACD,EACR,EAEM,OAAO,iBACL,aACA,IAAM,CACJ,MAAM9F,EAAM+T,EAAG,MAAM,OAAO,SAAS,IAAI,EACrC/T,GACFgU,EAAI,MAAMhU,CAAG,CAEhB,EACD,EACD","x_google_ignoreList":[0,1,2,3,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]} \ No newline at end of file +{"version":3,"file":"index-BLLwekxr.js","sources":["../../node_modules/decode-uri-component/index.js","../../node_modules/split-on-first/index.js","../../node_modules/filter-obj/index.js","../../node_modules/query-string/base.js","../../src/meta.js","../../src/riff.js","../../src/sf2.js","../../src/loader.js","../../node_modules/@thi.ng/random/arandom.js","../../node_modules/@thi.ng/random/system.js","../../node_modules/@thi.ng/colored-noise/api.js","../../node_modules/@thi.ng/colored-noise/utils.js","../../node_modules/@thi.ng/colored-noise/blue.js","../../node_modules/@thi.ng/colored-noise/green.js","../../node_modules/@thi.ng/binary/count.js","../../node_modules/@thi.ng/colored-noise/pink.js","../../node_modules/@thi.ng/colored-noise/red.js","../../node_modules/@thi.ng/colored-noise/violet.js","../../node_modules/@thi.ng/colored-noise/white.js","../../node_modules/@thi.ng/checks/implements-function.js","../../node_modules/@thi.ng/transducers/ensure.js","../../node_modules/@thi.ng/checks/is-iterable.js","../../node_modules/@thi.ng/api/fn.js","../../node_modules/@thi.ng/transducers/reduced.js","../../node_modules/@thi.ng/transducers/reduce.js","../../node_modules/@thi.ng/transducers/push.js","../../node_modules/@thi.ng/transducers/iterator.js","../../node_modules/@thi.ng/transducers/compr.js","../../node_modules/@thi.ng/transducers/take.js","../../node_modules/@logue/reverb/dist/Reverb.es.js","../../src/sound_font_synth_note.js","../../src/sound_font_synth.js","../../src/wml.js","../../src/web_midi_api.js","../../src/index.js","../../index.html?html-proxy&index=0.js"],"sourcesContent":["const token = '%[a-f0-9]{2}';\nconst singleMatcher = new RegExp('(' + token + ')|([^%]+?)', 'gi');\nconst multiMatcher = new RegExp('(' + token + ')+', 'gi');\n\nfunction decodeComponents(components, split) {\n\ttry {\n\t\t// Try to decode the entire string first\n\t\treturn [decodeURIComponent(components.join(''))];\n\t} catch {\n\t\t// Do nothing\n\t}\n\n\tif (components.length === 1) {\n\t\treturn components;\n\t}\n\n\tsplit = split || 1;\n\n\t// Split the array in 2 parts\n\tconst left = components.slice(0, split);\n\tconst right = components.slice(split);\n\n\treturn Array.prototype.concat.call([], decodeComponents(left), decodeComponents(right));\n}\n\nfunction decode(input) {\n\ttry {\n\t\treturn decodeURIComponent(input);\n\t} catch {\n\t\tlet tokens = input.match(singleMatcher) || [];\n\n\t\tfor (let i = 1; i < tokens.length; i++) {\n\t\t\tinput = decodeComponents(tokens, i).join('');\n\n\t\t\ttokens = input.match(singleMatcher) || [];\n\t\t}\n\n\t\treturn input;\n\t}\n}\n\nfunction customDecodeURIComponent(input) {\n\t// Keep track of all the replacements and prefill the map with the `BOM`\n\tconst replaceMap = {\n\t\t'%FE%FF': '\\uFFFD\\uFFFD',\n\t\t'%FF%FE': '\\uFFFD\\uFFFD',\n\t};\n\n\tlet match = multiMatcher.exec(input);\n\twhile (match) {\n\t\ttry {\n\t\t\t// Decode as big chunks as possible\n\t\t\treplaceMap[match[0]] = decodeURIComponent(match[0]);\n\t\t} catch {\n\t\t\tconst result = decode(match[0]);\n\n\t\t\tif (result !== match[0]) {\n\t\t\t\treplaceMap[match[0]] = result;\n\t\t\t}\n\t\t}\n\n\t\tmatch = multiMatcher.exec(input);\n\t}\n\n\t// Add `%C2` at the end of the map to make sure it does not replace the combinator before everything else\n\treplaceMap['%C2'] = '\\uFFFD';\n\n\tconst entries = Object.keys(replaceMap);\n\n\tfor (const key of entries) {\n\t\t// Replace all decoded components\n\t\tinput = input.replace(new RegExp(key, 'g'), replaceMap[key]);\n\t}\n\n\treturn input;\n}\n\nexport default function decodeUriComponent(encodedURI) {\n\tif (typeof encodedURI !== 'string') {\n\t\tthrow new TypeError('Expected `encodedURI` to be of type `string`, got `' + typeof encodedURI + '`');\n\t}\n\n\ttry {\n\t\t// Try the built in decoder first\n\t\treturn decodeURIComponent(encodedURI);\n\t} catch {\n\t\t// Fallback to a more advanced decoder\n\t\treturn customDecodeURIComponent(encodedURI);\n\t}\n}\n","export default function splitOnFirst(string, separator) {\n\tif (!(typeof string === 'string' && typeof separator === 'string')) {\n\t\tthrow new TypeError('Expected the arguments to be of type `string`');\n\t}\n\n\tif (string === '' || separator === '') {\n\t\treturn [];\n\t}\n\n\tconst separatorIndex = string.indexOf(separator);\n\n\tif (separatorIndex === -1) {\n\t\treturn [];\n\t}\n\n\treturn [\n\t\tstring.slice(0, separatorIndex),\n\t\tstring.slice(separatorIndex + separator.length)\n\t];\n}\n","export function includeKeys(object, predicate) {\n\tconst result = {};\n\n\tif (Array.isArray(predicate)) {\n\t\tfor (const key of predicate) {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (descriptor?.enumerable) {\n\t\t\t\tObject.defineProperty(result, key, descriptor);\n\t\t\t}\n\t\t}\n\t} else {\n\t\t// `Reflect.ownKeys()` is required to retrieve symbol properties\n\t\tfor (const key of Reflect.ownKeys(object)) {\n\t\t\tconst descriptor = Object.getOwnPropertyDescriptor(object, key);\n\t\t\tif (descriptor.enumerable) {\n\t\t\t\tconst value = object[key];\n\t\t\t\tif (predicate(key, value, object)) {\n\t\t\t\t\tObject.defineProperty(result, key, descriptor);\n\t\t\t\t}\n\t\t\t}\n\t\t}\n\t}\n\n\treturn result;\n}\n\nexport function excludeKeys(object, predicate) {\n\tif (Array.isArray(predicate)) {\n\t\tconst set = new Set(predicate);\n\t\treturn includeKeys(object, key => !set.has(key));\n\t}\n\n\treturn includeKeys(object, (key, value, object) => !predicate(key, value, object));\n}\n","import decodeComponent from 'decode-uri-component';\nimport splitOnFirst from 'split-on-first';\nimport {includeKeys} from 'filter-obj';\n\nconst isNullOrUndefined = value => value === null || value === undefined;\n\n// eslint-disable-next-line unicorn/prefer-code-point\nconst strictUriEncode = string => encodeURIComponent(string).replaceAll(/[!'()*]/g, x => `%${x.charCodeAt(0).toString(16).toUpperCase()}`);\n\nconst encodeFragmentIdentifier = Symbol('encodeFragmentIdentifier');\n\nfunction encoderForArrayFormat(options) {\n\tswitch (options.arrayFormat) {\n\t\tcase 'index': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tconst index = result.length;\n\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result, [encode(key, options), '[', index, ']'].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '[', encode(index, options), ']=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\t[encode(key, options), '[]'].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '[]=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'colon-list-separator': {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\t[encode(key, options), ':list='].join(''),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), ':list=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\n\t\tcase 'comma':\n\t\tcase 'separator':\n\t\tcase 'bracket-separator': {\n\t\t\tconst keyValueSeparator = options.arrayFormat === 'bracket-separator'\n\t\t\t\t? '[]='\n\t\t\t\t: '=';\n\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\t// Translate null to an empty string so that it doesn't serialize as 'null'\n\t\t\t\tvalue = value === null ? '' : value;\n\n\t\t\t\tif (result.length === 0) {\n\t\t\t\t\treturn [[encode(key, options), keyValueSeparator, encode(value, options)].join('')];\n\t\t\t\t}\n\n\t\t\t\treturn [[result, encode(value, options)].join(options.arrayFormatSeparator)];\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn key => (result, value) => {\n\t\t\t\tif (\n\t\t\t\t\tvalue === undefined\n\t\t\t\t\t|| (options.skipNull && value === null)\n\t\t\t\t\t|| (options.skipEmptyString && value === '')\n\t\t\t\t) {\n\t\t\t\t\treturn result;\n\t\t\t\t}\n\n\t\t\t\tif (value === null) {\n\t\t\t\t\treturn [\n\t\t\t\t\t\t...result,\n\t\t\t\t\t\tencode(key, options),\n\t\t\t\t\t];\n\t\t\t\t}\n\n\t\t\t\treturn [\n\t\t\t\t\t...result,\n\t\t\t\t\t[encode(key, options), '=', encode(value, options)].join(''),\n\t\t\t\t];\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction parserForArrayFormat(options) {\n\tlet result;\n\n\tswitch (options.arrayFormat) {\n\t\tcase 'index': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /\\[(\\d*)]$/.exec(key);\n\n\t\t\t\tkey = key.replace(/\\[\\d*]$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = {};\n\t\t\t\t}\n\n\t\t\t\taccumulator[key][result[1]] = value;\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /(\\[])$/.exec(key);\n\t\t\t\tkey = key.replace(/\\[]$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = [value];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], value];\n\t\t\t};\n\t\t}\n\n\t\tcase 'colon-list-separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tresult = /(:list)$/.exec(key);\n\t\t\t\tkey = key.replace(/:list$/, '');\n\n\t\t\t\tif (!result) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = [value];\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], value];\n\t\t\t};\n\t\t}\n\n\t\tcase 'comma':\n\t\tcase 'separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tconst isArray = typeof value === 'string' && value.includes(options.arrayFormatSeparator);\n\t\t\t\tconst isEncodedArray = (typeof value === 'string' && !isArray && decode(value, options).includes(options.arrayFormatSeparator));\n\t\t\t\tvalue = isEncodedArray ? decode(value, options) : value;\n\t\t\t\tconst newValue = isArray || isEncodedArray ? value.split(options.arrayFormatSeparator).map(item => decode(item, options)) : (value === null ? value : decode(value, options));\n\t\t\t\taccumulator[key] = newValue;\n\t\t\t};\n\t\t}\n\n\t\tcase 'bracket-separator': {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tconst isArray = /(\\[])$/.test(key);\n\t\t\t\tkey = key.replace(/\\[]$/, '');\n\n\t\t\t\tif (!isArray) {\n\t\t\t\t\taccumulator[key] = value ? decode(value, options) : value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\tconst arrayValue = value === null\n\t\t\t\t\t? []\n\t\t\t\t\t: value.split(options.arrayFormatSeparator).map(item => decode(item, options));\n\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = arrayValue;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...accumulator[key], ...arrayValue];\n\t\t\t};\n\t\t}\n\n\t\tdefault: {\n\t\t\treturn (key, value, accumulator) => {\n\t\t\t\tif (accumulator[key] === undefined) {\n\t\t\t\t\taccumulator[key] = value;\n\t\t\t\t\treturn;\n\t\t\t\t}\n\n\t\t\t\taccumulator[key] = [...[accumulator[key]].flat(), value];\n\t\t\t};\n\t\t}\n\t}\n}\n\nfunction validateArrayFormatSeparator(value) {\n\tif (typeof value !== 'string' || value.length !== 1) {\n\t\tthrow new TypeError('arrayFormatSeparator must be single character string');\n\t}\n}\n\nfunction encode(value, options) {\n\tif (options.encode) {\n\t\treturn options.strict ? strictUriEncode(value) : encodeURIComponent(value);\n\t}\n\n\treturn value;\n}\n\nfunction decode(value, options) {\n\tif (options.decode) {\n\t\treturn decodeComponent(value);\n\t}\n\n\treturn value;\n}\n\nfunction keysSorter(input) {\n\tif (Array.isArray(input)) {\n\t\treturn input.sort();\n\t}\n\n\tif (typeof input === 'object') {\n\t\treturn keysSorter(Object.keys(input))\n\t\t\t.sort((a, b) => Number(a) - Number(b))\n\t\t\t.map(key => input[key]);\n\t}\n\n\treturn input;\n}\n\nfunction removeHash(input) {\n\tconst hashStart = input.indexOf('#');\n\tif (hashStart !== -1) {\n\t\tinput = input.slice(0, hashStart);\n\t}\n\n\treturn input;\n}\n\nfunction getHash(url) {\n\tlet hash = '';\n\tconst hashStart = url.indexOf('#');\n\tif (hashStart !== -1) {\n\t\thash = url.slice(hashStart);\n\t}\n\n\treturn hash;\n}\n\nfunction parseValue(value, options) {\n\tif (options.parseNumbers && !Number.isNaN(Number(value)) && (typeof value === 'string' && value.trim() !== '')) {\n\t\tvalue = Number(value);\n\t} else if (options.parseBooleans && value !== null && (value.toLowerCase() === 'true' || value.toLowerCase() === 'false')) {\n\t\tvalue = value.toLowerCase() === 'true';\n\t}\n\n\treturn value;\n}\n\nexport function extract(input) {\n\tinput = removeHash(input);\n\tconst queryStart = input.indexOf('?');\n\tif (queryStart === -1) {\n\t\treturn '';\n\t}\n\n\treturn input.slice(queryStart + 1);\n}\n\nexport function parse(query, options) {\n\toptions = {\n\t\tdecode: true,\n\t\tsort: true,\n\t\tarrayFormat: 'none',\n\t\tarrayFormatSeparator: ',',\n\t\tparseNumbers: false,\n\t\tparseBooleans: false,\n\t\t...options,\n\t};\n\n\tvalidateArrayFormatSeparator(options.arrayFormatSeparator);\n\n\tconst formatter = parserForArrayFormat(options);\n\n\t// Create an object with no prototype\n\tconst returnValue = Object.create(null);\n\n\tif (typeof query !== 'string') {\n\t\treturn returnValue;\n\t}\n\n\tquery = query.trim().replace(/^[?#&]/, '');\n\n\tif (!query) {\n\t\treturn returnValue;\n\t}\n\n\tfor (const parameter of query.split('&')) {\n\t\tif (parameter === '') {\n\t\t\tcontinue;\n\t\t}\n\n\t\tconst parameter_ = options.decode ? parameter.replaceAll('+', ' ') : parameter;\n\n\t\tlet [key, value] = splitOnFirst(parameter_, '=');\n\n\t\tif (key === undefined) {\n\t\t\tkey = parameter_;\n\t\t}\n\n\t\t// Missing `=` should be `null`:\n\t\t// http://w3.org/TR/2012/WD-url-20120524/#collect-url-parameters\n\t\tvalue = value === undefined ? null : (['comma', 'separator', 'bracket-separator'].includes(options.arrayFormat) ? value : decode(value, options));\n\t\tformatter(decode(key, options), value, returnValue);\n\t}\n\n\tfor (const [key, value] of Object.entries(returnValue)) {\n\t\tif (typeof value === 'object' && value !== null) {\n\t\t\tfor (const [key2, value2] of Object.entries(value)) {\n\t\t\t\tvalue[key2] = parseValue(value2, options);\n\t\t\t}\n\t\t} else {\n\t\t\treturnValue[key] = parseValue(value, options);\n\t\t}\n\t}\n\n\tif (options.sort === false) {\n\t\treturn returnValue;\n\t}\n\n\t// TODO: Remove the use of `reduce`.\n\t// eslint-disable-next-line unicorn/no-array-reduce\n\treturn (options.sort === true ? Object.keys(returnValue).sort() : Object.keys(returnValue).sort(options.sort)).reduce((result, key) => {\n\t\tconst value = returnValue[key];\n\t\tresult[key] = Boolean(value) && typeof value === 'object' && !Array.isArray(value) ? keysSorter(value) : value;\n\t\treturn result;\n\t}, Object.create(null));\n}\n\nexport function stringify(object, options) {\n\tif (!object) {\n\t\treturn '';\n\t}\n\n\toptions = {\n\t\tencode: true,\n\t\tstrict: true,\n\t\tarrayFormat: 'none',\n\t\tarrayFormatSeparator: ',',\n\t\t...options,\n\t};\n\n\tvalidateArrayFormatSeparator(options.arrayFormatSeparator);\n\n\tconst shouldFilter = key => (\n\t\t(options.skipNull && isNullOrUndefined(object[key]))\n\t\t|| (options.skipEmptyString && object[key] === '')\n\t);\n\n\tconst formatter = encoderForArrayFormat(options);\n\n\tconst objectCopy = {};\n\n\tfor (const [key, value] of Object.entries(object)) {\n\t\tif (!shouldFilter(key)) {\n\t\t\tobjectCopy[key] = value;\n\t\t}\n\t}\n\n\tconst keys = Object.keys(objectCopy);\n\n\tif (options.sort !== false) {\n\t\tkeys.sort(options.sort);\n\t}\n\n\treturn keys.map(key => {\n\t\tconst value = object[key];\n\n\t\tif (value === undefined) {\n\t\t\treturn '';\n\t\t}\n\n\t\tif (value === null) {\n\t\t\treturn encode(key, options);\n\t\t}\n\n\t\tif (Array.isArray(value)) {\n\t\t\tif (value.length === 0 && options.arrayFormat === 'bracket-separator') {\n\t\t\t\treturn encode(key, options) + '[]';\n\t\t\t}\n\n\t\t\treturn value\n\t\t\t\t.reduce(formatter(key), [])\n\t\t\t\t.join('&');\n\t\t}\n\n\t\treturn encode(key, options) + '=' + encode(value, options);\n\t}).filter(x => x.length > 0).join('&');\n}\n\nexport function parseUrl(url, options) {\n\toptions = {\n\t\tdecode: true,\n\t\t...options,\n\t};\n\n\tlet [url_, hash] = splitOnFirst(url, '#');\n\n\tif (url_ === undefined) {\n\t\turl_ = url;\n\t}\n\n\treturn {\n\t\turl: url_?.split('?')?.[0] ?? '',\n\t\tquery: parse(extract(url), options),\n\t\t...(options && options.parseFragmentIdentifier && hash ? {fragmentIdentifier: decode(hash, options)} : {}),\n\t};\n}\n\nexport function stringifyUrl(object, options) {\n\toptions = {\n\t\tencode: true,\n\t\tstrict: true,\n\t\t[encodeFragmentIdentifier]: true,\n\t\t...options,\n\t};\n\n\tconst url = removeHash(object.url).split('?')[0] || '';\n\tconst queryFromUrl = extract(object.url);\n\n\tconst query = {\n\t\t...parse(queryFromUrl, {sort: false}),\n\t\t...object.query,\n\t};\n\n\tlet queryString = stringify(query, options);\n\tqueryString &&= `?${queryString}`;\n\n\tlet hash = getHash(object.url);\n\tif (typeof object.fragmentIdentifier === 'string') {\n\t\tconst urlObjectForFragmentEncode = new URL(url);\n\t\turlObjectForFragmentEncode.hash = object.fragmentIdentifier;\n\t\thash = options[encodeFragmentIdentifier] ? urlObjectForFragmentEncode.hash : `#${object.fragmentIdentifier}`;\n\t}\n\n\treturn `${url}${queryString}${hash}`;\n}\n\nexport function pick(input, filter, options) {\n\toptions = {\n\t\tparseFragmentIdentifier: true,\n\t\t[encodeFragmentIdentifier]: false,\n\t\t...options,\n\t};\n\n\tconst {url, query, fragmentIdentifier} = parseUrl(input, options);\n\n\treturn stringifyUrl({\n\t\turl,\n\t\tquery: includeKeys(query, filter),\n\t\tfragmentIdentifier,\n\t}, options);\n}\n\nexport function exclude(input, filter, options) {\n\tconst exclusionFilter = Array.isArray(filter) ? key => !filter.includes(key) : (key, value) => !filter(key, value);\n\n\treturn pick(input, exclusionFilter, options);\n}\n","// This file is auto-generated by the build system.\nconst meta = {\n version: '0.7.0',\n date: '2024-04-25T09:42:07.235Z',\n};\nexport default meta;\n","/**\n * Riff Parser class\n *\n * @author imaya\n */\nexport class Riff {\n /**\n * @param {ArrayBuffer} input Input buffer.\n * @param {Object} [optParams] Option parameters.\n */\n constructor(input, optParams = {}) {\n /** @type {ArrayBuffer} */\n this.input = input;\n /** @type {number} */\n this.ip = optParams.index || 0;\n /** @type {number} */\n this.length = optParams.length || input.byteLength - this.ip;\n /** @type {RiffChunk[]} */\n this.chunkList = [];\n /** @type {number} */\n this.offset = this.ip;\n /** @type {boolean} */\n this.padding = optParams.padding !== undefined ? optParams.padding : true;\n /** @type {boolean} */\n this.bigEndian =\n optParams.bigEndian !== undefined ? optParams.bigEndian : false;\n }\n\n /** @returns {void} */\n parse() {\n /** @type {number} */\n const length = this.length + this.offset;\n\n this.chunkList = [];\n\n while (this.ip < length) {\n this.parseChunk();\n }\n }\n\n /** @returns {void} */\n parseChunk() {\n /** @type {ArrayBuffer} */\n const input = this.input;\n /** @type {number} */\n let ip = this.ip;\n /** @type {number} */\n let size;\n\n this.chunkList.push(\n new RiffChunk(\n String.fromCharCode(input[ip++], input[ip++], input[ip++], input[ip++]),\n (size = this.bigEndian\n ? ((input[ip++] << 24) |\n (input[ip++] << 16) |\n (input[ip++] << 8) |\n input[ip++]) >>>\n 0\n : (input[ip++] |\n (input[ip++] << 8) |\n (input[ip++] << 16) |\n (input[ip++] << 24)) >>>\n 0),\n ip\n )\n );\n\n ip += size;\n\n // padding\n if (this.padding && ((ip - this.offset) & 1) === 1) {\n ip++;\n }\n\n this.ip = ip;\n }\n\n /**\n * @param {number} index Chunk index.\n * @returns {RiffChunk | null}\n */\n getChunk(index) {\n /** @type {RiffChunk} */\n const chunk = this.chunkList[index];\n\n return chunk !== undefined ? chunk : null;\n }\n\n /** @returns {number} */\n getNumberOfChunks() {\n return this.chunkList.length;\n }\n}\n\n/**\n * Riff Chunk Structure\n *\n * @interface\n */\nexport class RiffChunk {\n /**\n * @param {string} type\n * @param {number} size\n * @param {number} offset\n */\n constructor(type, size, offset) {\n /** @type {string} */\n this.type = type;\n /** @type {number} */\n this.size = size;\n /** @type {number} */\n this.offset = offset;\n }\n}\n","import { Riff } from './riff.js';\n\n/**\n * SoundFont Parser Class\n *\n * @author imaya\n */\nexport default class Parser {\n /**\n * @param {Uint8Array} input\n * @param {Object} [optParams]\n */\n constructor(input, optParams = {}) {\n /** @type {Uint8Array} */\n this.input = input;\n /** @type {object} */\n this.parserOption = optParams.parserOption || {};\n /** @type {number} */\n this.sampleRate = optParams.sampleRate || 22050; // よくわからんが、OSで指定されているサンプルレートを入れないと音が切れ切れになる。\n\n /** @type {object[]} */\n this.presetHeader = [];\n /** @type {object[]} */\n this.presetZone = [];\n /** @type {object[]} */\n this.presetZoneModulator = [];\n /** @type {object[]} */\n this.presetZoneGenerator = [];\n /** @type {object[]} */\n this.instrument = [];\n /** @type {object[]} */\n this.instrumentZone = [];\n /** @type {object[]} */\n this.instrumentZoneModulator = [];\n /** @type {object[]} */\n this.instrumentZoneGenerator = [];\n /** @type {object[]} */\n this.sampleHeader = [];\n /** @type {string[]} */\n this.GeneratorEnumeratorTable = Object.keys(Parser.getGeneratorTable());\n }\n\n /** @return {Record} ジェネレータとデフォルト値 */\n static getGeneratorTable() {\n return Object.freeze({\n /** @type {number} サンプルヘッダの音声波形データ開始位置に加算されるオフセット(下位16bit) */\n startAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データ終了位置に加算されるオフセット(下位16bit) */\n endAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(下位16bit) */\n startloopAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(下位16bit) */\n endloopAddrsOffset: 0,\n /** @type {number} サンプルヘッダの音声波形データ開始位置に加算されるオフセット(上位16bit) */\n startAddrsCoarseOffset: 0,\n /** @type {number} LFOによるピッチの揺れ幅 */\n modLfoToPitch: 0,\n /** @type {number} モジュレーションホイール用LFOからピッチに対しての影響量 */\n vibLfoToPitch: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープからピッチに対しての影響量 */\n modEnvToPitch: 0,\n /** @type {number} フィルタのカットオフ周波数 */\n initialFilterFc: 13500,\n /** @type {number} フィルターのQ値(レゾナンス) */\n initialFilterQ: 0,\n /** @type {number} LFOによるフィルターカットオフ周波数の揺れ幅 */\n modLfoToFilterFc: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープからフィルターカットオフに対しての影響量 */\n modEnvToFilterFc: 0,\n /** @type {number} サンプルヘッダの音声波形データ終了位置に加算されるオフセット(上位16bit) */\n endAddrsCoarseOffset: 0,\n /** @type {number} LFOによるボリュームの揺れ幅 */\n modLfoToVolume: 0,\n /** @type {undefined} 未使用1 */\n unused1: undefined, // 14\n /** @type {number} コーラスエフェクトのセンドレベル */\n chorusEffectsSend: 0,\n /** @type {number} リバーブエフェクトのセンドレベル */\n reverbEffectsSend: 0,\n /** @type {number} パンの位置 */\n pan: 0,\n /** @type {undefined} 未使用2 */\n unused2: undefined,\n /** @type {undefined} 未使用3 */\n unused3: undefined,\n /** @type {undefined} 未使用4 */\n unused4: undefined,\n /** @type {number} LFOの揺れが始まるまでの時間 */\n delayModLFO: -12000,\n /** @type {number} LFOの揺れの周期 */\n freqModLFO: 0,\n /** @type {number} ホイールの揺れが始まるまでの時間 */\n delayVibLFO: -12000,\n /** @type {number} ホイールの揺れの周期 */\n freqVibLFO: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープのディレイ(アタックが始まるまでの時間) */\n delayModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのアタック時間 */\n attackModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのホールド時間(アタックが終わってからディケイが始まるまでの時間) */\n holdModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのディケイ時間 */\n decayModEnv: -12000,\n /** @type {number} フィルタ・ピッチ用エンベロープのサステイン量 */\n sustainModEnv: 0,\n /** @type {number} フィルタ・ピッチ用エンベロープのリリース時間 */\n releaseModEnv: -12000,\n /** @type {number} キー(ノートNo)によるフィルタ・ピッチ用エンベロープのホールド時間への影響 */\n keynumToModEnvHold: 0,\n /** @type {number} キー(ノートNo)によるフィルタ・ピッチ用エンベロープのディケイ時間への影響 */\n keynumToModEnvDecay: 0,\n /** @type {number} アンプ用エンベロープのディレイ(アタックが始まるまでの時間) */\n delayVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのアタック時間 */\n attackVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのホールド時間(アタックが終わってからディケイが始まるまでの時間) */\n holdVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのディケイ時間 */\n decayVolEnv: -12000,\n /** @type {number} アンプ用エンベロープのサステイン量 */\n sustainVolEnv: 0,\n /** @type {number} アンプ用エンベロープのリリース時間 */\n releaseVolEnv: -12000,\n /** @type {number} キー(ノートNo)によるアンプ用エンベロープのホールド時間への影響 */\n keynumToVolEnvHold: 0,\n /** @type {number} キー(ノートNo)によるアンプ用エンベロープのディケイ時間への影響 */\n keynumToVolEnvDecay: 0,\n /** @type {number} 割り当てるインストルメント(楽器) */\n instrument: null,\n /** @type {undefined} 予約済み1 */\n reserved1: undefined, // 42\n /** @type {number} マッピングするキー(ノートNo)の範囲 */\n keyRange: null,\n /** @type {number} マッピングするベロシティの範囲 */\n velRange: null,\n /** @type {number} サンプルヘッダの音声波形データループ開始位置に加算されるオフセット(上位16bit) */\n startloopAddrsCoarseOffset: 0,\n /** @type {number} どのキー(ノートNo)でも強制的に指定したキー(ノートNo)に変更する */\n keynum: null,\n /** @type {number} どのベロシティでも強制的に指定したベロシティに変更する */\n velocity: null,\n /** @type {number} 調整する音量 */\n initialAttenuation: 0,\n /** @type {undefined} 予約済み2 */\n reserved2: undefined, // 49\n /** @type {number} サンプルヘッダの音声波形データループ終了位置に加算されるオフセット(上位16bit) */\n endloopAddrsCoarseOffset: 0,\n /** @type {number} 半音単位での音程の調整 */\n coarseTune: 0,\n /** @type {number} cent単位での音程の調整 */\n fineTune: 0,\n /** @type {number} 割り当てるサンプル(音声波形) */\n sampleID: null,\n /** @type {number} サンプル(音声波形)をループさせるか等のフラグ */\n sampleModes: 0,\n /** @type {undefined} 予約済み3 */\n reserved3: undefined, // 55\n /** @type {number} キー(ノートNo)が+1されるごとに音程を何centあげるかの音階情報 */\n scaleTuning: 100,\n /** @type {number} 同時に音を鳴らさないようにするための排他ID(ハイハットのOpen、Close等に使用) */\n exclusiveClass: null,\n /** @type {number} サンプル(音声波形)の音程の上書き情報 */\n overridingRootKey: null,\n /** @type {undefined} 未使用5 */\n unuded5: undefined, // 59\n /** @type {undefined} 最後を示すオペレータ */\n endOper: undefined,\n });\n }\n\n /** @export */\n parse() {\n /** @type {Riff} */\n const parser = new Riff(this.input, this.parserOption);\n\n // parse RIFF chunk\n parser.parse();\n if (parser.chunkList.length !== 1) {\n throw new Error('wrong chunk length');\n }\n\n /** @type {import('./riff.js').RiffChunk | null} */\n const chunk = parser.getChunk(0);\n if (chunk === null) {\n throw new Error('chunk not found');\n }\n\n this.parseRiffChunk(chunk);\n this.input = null;\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseRiffChunk(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'RIFF') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'sfbk') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n if (parser.getNumberOfChunks() !== 3) {\n throw new Error('invalid sfbk structure');\n }\n\n // INFO-list\n this.parseInfoList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(0))\n );\n\n // sdta-list\n this.parseSdtaList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(1))\n );\n\n // pdta-list\n this.parsePdtaList(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(2))\n );\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseInfoList(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'INFO') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseSdtaList(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'sdta') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n if (parser.chunkList.length !== 1) {\n throw new Error('TODO');\n }\n this.samplingData =\n /** @type {{ type: string; size: number; offset: number }} */\n (parser.getChunk(0));\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePdtaList(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n\n // check parse target\n if (chunk.type !== 'LIST') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n // check signature\n /** @type {string} */\n const signature = String.fromCharCode(\n data[ip++],\n data[ip++],\n data[ip++],\n data[ip++]\n );\n if (signature !== 'pdta') {\n throw new Error('invalid signature:' + signature);\n }\n\n // read structure\n /** @type {import('./riff.js').Riff} */\n const parser = new Riff(data, { index: ip, length: chunk.size - 4 });\n parser.parse();\n\n // check number of chunks\n if (parser.getNumberOfChunks() !== 9) {\n throw new Error('invalid pdta chunk');\n }\n\n this.parsePhdr(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(0))\n );\n this.parsePbag(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(1))\n );\n this.parsePmod(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(2))\n );\n this.parsePgen(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(3))\n );\n this.parseInst(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(4))\n );\n this.parseIbag(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(5))\n );\n this.parseImod(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(6))\n );\n this.parseIgen(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(7))\n );\n this.parseShdr(\n /** @type {import('./riff.js').RiffChunk} */ (parser.getChunk(8))\n );\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePhdr(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const presetHeader = (this.presetHeader = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'phdr') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n presetHeader.push({\n presetName: String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n ),\n preset: data[ip++] | (data[ip++] << 8),\n bank: data[ip++] | (data[ip++] << 8),\n presetBagIndex: data[ip++] | (data[ip++] << 8),\n library:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n genre:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n morphology:\n (data[ip++] |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0,\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePbag(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const presetZone = (this.presetZone = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'pbag') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n presetZone.push({\n presetGeneratorIndex: data[ip++] | (data[ip++] << 8),\n presetModulatorIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePmod(chunk) {\n // check parse target\n if (chunk.type !== 'pmod') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.presetZoneModulator = this.parseModulator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parsePgen(chunk) {\n // check parse target\n if (chunk.type !== 'pgen') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n this.presetZoneGenerator = this.parseGenerator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseInst(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const instrument = (this.instrument = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'inst') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n instrument.push({\n instrumentName: String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n ),\n instrumentBagIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseIbag(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const instrumentZone = (this.instrumentZone = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n\n // check parse target\n if (chunk.type !== 'ibag') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n instrumentZone.push({\n instrumentGeneratorIndex: data[ip++] | (data[ip++] << 8),\n instrumentModulatorIndex: data[ip++] | (data[ip++] << 8),\n });\n }\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseImod(chunk) {\n // check parse target\n if (chunk.type !== 'imod') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.instrumentZoneModulator = this.parseModulator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseIgen(chunk) {\n // check parse target\n if (chunk.type !== 'igen') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n this.instrumentZoneGenerator = this.parseGenerator(chunk);\n }\n\n /** @param {import('./riff.js').RiffChunk} chunk */\n parseShdr(chunk) {\n /** @type {Uint8Array} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {Object[]} */\n const samples = (this.sample = []);\n /** @type {Object[]} */\n const sampleHeader = (this.sampleHeader = []);\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {string} */\n let sampleName;\n /** @type {number} */\n let start;\n /** @type {number} */\n let end;\n /** @type {number} */\n let startLoop;\n /** @type {number} */\n let endLoop;\n /** @type {number} */\n let sampleRate;\n /** @type {number} */\n let originalPitch;\n /** @type {number} */\n let pitchCorrection;\n /** @type {number} */\n let sampleLink;\n /** @type {number} */\n let sampleType;\n\n // check parse target\n if (chunk.type !== 'shdr') {\n throw new Error('invalid chunk type:' + chunk.type);\n }\n\n while (ip < size) {\n sampleName = String.fromCharCode.apply(\n null,\n data.subarray(ip, (ip += 20))\n );\n start =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n end =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n startLoop =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n endLoop =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n sampleRate =\n ((data[ip++] << 0) |\n (data[ip++] << 8) |\n (data[ip++] << 16) |\n (data[ip++] << 24)) >>>\n 0;\n originalPitch = data[ip++];\n pitchCorrection = (data[ip++] << 24) >> 24;\n sampleLink = data[ip++] | (data[ip++] << 8);\n sampleType = data[ip++] | (data[ip++] << 8);\n\n let sample = new Int16Array(\n new Uint8Array(\n data.subarray(\n this.samplingData.offset + start * 2,\n this.samplingData.offset + end * 2\n )\n ).buffer\n );\n\n startLoop -= start;\n endLoop -= start;\n\n if (sampleRate > 0) {\n const adjust = this.adjustSampleData(sample, sampleRate);\n sample = adjust.sample;\n sampleRate *= adjust.multiply;\n startLoop *= adjust.multiply;\n endLoop *= adjust.multiply;\n }\n\n samples.push(sample);\n\n sampleHeader.push({\n sampleName,\n start,\n end,\n startLoop,\n endLoop,\n sampleRate,\n originalPitch,\n pitchCorrection,\n sampleLink,\n sampleType,\n });\n }\n }\n\n /**\n * @param {Int16Array} sample\n * @param {number} sampleRate\n * @return {object}\n */\n adjustSampleData(sample, sampleRate) {\n /** @type {Int16Array} */\n let newSample;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let multiply = 1;\n\n // buffer\n while (sampleRate < this.sampleRate) {\n // AudioContextのサンプルレートに変更\n newSample = new Int16Array(sample.length * 2);\n for (i = j = 0, il = sample.length; i < il; ++i) {\n newSample[j++] = sample[i];\n newSample[j++] = sample[i];\n }\n sample = newSample;\n multiply *= 2;\n sampleRate *= 2;\n }\n\n return {\n sample,\n multiply,\n };\n }\n\n /**\n * @param {import('./riff.js').RiffChunk} chunk\n * @return {Object[]}\n */\n parseModulator(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {number} */\n let code;\n /** @type {string} */\n let key;\n /** @type {Object[]} */\n const output = [];\n\n while (ip < size) {\n // Src Oper\n // TODO\n ip += 2;\n\n // Dest Oper\n code = data[ip++] | (data[ip++] << 8);\n key = this.GeneratorEnumeratorTable[code];\n if (!key) {\n // Amount\n output.push({\n type: key,\n value: {\n code,\n amount: data[ip] | (((data[ip + 1] << 8) << 16) >> 16),\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n } else {\n // Amount\n switch (key) {\n case 'keyRange':\n /* FALLTHROUGH */\n case 'velRange':\n /* FALLTHROUGH */\n case 'keynum':\n /* FALLTHROUGH */\n case 'velocity':\n output.push({\n type: key,\n value: {\n amount: null,\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n break;\n default:\n output.push({\n type: key,\n value: {\n amount: data[ip++] | (((data[ip++] << 8) << 16) >> 16),\n },\n });\n break;\n }\n }\n\n // AmtSrcOper\n // TODO\n ip += 2;\n\n // Trans Oper\n // TODO\n ip += 2;\n }\n\n return output;\n }\n\n /**\n * @param {import('./riff.js').RiffChunk} chunk\n * @return {Object[]}\n */\n parseGenerator(chunk) {\n /** @type {ArrayBuffer} */\n const data = this.input;\n /** @type {number} */\n let ip = chunk.offset;\n /** @type {number} */\n const size = chunk.offset + chunk.size;\n /** @type {number} */\n let code;\n /** @type {string} */\n let key;\n /** @type {Object[]} */\n const output = [];\n\n while (ip < size) {\n code = data[ip++] | (data[ip++] << 8);\n key = this.GeneratorEnumeratorTable[code];\n if (!key) {\n output.push({\n type: key,\n value: {\n code,\n amount: data[ip] | (((data[ip + 1] << 8) << 16) >> 16),\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n continue;\n }\n\n switch (key) {\n case 'keynum':\n /* FALLTHROUGH */\n case 'keyRange':\n /* FALLTHROUGH */\n case 'velRange':\n /* FALLTHROUGH */\n case 'velocity':\n output.push({\n type: key,\n value: {\n amount: null,\n lo: data[ip++],\n hi: data[ip++],\n },\n });\n break;\n default:\n output.push({\n type: key,\n value: {\n amount: data[ip++] | (((data[ip++] << 8) << 16) >> 16),\n },\n });\n break;\n }\n }\n\n return output;\n }\n\n /** @return {object[]} */\n createInstrument() {\n /** @type {Object[]} */\n const instrument = this.instrument;\n /** @type {Object[]} */\n const zone = this.instrumentZone;\n /** @type {Object[]} */\n const output = [];\n /** @type {number} */\n let bagIndex;\n /** @type {number} */\n let bagIndexEnd;\n /** @type {Object[]} */\n let zoneInfo;\n /** @type {{ generator: Object; generatorInfo: Object[] }} */\n let instrumentGenerator;\n /** @type {{ modulator: Object; modulatorInfo: Object[] }} */\n let instrumentModulator;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let jl;\n\n // instrument -> instrument bag -> generator / modulator\n for (i = 0, il = instrument.length; i < il; ++i) {\n bagIndex = instrument[i].instrumentBagIndex;\n bagIndexEnd = instrument[i + 1]\n ? instrument[i + 1].instrumentBagIndex\n : zone.length;\n zoneInfo = [];\n\n // instrument bag\n for (j = bagIndex, jl = bagIndexEnd; j < jl; ++j) {\n instrumentGenerator = this.createInstrumentGenerator_(zone, j);\n instrumentModulator = this.createInstrumentModulator_(zone, j);\n\n zoneInfo.push({\n generator: instrumentGenerator.generator,\n generatorSequence: instrumentGenerator.generatorInfo,\n modulator: instrumentModulator.modulator,\n modulatorSequence: instrumentModulator.modulatorInfo,\n });\n }\n\n output.push({\n name: instrument[i].instrumentName,\n info: zoneInfo,\n });\n }\n\n return output;\n }\n\n /** @return {object[]} */\n createPreset() {\n /** @type {Object[]} */\n const preset = this.presetHeader;\n /** @type {Object[]} */\n const zone = this.presetZone;\n /** @type {Object[]} */\n const output = [];\n /** @type {number} */\n let bagIndex;\n /** @type {number} */\n let bagIndexEnd;\n /** @type {Object[]} */\n let zoneInfo;\n /** @type {number} */\n let instrument;\n /** @type {{ generator: Object; generatorInfo: Object[] }} */\n let presetGenerator;\n /** @type {{ modulator: Object; modulatorInfo: Object[] }} */\n let presetModulator;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {number} */\n let j;\n /** @type {number} */\n let jl;\n\n // preset -> preset bag -> generator / modulator\n for (i = 0, il = preset.length; i < il; ++i) {\n bagIndex = preset[i].presetBagIndex;\n bagIndexEnd = preset[i + 1] ? preset[i + 1].presetBagIndex : zone.length;\n zoneInfo = [];\n\n // preset bag\n for (j = bagIndex, jl = bagIndexEnd; j < jl; ++j) {\n presetGenerator = this.createPresetGenerator_(zone, j);\n presetModulator = this.createPresetModulator_(zone, j);\n\n zoneInfo.push({\n generator: presetGenerator.generator,\n generatorSequence: presetGenerator.generatorInfo,\n modulator: presetModulator.modulator,\n modulatorSequence: presetModulator.modulatorInfo,\n });\n\n instrument =\n presetGenerator.generator.instrument !== undefined\n ? presetGenerator.generator.instrument.amount\n : presetModulator.modulator.instrument !== undefined\n ? presetModulator.modulator.instrument.amount\n : null;\n }\n\n output.push({\n name: preset[i].presetName,\n info: zoneInfo,\n header: preset[i],\n instrument,\n });\n }\n\n return output;\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ generator: Object; generatorInfo: Object[] }}\n */\n createInstrumentGenerator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].instrumentGeneratorIndex,\n zone[index + 1]\n ? zone[index + 1].instrumentGeneratorIndex\n : this.instrumentZoneGenerator.length,\n this.instrumentZoneGenerator\n );\n\n return {\n generator: modgen.modgen,\n generatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ modulator: Object; modulatorInfo: Object[] }}\n */\n createInstrumentModulator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetModulatorIndex,\n zone[index + 1]\n ? zone[index + 1].instrumentModulatorIndex\n : this.instrumentZoneModulator.length,\n this.instrumentZoneModulator\n );\n\n return {\n modulator: modgen.modgen,\n modulatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ generator: Object; generatorInfo: Object[] }}\n */\n createPresetGenerator_(zone, index) {\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetGeneratorIndex,\n zone[index + 1]\n ? zone[index + 1].presetGeneratorIndex\n : this.presetZoneGenerator.length,\n this.presetZoneGenerator\n );\n\n return {\n generator: modgen.modgen,\n generatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} zone\n * @param {number} index\n * @returns {{ modulator: Object; modulatorInfo: Object[] }}\n */\n createPresetModulator_(zone, index) {\n /** @type {{ modgen: Object; modgenInfo: Object[] }} */\n const modgen = this.createBagModGen_(\n zone,\n zone[index].presetModulatorIndex,\n zone[index + 1]\n ? zone[index + 1].presetModulatorIndex\n : this.presetZoneModulator.length,\n this.presetZoneModulator\n );\n\n return {\n modulator: modgen.modgen,\n modulatorInfo: modgen.modgenInfo,\n };\n }\n\n /**\n *\n * @private\n * @param {Object[]} _zone\n * @param {number} indexStart\n * @param {number} indexEnd\n * @param {Array} zoneModGen\n * @returns {{ modgen: Object; modgenInfo: Object[] }}\n */\n createBagModGen_(_zone, indexStart, indexEnd, zoneModGen) {\n /** @type {Object[]} */\n const modgenInfo = [];\n /** @type {Object} */\n const modgen = {\n unknown: [],\n keyRange: {\n amount: null,\n hi: 127,\n lo: 0,\n },\n }; // TODO\n /** @type {Object} */\n let info;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n for (i = indexStart, il = indexEnd; i < il; ++i) {\n info = zoneModGen[i];\n modgenInfo.push(info);\n\n if (info.type === 'unknown') {\n modgen.unknown.push(info.value);\n } else {\n modgen[info.type] = info.value;\n }\n }\n\n return {\n modgen,\n modgenInfo,\n };\n }\n}\n","/**\n * @classdesc File Loader Class\n * @private\n * @author Logue \n */\nexport default class Loader {\n /** キャッシュの名前空間 */\n static CACHE_NAME = 'wml';\n /**\n * コンストラクタ\n *\n * @constructor\n * @param {string} url\n * @param {HTMLDivElement} placeholder\n * @param {boolean} cache\n * @param {Function} callback\n */\n constructor(url, placeholder, cache, callback) {\n this.url = url;\n this.cache = cache;\n this.callback = callback;\n\n /** @type {HTMLDivElement} */\n this.alert = document.createElement('div');\n this.alert.className = 'alert alert-warning';\n\n /** @type {HTMLParagraphElement} */\n this.message = document.createElement('p');\n this.message.innerText = 'Now Loading...';\n\n /** @type {HTMLDivElement} */\n this.progressOuter = document.createElement('div');\n this.progressOuter.className = 'progress';\n this.progressOuter.role = 'progressbar';\n this.progressOuter.ariaLabel = 'Loading Progress';\n this.progressOuter.ariaValueMin = '0';\n this.progressOuter.ariaValueNow = '0';\n this.progressOuter.ariaValueMax = '100';\n\n /** @type {HTMLDivElement} */\n this.progress = document.createElement('div');\n this.progress.className = 'progress-bar';\n\n this.progressOuter.appendChild(this.progress);\n this.alert.appendChild(this.message);\n this.alert.appendChild(this.progressOuter);\n\n placeholder.appendChild(this.alert);\n }\n\n /**\n * ダウンロード中のハンドラ\n * @param {number} current\n * @param {number} total\n * @private\n */\n onProgress(current, total) {\n const percentCompleted = Math.floor((current / total) * 100);\n this.progress.style.width = `${percentCompleted}%`;\n this.progress.innerText = `${percentCompleted}%`;\n }\n\n /**\n * ロード完了時のハンドラ\n *\n * @param {ArrayBuffer} buffer\n * @private\n */\n onComplete(buffer) {\n this.alert.className = 'alert alert-info';\n this.message.innerText = 'Initializing...';\n this.progress.className =\n 'progress-bar progress-bar-striped progress-bar-animated';\n this.progress.style.width = '100%';\n // コールバック実行\n this.callback(new Uint8Array(buffer));\n }\n\n /**\n * エラー時のハンドラ\n *\n * @param {Error | undefined} error エラー内容\n * @private\n */\n onError(error = undefined) {\n requestAnimationFrame(() => {\n this.alert.className = 'alert alert-danger';\n this.message.innerText =\n 'An error occurred while loading SoundFont. See the console log for details. In addition, it may be cured by deleting the cache of the browser.';\n this.progressOuter.style.display = 'none';\n });\n }\n\n /**\n * データ取得\n * @public\n */\n async fetch() {\n /** @type {Cache} */\n const cache = await window.caches.open(Loader.CACHE_NAME);\n /** @type {Response} */\n const cached = await cache.match(this.url);\n\n if (this.cache && cached) {\n // キャッシュが存在する場合、キャッシュの値を返す\n this.onComplete(await cached.arrayBuffer());\n return;\n }\n\n /** @type {void | Response} キャッシュがない場合Fetchで取得 */\n const response = await fetch(this.url, {\n method: 'GET',\n }).catch(e => this.onError(e));\n\n if (!response || (response && !response.ok)) {\n return;\n }\n\n /** @type {Response} キャッシュ用レスポンス */\n const cloned = response.clone();\n\n /** @type {number} ファイルの容量 */\n const contentLength = parseInt(response.headers.get('Content-Length'));\n\n /** @type {ReadableStreamDefaultReader} ファイルリーダー */\n const reader = cloned.body.getReader();\n\n /** @type {number} 読み込まれたチャンクの長さ */\n let receivedLength = 0;\n\n /** @type {Uint8Array[]} 受信したバイナリチャンクの配列(本文を構成します) */\n const chunks = [];\n\n // eslint-disable-next-line\n while (true) {\n // 最後のチャンクも場合、done は true。\n // value はチャンクバイトの Uint8Array\n const { done, value } = await reader.read();\n if (done) {\n break;\n }\n chunks.push(value);\n receivedLength += value.length;\n\n this.message.innerText = `Now Loading... (${receivedLength} of ${contentLength} byte)`;\n\n // Content lengthヘッダーが出力されている場合プログレスバーを表示\n this.onProgress(receivedLength, contentLength);\n }\n\n /** @type {Uint8Array} 全チャンク */\n const chunksAll = new Uint8Array(receivedLength);\n /** @type {number} 現在の読み込んだチャンク位置 */\n let position = 0;\n for (const chunk of chunks) {\n chunksAll.set(chunk, position);\n position += chunk.length;\n }\n\n // キャッシュへ保存\n await cache.put(this.url, response);\n // 完了時のイベントを実行\n this.onComplete(chunksAll);\n }\n}\n","const INV_MAX = 1 / 2 ** 32;\nclass ARandom {\n float(norm = 1) {\n return this.int() * INV_MAX * norm;\n }\n probability(p) {\n return this.float() < p;\n }\n norm(norm = 1) {\n return (this.int() * INV_MAX - 0.5) * 2 * norm;\n }\n normMinMax(min, max) {\n const x = this.minmax(min, max);\n return this.float() < 0.5 ? x : -x;\n }\n minmax(min, max) {\n return this.float() * (max - min) + min;\n }\n minmaxInt(min, max) {\n min |= 0;\n const range = (max | 0) - min;\n return range ? min + this.int() % range : min;\n }\n minmaxUint(min, max) {\n min >>>= 0;\n const range = (max >>> 0) - min;\n return range ? min + this.int() % range : min;\n }\n}\nexport {\n ARandom\n};\n","import { ARandom } from \"./arandom.js\";\nconst random = Math.random;\nclass SystemRandom extends ARandom {\n int() {\n return random() * 4294967296 >>> 0;\n }\n float(norm = 1) {\n return random() * norm;\n }\n norm(norm = 1) {\n return (random() - 0.5) * 2 * norm;\n }\n}\nconst SYSTEM = new SystemRandom();\nexport {\n SYSTEM,\n SystemRandom\n};\n","import { SYSTEM } from \"@thi.ng/random/system\";\nconst DEFAULT_OPTS = {\n bins: 2,\n scale: 1,\n rnd: SYSTEM\n};\nexport {\n DEFAULT_OPTS\n};\n","const preseed = (n, scale, rnd) => {\n const state = new Array(n);\n for (let i = 0; i < n; i++) {\n state[i] = rnd.norm(scale);\n }\n return state;\n};\nconst sum = (src) => src.reduce((sum2, x) => sum2 + x, 0);\nfunction* interleave(a, b) {\n const src = [a[Symbol.iterator](), b[Symbol.iterator]()];\n for (let i = 0; true; i ^= 1) {\n const next = src[i].next();\n if (next.done)\n return;\n yield next.value;\n }\n}\nexport {\n interleave,\n preseed,\n sum\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* blue(opts) {\n const { bins, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n state.forEach((x, i) => state[i] = i & 1 ? x : -x);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0, sign = -1; true; ++i >= bins && (i = 0)) {\n acc -= state[i];\n acc += state[i] = sign * rnd.norm(scale);\n sign ^= 4294967294;\n yield sign * acc * invN;\n }\n}\nexport {\n blue\n};\n","import { blue } from \"./blue.js\";\nimport { interleave } from \"./utils.js\";\nconst green = (opts) => interleave(blue(opts), blue(opts));\nexport {\n green\n};\n","const popCount = (x) => (x = x - (x >>> 1 & 1431655765), x = (x & 858993459) + (x >>> 2 & 858993459), (x + (x >>> 4) & 252645135) * 16843009 >>> 24);\nconst popCountArray = (data, start = 0, n = data.length) => {\n let num = 0;\n for (let end = start + n; start < end; start++) {\n const x = data[start];\n x > 0 && (num += popCount(x));\n }\n return num;\n};\nconst hammingDist = (x, y) => popCount(x ^ y);\nconst clz32 = (x) => x !== 0 ? 31 - (Math.log(x >>> 0) / Math.LN2 | 0) : 32;\nconst ctz32 = (x) => {\n let c = 32;\n x &= -x;\n x && c--;\n x & 65535 && (c -= 16);\n x & 16711935 && (c -= 8);\n x & 252645135 && (c -= 4);\n x & 858993459 && (c -= 2);\n x & 1431655765 && (c -= 1);\n return c;\n};\nconst bitSize = (x) => x > 1 ? Math.ceil(Math.log2(x)) : 0;\nexport {\n bitSize,\n clz32,\n ctz32,\n hammingDist,\n popCount,\n popCountArray\n};\n","import { ctz32 } from \"@thi.ng/binary/count\";\nimport { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* pink(opts) {\n const { bins = 8, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0; true; i = i + 1 >>> 0) {\n const id = ctz32(i) % bins;\n acc -= state[id];\n acc += state[id] = rnd.norm(scale);\n yield acc * invN;\n }\n}\nexport {\n pink\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nimport { preseed, sum } from \"./utils.js\";\nfunction* red(opts) {\n const { bins, scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n const state = preseed(bins, scale, rnd);\n const invN = 1 / bins;\n let acc = sum(state);\n for (let i = 0; true; ++i >= bins && (i = 0)) {\n acc -= state[i];\n acc += state[i] = rnd.norm(scale);\n yield acc * invN;\n }\n}\nexport {\n red\n};\n","import { red } from \"./red.js\";\nimport { interleave } from \"./utils.js\";\nconst violet = (opts) => interleave(red(opts), red(opts));\nexport {\n violet\n};\n","import { DEFAULT_OPTS } from \"./api.js\";\nfunction* white(opts) {\n const { scale, rnd } = { ...DEFAULT_OPTS, ...opts };\n while (true) {\n yield rnd.norm(scale);\n }\n}\nexport {\n white\n};\n","const implementsFunction = (x, fn) => x != null && typeof x[fn] === \"function\";\nexport {\n implementsFunction\n};\n","import { implementsFunction } from \"@thi.ng/checks/implements-function\";\nconst ensureTransducer = (x) => implementsFunction(x, \"xform\") ? x.xform() : x;\nexport {\n ensureTransducer\n};\n","const isIterable = (x) => x != null && typeof x[Symbol.iterator] === \"function\";\nexport {\n isIterable\n};\n","const identity = (x) => x;\nconst always = () => true;\nconst never = () => false;\nexport {\n always,\n identity,\n never\n};\n","class Reduced {\n value;\n constructor(val) {\n this.value = val;\n }\n deref() {\n return this.value;\n }\n}\nconst reduced = (x) => new Reduced(x);\nconst isReduced = (x) => x instanceof Reduced;\nconst ensureReduced = (x) => x instanceof Reduced ? x : new Reduced(x);\nconst unreduced = (x) => x instanceof Reduced ? x.deref() : x;\nexport {\n Reduced,\n ensureReduced,\n isReduced,\n reduced,\n unreduced\n};\n","import { identity } from \"@thi.ng/api/fn\";\nimport { implementsFunction } from \"@thi.ng/checks/implements-function\";\nimport { isArrayLike } from \"@thi.ng/checks/is-arraylike\";\nimport { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { illegalArity } from \"@thi.ng/errors/illegal-arity\";\nimport { isReduced, unreduced } from \"./reduced.js\";\nconst parseArgs = (args) => args.length === 2 ? [void 0, args[1]] : args.length === 3 ? [args[1], args[2]] : illegalArity(args.length);\nfunction reduce(...args) {\n const rfn = args[0];\n const init = rfn[0];\n const complete = rfn[1];\n const reduce2 = rfn[2];\n args = parseArgs(args);\n const acc = args[0] == null ? init() : args[0];\n const xs = args[1];\n return unreduced(\n complete(\n implementsFunction(xs, \"$reduce\") ? xs.$reduce(reduce2, acc) : isArrayLike(xs) ? reduceArray(reduce2, acc, xs) : reduceIterable(reduce2, acc, xs)\n )\n );\n}\nfunction reduceRight(...args) {\n const [init, complete, reduce2] = args[0];\n args = parseArgs(args);\n let acc = args[0] == null ? init() : args[0];\n const xs = args[1];\n for (let i = xs.length; i-- > 0; ) {\n acc = reduce2(acc, xs[i]);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return unreduced(complete(acc));\n}\nconst reduceArray = (rfn, acc, xs) => {\n for (let i = 0, n = xs.length; i < n; i++) {\n acc = rfn(acc, xs[i]);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return acc;\n};\nconst reduceIterable = (rfn, acc, xs) => {\n for (let x of xs) {\n acc = rfn(acc, x);\n if (isReduced(acc)) {\n acc = acc.deref();\n break;\n }\n }\n return acc;\n};\nconst reducer = (init, rfn) => [init, identity, rfn];\nconst $$reduce = (rfn, args) => {\n const n = args.length - 1;\n return isIterable(args[n]) ? args.length > 1 ? reduce(rfn.apply(null, args.slice(0, n)), args[n]) : reduce(rfn(), args[0]) : void 0;\n};\nexport {\n $$reduce,\n reduce,\n reduceRight,\n reducer\n};\n","import { reducer } from \"./reduce.js\";\nfunction push(xs) {\n return xs ? [...xs] : reducer(\n () => [],\n (acc, x) => (acc.push(x), acc)\n );\n}\nexport {\n push\n};\n","import { NO_OP, SEMAPHORE } from \"@thi.ng/api/api\";\nimport { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { ensureTransducer } from \"./ensure.js\";\nimport { push } from \"./push.js\";\nimport { isReduced, unreduced } from \"./reduced.js\";\nfunction* iterator(xform, xs) {\n const rfn = ensureTransducer(xform)(push());\n const complete = rfn[1];\n const reduce = rfn[2];\n for (let x of xs) {\n const y = reduce([], x);\n if (isReduced(y)) {\n yield* unreduced(complete(y.deref()));\n return;\n }\n if (y.length) {\n yield* y;\n }\n }\n yield* unreduced(complete([]));\n}\nfunction* iterator1(xform, xs) {\n const reduce = ensureTransducer(xform)([NO_OP, NO_OP, (_, x) => x])[2];\n for (let x of xs) {\n let y = reduce(SEMAPHORE, x);\n if (isReduced(y)) {\n y = unreduced(y.deref());\n if (y !== SEMAPHORE) {\n yield y;\n }\n return;\n }\n if (y !== SEMAPHORE) {\n yield y;\n }\n }\n}\nconst __iter = (xform, args, impl = iterator1) => {\n const n = args.length - 1;\n return isIterable(args[n]) ? args.length > 1 ? impl(xform.apply(null, args.slice(0, n)), args[n]) : impl(xform(), args[0]) : void 0;\n};\nexport {\n __iter,\n iterator,\n iterator1\n};\n","const compR = (rfn, fn) => [rfn[0], rfn[1], fn];\nexport {\n compR\n};\n","import { isIterable } from \"@thi.ng/checks/is-iterable\";\nimport { compR } from \"./compr.js\";\nimport { iterator } from \"./iterator.js\";\nimport { ensureReduced, reduced } from \"./reduced.js\";\nfunction take(n, src) {\n return isIterable(src) ? iterator(take(n), src) : (rfn) => {\n const r = rfn[2];\n let m = n;\n return compR(\n rfn,\n (acc, x) => --m > 0 ? r(acc, x) : m === 0 ? ensureReduced(r(acc, x)) : reduced(acc)\n );\n };\n}\nexport {\n take\n};\n","/**\n * @logue/reverb\n *\n * @description JavaScript Reverb effect class\n * @author Logue \n * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved.\n * @license MIT\n * @version 1.3.9\n * @see {@link https://github.com/logue/Reverb.js}\n */\n\nimport { white as c, violet as m, red as f, pink as b, green as N, blue as g } from \"@thi.ng/colored-noise\";\nimport { take as v } from \"@thi.ng/transducers\";\nimport { SYSTEM as w } from \"@thi.ng/random\";\nconst d = {\n version: \"1.3.9\",\n date: \"2024-04-24T08:29:36.615Z\"\n}, o = {\n /** Blue noise */\n blue: \"blue\",\n /** Brown noise (same as red noise) */\n brown: \"red\",\n /** Green noise */\n green: \"green\",\n /** Pink noise */\n pink: \"pink\",\n /** Red noise */\n red: \"red\",\n /** Violet noise */\n violet: \"violet\",\n /** White noise */\n white: \"white\"\n}, y = {\n noise: \"white\",\n scale: 1,\n peaks: 2,\n randomAlgorithm: w,\n decay: 2,\n delay: 0,\n reverse: !1,\n time: 2,\n filterType: \"allpass\",\n filterFreq: 2200,\n filterQ: 1,\n mix: 0.5,\n once: !1\n};\nclass s {\n /** Version strings */\n static version = d.version;\n /** Build date */\n static build = d.date;\n /** AudioContext */\n ctx;\n /** Wet Level (Reverberated node) */\n wetGainNode;\n /** Dry Level (Original sound node) */\n dryGainNode;\n /** Impulse response filter */\n filterNode;\n /** Convolution node for applying impulse response */\n convolverNode;\n /** Output gain node */\n outputNode;\n /** Option */\n options;\n /** Connected flag */\n isConnected;\n /** Noise Generator */\n noise = c;\n /**\n * Constructor\n *\n * @param ctx - Root AudioContext\n * @param options - Configure\n */\n constructor(e, t) {\n this.ctx = e, this.options = Object.assign(y, t), this.wetGainNode = this.ctx.createGain(), this.dryGainNode = this.ctx.createGain(), this.filterNode = this.ctx.createBiquadFilter(), this.convolverNode = this.ctx.createConvolver(), this.outputNode = this.ctx.createGain(), this.isConnected = !1, this.filterType(this.options.filterType), this.setNoise(this.options.noise), this.buildImpulse(), this.mix(this.options.mix);\n }\n /**\n * Connect the node for the reverb effect to the original sound node.\n *\n * @param sourceNode - Input source node\n */\n connect(e) {\n return this.isConnected && this.options.once ? (this.isConnected = !1, this.outputNode) : (this.convolverNode.connect(this.filterNode), this.filterNode.connect(this.wetGainNode), e.connect(this.convolverNode), e.connect(this.dryGainNode).connect(this.outputNode), e.connect(this.wetGainNode).connect(this.outputNode), this.isConnected = !0, this.outputNode);\n }\n /**\n * Disconnect the reverb node\n *\n * @param sourceNode - Input source node\n */\n disconnect(e) {\n return this.isConnected && (this.convolverNode.disconnect(this.filterNode), this.filterNode.disconnect(this.wetGainNode)), this.isConnected = !1, e;\n }\n /**\n * Dry/Wet ratio\n *\n * @param mix - Ratio (0~1)\n */\n mix(e) {\n if (!s.inRange(e, 0, 1))\n throw new RangeError(\"[Reverb.js] Dry/Wet ratio must be between 0 to 1.\");\n this.options.mix = e, this.dryGainNode.gain.value = 1 - this.options.mix, this.wetGainNode.gain.value = this.options.mix;\n }\n /**\n * Set Impulse Response time length (second)\n *\n * @param value - IR length\n */\n time(e) {\n if (!s.inRange(e, 1, 50))\n throw new RangeError(\n \"[Reverb.js] Time length of inpulse response must be less than 50sec.\"\n );\n this.options.time = e, this.buildImpulse();\n }\n /**\n * Impulse response decay rate.\n *\n * @param value - Decay value\n */\n decay(e) {\n if (!s.inRange(e, 0, 100))\n throw new RangeError(\n \"[Reverb.js] Inpulse Response decay level must be less than 100.\"\n );\n this.options.decay = e, this.buildImpulse();\n }\n /**\n * Delay before reverberation starts\n *\n * @param value - Time[ms]\n */\n delay(e) {\n if (!s.inRange(e, 0, 100))\n throw new RangeError(\n \"[Reverb.js] Inpulse Response delay time must be less than 100.\"\n );\n this.options.delay = e, this.buildImpulse();\n }\n /**\n * Reverse the impulse response.\n *\n * @param reverse - Reverse IR\n */\n reverse(e) {\n this.options.reverse = e, this.buildImpulse();\n }\n /**\n * Filter for impulse response\n *\n * @param type - Filiter Type\n */\n filterType(e = \"allpass\") {\n this.filterNode.type = this.options.filterType = e;\n }\n /**\n * Filter frequency applied to impulse response\n *\n * @param freq - Frequency\n */\n filterFreq(e) {\n if (!s.inRange(e, 20, 2e4))\n throw new RangeError(\n \"[Reverb.js] Filter frequrncy must be between 20 and 20000.\"\n );\n this.options.filterFreq = e, this.filterNode.frequency.value = this.options.filterFreq;\n }\n /**\n * Filter quality.\n *\n * @param q - Quality\n */\n filterQ(e) {\n if (!s.inRange(e, 0, 10))\n throw new RangeError(\n \"[Reverb.js] Filter Q value must be between 0 and 10.\"\n );\n this.options.filterQ = e, this.filterNode.Q.value = this.options.filterQ;\n }\n /**\n * set IR source noise peaks\n *\n * @param p - Peaks\n */\n peaks(e) {\n this.options.peaks = e, this.buildImpulse();\n }\n /**\n * set IR source noise scale.\n *\n * @param s - Scale\n */\n scale(e) {\n this.options.scale = e, this.buildImpulse();\n }\n /**\n * set IR source noise generator.\n *\n * @param a - Algorithm\n */\n randomAlgorithm(e) {\n this.options.randomAlgorithm = e, this.buildImpulse();\n }\n /**\n * Inpulse Response Noise algorithm.\n *\n * @param type - IR noise algorithm type.\n */\n setNoise(e) {\n switch (this.options.noise = e, e) {\n case o.blue:\n this.noise = g;\n break;\n case o.green:\n this.noise = N;\n break;\n case o.pink:\n this.noise = b;\n break;\n case o.red:\n case o.brown:\n this.noise = f;\n break;\n case o.violet:\n this.noise = m;\n break;\n default:\n this.noise = c;\n }\n this.buildImpulse();\n }\n /**\n * Set Random Algorythm\n *\n * @param algorithm - Algorythm\n */\n setRandomAlgorythm(e) {\n this.options.randomAlgorithm = e, this.buildImpulse();\n }\n /**\n * Return true if in range, otherwise false\n *\n * @param x - Target value\n * @param min - Minimum value\n * @param max - Maximum value\n */\n static inRange(e, t, n) {\n return (e - t) * (e - n) <= 0;\n }\n /** Utility function for building an impulse response from the module parameters. */\n buildImpulse() {\n const e = this.ctx.sampleRate, t = Math.max(e * this.options.time, 1), n = e * this.options.delay, a = this.ctx.createBuffer(2, t, e), h = new Float32Array(t), l = new Float32Array(t), p = this.getNoise(t), u = this.getNoise(t);\n for (let i = 0; i < t; i++) {\n let r = 0;\n i < n ? (h[i] = 0, l[i] = 0, r = this.options.reverse ?? !1 ? t - (i - n) : i - n) : r = this.options.reverse ?? !1 ? t - i : i, h[i] = (p[i] ?? 0) * (1 - r / t) ** this.options.decay, l[i] = (u[i] ?? 0) * (1 - r / t) ** this.options.decay;\n }\n a.getChannelData(0).set(h), a.getChannelData(1).set(l), this.convolverNode.buffer = a;\n }\n /**\n * Noise source\n *\n * @param duration - length of IR.\n */\n getNoise(e) {\n return [\n ...v(\n e,\n this.noise({\n bins: this.options.peaks,\n scale: this.options.scale,\n rnd: this.options.randomAlgorithm\n })\n )\n ];\n }\n}\nexport {\n s as default\n};\n","/**\n * SynthesizerNote Class\n *\n * @author imaya\n * @private\n */\nexport default class SynthesizerNote {\n /**\n * @param {AudioContext} ctx\n * @param {AudioNode} destination\n * @param {{\n * channel: number;\n * key: number;\n * velocity:number;\n * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * sampleRate: number;\n * volume: number;\n * panpot: number;\n * pitchBend: number;\n * pitchBendSensitivity: number;\n * modEnvToPitch: number;\n * expression: number;\n * modulation: number;\n * cutOffFrequency: number;\n * hermonicContent: number;\n * reverb: import('@logue/reverb').default;\n * volDelay: number;\n * modDelay: number;\n * volAttack: number;\n * modAttack: number;\n * volHold: number;\n * modHold: number;\n * volDecay: number;\n * modDecay: number;\n * releaseTime: number;\n * volRelease: number;\n * modRelease: number;\n * start: number;\n * end: number;\n * pan: number;\n * sampleModes: number;\n * initialAttenuation: number;\n * volSustain:number;\n * modSustain:number;\n * initialFilterFc :number;\n * modEnvToFilterFc:number;\n * initialFilterQ: number;\n * mute: number;\n * scaleTuning: number;\n * }} instrument\n */\n constructor(ctx, destination, instrument) {\n /** @type {AudioContext} */\n this.ctx = ctx;\n /** @type {AudioNode} */\n this.destination = destination;\n\n this.instrument = instrument;\n /** @type {number} */\n this.channel = instrument.channel;\n /** @type {number} */\n this.key = instrument.key;\n /** @type {number} */\n this.velocity = instrument.velocity;\n /** @type {Uint8Array} */\n this.buffer = instrument.sample;\n /** @type {number} */\n this.playbackRate = instrument.basePlaybackRate;\n /** @type {number} */\n this.loopStart = instrument.loopStart;\n /** @type {number} */\n this.loopEnd = instrument.loopEnd;\n /** @type {number} */\n this.sampleRate = instrument.sampleRate;\n /** @type {number} */\n this.volume = instrument.volume;\n /** @type {number} */\n this.panpot = instrument.panpot;\n /** @type {number} */\n this.pitchBend = instrument.pitchBend;\n /** @type {number} */\n this.pitchBendSensitivity = instrument.pitchBendSensitivity;\n /** @type {number} */\n this.modEnvToPitch = instrument.modEnvToPitch;\n /** @type {number} */\n this.expression = instrument.expression;\n /** @type {number} */\n this.modulation = instrument.modulation;\n /** @type {number} */\n this.cutOffFrequency = instrument.cutOffFrequency;\n /** @type {number} */\n this.hermonicContent = instrument.hermonicContent;\n\n /** @type {import('@logue/reverb').default} */\n this.reverb = instrument.reverb;\n\n // state\n /** @type {number} */\n this.startTime = ctx.currentTime;\n /** @type {number} */\n this.computedPlaybackRate = this.playbackRate | 0;\n /** @type {boolean} */\n this.noteOffState = false;\n\n // ---------------------------------------------------------------------------\n // audio node\n // ---------------------------------------------------------------------------\n\n /** @type {AudioBuffer} */\n this.audioBuffer = null;\n /** @type {AudioBufferSourceNode} */\n this.bufferSource = ctx.createBufferSource();\n /** @type {PannerNode} */\n this.panner = ctx.createPanner();\n /** @type {GainNode} */\n this.outputGainNode = ctx.createGain();\n /** @type {GainNode} */\n this.expressionGainNode = ctx.createGain();\n /** @type {BiquadFilterNode} */\n this.filter = ctx.createBiquadFilter();\n /** @type {BiquadFilterNode} */\n this.modulator = ctx.createBiquadFilter();\n }\n\n /** Note on */\n noteOn() {\n /** @type {AudioContext} */\n const ctx = this.ctx;\n const instrument = this.instrument;\n /** @type {number} */\n const now = this.ctx.currentTime || 0;\n /** @type {number} */\n const volDelay = now + instrument.volDelay;\n /** @type {number} */\n const modDelay = now + instrument.modDelay;\n /** @type {number} */\n const volAttack = volDelay + instrument.volAttack;\n /** @type {number} */\n const modAttack = volDelay + instrument.modAttack;\n /** @type {number} */\n const volHold = volAttack + instrument.volHold;\n /** @type {number} */\n const modHold = modAttack + instrument.modHold;\n /** @type {number} */\n const volDecay = volHold + instrument.volDecay;\n /** @type {number} */\n const modDecay = modHold + instrument.modDecay;\n /** @type {number} */\n const loopStart = instrument.loopStart / this.sampleRate;\n /** @type {number} */\n const loopEnd = instrument.loopEnd / this.sampleRate;\n /** @type {number} */\n const startTime = instrument.start / this.sampleRate;\n // TODO: ドラムパートのPanが変化した場合、その計算をしなければならない\n // http://cpansearch.perl.org/src/PJB/MIDI-SoundFont-1.08/doc/sfspec21.html#8.4.6\n /** @type {number} */\n const pan = instrument.pan !== 0 ? instrument.pan : this.panpot;\n\n const sample = this.buffer.subarray(0, this.buffer.length + instrument.end);\n /** @type {AudioBuffer} */\n const buffer = (this.audioBuffer = ctx.createBuffer(\n 1,\n sample.length,\n this.sampleRate\n ));\n /** @type {Float32Array} */\n const channelData = buffer.getChannelData(0);\n channelData.set(sample);\n\n // buffer source\n /** @type {AudioBufferSourceNode} */\n const bufferSource = this.bufferSource;\n bufferSource.buffer = buffer;\n bufferSource.loop = instrument.sampleModes !== 0;\n bufferSource.loopStart = loopStart;\n bufferSource.loopEnd = loopEnd;\n this.updatePitchBend(this.pitchBend);\n\n // Output\n /** @type {GainNode} */\n const output = this.outputGainNode;\n\n // expression\n this.expressionGainNode.gain.value = this.expression / 127;\n\n // panpot\n /** @type {PannerNode} */\n const panner = this.panner;\n panner.panningModel = 'equalpower';\n panner.distanceModel = 'inverse';\n panner.positionX.setValueAtTime(Math.sin((pan * Math.PI) / 2), 0);\n panner.positionY.setValueAtTime(0, 0);\n panner.positionZ.setValueAtTime(Math.cos((pan * Math.PI) / 2), 0);\n\n // ---------------------------------------------------------------------------\n // Delay, Attack, Hold, Decay, Sustain\n // ---------------------------------------------------------------------------\n\n /** @type {number} */\n let volume =\n this.volume *\n (this.velocity / 127) *\n (1 - instrument.initialAttenuation / 1000);\n if (volume < 0) {\n volume = 0;\n }\n\n /** @type {AudioParam} volume envelope */\n const outputGain = output.gain;\n outputGain.setValueAtTime(0, now);\n outputGain.setValueAtTime(0, volDelay);\n outputGain.setTargetAtTime(volume, volDelay, instrument.volAttack);\n outputGain.setValueAtTime(volume, volHold);\n outputGain.linearRampToValueAtTime(\n volume * (1 - instrument.volSustain),\n volDecay\n );\n\n // modulation envelope\n /** @type {number} */\n const baseFreq = instrument.initialFilterFc;\n /** @type {number} */\n const peekFreq = instrument.initialFilterFc + instrument.modEnvToFilterFc;\n /** @type {number} */\n const sustainFreq =\n baseFreq + (peekFreq - baseFreq) * (1 - instrument.modSustain);\n\n /** @type {BiquadFilterNode} */\n const modulator = this.modulator;\n modulator.Q.setValueAtTime(10 ** (instrument.initialFilterQ / 200), now);\n modulator.frequency.value = baseFreq;\n modulator.type = 'lowpass';\n modulator.frequency.setTargetAtTime(\n baseFreq / 127,\n this.ctx.currentTime,\n 0.5\n );\n modulator.frequency.setValueAtTime(baseFreq, now);\n modulator.frequency.setValueAtTime(baseFreq, modDelay);\n modulator.frequency.setTargetAtTime(\n peekFreq,\n modDelay,\n instrument.modAttack\n );\n modulator.frequency.setValueAtTime(peekFreq, modHold);\n modulator.frequency.exponentialRampToValueAtTime(sustainFreq, modDecay);\n\n // Vibrato\n /* * @type {GainNode} LFO Depth * /\n const lfoDepth = this.ctx.createGain();\n /* * @type {OscillatorNode} LFO Oscillator * /\n const lfo = this.ctx.createOscillator();\n // Set parameters for LFO\n lfo.type = 'sine';\n lfoDepth.gain.value = 1;\n lfo.frequency.value = this.instrument['freqVibLFO'];\n\n if (this.modulation) {\n // Effector (Vibrato) ON\n lfo.start(0);\n } else {\n // Effector (Vibrato) Off\n lfo.stop(0);\n }\n // OscillatorNode (LFO) -> GainNode (Depth) -> frequency (AudioParam)\n lfo.connect(lfoDepth);\n\n // connect\n bufferSource.connect(lfoDepth);\n lfoDepth.connect(modulator);\n modulator.connect(panner);\n panner.connect(this.expressionGainNode);\n */\n bufferSource.connect(modulator);\n modulator.connect(panner);\n panner.connect(this.expressionGainNode);\n\n if (!instrument.mute) {\n this.connect();\n }\n\n this.expressionGainNode.connect(output);\n\n // fire\n bufferSource.start(0, startTime);\n }\n\n /**\n * @param {number} val\n * @return {number}\n */\n amountToFreq(val) {\n return 2 ** ((val - 6900) / 1200) * 440;\n }\n\n /** Note off */\n noteOff() {\n this.noteOffState = true;\n }\n\n /** @return {boolean} */\n isNoteOff() {\n return this.noteOffState;\n }\n\n /** @return {void} */\n release() {\n const instrument = this.instrument;\n /** @type {AudioBufferSourceNode} */\n const bufferSource = this.bufferSource;\n /** @type {GainNode} */\n const output = this.outputGainNode;\n /** @type {number} */\n const now = this.ctx.currentTime;\n /** @type {number} */\n const release = instrument.releaseTime - 64;\n\n // ---------------------------------------------------------------------------\n // volume release time\n // ---------------------------------------------------------------------------\n /** @type {number} */\n const volEndTimeTmp = instrument.volRelease * output.gain.value;\n /** @type {number} */\n const volEndTime =\n now + volEndTimeTmp * (1 + release / (release < 0 ? 64 : 63));\n // now + instrument['volRelease'] * (1 - instrument['volSustain']);\n\n // ---------------------------------------------------------------------------\n // modulation release time\n // ---------------------------------------------------------------------------\n /** @type {BiquadFilterNode} */\n const modulator = this.modulator;\n /** @type {number} */\n const baseFreq = instrument.initialFilterFc;\n /** @type {number} */\n const peekFreq = instrument.initialFilterFc + instrument.modEnvToFilterFc;\n /** @type {number} */\n const modEndTime =\n now +\n instrument.modRelease *\n (baseFreq === peekFreq\n ? 1\n : (modulator.frequency.value - baseFreq) / (peekFreq - baseFreq));\n\n // const modEndTime =\n // now + instrument['modRelease'] * (1 - instrument['modSustain']);\n\n if (!this.audioBuffer) {\n return;\n }\n\n // ---------------------------------------------------------------------------\n // Release\n // ---------------------------------------------------------------------------\n\n switch (instrument.sampleModes) {\n case 0:\n // ループしない\n bufferSource.loop = false;\n break;\n case 1:\n // ループさせる\n output.gain.cancelScheduledValues(0);\n output.gain.setValueAtTime(output.gain.value, now);\n output.gain.linearRampToValueAtTime(0, volEndTime);\n\n modulator.frequency.cancelScheduledValues(0);\n modulator.frequency.setValueAtTime(modulator.frequency.value, now);\n modulator.frequency.exponentialRampToValueAtTime(baseFreq, modEndTime);\n\n bufferSource.playbackRate.cancelScheduledValues(0);\n bufferSource.playbackRate.setValueAtTime(\n bufferSource.playbackRate.value,\n now\n );\n bufferSource.playbackRate.exponentialRampToValueAtTime(\n this.computedPlaybackRate,\n modEndTime\n );\n\n bufferSource.stop(volEndTime);\n break;\n case 2:\n // 未定義\n throw Error('[SynthesizerNote] Detect unused sampleModes');\n case 3:\n // ノートオフまでループさせる\n output.gain.cancelScheduledValues(0);\n output.gain.setValueAtTime(output.gain.value, now);\n output.gain.linearRampToValueAtTime(0, volEndTime);\n\n modulator.frequency.cancelScheduledValues(0);\n modulator.frequency.setValueAtTime(modulator.frequency.value, now);\n modulator.frequency.exponentialRampToValueAtTime(baseFreq, modEndTime);\n\n bufferSource.playbackRate.cancelScheduledValues(0);\n bufferSource.playbackRate.setValueAtTime(\n bufferSource.playbackRate.value,\n now\n );\n bufferSource.playbackRate.exponentialRampToValueAtTime(\n this.computedPlaybackRate,\n modEndTime\n );\n bufferSource.loop = false;\n bufferSource.buffer = null;\n break;\n default:\n throw Error(\n `[SynthesizerNote] ${instrument.sampleModes} is undefined sampleModes.`\n );\n }\n }\n\n /** Connect AudioContext */\n connect() {\n this.reverb.connect(this.outputGainNode).connect(this.destination);\n }\n\n /** Disconnect AudioContext */\n disconnect() {\n this.outputGainNode.disconnect(0);\n }\n\n /** Caluclate playback rate */\n schedulePlaybackRate() {\n /** @type {AudioParam} */\n const playbackRate = this.bufferSource.playbackRate;\n /** @type {number} */\n const computed = this.computedPlaybackRate;\n /** @type {number} */\n const start = this.startTime;\n /** @type {Object} */\n const instrument = this.instrument;\n /** @type {number} */\n const modAttack = start + instrument.modAttack;\n /** @type {number} */\n const modDecay = modAttack + instrument.modDecay;\n /** @type {number} */\n const peekPitch =\n computed *\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n (this.modEnvToPitch * this.instrument.scaleTuning);\n\n playbackRate.cancelScheduledValues(0);\n playbackRate.setValueAtTime(computed, start);\n playbackRate.linearRampToValueAtTime(peekPitch, modAttack);\n playbackRate.linearRampToValueAtTime(\n computed + (peekPitch - computed) * (1 - instrument.modSustain),\n modDecay\n );\n }\n\n /** @param {number} expression */\n updateExpression(expression) {\n this.expressionGainNode.gain.value = (this.expression = expression) / 127;\n }\n\n /** @param {number} pitchBend */\n updatePitchBend(pitchBend) {\n this.computedPlaybackRate =\n this.playbackRate *\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n ((pitchBend / (pitchBend < 0 ? 8192 : 8191)) *\n this.pitchBendSensitivity *\n this.instrument.scaleTuning);\n this.schedulePlaybackRate();\n }\n}\n","import Reverb from '@logue/reverb';\n\nimport Parser from './sf2.js';\nimport SynthesizerNote from './sound_font_synth_note.js';\n\n/**\n * Synthesizer Class\n *\n * @author imaya\n */\nexport default class Synthesizer {\n /** @param {Uint8Array} input */\n constructor(input) {\n /** @type {number} */\n let i;\n /** @type {Uint8Array} */\n this.input = input;\n /** @type {Parser} */\n this.parser = undefined;\n /** @type {number} */\n this.bank = 0;\n /** @type {Object} */\n this.bankSet = {};\n /** @type {number} */\n this.bufferSize = 2048;\n /** @type {AudioContext} */\n this.ctx = this.getAudioContext();\n /** @type {GainNode} */\n this.gainMaster = this.ctx.createGain();\n /** @type {AudioBufferSourceNode} */\n this.bufSrc = this.ctx.createBufferSource();\n /** @type {number[]} */\n this.channelInstrument = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelBank = [0, 0, 0, 0, 0, 0, 0, 0, 0, 127, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelVolume = [\n 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100, 100,\n 100,\n ];\n /** @type {number[]} */\n this.channelPanpot = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelPitchBend = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.channelPitchBendSensitivity = [\n 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,\n ];\n /** @type {number[]} */\n this.channelExpression = [\n 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127, 127,\n 127,\n ];\n /** @type {number[]} */\n this.channelAttack = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelDecay = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelSustin = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelRelease = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n\n /** @type {boolean[]} */\n this.channelHold = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n /** @type {number[]} */\n this.channelHarmonicContent = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n /** @type {number[]} */\n this.channelCutOffFrequency = [\n 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64, 64,\n ];\n\n /** @type {'GM'|'GM2'|'XG'|'GS'} */\n this.mode = 'GM2';\n\n /** @type {string[][]} */\n this.programSet = [];\n\n /** @type {boolean[]} */\n this.channelMute = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n /** @type {SynthesizerNote[][]} */\n this.currentNoteOn = [\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n [],\n ];\n /** @type {number} @const */\n this.baseVolume = 1 / 0xffff;\n /** @type {number} */\n this.masterVolume = 16384;\n\n /** @type {boolean[]} */\n this.percussionPart = [\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n false,\n true,\n false,\n false,\n false,\n false,\n false,\n false,\n ];\n\n /** @type {number[]} */\n this.percussionVolume = [];\n while (i === 127) {\n this.percussionVolume[i] = 127;\n i++;\n }\n\n /** @type {string[][]} */\n this.programSet = [];\n\n /** @type {Reverb[]} リバーブエフェクト(チャンネル毎に用意する) */\n this.reverb = [];\n\n /** @type {number[]} モジュレーション(ビブラート) */\n this.modulation = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n\n /** @type {BiquadFilterNode[]} フィルタ */\n this.filter = [];\n\n for (i = 0; i < 16; ++i) {\n // @ts-ignore\n this.reverb[i] = new Reverb(this.ctx, { noise: 'violet' });\n // フィルタを定義\n this.filter[i] = this.ctx.createBiquadFilter();\n }\n\n /** 表示項目 */\n this.items = [];\n\n /** @type {IntersectionObserver} 交差していない */\n this.intersection = new IntersectionObserver(\n entries =>\n entries.forEach(entry => {\n // @ts-ignore\n entry.target.dataset.isIntersecting = entry.isIntersecting;\n }),\n {}\n );\n\n /** @type {NodeJS.Timeout} タイマーのスレッド */\n this.timer = undefined;\n /** @type {boolean} */\n this.drag = false;\n }\n\n /** @return {AudioContext} */\n getAudioContext() {\n /** @type {AudioContext} */\n const ctx = new AudioContext();\n\n // Defreeze AudioContext for iOS.\n const initAudioContext = () => {\n document.removeEventListener('touchstart', initAudioContext);\n /** @type {AudioBufferSourceNode} wake up AudioContext */\n const emptySource = ctx.createBufferSource();\n emptySource.start();\n emptySource.stop();\n };\n\n document.addEventListener('touchstart', initAudioContext);\n\n return ctx;\n }\n\n /**\n * System Reset\n *\n * @param {'GM'|'GM2'|'XG'|'GS'} mode 音源モード\n */\n init(mode = 'GM') {\n this.gainMaster.disconnect();\n\n this.refreshInstruments(this.input);\n\n this.mode = mode;\n\n for (let i = 0; i < 16; ++i) {\n this.setPercussionPart(i, i === 9);\n this.programChange(i, 0);\n this.volumeChange(i, 100);\n this.panpotChange(i, 64);\n this.pitchBend(i, 0x00, 0x40); // 8192\n this.pitchBendSensitivity(i, 2);\n this.hold(i, 0);\n this.expression(i, 127);\n this.bankSelectMsb(i, i === 9 ? 127 : 0);\n this.bankSelectLsb(i, i === 9 ? 127 : 0);\n this.attackTime(i, 64);\n this.decayTime(i, 64);\n this.sustinTime(i, 64);\n this.releaseTime(i, 64);\n this.harmonicContent(i, 64);\n this.cutOffFrequency(i, 64);\n this.reverbDepth(i, 40);\n this.modulationDepth(i, 0);\n\n this.updateBankSelect(i);\n this.updateProgramSelect(i);\n }\n\n this.setPercussionPart(9, true);\n\n for (let i = 0; i < 128; ++i) {\n this.percussionVolume[i] = 127;\n }\n\n this.setMasterVolume(8192);\n\n this.gainMaster.connect(this.ctx.destination);\n\n if (this.element) {\n /** @type {HTMLDivElement} */\n const modeElement = this.element.querySelector('.header .keys div');\n modeElement.innerText = mode + ' Mode';\n /** @type {NodeListOf} */\n const bankSelectElement = this.element.querySelectorAll(\n '.instrument .bank > select'\n );\n\n bankSelectElement.forEach(element => (element.disabled = mode === 'GM'));\n this.element.dataset.mode = mode;\n }\n }\n\n /** Close AudioContext */\n async close() {\n await this.ctx.close();\n }\n\n /** @param {Uint8Array} input */\n refreshInstruments(input) {\n this.input = input;\n this.parser = new Parser(input, {\n sampleRate: this.ctx.sampleRate,\n });\n this.bankSet = this.createAllInstruments();\n }\n\n /** @returns {Object[][]} */\n createAllInstruments() {\n /** @type {Parser} */\n const parser = this.parser;\n parser.parse();\n /** @type {Array} TODO */\n const presets = parser.createPreset();\n /** @type {Array} TODO */\n const instruments = parser.createInstrument();\n /** @type {Array} */\n const banks = [];\n /** @type {Record} */\n let bank;\n /** @type {number} */\n let bankNumber;\n /** @type {Object} */\n let instrument;\n /** @type {number} */\n let presetNumber;\n /** @type {string} */\n let presetName;\n\n const programSet = [];\n\n presets.forEach(preset => {\n presetNumber = preset.header.preset;\n bankNumber = preset.header.bank;\n presetName = preset.name.replace(/\\0*$/, '');\n\n if (typeof preset.instrument !== 'number') {\n return;\n }\n\n instrument = instruments[preset.instrument];\n if (instrument.name.replace(/\\0*$/, '') === 'EOI') {\n return;\n }\n\n // select bank\n banks[bankNumber] = banks[bankNumber] ?? [];\n bank = banks[bankNumber];\n bank[presetNumber] = {};\n bank[presetNumber].name = presetName;\n\n instrument.info.forEach(info =>\n this.createNoteInfo(parser, info, bank[presetNumber])\n );\n\n if (!programSet[bankNumber]) {\n programSet[bankNumber] = [];\n }\n programSet[bankNumber][presetNumber] = presetName;\n });\n\n this.programSet = programSet;\n\n return banks;\n }\n\n /**\n * @param {Parser} parser\n * @param {any} info\n * @param {any} preset\n */\n createNoteInfo(parser, info, preset) {\n /** @type {*} */\n const generator = info.generator;\n\n if (!generator.keyRange || !generator.sampleID) {\n return;\n }\n\n // デフォルト値\n // https://www.utsbox.com/?p=2390\n\n /** @type {number} 33: DelayVolEnv */\n const volDelay = this.getModGenAmount(generator, 'delayVolEnv');\n /** @type {number} 34: AttackVolEnv */\n const volAttack = this.getModGenAmount(generator, 'attackVolEnv');\n /** @type {number} 35: HoldVolEnv */\n const volHold = this.getModGenAmount(generator, 'holdVolEnv');\n /** @type {number} 36: DecayVolEnv */\n const volDecay = this.getModGenAmount(generator, 'decayVolEnv');\n /** @type {number} 37: SustainVolEnv */\n const volSustain = this.getModGenAmount(generator, 'sustainVolEnv');\n /** @type {number} 38: ReleaseVolEnv */\n const volRelease = this.getModGenAmount(generator, 'releaseVolEnv');\n /** @type {number} 25: DelayModEnv */\n const modDelay = this.getModGenAmount(generator, 'delayModEnv');\n /** @type {number} 26: AttackModEnv */\n const modAttack = this.getModGenAmount(generator, 'attackModEnv');\n /** @type {number} 27: HoldModEnv */\n const modHold = this.getModGenAmount(generator, 'holdModEnv');\n /** @type {number} 28: DecayModEnv */\n const modDecay = this.getModGenAmount(generator, 'decayModEnv');\n /** @type {number} 29: SustainModEnv */\n const modSustain = this.getModGenAmount(generator, 'sustainModEnv');\n /** @type {number} 30: ReleaseModEnv */\n const modRelease = this.getModGenAmount(generator, 'releaseModEnv');\n /** @type {number} 56: ScaleTuning */\n const scale = this.getModGenAmount(generator, 'scaleTuning') / 100;\n /** @type {number} */\n const tune =\n this.getModGenAmount(generator, 'coarseTune') +\n this.getModGenAmount(generator, 'fineTune') / 100;\n /** @type {number} */\n const sampleModes = this.getModGenAmount(generator, 'sampleModes');\n\n for (\n let i = generator.keyRange.lo, il = generator.keyRange.hi;\n i <= il;\n ++i\n ) {\n if (preset[i]) {\n continue;\n }\n /** @type {number} */\n const sampleId = this.getModGenAmount(generator, 'sampleID');\n /** @type {object} */\n const sampleHeader = parser.sampleHeader[sampleId];\n\n preset[i] = {\n sample: parser.sample[sampleId],\n sampleRate: sampleHeader.sampleRate,\n // 54\n sampleModes,\n basePlaybackRate:\n 1.0594630943592953 ** // Math.pow(2, 1 / 12)\n ((i -\n this.getModGenAmount(generator, 'overridingRootKey') +\n tune +\n sampleHeader.pitchCorrection / 100) *\n scale),\n modEnvToPitch: this.getModGenAmount(generator, 'modEnvToPitch') / 100,\n scaleTuning: scale,\n start:\n this.getModGenAmount(generator, 'startAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'startAddrsOffset'),\n end:\n this.getModGenAmount(generator, 'endAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'endAddrsOffset'),\n loopStart:\n // (sampleHeader.startLoop - sampleHeader.start) +\n sampleHeader.startLoop +\n this.getModGenAmount(generator, 'startloopAddrsCoarseOffset') *\n 32768 +\n this.getModGenAmount(generator, 'startloopAddrsOffset'),\n loopEnd:\n // (sampleHeader.endLoop - sampleHeader.start) +\n sampleHeader.endLoop +\n this.getModGenAmount(generator, 'endloopAddrsCoarseOffset') * 32768 +\n this.getModGenAmount(generator, 'endloopAddrsOffset'),\n volDelay: 2 ** (volDelay / 1200),\n volAttack: 2 ** (volAttack / 1200),\n volHold:\n 2 ** (volHold / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToVolEnvHold')) /\n 1200),\n volDecay:\n 2 ** (volDecay / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToVolEnvDecay')) /\n 1200),\n volSustain: volSustain / 1000,\n volRelease: 2 ** (volRelease / 1200),\n modDelay: 2 ** (modDelay / 1200),\n modAttack: 2 ** (modAttack / 1200),\n modHold:\n 2 ** (modHold / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToModEnvHold')) /\n 1200),\n modDecay:\n 2 ** (modDecay / 1200) *\n 2 **\n (((60 - i) *\n this.getModGenAmount(generator, 'keynumToModEnvDecay')) /\n 1200),\n modSustain: modSustain / 1000,\n modRelease: 2 ** (modRelease / 1200),\n initialFilterFc:\n 8.176 *\n Math.pow(\n 2,\n this.getModGenAmount(generator, 'initialFilterFc') / 1200\n ),\n modEnvToFilterFc:\n this.getModGenAmount(generator, 'modEnvToFilterFc') / 100,\n initialFilterQ: this.getModGenAmount(generator, 'initialFilterQ') / 10,\n reverbEffectSend:\n this.getModGenAmount(generator, 'reverbEffectSend') / 10,\n initialAttenuation:\n this.getModGenAmount(generator, 'initialAttenuation') / 10,\n freqVibLFO:\n 8.176 *\n Math.pow(2, this.getModGenAmount(generator, 'freqVibLFO') / 1200),\n pan: this.getModGenAmount(generator, 'pan') / 1200,\n };\n }\n }\n\n /**\n * @param {Object} generator\n * @param {string} enumeratorType\n * @return {number}\n */\n getModGenAmount(generator, enumeratorType) {\n return generator[enumeratorType]\n ? generator[enumeratorType].amount\n : Parser.getGeneratorTable()[enumeratorType];\n }\n\n /**\n * Start Tone Generator\n */\n start() {\n this.connect();\n this.bufSrc.start(0);\n this.setMasterVolume(16383);\n }\n\n /** @param {number} volume */\n setMasterVolume(volume) {\n this.masterVolume = volume;\n this.gainMaster.gain.value = this.baseVolume * (volume / 16384);\n }\n\n /** Connect root AudioContext */\n connect() {\n this.bufSrc.connect(this.gainMaster);\n }\n\n /** Disconnect root AudioContext */\n disconnect() {\n this.bufSrc.disconnect(this.gainMaster);\n this.bufSrc.buffer = null;\n }\n\n /** @return {HTMLDivElement} */\n drawSynth() {\n /** @type {Document} */\n const doc = window.document;\n /** @type {HTMLDivElement} */\n const wrapper = (this.element = doc.createElement('div'));\n wrapper.className = 'synthesizer';\n /** @type {HTMLDivElement} */\n const instElem = doc.createElement('div');\n instElem.className = 'instrument';\n /** @type {string[]} */\n this.items = [\n 'mute',\n 'bank',\n 'program',\n 'volume',\n 'expression',\n 'panpot',\n 'pitchBend',\n 'pitchBendSensitivity',\n 'reverbDepth',\n 'keys',\n ];\n /** @type {string} */\n const eventStart = 'ontouchstart' in window ? 'touchstart' : 'mousedown';\n /** @type {string} */\n const eventEnd = 'ontouchend' in window ? 'touchend' : 'mouseup';\n\n for (let channel = 0; channel < 16; channel++) {\n /** @type {HTMLDivElement} */\n const channelElem = doc.createElement('div');\n channelElem.className = 'channel';\n // ホールドを無効化する処理\n channelElem.addEventListener(eventStart, () => {\n this.hold(channel, 0);\n });\n for (const item in this.items) {\n if (!Object.hasOwn(this.items, item)) {\n continue;\n }\n /** @type {HTMLDivElement} */\n const itemElem = doc.createElement('div');\n itemElem.className = this.items[item];\n\n switch (this.items[item]) {\n case 'mute': {\n /** @type {HTMLDivElement | null} */\n const checkboxElement = doc.createElement('div');\n checkboxElement.className = 'form-check form-check-inline';\n /** @type {HTMLInputElement | null} */\n const checkbox = doc.createElement('input');\n checkbox.ariaLabel = `Ch.${channel + 1} Mute`;\n checkbox.setAttribute('type', 'checkbox');\n checkbox.className = 'form-check-input';\n checkbox.id = 'mute' + channel + 'ch';\n checkbox.value = channel.toString();\n checkbox.addEventListener(\n 'change',\n event => {\n // @ts-ignore\n this.mute(channel, event.target.checked);\n },\n false\n );\n checkboxElement.appendChild(checkbox);\n /** @type {HTMLLabelElement} */\n const labelElem = doc.createElement('label');\n\n labelElem.className = 'form-check-label';\n labelElem.textContent = (channel + 1).toString();\n labelElem.setAttribute('for', 'mute' + channel + 'ch');\n checkboxElement.appendChild(labelElem);\n itemElem.appendChild(checkboxElement);\n break;\n }\n case 'bank': {\n /** @type {HTMLSelectElement} Bank select */\n const bankSelect = doc.createElement('select');\n bankSelect.ariaLabel = `Ch.${channel + 1} Bank Select`;\n bankSelect.className = 'form-select form-select-sm bank-select';\n bankSelect.addEventListener(\n 'change',\n ((synth, ch) => event => {\n /** @type {HTMLSelectElement} */\n const program = channelElem.querySelector('.program select');\n // console.log(ch, event.target.value, program);\n // @ts-ignore\n synth.bankChange(ch, event.target.value);\n synth.programChange(ch, parseInt(program.value));\n })(this, channel),\n false\n );\n itemElem.appendChild(bankSelect);\n break;\n }\n case 'program': {\n /** @type {HTMLSelectElement} Program change */\n const select = doc.createElement('select');\n select.className = 'form-select form-select-sm';\n select.ariaLabel = `Ch.${channel + 1} Program Change`;\n select.addEventListener(\n 'change',\n ((synth, ch) => event => {\n // @ts-ignore\n synth.programChange(ch, event.target.value);\n })(this, channel),\n false\n );\n itemElem.appendChild(select);\n break;\n }\n case 'volume': {\n /** @type {HTMLElement} */\n const volumeElem = document.createElement('var');\n volumeElem.ariaLabel = `Ch.${channel + 1} Volume`;\n volumeElem.innerText = '100';\n itemElem.appendChild(volumeElem);\n break;\n }\n case 'expression': {\n /** @type {HTMLElement} */\n const expressionElem = document.createElement('var');\n expressionElem.ariaLabel = `Ch.${channel + 1} Expression`;\n expressionElem.innerText = '127';\n itemElem.appendChild(expressionElem);\n break;\n }\n case 'pitchBendSensitivity': {\n /** @type {HTMLElement} */\n const pitchSensElem = document.createElement('var');\n pitchSensElem.ariaLabel = `Ch.${\n channel + 1\n } Pitch Bend Sensitivity`;\n pitchSensElem.innerText = '2';\n itemElem.appendChild(pitchSensElem);\n break;\n }\n case 'reverbDepth': {\n /** @type {HTMLElement} */\n const reverbDepthElem = document.createElement('var');\n reverbDepthElem.ariaLabel = `Ch.${channel + 1} Reverb Depth`;\n reverbDepthElem.innerText = '40';\n itemElem.appendChild(reverbDepthElem);\n break;\n }\n case 'panpot': {\n /** @type {HTMLDivElement} */\n const panpotOuter = doc.createElement('div');\n panpotOuter.role = 'progressbar';\n panpotOuter.ariaLabel = `Ch.${channel + 1} Panpod`;\n panpotOuter.ariaValueMin = '0';\n panpotOuter.ariaValueNow = '64';\n panpotOuter.ariaValueMax = '127';\n panpotOuter.className = 'progress';\n const panpot = doc.createElement('div');\n // 緑色\n panpot.className = 'progress-bar';\n panpotOuter.appendChild(panpot);\n itemElem.appendChild(panpotOuter);\n break;\n }\n case 'pitchBend': {\n /** @type {HTMLDivElement} */\n const pitchOuter = doc.createElement('div');\n pitchOuter.className = 'progress';\n pitchOuter.role = 'progressbar';\n pitchOuter.ariaLabel = `Ch.${channel + 1} Pitch Bend`;\n pitchOuter.ariaValueMin = '-8192';\n pitchOuter.ariaValueNow = '0';\n pitchOuter.ariaValueMax = '8192';\n pitchOuter.className = 'progress';\n /** @type {HTMLDivElement} */\n const pitch = doc.createElement('div');\n // 黄色\n pitch.className = 'progress-bar progress-bar-animated';\n pitchOuter.appendChild(pitch);\n itemElem.appendChild(pitchOuter);\n break;\n }\n case 'keys': {\n // 鍵盤の描画\n for (let key = 0; key < 127; key++) {\n /** @type {HTMLDivElement} */\n const keyElem = doc.createElement('div');\n /** @type {number} */\n const n = key % 12;\n // 白鍵と黒鍵の色分け\n keyElem.className =\n 'key ' + ([1, 3, 6, 8, 10].includes(n) ? 'semitone' : 'tone');\n itemElem.appendChild(keyElem);\n\n // イベント割当\n keyElem.addEventListener(\n eventStart,\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.drag = true;\n synth.noteOn(ch, k, 127);\n })(this, channel, key)\n );\n keyElem.addEventListener(\n 'mouseover',\n ((synth, ch, k) => event => {\n event.preventDefault();\n if (synth.drag) {\n synth.noteOn(ch, k, 127);\n }\n })(this, channel, key)\n );\n keyElem.addEventListener(\n 'mouseout',\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.noteOff(ch, k);\n })(this, channel, key)\n );\n keyElem.addEventListener(\n eventEnd,\n ((synth, ch, k) => event => {\n event.preventDefault();\n synth.drag = false;\n synth.noteOff(ch, k);\n })(this, channel, key)\n );\n }\n break;\n }\n }\n channelElem.appendChild(itemElem);\n }\n instElem.appendChild(channelElem);\n this.intersection.observe(channelElem);\n }\n // ヘッダー行の描画\n const itemName = [\n 'Ch.',\n 'Bank',\n 'Program',\n 'Vol.',\n 'Exp.',\n 'Panpot',\n 'Pitch Bend',\n '',\n 'Rev.',\n '',\n ];\n /** @type {HTMLDivElement} */\n const headerElem = doc.createElement('div');\n headerElem.className = 'header';\n for (const item in this.items) {\n if (!Object.hasOwn(this.items, item)) {\n continue;\n }\n /** @type {HTMLDivElement} */\n const itemElem = doc.createElement('div');\n itemElem.className = this.items[item];\n itemElem.textContent = itemName[item];\n if (this.items[item] === 'keys') {\n // MIDI音源のLCDのテキスト領域エミュレーター\n itemElem.appendChild(document.createElement('code'));\n // GM / GS / XG表記\n itemElem.appendChild(document.createElement('div'));\n }\n headerElem.appendChild(itemElem);\n }\n instElem.prepend(headerElem);\n wrapper.appendChild(instElem);\n\n // ヘッダー行のリサイズ\n const ro = new ResizeObserver(_entries => {\n this.items.forEach(item => {\n /** @type {HTMLElement} */\n const headerItem = wrapper.querySelector(`.header .${item}`);\n /** @type {HTMLElement} */\n const channelItem = wrapper.querySelector(`.channel .${item}`);\n\n headerItem.style.width = channelItem.offsetWidth + 'px';\n });\n /** @type {HTMLElement} */\n const keysItem = wrapper.querySelector('.header .keys');\n\n keysItem.style.display =\n document.documentElement.clientWidth <= 680 ? 'none' : 'flex';\n });\n ro.observe(wrapper);\n\n return wrapper;\n }\n\n /**\n * シンセサイザーのDOMの更新\n *\n * @param {number} channel\n * @param {number} key\n * @param {number} velocity\n */\n updateSynthElement(channel, key, velocity) {\n if (!this.element) {\n return;\n }\n /** @type {NodeListOf} */\n const channelElems = this.element.querySelectorAll(\n '.instrument > .channel'\n );\n\n if (channelElems[channel].dataset.isIntersecting) {\n /** @type {HTMLDivElement} */\n const keyElem = channelElems[channel].querySelector(\n `.key:nth-child(${key + 1})`\n );\n if (velocity === 0) {\n if (keyElem.classList.contains('note-on')) {\n keyElem.classList.remove('note-on');\n }\n keyElem.style.opacity = '1';\n } else {\n keyElem.classList.add('note-on');\n // ベロシティに応じて透過度を調整\n keyElem.style.opacity = (velocity / 127).toFixed(2);\n }\n }\n }\n\n /**\n * バンクセレクタの選択ボックスの処理\n *\n * @param {number} channel\n */\n updateBankSelect(channel) {\n if (!this.element) {\n return;\n }\n /** @type {HTMLElement} */\n const bankElement = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.bank > select');\n\n while (bankElement.firstChild) {\n bankElement.removeChild(bankElement.firstChild);\n }\n\n for (const bankNo in this.programSet) {\n if (!Object.hasOwn(this.programSet, bankNo)) {\n continue;\n }\n const option = document.createElement('option');\n option.value = bankNo;\n option.textContent = ('000' + parseInt(bankNo)).slice(-3);\n if (parseInt(bankNo) === this.channelBank[channel]) {\n option.selected = true;\n }\n bankElement.appendChild(option);\n }\n }\n\n /**\n * プログラムチェンジの選択ボックスの処理\n *\n * @param {number} channel\n */\n updateProgramSelect(channel) {\n if (!this.element) {\n return;\n }\n const dom = this.element.querySelectorAll('.instrument > .channel')[\n channel\n ];\n\n /** @type {number} */\n const bankIndex = this.channelBank[channel];\n /** @type {HTMLSelectElement} */\n const bankElement = dom.querySelector('.bank > select');\n /** @type {HTMLSelectElement} */\n const programElement = dom.querySelector('.program > select');\n\n bankElement.value = this.channelBank[channel].toString();\n while (programElement.firstChild) {\n programElement.removeChild(programElement.firstChild);\n }\n\n for (const programNo in this.programSet[bankIndex]) {\n if (!Object.hasOwn(this.programSet[bankIndex], programNo)) {\n continue;\n }\n // TODO: 存在しないプログラムの場合、現状では空白になってしまう\n /** @type {HTMLOptionElement} */\n const option = document.createElement('option');\n option.value = programNo;\n option.textContent = `${('000' + (parseInt(programNo) + 1)).slice(-3)}:${\n this.programSet[bankIndex][programNo]\n }`;\n if (parseInt(programNo) === this.channelInstrument[channel]) {\n option.selected = true;\n }\n programElement.appendChild(option);\n }\n }\n\n /**\n * ノートオン\n *\n * @param {number} channel NoteOn するチャンネル.\n * @param {number} key NoteOn するキー.\n * @param {number} velocity 強さ.\n */\n noteOn(channel, key, velocity = 100) {\n /** @type {number} */\n const bankIndex = this.channelBank[channel];\n // バンクに楽器が存在しない場合は、原則的にバンク0の楽器を選択する。\n // ただし、SFX(Bank 64)は発音しない、\n // パーカッション(Bank127~128) の場合、0のStandard Kitの音を鳴らさなければならない)\n /** @type {Object} */\n const bank =\n typeof this.bankSet[bankIndex] === 'object'\n ? this.bankSet[bankIndex]\n : this.bankSet[0];\n\n /** @type {Object} */\n let instrument;\n\n if (typeof bank[this.channelInstrument[channel]] === 'object') {\n // 音色が存在する場合\n instrument = bank[this.channelInstrument[channel]];\n } else if (this.percussionPart[channel]) {\n // パーカッションバンクが選択されている場合で音色が存在しない場合Standard Kitを選択\n instrument = this.bankSet[this.mode === 'XG' ? 127 : 128][0];\n } else {\n // 通常の音色が選択されている状態で音色が存在しない場合バンク0を選択\n instrument = this.bankSet[0][this.channelInstrument[channel]];\n }\n\n if (!instrument[key]) {\n // TODO\n console.warn(\n 'instrument not found: bank=%s instrument=%s channel=%s key=%s',\n bankIndex,\n this.channelInstrument[channel],\n channel,\n key\n );\n return;\n }\n /** @type {Object} */\n const instrumentKey = instrument[key];\n /** @type {number} */\n let panpot =\n this.channelPanpot[channel] === 0\n ? Math.floor(Math.random() * 127) // パンが0の場合ランダムとなる。\n : this.channelPanpot[channel] - 64;\n panpot /= panpot < 0 ? 64 : 63;\n\n // create note information\n instrumentKey.channel = channel;\n instrumentKey.key = key;\n instrumentKey.velocity = velocity;\n instrumentKey.panpot = panpot;\n instrumentKey.volume = this.channelVolume[channel] / 127;\n instrumentKey.pitchBend = this.channelPitchBend[channel] - 8192;\n instrumentKey.expression = this.channelExpression[channel];\n instrumentKey.pitchBendSensitivity = Math.round(\n this.channelPitchBendSensitivity[channel]\n );\n instrumentKey.mute = this.channelMute[channel];\n instrumentKey.releaseTime = this.channelRelease[channel];\n instrumentKey.cutOffFrequency = this.cutOffFrequency[channel];\n instrumentKey.harmonicContent = this.harmonicContent[channel];\n instrumentKey.reverb = this.reverb[channel];\n instrumentKey.modulation = this.modulation[channel];\n\n // percussion\n if (bankIndex >= 127) {\n // ドラムパートのハイハットクローズはここで定義するべきではない。\n if (key === 42 || key === 44) {\n // 42: Closed Hi-Hat\n // 44: Pedal Hi-Hat\n // 46: Open Hi-Hat\n this.noteOff(channel, 46);\n }\n if (key === 80) {\n // 80: Mute Triangle\n // 81: Open Triangle\n this.noteOff(channel, 81);\n }\n instrument.volume *= this.percussionVolume[key] / 127;\n }\n\n // note on\n /** @type {SynthesizerNote} */\n const note = new SynthesizerNote(this.ctx, this.gainMaster, instrumentKey);\n // TODO: 本来パンポットはここで指定する\n note.noteOn();\n this.currentNoteOn[channel].push(note);\n\n this.updateSynthElement(channel, key, velocity);\n }\n\n /**\n * ノートオフ\n *\n * @param {number} channel NoteOff するチャンネル.\n * @param {number} key NoteOff するキー.\n */\n noteOff(channel, key) {\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {SynthesizerNote} */\n let note;\n /** @type {boolean} */\n const hold = this.channelHold[channel];\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n note = currentNoteOn[i];\n if (note.key === key) {\n note.noteOff();\n // hold している時は NoteOff にはするがリリースはしない\n if (!hold) {\n note.release();\n currentNoteOn.splice(i, 1);\n --i;\n --il;\n }\n }\n }\n this.updateSynthElement(channel, key, 0);\n }\n\n /**\n * ホールド(ダンパーペダル)\n *\n * @param {number} channel ホールドするチャンネル\n * @param {number} value 値\n */\n hold(channel, value) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {boolean} 0以外はonである。 */\n const hold = (this.channelHold[channel] = value > 64);\n /** @type {SynthesizerNote} */\n let note;\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n if (!hold) {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n note = currentNoteOn[i];\n if (note.isNoteOff()) {\n note.release();\n currentNoteOn.splice(i, 1);\n --i;\n --il;\n }\n }\n }\n\n if (this.element) {\n /** @type {NodeListOf} */\n const channelElements = this.element.querySelectorAll(\n '.instrument > .channel'\n );\n\n if (!channelElements[channel]) {\n return;\n }\n if (this.channelHold[channel]) {\n channelElements[channel].classList.add('hold');\n } else if (channelElements[channel].classList.contains('hold')) {\n channelElements[channel].classList.remove('hold');\n }\n }\n }\n\n /**\n * バンクセレクトMSB(GS音源/GM Level2用)\n *\n * @param {number} channel チャンネルのバンクセレクトMSB\n * @param {number} value 値\n */\n bankSelectMsb(channel, value) {\n // 125より値が大きい場合、パーカッションとして処理\n this.percussionPart[channel] = value >= 125;\n // 念の為バンクを0にリセット\n this.channelBank[channel] = channel === 9 ? 128 : 0;\n\n if (this.mode === 'GM') {\n // GM音源モードのときはバンク・セレクトを無視\n return;\n } else if (this.mode === 'XG') {\n // XG音源は、MSB→LSBの優先順でバンクセレクトをする。\n if (value === 64) {\n // Bank Select MSB #64 (Voice Type: SFX)\n this.channelBank[channel] = 125;\n } else if (value === 126 || value === 127) {\n // Bank Select MSB #126 (Voice Type: Drum)\n // Bank Select MSB #127 (Voice Type: Drum)\n this.channelBank[channel] = value;\n } else if (value === 128) {\n this.channelBank[channel] = 127;\n }\n } else {\n // GS音源\n // ※チャンネル10のバンク・セレクト命令は無視する。\n this.channelBank[channel] = channel === 9 ? 128 : value;\n this.percussionPart[channel] = value === 128;\n }\n this.updateBankSelect(channel);\n }\n\n /**\n * バンクセレクトLSB(XG音源)\n *\n * @param {number} channel チャンネルのバンクセレクトLSB\n * @param {number} value 値\n */\n bankSelectLsb(channel, value) {\n // XG音源以外は処理しない\n if (this.mode !== 'XG') {\n return;\n }\n\n if (!this.percussionPart[channel]) {\n // ドラムパートではバンクセレクトLSB命令を無視する。\n this.channelBank[channel] = value;\n }\n\n this.updateBankSelect(channel);\n }\n\n /**\n * プログラムチェンジ\n *\n * @param {number} channel 音色を変更するチャンネル.\n * @param {number} instrument 音色番号.\n */\n programChange(channel, instrument) {\n this.channelInstrument[channel] = instrument;\n\n this.bankChange(channel, this.channelBank[channel]);\n if (this.element) {\n /** @type {HTMLSelectElement} */\n const select = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.program > select');\n\n select.value = instrument.toString();\n }\n }\n\n /**\n * バンクセレクト\n *\n * @param {number} channel 音色を変更するチャンネル.\n * @param {number} bank バンク・セレクト.\n */\n bankChange(channel, bank) {\n /** パーカッションバンク */\n const percussionBank = this.mode === 'XG' || this.mode === 'GM' ? 127 : 128;\n if (this.mode === 'GM') {\n // GMの場合バンクセレクトを無効化\n bank = 0;\n }\n if (channel === 9) {\n // GS、XGフラグが立っていない(拡張音源ではない)場合は、ch10はドラム固定、それ以外は0とする。\n bank = percussionBank;\n }\n if (this.bankSet[bank]) {\n this.channelBank[channel] = bank;\n } else {\n // 存在しない場合0を選択\n this.channelBank[channel] = this.percussionPart[channel]\n ? percussionBank\n : 0;\n }\n // }\n\n if (this.element) {\n /** @type {HTMLSelectElement} バンクセレクトの値 */\n const bankSelect = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.bank > select');\n bankSelect.value = bank.toString();\n }\n // TODO: 厳密にはMIDI音源はプログラムチェンジがあったときに、バンク・セレクトの値が反映されるのでこの実装は正しくない。\n this.updateProgramSelect(channel);\n }\n\n /**\n * ボリューム\n *\n * @param {number} channel 音量を変更するチャンネル.\n * @param {number} volume 音量(0-127).\n */\n volumeChange(channel, volume) {\n if (this.element) {\n /** @type {HTMLElement} */\n const volumeVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.volume var');\n volumeVariable.innerText = volume.toString();\n }\n\n this.channelVolume[channel] = volume;\n }\n\n /**\n * エクスプレッション\n *\n * @param {number} channel 音量を変更するチャンネル.\n * @param {number} expression 音量(0-127).\n */\n expression(channel, expression) {\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].updateExpression(expression);\n }\n\n if (this.element) {\n /** @type {HTMLElement} */\n const expressionVariabe = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.expression var');\n\n expressionVariabe.innerText = expression.toString();\n }\n\n this.channelExpression[channel] = expression;\n }\n\n /**\n * パンポット\n *\n * @param {number} channel Panpot を変更するチャンネル.\n * @param {number} panpot Panpot(0-127).\n */\n panpotChange(channel, panpot) {\n this.channelPanpot[channel] = panpot;\n if (this.element) {\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.panpot');\n dom.ariaValueNow = panpot.toString();\n /** @type {HTMLDivElement} */\n const progressBar = dom.querySelector('.progress-bar');\n const percentage = (panpot / 127) * 100;\n progressBar.style.width = `${percentage}%`;\n progressBar.classList.remove('left', 'right');\n progressBar.title = panpot.toString();\n if (panpot === 64) {\n return;\n }\n dom.classList.add(panpot < 63 ? 'left' : 'right');\n }\n }\n\n /**\n * ピッチベンド\n *\n * @param {number} channel ピッチベンドを変更するチャンネル.\n * @param {number} lowerByte\n * @param {number} higherByte\n */\n pitchBend(channel, lowerByte, higherByte) {\n /** @type {number} */\n const bend = (lowerByte & 0x7f) | ((higherByte & 0x7f) << 7);\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n /** @type {import('./sound_font_synth_note.js').default[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {number} */\n const calculated = bend - 8192;\n\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].updatePitchBend(calculated);\n }\n\n this.channelPitchBend[channel] = bend;\n\n if (this.element) {\n /** @type {HTMLDivElement} */\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBend');\n dom.ariaValueNow = bend.toString();\n /** @type {HTMLDivElement} */\n const progressBar = dom.querySelector('.progress-bar');\n progressBar.style.width = `${Math.floor((bend / 16384) * 100)}%`;\n progressBar.title = calculated.toString();\n progressBar.classList.remove('high', 'low');\n if (calculated === 0) {\n return;\n }\n progressBar.classList.add(calculated < 0 ? 'low' : 'high');\n }\n }\n\n /**\n * ピッチベンド・センシビリティ\n *\n * @param {number} channel Pitch bend sensitivity を変更するチャンネル.\n * @param {number} sensitivity\n */\n pitchBendSensitivity(channel, sensitivity) {\n if (this.element) {\n /** @type {HTMLElement} */\n const pitchBendSensitivityVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBendSensitivity > var');\n pitchBendSensitivityVariable.innerText = sensitivity.toString();\n }\n this.channelPitchBendSensitivity[channel] = sensitivity;\n }\n\n /**\n * アタックタイム\n *\n * @param {number} channel\n * @param {number} attackTime\n */\n attackTime(channel, attackTime) {\n this.channelAttack[channel] = attackTime;\n }\n\n /**\n * ディケイタイム\n *\n * @param {number} channel\n * @param {number} decayTime\n */\n decayTime(channel, decayTime) {\n this.channelDecay[channel] = decayTime;\n }\n\n /**\n * サスティンタイム\n *\n * @param {number} channel\n * @param {number} sustinTime\n */\n sustinTime(channel, sustinTime) {\n this.channelSustin[channel] = sustinTime;\n }\n\n /**\n * リリースタイム\n *\n * @param {number} channel\n * @param {number} releaseTime\n */\n releaseTime(channel, releaseTime) {\n this.channelRelease[channel] = releaseTime;\n }\n\n /**\n * ハーモニックコンテント(ブライトネス)\n *\n * @param {number} channel\n * @param {number} value\n */\n harmonicContent(channel, value) {\n this.channelHarmonicContent[channel] = value;\n }\n\n /**\n * カットオフフリクエンシー\n *\n * @param {number} channel\n * @param {number} value\n */\n cutOffFrequency(channel, value) {\n this.channelCutOffFrequency[channel] = value;\n }\n\n /**\n * リバーブエフェクト\n *\n * @param {number} channel\n * @param {number} depth\n */\n reverbDepth(channel, depth) {\n // リバーブ深度は、ドライ/ウェット比とする。\n this.reverb[channel].mix(depth / 127);\n\n if (this.element) {\n /** @type {HTMLElement} */\n const reverbVariable = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.reverbDepth var');\n reverbVariable.innerText = depth.toString();\n }\n }\n\n /**\n * モジュレーション(ビブラート)デプス\n *\n * @param {number} channel\n * @param {number} depth\n */\n modulationDepth(channel, depth) {\n if (this.element) {\n const dom = this.element\n .querySelectorAll('.instrument > .channel')\n [channel].querySelector('.pitchBend .progress-bar');\n\n // モデレーターが0でないときは、ピッチに斜め線を入れる\n if (depth !== 0) {\n dom.classList.add('progress-bar-striped');\n } else {\n dom.classList.remove('progress-bar-striped');\n }\n }\n this.modulation[channel] = depth;\n }\n\n /**\n * @param {number} channel Pitch bend sensitivity を取得するチャンネル.\n * @return {number}\n */\n getPitchBendSensitivity(channel) {\n return this.channelPitchBendSensitivity[channel];\n }\n\n /**\n * @param {number} key\n * @param {number} volume\n */\n drumInstrumentLevel(key, volume) {\n this.percussionVolume[key] = volume;\n }\n\n /**\n * オールノートオフ\n *\n * @param {number} channel NoteOff するチャンネル.\n */\n allNoteOff(channel) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n\n // ホールドを解除\n this.hold(channel, 0);\n\n // 再生中の音をすべて止める\n while (currentNoteOn.length > 0) {\n this.noteOff(channel, currentNoteOn[0].key);\n }\n }\n\n /**\n * オールサウンドオフ\n *\n * @param {number} channel 音を消すチャンネル.\n */\n allSoundOff(channel) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {SynthesizerNote} */\n let note;\n\n while (currentNoteOn.length > 0) {\n note = currentNoteOn.shift();\n this.noteOff(channel, note.key);\n note.release();\n note.disconnect();\n }\n\n // ホールドを解除\n this.hold(channel, 0);\n }\n\n /**\n * リセットオールコントロール\n *\n * @param {number} channel リセットするチャンネル\n */\n resetAllControl(channel) {\n // 実装不十分では?\n this.allNoteOff(channel);\n this.expression(channel, 127);\n this.pitchBend(channel, 0x00, 0x40);\n }\n\n /**\n * ミュート\n *\n * @param {number} channel ミュートの設定を変更するチャンネル.\n * @param {boolean} mute ミュートにするなら true.\n */\n mute(channel, mute) {\n /** @type {SynthesizerNote[]} */\n const currentNoteOn = this.currentNoteOn[channel];\n /** @type {number} */\n let i;\n /** @type {number} */\n let il;\n\n this.channelMute[channel] = mute;\n\n if (mute) {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].disconnect();\n }\n } else {\n for (i = 0, il = currentNoteOn.length; i < il; ++i) {\n currentNoteOn[i].connect();\n }\n }\n }\n\n /**\n * パーカッションチャネルにする\n *\n * @param {number} channel パーカッションチャネルとしてセットするチャンネル\n * @param {boolean} sw パーカッションチャネルか通常かのスイッチ\n */\n setPercussionPart(channel, sw) {\n this.channelBank[channel] =\n this.mode === 'GS' || this.mode === 'GM2' ? 128 : 127;\n\n this.percussionPart[channel] = sw;\n this.updateBankSelect(channel);\n }\n\n /**\n * MIDI音源のメッセージ欄に送られるsysExを解析\n *\n * @param {number[]} message\n */\n processMidiMessage(message) {\n clearTimeout(this.timer);\n /** @type {HTMLElement} */\n const dom = this.element.querySelector('.header .keys code');\n dom.innerText = message.map(e => String.fromCharCode(e)).join('');\n\n // 10秒後に削除\n this.timer = setTimeout(() => {\n dom.innerText = '';\n }, 50000);\n }\n}\n","import Loader from './loader.js';\nimport Synthesizer from './sound_font_synth.js';\n\n/**\n * WebMidiLink Class\n *\n * @author imaya\n */\nexport default class WebMidiLink {\n /** @param {object} option */\n constructor(option = {}) {\n /** @type {number[]} */\n this.NrpnMsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.NrpnLsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.RpnMsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {number[]} */\n this.RpnLsb = [0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0];\n /** @type {boolean} */\n this.ready = false;\n /** @type {Synthesizer} */\n this.synth = undefined;\n /** @type {Function} */\n this.messageHandler = this.onMessage.bind(this);\n /** @type {boolean} */\n this.rpnMode = true;\n /** @type {object} */\n this.option = {};\n /** @type {boolean} Display synthsizer Web UI */\n this.option.drawSynth = option.drawSynth !== 'false';\n /** @type {boolean} Use Cache API */\n this.option.cache = option.cache ?? true;\n /** @type {string} CORS */\n this.option.targetOrigin = option.targetOrigin ?? '*';\n /** @type {'dark'|'light'|'auto'|undefined} Color mode */\n this.option.colorMode = option.colorMode ?? 'auto';\n /** @type {string} SoundFont URL */\n this.url =\n option.url ??\n 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2';\n\n /** @type {HTMLDivElement} */\n // @ts-ignore\n this.placeholder = option.placeholder\n ? document.getElementById(option.placeholder)\n : window.document.body;\n this.setColorMode(this.option.colorMode);\n /** @type {Window} */\n this.window = null;\n\n if (window.opener) {\n this.window = window.opener;\n } else if (window.parent !== window) {\n this.window = window.parent;\n } else {\n this.window = window;\n }\n }\n\n /**\n * Setup Soundfont by URL.\n *\n * @param {string?} url SoundFont URL\n * @public\n */\n async setup(url = undefined) {\n // DOMをクリア\n while (this.placeholder.firstChild) {\n this.placeholder.removeChild(this.placeholder.firstChild);\n }\n if (url) {\n // URLが明示的に指定されていた場合\n this.url = url;\n }\n\n /** 読み込み */\n const loader = new Loader(\n this.url,\n this.placeholder,\n this.option.cache,\n (/** @type {ArrayBuffer} */ buffer) => this.setupByBuffer(buffer)\n );\n await loader.fetch();\n }\n\n /**\n * Get SoundFont URL.\n *\n * @return {string}\n */\n getUrl() {\n return this.url;\n }\n\n /**\n * Setup SoundFont by ArrayBuffer.\n *\n * @param {ArrayBuffer} buffer\n */\n setupByBuffer(buffer) {\n // DOMをクリア\n while (this.placeholder.firstChild) {\n this.placeholder.removeChild(this.placeholder.firstChild);\n }\n\n if (!this.synth) {\n // 読み込まれていないときシンセサイザをセットアップ\n // @ts-ignore\n this.synth = new Synthesizer(buffer);\n // 待受開始\n this.synth.start();\n } else {\n // 別のSoundFontが読み込まれたときリロード\n // @ts-ignore\n this.synth.refreshInstruments(buffer);\n }\n if (this.option.drawSynth) {\n // キーボードなどを描画\n this.placeholder.appendChild(this.synth.drawSynth());\n } else {\n /** @type {HTMLDivElement} キーボードを描画しないときはReadyだけを表示する。 */\n const readyElem = document.createElement('div');\n readyElem.className = 'alert alert-success';\n readyElem.role = 'alert';\n readyElem.innerText = 'Ready.';\n this.placeholder.appendChild(readyElem);\n }\n // シンセサイザを初期化\n this.synth.init();\n\n this.onReady();\n }\n\n /**\n * Callback\n *\n * @protected\n */\n callback() {}\n\n /**\n * SoundFont Load Ready\n *\n * @protected\n */\n onReady() {\n // 一旦MIDI Link待受を解除\n // @ts-ignore\n window.removeEventListener('message', this.messageHandler);\n // コールバック実行\n this.callback();\n // MIDI Link待ち受け開始\n // @ts-ignore\n window.addEventListener('message', this.messageHandler, false);\n // ホスト側に準備完了通知を送信\n this.window.postMessage('link,ready', this.option.targetOrigin);\n }\n\n /**\n * WebMidiLink信号をパース\n *\n * @param {Event} ev\n * @private\n */\n onMessage(ev) {\n /** @type {Array} */\n // @ts-ignore\n const msg = typeof ev.data.split === 'function' ? ev.data.split(',') : [];\n /** @type {string} */\n // @ts-ignore\n const type = msg.length !== 0 ? msg.shift() : '';\n /** @type {string} */\n let command;\n\n switch (type) {\n case 'midi':\n this.processMidiMessage(msg.map(hex => parseInt(hex, 16)));\n break;\n case 'link':\n if (!this.window) {\n return;\n }\n command = msg.shift();\n switch (command) {\n case 'reqpatch':\n // TODO: dummy data\n this.window.postMessage('link,patch', this.option.targetOrigin);\n break;\n case 'setpatch':\n case 'ready':\n this.window.postMessage('link,ready', this.option.targetOrigin);\n // TODO: NOP\n break;\n case 'progress':\n // ※この命令は、WebMidiLinkの仕様に含まれていません。\n this.window.postMessage('link,progress', this.option.targetOrigin);\n break;\n default:\n console.error('unknown link message:', command);\n break;\n }\n break;\n default:\n console.error('unknown message type');\n }\n }\n\n /**\n * MIDI準備完了時のコールバック処理を登録する\n *\n * @param {()=>{}} callback コールバック関数\n * @public\n */\n setLoadCallback(callback) {\n this.callback = callback;\n }\n\n /**\n * MIDI信号を解析し、シンセサイザーを操作する\n *\n * @param {number[]} message\n * @protected\n */\n processMidiMessage(message) {\n /** @type {number} */\n const channel = message[0] & 0x0f;\n /** @type {Synthesizer} */\n const synth = this.synth;\n\n // http://amei.or.jp/midistandardcommittee/MIDI1.0.pdf\n switch (message[0] & 0xf0) {\n case 0x80: // NoteOff: 8n kk vv\n // @ts-ignore\n synth.noteOff(channel, message[1], message[2]);\n break;\n case 0x90: // NoteOn: 9n kk vv\n if (message[2] > 0) {\n synth.noteOn(channel, message[1], message[2]);\n } else {\n // @ts-ignore\n synth.noteOff(channel, message[1], 0);\n }\n break;\n case 0xb0: {\n // Control Change: Bn cc dd\n /** @type {number} */\n const value = message[2];\n switch (message[1]) {\n case 0x00: // Bank Select MSB: Bn 00 dd\n synth.bankSelectMsb(channel, value);\n break;\n case 0x01: // Modulation Depth\n synth.modulationDepth(channel, value);\n break;\n case 0x05: // Portament Time\n break;\n case 0x06: // Data Entry(MSB): Bn 06 dd\n if (this.rpnMode) {\n // RPN\n switch (this.RpnMsb[channel]) {\n case 0:\n switch (this.RpnLsb[channel]) {\n case 0: // Pitch Bend Sensitivity\n synth.pitchBendSensitivity(channel, value);\n break;\n case 1:\n // console.log(\"fine\");\n break;\n case 2:\n // console.log(\"coarse\");\n break;\n default:\n // console.log(\"default\");\n break;\n }\n break;\n default:\n // console.log(\"default:\", this.RpnMsb[channel], this.RpnLsb[channel]);\n break;\n }\n } else {\n // NRPN\n switch (this.NrpnMsb[channel]) {\n case 26: // Drum Instrument Level\n synth.drumInstrumentLevel(this.NrpnLsb[channel], value);\n break;\n default:\n // console.log(\"default:\", this.RpnMsb[channel], this.RpnLsb[channel]);\n break;\n }\n }\n break;\n case 0x26: // Data Entry(LSB): Bn 26 dd\n if (this.rpnMode) {\n // RPN\n switch (this.RpnMsb[channel]) {\n case 0:\n switch (this.RpnLsb[channel]) {\n case 0: // Pitch Bend Sensitivity\n synth.pitchBendSensitivity(\n channel,\n synth.getPitchBendSensitivity(channel) + value / 100\n );\n break;\n case 1:\n // console.log(\"fine\");\n break;\n case 2:\n // console.log(\"coarse\");\n break;\n }\n break;\n }\n }\n\n // NRPN で LSB が必要なものは今のところない\n break;\n\n case 0x07: // Volume Change: Bn 07 dd\n synth.volumeChange(channel, value);\n break;\n case 0x0a: // Panpot Change: Bn 0A dd\n synth.panpotChange(channel, value);\n break;\n case 0x78: // All Sound Off: Bn 78 00]\n synth.allSoundOff(channel);\n break;\n case 0x79: // Reset All Control: Bn 79 00\n synth.resetAllControl(channel);\n break;\n case 0x20: // BankSelect LSB: Bn 00 dd\n synth.bankSelectLsb(channel, value);\n break;\n case 0x47: // Harmonic Content\n synth.harmonicContent(channel, value);\n break;\n case 0x60: //\n // console.log(60);\n break;\n case 0x61: //\n // console.log(61);\n break;\n case 0x62: // NRPN LSB\n this.rpnMode = false;\n this.NrpnLsb[channel] = value;\n break;\n case 0x63: // NRPN MSB\n this.rpnMode = false;\n this.NrpnMsb[channel] = value;\n break;\n case 0x64: // RPN LSB\n this.rpnMode = true;\n this.RpnLsb[channel] = value;\n break;\n case 0x65: // RPN MSB\n this.rpnMode = true;\n this.RpnMsb[channel] = value;\n break;\n case 0x40: // Hold\n synth.hold(channel, value);\n break;\n case 0x0b: // Expression\n synth.expression(channel, value);\n break;\n case 0x48: // DecayTyme\n synth.decayTime(channel, value);\n break;\n case 0x49: // ReleaseTime\n synth.releaseTime(channel, value);\n break;\n case 0x4a: // Attack time\n synth.attackTime(channel, value);\n break;\n case 0x4b: // Brightness\n synth.cutOffFrequency(channel, value);\n break;\n case 0x5b: // Effect1 Depth(Reverb Send Level)\n synth.reverbDepth(channel, value);\n break;\n default:\n // not supported\n break;\n }\n break;\n }\n case 0xc0: // Program Change: Cn pp\n synth.programChange(channel, message[1]);\n break;\n case 0xe0: // Pitch Bend\n synth.pitchBend(channel, message[1], message[2]);\n break;\n case 0xf0: {\n // delete checksum\n message.splice(1, 1);\n\n // System Exclusive Message\n // [1] F0\n // [2] https://www.amei.or.jp/report/report6.html\n // [3] \n // [4] \n // [5] \n // [6] \n // [7] \n // [8] \n // [9] \n // [10] \n // [11] [IGNORE]\n // [12] F7 EOX [IGNORE]\n // console.log(this.dumpMessage(message));\n\n /**\n * @type {number} System Exclusive Manufacture's ID Number\n * @see {@link https://electronicmusic.fandom.com/wiki/List_of_MIDI_Manufacturer_IDs}\n */\n const manufacturerId = message[1];\n /** @type {number} Device ID (GM extended=0x10 / ポケミク=0x79 / Any=0x7F) */\n const device = message[2];\n /** @type {number} Model ID: (GM=0x09 / GS=0x42 / XG=0x4C) */\n const model = message[3];\n\n if (manufacturerId === 0x7e || device === 0x09) {\n // Gneral MIDI\n // http://amei.or.jp/midistandardcommittee/Recommended_Practice/GM2_japanese.pdf\n // console.log('GM:', this.dumpMessage(message));\n // Non Realtime\n switch (model) {\n case 0x01:\n // GM System On\n synth.init('GM');\n console.info('\\x1b[34mGM System On\\x1b[0m');\n break;\n case 0x02:\n // GM System Off\n console.info('\\x1b[34mGM System Off\\x1b[0m');\n // Throuh\n break;\n case 0x03:\n // GM2 System On\n console.info('\\x1b[34mGM (v2) System On\\x1b[0m');\n synth.init('GM2');\n break;\n default:\n // @ts-ignore\n console.log('\\x1b[34mGM\\x1b[0m: ' + this.dumpMessage(message));\n }\n } else if (manufacturerId === 0x7f) {\n // Realtime\n if (model === 0x01) {\n // master volume: F0 7F 7F 04 01 [value] [value] F7\n synth.setMasterVolume(message[4] + (message[5] << 7));\n } else {\n // @ts-ignore\n console.log(\n '\\x1b[34mRealtime\\x1b[0m: ' + this.dumpMessage(message)\n );\n }\n } else if (manufacturerId === 0x7d) {\n // smfplayer / sf2synth固有命令は、プライベート/非営利用途用のManufacturer IDである0x7Dを使用する。\n // プログラム上意味はないが、GM互換であるため、deviceID:0x10、ModelID:0x00とする。\n // よって、F0 7D 10 00 [...] 7Fで定義\n\n if (message[4] === 0x01) {\n // カラーモード切替\n // F0 7D 10 00 01 [value]\n if (message[5] === 0x01) {\n // 明示的にライトモード\n this.setColorMode('light');\n } else if (message[5] === 0x02) {\n // 明示的にダークモード\n this.setColorMode('dark');\n } else {\n // OSの設定に合わせる\n this.setColorMode('auto');\n }\n }\n }\n\n if (model === 0x42) {\n // Roland GS\n // http://lib.roland.co.jp/support/jp/manuals/res/1809974/SC-88VL_j.pdf\n // deviceは10、modelIDは42固定。\n // F0 41 10 42 12 [addr] [part] [key] [value] [checksum] F7\n // (DeviceID = 10, ModelID = 42, CommandID = 12)\n\n // QuickTime音源や、WindowsMIDI音源は、GS互換音源なのでmanufacturerIdが41とは限らない\n\n /* * @param {number} GsAddress GSアドレス(未使用)\n const GsAddress = message[6];\n */\n /** @type {number} GSパート番号 */\n const GsPart = message[6] - 0x0f;\n /** @type {number} GSのキーパラメータ */\n const GsKey = message[7];\n /** @type {number} GSの値 */\n const GsValue = message[8];\n // TODO\n switch (GsKey) {\n case 0x00:\n // TEXT INSERT FOR SC (ASCI code)\n // http://kurizill.g1.xrea.com/memorandum/midi2.htm\n // F0 41 10 45 12 10 [page] 00 [...value] [checksum] F7\n // ex. F0 41 10 45 12 10 00 00 [48 65 6C 6C 6F] 21 F7 = Hello\n\n // device IDの値は0x45固定だがその判定処理は省略\n\n if (GsPart === 0x00) {\n // ページが0x00の場合、LCDに表示するメッセージとする\n // @ts-ignore\n const msg = message.splice(8);\n // Remove F7\n msg.pop();\n // Remove Checksum\n msg.pop();\n synth.processMidiMessage(msg);\n } else {\n // GS音源のLCDの16x16のビットマップ画像\n // @ts-ignore\n console.log(\n '\\x1b[31mGS Bitmap message\\x1b[0m:' +\n this.dumpMessage(message)\n );\n }\n break;\n case 0x04:\n // GS Master Volume:\n // F0 41 10 42 12 40 00 04 [value] [checksum] F7\n // console.log('GS Volume:', this.dumpMessage(message));\n synth.setMasterVolume(GsValue * 64);\n break;\n\n case 0x15: {\n // GS Dram part: F0 41 10 42 12 40 1[part no] [Map] [checksum] F7\n // Notice: [sum] is ignroe in this program.\n\n if (GsPart === 0) {\n // 10 Ch.\n synth.setPercussionPart(9, GsValue !== 0x00);\n } else if (GsPart >= 10) {\n // 1~9 Ch.\n synth.setPercussionPart(GsPart - 1, GsValue !== 0x00);\n } else {\n // 11~16 Ch.\n synth.setPercussionPart(GsPart, GsValue !== 0x00);\n }\n break;\n }\n case 0x19:\n // VOLUME ON/OFF (PART LEVEL)\n // F0 41 10 42 12 40 1[part no] 19 [value] [checksum] F7\n console.info(\n '\\x1b[31mGS Volume On/Off\\x1b[0m: ' + GsPart,\n GsValue\n );\n break;\n case 0x30:\n // Reverb Effect\n console.info(\n '\\x1b[31mGS Reverb\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x38:\n // Chorus Effect\n console.info(\n '\\x1b[31mGS Chorus\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x45:\n // Bitmap icon 16x16 ?\n console.info(\n '\\x1b[31mGS Bitmap\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x7f:\n // GS Reset: F0 41 10 42 12 40 00 7F 00 [checksum] F7\n synth.init('GS');\n console.info('\\x1b[31mGS Reset\\x1b[0m');\n break;\n default:\n // @ts-ignore\n console.log('\\x1b[31mGS\\x1b[0m: ' + this.dumpMessage(message));\n }\n } else if (model === 0x4c) {\n // YAMAHA XG\n // F0 43 10 4C [...] F7\n // https://jp.yamaha.com/files/download/other_assets/9/321739/read_aoyama.pdf\n // https://jp.yamaha.com/files/download/other_assets/1/316861/MU100J1.pdf\n\n // カシオとKORGはXG互換音源を作っていたためmanufacturerIdが43とは限らない\n\n /** @type {number} Xg音源のキー */\n const XgKey = message[4];\n /** @type {number} Xg音源のパート */\n const XgPart = message[5];\n\n switch (XgKey) {\n case 0x00:\n // XG Reset:\n // F0 43 1n 4C 00 00 7E 00 F7\n if (message[6] === 0x7e) {\n synth.init('XG');\n console.info('\\x1b[32mXG Reset\\x1b[0m');\n }\n break;\n case 0x02:\n // Effect\n // https://jp.yamaha.com/files/download/other_assets/5/321745/efctparamlist.pdf\n // F0 43 10 4C 02 01 [type] [value] F7\n //\n // type\n // 02: Reverb\n // リバーブエフェクトのインパルス応答を選択する\n // 40: Variation\n // F0 43 10 4C 02 01 40 [type] 00 F7\n // インサーションエフェクトとして使用するモードと全チャンネルにかけるシステムエフェクトモード場合がある。\n // アンプシミュレーターやディストーション、フェイザー、ディレイなど飛び道具的なエフェクトはここに入っていた。\n // 41: バリエーションエフェクトの種類\n // [value]にエフェクトの種類\n // 5B: バリエーションエフェクトをかけるパート\n // F0 43 10 4C 02 01 5B [part] F7\n // [value]が0でインサーションエフェクト、1でシステムエフェクトモードに切り替える。\n // インサーションエフェクトが実装される前(MU100よりも前の機種)は、ディレイ・エフェクトで使う場合が多かった。\n console.log(\n '\\x1b[32mXG Effect\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x03:\n // Insertion Effect\n // F0 43 10 4C 03 [type] [value] F7\n // MU100以降の機種で実装されている。最大2系統。1チャンネルのみ指定可能。\n console.log(\n '\\x1b[32mXG Insertion Effect\\x1b[0m: ' +\n this.dumpMessage(message)\n );\n break;\n case 0x04:\n // XG Master Volume:\n // F0 43 1n 4C 00 00 04 [value] F7\n synth.setMasterVolume(message[9] * 64);\n break;\n case 0x06: {\n // Text:\n // F0 43 1n 4C 06 00 00 [text] F7\n // ex. F0 43 1n 4C 06 00 00 48 65 6C 6C 6F 21 F7 = Hello\n // @ts-ignore\n const msg = message.splice(8);\n // Remove F7\n msg.pop();\n synth.processMidiMessage(msg);\n break;\n }\n case 0x07:\n // Bitmap Window\n // F0 43 10 4C 07 00 00 [bitmap] F7\n // 音源のアイコン描画領域に描画する16x16のビットマップ画像。\n // 7bitごとに左上から描画する。仕様がややこしいので処理しない\n console.log(\n '\\x1b[32mXG Bitmap\\x1b[0m: ' + this.dumpMessage(message)\n );\n break;\n case 0x08:\n // XG Dram Part:\n // F0 43 10 4C 08 [partNum] 07 [map] F7\n // 厳密には[map]は1以上の値が入り、3+1系統までしか使えない(MU2000の場合)が、本プログラムでは制限しない。\n synth.setPercussionPart(XgPart, message[8] !== 0x00);\n break;\n\n default:\n // @ts-ignore\n console.log('\\x1b[32mXG\\x1b[0m: ', this.dumpMessage(message));\n }\n }\n break;\n }\n default:\n // not supported\n synth.setPercussionPart(9, true);\n break;\n }\n }\n\n /**\n * Dump System Exclusive Message\n *\n * @private\n * @param {number[]} messages\n * @return {string}\n */\n dumpMessage(messages) {\n const ret = [];\n let i = 0;\n for (const msg of messages) {\n let str = '';\n switch (i) {\n case 0:\n // 青\n str = '\\x1b[35m';\n break;\n case 1:\n case 2:\n case 3:\n // 黄色\n str = '\\x1b[33m';\n break;\n default:\n // 末尾の場合は青、それ以外はシアン\n str = messages.length - 1 === i ? '\\x1b[35m' : '\\x1b[36m';\n break;\n }\n\n ret.push(str + msg.toString(16).toUpperCase().padStart(2, '0'));\n i++;\n }\n return ret.join(' ') + '\\x1b[0m';\n }\n\n /**\n * Change Color mode\n *\n * @param {'dark'|'light'|'auto'|undefined} mode Color Mode\n * @public\n */\n setColorMode(mode) {\n // Mode was given\n if (mode) {\n if (mode === 'auto') {\n mode = window.matchMedia('(prefers-color-scheme: dark)').matches\n ? 'dark'\n : 'light';\n }\n // Update data-* attr on html\n document.documentElement.setAttribute('data-bs-theme', mode);\n }\n // No mode given (e.g. reset)\n else {\n document.documentElement.setAttribute('data-bs-theme', 'auto');\n // Remove data-* attr from html\n document.documentElement.removeAttribute('data-bs-theme');\n }\n }\n}\n","import WebMidiLink from './wml';\n\n/**\n * Web MIDI API Reciever Class.\n *\n * @author Logue \n */\nexport default class WebMidiApi extends WebMidiLink {\n /**\n * @inheritdoc\n */\n constructor(option = {}) {\n super(option);\n /** @type {WebMidi.MIDIAccess | undefined} */\n this.midi = undefined;\n }\n\n /**\n * @inheritdoc\n * @param {string} url\n */\n async setup(url) {\n this.midi = await window.navigator.requestMIDIAccess({ sysex: true });\n await super.setup(url);\n }\n\n /**\n * @inheritdoc\n */\n onReady() {\n // コールバック実行\n super.callback();\n // Web MIDI APIを待ち受け\n this.midi.inputs.forEach(\n (\n /** @type {{ onmidimessage: (msg: WebMidi.MIDIMessageEvent) => void; }} */ input\n ) =>\n (input.onmidimessage = msg =>\n super.processMidiMessage(Array.from(msg.data)))\n );\n }\n}\n","import Meta from './meta.js';\nimport Parser from './sf2.js';\nimport WebMidiApi from './web_midi_api.js';\nimport WebMidiLink from './wml.js';\nimport './wml.scss';\n\nconst SoundFont = {\n version: Meta.version,\n build: Meta.date,\n WebMidiLink,\n WebMidiApi,\n Parser,\n};\n\nexport default SoundFont;\n","\n import qs from 'query-string';\n import SoundFont from '/src/index';\n\n /** sf2synth.js Option */\n let options = {\n ...{\n // URL to SoundFont File\n // url: 'https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/Yamaha XG Sound Set.sf2',\n // Show Keyboard\n drawSynth: true,\n // Target dom id\n placeholder: 'placeholder',\n // Color Mode (auto, dark, light)\n colorMode: 'auto',\n },\n ...qs.parse(window.location.search),\n ...qs.parse(window.location.hash),\n };\n\n /** @type {typeof import(\"./src/wml\").WebMidiLink } WebMidiLink */\n const wml = new SoundFont.WebMidiLink(options);\n\n document.addEventListener(\n 'DOMContentLoaded',\n event => {\n /** @type {HTMLInputElement} File Input Form */\n const fileInput = document.getElementById('file');\n /** @type {HTMLDivElement} drag area */\n const dragArea = document.getElementById('drag');\n /** @type {HTMLTimeElement} Build Date */\n const build = document.getElementById('build');\n /** @type {HTMLInputElement} */\n const toggleDarkMode = document.getElementById('toggleDarkMode');\n /** @type {HTMLSelectElement} */\n // const selector = document.getElementById('selector');\n\n wml.setLoadCallback(() => {\n dragArea.classList.remove('bg-info');\n document.getElementById('soundfont').innerText = decodeURIComponent(\n wml.getUrl()\n ).match('.+/(.+?)([?#;].*)?$')[1];\n });\n\n // Apply build time\n build.dateTime = SoundFont.build;\n build.innerText = new Date(SoundFont.build).toLocaleString();\n\n wml.setup();\n\n // Keep an eye out for System Light/Dark Mode Changes\n const mediaQuery = window.matchMedia('(prefers-color-scheme: dark)');\n mediaQuery.addListener(() => {\n // Ignore change if there's an override set\n if (document.documentElement.getAttribute('data-bs-theme')) {\n return;\n }\n\n // Apply color mode.\n wml.setColorMode(options.colorMode);\n\n // Make sure the checkbox is up-to-date\n toggleDarkMode.checked = mediaQuery.matches;\n });\n\n /**\n * Load sound font\n *\n * @param {File} file\n */\n const handleSoundFont = file => {\n const reader = new FileReader();\n reader.readAsArrayBuffer(file);\n\n reader.onload = e => {\n document.getElementById('soundfont').innerText = file.name;\n const data = new Uint8Array(e.target.result);\n wml.setupByBuffer(data);\n };\n };\n\n // When select SoundFont file\n fileInput.addEventListener(\n 'change',\n event => {\n event.preventDefault();\n handleSoundFont(fileInput.files[0]);\n fileInput.value = '';\n },\n false\n );\n\n // When SoundFont Drag and Drop.\n dragArea.addEventListener(\n 'drop',\n event => {\n const dt = event.dataTransfer;\n if (dt.files.length) {\n event.preventDefault();\n event.stopPropagation();\n handleSoundFont(dt.files[0]);\n }\n dragArea.classList.remove('bg-info');\n },\n false\n );\n dragArea.addEventListener(\n 'dragover',\n event => {\n event.preventDefault();\n event.stopPropagation();\n dragArea.classList.add('bg-info');\n },\n false\n );\n dragArea.addEventListener(\n 'dragleave',\n event => {\n event.preventDefault();\n event.stopPropagation();\n dragArea.classList.remove('bg-info');\n },\n false\n );\n\n // Toggle Dark mode\n toggleDarkMode.addEventListener('change', e => {\n wml.setColorMode(e.target.checked ? 'dark' : 'light');\n });\n\n /*\n selector.addEventListener('change', () => {\n console.log(selector.value);\n wml.setup(\n `https://cdn.jsdelivr.net/npm/@logue/sf2synth@latest/dist/${selector.value}`\n );\n });\n */\n },\n false\n );\n\n window.addEventListener(\n 'hashchange',\n () => {\n const url = qs.parse(window.location.hash);\n if (url) {\n wml.setup(url);\n }\n },\n false\n );\n "],"names":["token","singleMatcher","multiMatcher","decodeComponents","components","split","left","right","decode","input","tokens","i","customDecodeURIComponent","replaceMap","match","result","entries","key","decodeUriComponent","encodedURI","splitOnFirst","string","separator","separatorIndex","includeKeys","object","predicate","descriptor","value","isNullOrUndefined","strictUriEncode","x","encodeFragmentIdentifier","encoderForArrayFormat","options","index","encode","keyValueSeparator","parserForArrayFormat","accumulator","isArray","isEncodedArray","newValue","item","arrayValue","validateArrayFormatSeparator","decodeComponent","keysSorter","a","b","removeHash","hashStart","getHash","url","hash","parseValue","extract","queryStart","parse","query","formatter","returnValue","parameter","parameter_","key2","value2","stringify","shouldFilter","objectCopy","keys","parseUrl","url_","stringifyUrl","queryFromUrl","queryString","urlObjectForFragmentEncode","pick","filter","fragmentIdentifier","exclude","exclusionFilter","meta","Riff","optParams","length","ip","size","RiffChunk","chunk","type","offset","Parser","parser","data","signature","presetHeader","presetZone","instrument","instrumentZone","samples","sampleHeader","sampleName","start","end","startLoop","endLoop","sampleRate","originalPitch","pitchCorrection","sampleLink","sampleType","sample","adjust","newSample","il","j","multiply","code","output","zone","bagIndex","bagIndexEnd","zoneInfo","instrumentGenerator","instrumentModulator","jl","preset","presetGenerator","presetModulator","modgen","_zone","indexStart","indexEnd","zoneModGen","modgenInfo","info","Loader","placeholder","cache","callback","current","total","percentCompleted","buffer","error","cached","response","e","cloned","contentLength","reader","receivedLength","chunks","done","chunksAll","position","INV_MAX","ARandom","norm","p","min","max","range","random","SystemRandom","SYSTEM","DEFAULT_OPTS","preseed","n","scale","rnd","state","sum","src","sum2","interleave","next","blue","opts","bins","invN","acc","sign","green","ctz32","c","pink","id","red","violet","white","implementsFunction","fn","ensureTransducer","isIterable","identity","Reduced","val","reduced","isReduced","ensureReduced","unreduced","reducer","init","rfn","push","xs","iterator","xform","complete","reduce","y","compR","take","r","m","d","o","w","s","g","N","f","h","l","u","v","SynthesizerNote","ctx","destination","now","volDelay","modDelay","volAttack","modAttack","volHold","modHold","volDecay","modDecay","loopStart","loopEnd","startTime","pan","bufferSource","panner","volume","outputGain","baseFreq","peekFreq","sustainFreq","modulator","release","volEndTimeTmp","volEndTime","modEndTime","playbackRate","computed","peekPitch","expression","pitchBend","Synthesizer","Reverb","entry","initAudioContext","emptySource","mode","modeElement","element","presets","instruments","banks","bank","bankNumber","presetNumber","presetName","programSet","generator","volSustain","volRelease","modSustain","modRelease","tune","sampleModes","sampleId","enumeratorType","doc","wrapper","instElem","eventStart","eventEnd","channel","channelElem","itemElem","checkboxElement","checkbox","event","labelElem","bankSelect","synth","ch","program","select","volumeElem","expressionElem","pitchSensElem","reverbDepthElem","panpotOuter","panpot","pitchOuter","pitch","keyElem","k","itemName","headerElem","_entries","headerItem","channelItem","keysItem","velocity","channelElems","bankElement","bankNo","option","dom","bankIndex","programElement","programNo","instrumentKey","note","currentNoteOn","hold","channelElements","percussionBank","volumeVariable","expressionVariabe","progressBar","percentage","lowerByte","higherByte","bend","calculated","sensitivity","pitchBendSensitivityVariable","attackTime","decayTime","sustinTime","releaseTime","depth","reverbVariable","mute","sw","message","WebMidiLink","readyElem","ev","msg","command","hex","manufacturerId","device","model","GsPart","GsKey","GsValue","XgKey","XgPart","messages","ret","str","WebMidiApi","SoundFont","Meta","qs","wml","fileInput","dragArea","build","toggleDarkMode","mediaQuery","handleSoundFont","file","dt"],"mappings":"ssBAAA,MAAMA,GAAQ,eACRC,EAAgB,IAAI,OAAO,IAAMD,GAAQ,aAAc,IAAI,EAC3DE,EAAe,IAAI,OAAO,IAAMF,GAAQ,KAAM,IAAI,EAExD,SAASG,EAAiBC,EAAYC,EAAO,CAC5C,GAAI,CAEH,MAAO,CAAC,mBAAmBD,EAAW,KAAK,EAAE,CAAC,CAAC,CACjD,MAAS,CAEP,CAED,GAAIA,EAAW,SAAW,EACzB,OAAOA,EAGRC,EAAQA,GAAS,EAGjB,MAAMC,EAAOF,EAAW,MAAM,EAAGC,CAAK,EAChCE,EAAQH,EAAW,MAAMC,CAAK,EAEpC,OAAO,MAAM,UAAU,OAAO,KAAK,CAAA,EAAIF,EAAiBG,CAAI,EAAGH,EAAiBI,CAAK,CAAC,CACvF,CAEA,SAASC,GAAOC,EAAO,CACtB,GAAI,CACH,OAAO,mBAAmBA,CAAK,CACjC,MAAS,CACP,IAAIC,EAASD,EAAM,MAAMR,CAAa,GAAK,CAAA,EAE3C,QAASU,EAAI,EAAGA,EAAID,EAAO,OAAQC,IAClCF,EAAQN,EAAiBO,EAAQC,CAAC,EAAE,KAAK,EAAE,EAE3CD,EAASD,EAAM,MAAMR,C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,EAAE,OAAO,MAAM,EAC3CkO,EAAI,cAAcxR,CAAI,CACpC,CACA,EAGUyR,EAAU,iBACR,SACA/E,GAAS,CACPA,EAAM,eAAc,EACpBoF,EAAgBL,EAAU,MAAM,CAAC,CAAC,EAClCA,EAAU,MAAQ,EACnB,EACD,EACZ,EAGUC,EAAS,iBACP,OACAhF,GAAS,CACP,MAAMsF,EAAKtF,EAAM,aACbsF,EAAG,MAAM,SACXtF,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBoF,EAAgBE,EAAG,MAAM,CAAC,CAAC,GAE7BN,EAAS,UAAU,OAAO,SAAS,CACpC,EACD,EACZ,EACUA,EAAS,iBACP,WACAhF,GAAS,CACPA,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBgF,EAAS,UAAU,IAAI,SAAS,CACjC,EACD,EACZ,EACUA,EAAS,iBACP,YACAhF,GAAS,CACPA,EAAM,eAAc,EACpBA,EAAM,gBAAe,EACrBgF,EAAS,UAAU,OAAO,SAAS,CACpC,EACD,EACZ,EAGUE,EAAe,iBAAiB,SAAUtO,GAAK,CAC7CkO,EAAI,aAAalO,EAAE,OAAO,QAAU,OAAS,OAAO,CAChE,CAAW,CAUF,EACD,EACR,EAEM,OAAO,iBACL,aACA,IAAM,CACJ,MAAM9F,EAAM+T,EAAG,MAAM,OAAO,SAAS,IAAI,EACrC/T,GACFgU,EAAI,MAAMhU,CAAG,CAEhB,EACD,EACD","x_google_ignoreList":[0,1,2,3,8,9,10,11,12,13,14,15,16,17,18,19,20,21,22,23,24,25,26,27,28,29]} \ No newline at end of file diff --git a/index.html b/index.html index 01c5e63..3f1e447 100644 --- a/index.html +++ b/index.html @@ -22,7 +22,7 @@ gtag('js', new Date()); gtag('config', 'G-2Y2FW3QEG4'); - +