From ae56262dd0da97059e863d4ce97e6596904acb15 Mon Sep 17 00:00:00 2001 From: logue Date: Thu, 25 Apr 2024 09:40:45 +0000 Subject: [PATCH] =?UTF-8?q?Deploying=20to=20gh-pages=20from=20@=20logue/sf?= =?UTF-8?q?2synth.js@7c5bc318b7b873c0714c57627c49de5cdfbb1b27=20?= =?UTF-8?q?=F0=9F=9A=80?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/index-Cb8h-mHG.js | 11 +++++++++++ assets/index-Cb8h-mHG.js.map | 1 + assets/{index-2TgRIiWo.css => index-DZOBEiJa.css} | 0 assets/index-PADGV00H.js | 11 ----------- assets/index-PADGV00H.js.map | 1 - index.html | 4 ++-- 6 files changed, 14 insertions(+), 14 deletions(-) create mode 100644 assets/index-Cb8h-mHG.js create mode 100644 assets/index-Cb8h-mHG.js.map rename assets/{index-2TgRIiWo.css => index-DZOBEiJa.css} (100%) delete mode 100644 assets/index-PADGV00H.js delete mode 100644 assets/index-PADGV00H.js.map diff --git a/assets/index-Cb8h-mHG.js b/assets/index-Cb8h-mHG.js new file mode 100644 index 0000000..77a56c0 --- /dev/null +++ b/assets/index-Cb8h-mHG.js @@ -0,0 +1,11 @@ +(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))}}/** + * @logue/reverb + * + * @description JavaScript Reverb effect class + * @author Logue + * @copyright 2019-2024 By Masashi Yoshikawa All rights reserved. + * @license MIT + * @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 diff --git a/assets/index-Cb8h-mHG.js.map b/assets/index-Cb8h-mHG.js.map new file mode 100644 index 0000000..9e594a6 --- /dev/null +++ b/assets/index-Cb8h-mHG.js.map @@ -0,0 +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,EAAE,KAAK,EAAE,EAE3CD,EAASD,EAAM,MAAMR,CAAa,GAAK,CAAA,EA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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/assets/index-2TgRIiWo.css b/assets/index-DZOBEiJa.css similarity index 100% rename from assets/index-2TgRIiWo.css rename to assets/index-DZOBEiJa.css diff --git a/assets/index-PADGV00H.js b/assets/index-PADGV00H.js deleted file mode 100644 index adff2fe..0000000 --- a/assets/index-PADGV00H.js +++ /dev/null @@ -1,11 +0,0 @@ -(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).replace(/[!'()*]/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.replace(/\+/g," "):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=`?${i}`);let o=Me(r.url);if(r.fragmentIdentifier){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"}));class Ae{constructor(e,t,n){this.ctx=e,this.destination=t,this.instrument=n,this.channel=n.channel,this.key=n.key,this.velocity=n.velocity,this.buffer=n.sample,this.playbackRate=n.basePlaybackRate,this.loopStart=n.loopStart,this.loopEnd=n.loopEnd,this.sampleRate=n.sampleRate,this.volume=n.volume,this.panpot=n.panpot,this.pitchBend=n.pitchBend,this.pitchBendSensitivity=n.pitchBendSensitivity,this.modEnvToPitch=n.modEnvToPitch,this.expression=n.expression,this.modulation=n.modulation,this.cutOffFrequency=n.cutOffFrequency,this.hermonicContent=n.hermonicContent,this.reverb=n.reverb,this.startTime=e.currentTime,this.computedPlaybackRate=this.playbackRate|0,this.noteOffState=!1,this.audioBuffer=null,this.bufferSource=e.createBufferSource(),this.panner=e.createPanner(),this.outputGainNode=e.createGain(),this.expressionGainNode=e.createGain(),this.filter=e.createBiquadFilter(),this.modulator=e.createBiquadFilter()}noteOn(){const e=this.ctx,t=this.instrument,n=this.ctx.currentTime||0,s=n+t.volDelay,i=n+t.modDelay,o=s+t.volAttack,a=s+t.modAttack,c=o+t.volHold,l=a+t.modHold,d=c+t.volDecay,u=l+t.modDecay,m=t.loopStart/this.sampleRate,h=t.loopEnd/this.sampleRate,f=t.start/this.sampleRate,b=t.pan!==0?t.pan:this.panpot,p=this.buffer.subarray(0,this.buffer.length+t.end),y=this.audioBuffer=e.createBuffer(1,p.length,this.sampleRate);y.getChannelData(0).set(p);const k=this.bufferSource;k.buffer=y,k.loop=t.sampleModes||0,k.loopStart=m,k.loopEnd=h,this.updatePitchBend(this.pitchBend);const v=this.outputGainNode;this.expressionGainNode.gain.value=this.expression/127;const E=this.panner;E.panningModel="equalpower",E.distanceModel="inverse",E.positionX.setValueAtTime(Math.sin(b*Math.PI/2),0),E.positionY.setValueAtTime(0,0),E.positionZ.setValueAtTime(Math.cos(b*Math.PI/2),0);let C=this.volume*(this.velocity/127)*(1-t.initialAttenuation/1e3);C<0&&(C=0);const S=v.gain;S.setValueAtTime(0,n),S.setValueAtTime(0,s),S.setTargetAtTime(C,s,t.volAttack),S.setValueAtTime(C,c),S.linearRampToValueAtTime(C*(1-t.volSustain),d);const T=t.initialFilterFc,L=t.initialFilterFc+t.modEnvToFilterFc,ge=T+(L-T)*(1-t.modSustain),x=this.modulator;x.Q.setValueAtTime(10**(t.initialFilterQ/200),n),x.frequency.value=T,x.type="lowpass",x.frequency.setTargetAtTime(T/127,this.ctx.currentTime,.5),x.frequency.setValueAtTime(T,n),x.frequency.setValueAtTime(T,i),x.frequency.setTargetAtTime(L,i,parseFloat(t.modAttack)),x.frequency.setValueAtTime(L,l),x.frequency.exponentialRampToValueAtTime(ge,u),k.connect(x),x.connect(E),E.connect(this.expressionGainNode),t.mute||this.connect(),this.expressionGainNode.connect(v),k.start(0,f)}amountToFreq(e){return 2**((e-6900)/1200)*440}noteOff(){this.noteOffState=!0}isNoteOff(){return this.noteOffState}release(){const e=this.instrument,t=this.bufferSource,n=this.outputGainNode,s=this.ctx.currentTime,i=e.releaseTime-64,o=e.volRelease*n.gain.value,a=s+o*(1+i/(i<0?64:63)),c=this.modulator,l=e.initialFilterFc,d=e.initialFilterFc+e.modEnvToFilterFc,u=s+e.modRelease*(l===d?1:(c.frequency.value-l)/(d-l));if(this.audioBuffer)switch(e.sampleModes){case 0:t.loop=!1;break;case 1:n.gain.cancelScheduledValues(0),n.gain.setValueAtTime(n.gain.value,s),n.gain.linearRampToValueAtTime(0,a),c.frequency.cancelScheduledValues(0),c.frequency.setValueAtTime(c.frequency.value,s),c.frequency.exponentialRampToValueAtTime(l,u),t.playbackRate.cancelScheduledValues(0),t.playbackRate.setValueAtTime(t.playbackRate.value,s),t.playbackRate.exponentialRampToValueAtTime(this.computedPlaybackRate,u),t.stop(a);break;case 2:throw Error("[SynthesizerNote] Detect unused sampleModes");case 3:n.gain.cancelScheduledValues(0),n.gain.setValueAtTime(n.gain.value,s),n.gain.linearRampToValueAtTime(0,a),c.frequency.cancelScheduledValues(0),c.frequency.setValueAtTime(c.frequency.value,s),c.frequency.exponentialRampToValueAtTime(l,u),t.playbackRate.cancelScheduledValues(0),t.playbackRate.setValueAtTime(t.playbackRate.value,s),t.playbackRate.exponentialRampToValueAtTime(this.computedPlaybackRate,u),t.loop=!1,t.buffer=null;break;default:throw Error(`[SynthesizerNote] ${e.sampleModes} is undefined sampleModes.`)}}connect(){this.reverb.connect(this.outputGainNode).connect(this.destination)}disconnect(){this.outputGainNode.disconnect(0)}schedulePlaybackRate(){const e=this.bufferSource.playbackRate,t=this.computedPlaybackRate,n=this.startTime,s=this.instrument,i=n+s.modAttack,o=i+s.modDecay,a=t*1.0594630943592953**(this.modEnvToPitch*this.instrument.scaleTuning);e.cancelScheduledValues(0),e.setValueAtTime(t,n),e.linearRampToValueAtTime(a,i),e.linearRampToValueAtTime(t+(a-t)*(1-s.modSustain),o)}updateExpression(e){this.expressionGainNode.gain.value=(this.expression=e)/127}updatePitchBend(e){this.computedPlaybackRate=this.playbackRate*1.0594630943592953**(e/(e<0?8192:8191)*this.pitchBendSensitivity*this.instrument.scaleTuning),this.schedulePlaybackRate()}}/** - * @logue/reverb - * - * @description JavaScript Reverb effect class - * @author Logue - * @copyright 2019-2023 By Masashi Yoshikawa All rights reserved. - * @license MIT - * @version 1.3.7 - * @see {@link https://github.com/logue/Reverb.js} - */const W=23283064365386963e-26;class Oe{float(e=1){return this.int()*W*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,Ie={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},Y={version:"1.3.7",date:"2024-01-29T10:30:54.595Z"},I={blue:"blue",brown:"red",green:"green",pink:"pink",red:"red",violet:"violet",white:"white"},R={bins:2,scale:1,rnd:de},z=(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}={...R,...r},s=z(e,t,n);s.forEach((a,c)=>s[c]=c&1?a:-a);const i=1/e;let o=U(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)),Ge=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*Fe(r){const{bins:e,scale:t,rnd:n}={...R,bins:8,...r},s=z(e,t,n),i=1/e;let o=U(s);for(let a=0;;a=a+1>>>0){const c=Ge(a)%e;o-=s[c],o+=s[c]=n.norm(t),yield o*i}}function*j(r){const{bins:e,scale:t,rnd:n}={...R,...r},s=z(e,t,n),i=1/e;let o=U(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}={...R,...r};for(;;)yield t.norm(e)}const Le=(r,e)=>r!=null&&typeof r[e]=="function",Be=r=>Le(r,"xform")?r.xform():r,Pe=r=>r!=null&&typeof r[Symbol.iterator]=="function";class G{value;constructor(e){this.value=e}deref(){return this.value}}const Ve=r=>new G(r),qe=r=>r instanceof G,De=r=>r instanceof G?r:new G(r),ee=r=>r instanceof G?r.deref():r,je=(r,e)=>[r,t=>t,e];function $e(r){return r?[...r]:je(()=>[],(e,t)=>(e.push(t),e))}function*He(r,e){const t=Be(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 me(r,e){return Pe(e)?He(me(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))}}class A{static version=Y.version;static build=Y.date;ctx;wetGainNode;dryGainNode;filterNode;convolverNode;outputNode;options;isConnected;noise=J;constructor(e,t){this.ctx=e,this.options=Object.assign(Ie,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 I.blue:this.noise=D;break;case I.green:this.noise=Ne;break;case I.pink:this.noise=Fe;break;case I.red:case I.brown:this.noise=j;break;case I.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;l>>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 ze{constructor(e,t,n){this.type=e,this.size=t,this.offset=n}}class F{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(F.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 N(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 N(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 N(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 N(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 N(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,m=(t[n++]<<0|t[n++]<<8|t[n++]<<16|t[n++]<<24)>>>0,h=t[n++],f=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,m>0){const w=this.adjustSampleData(y,m);y=w.sample,m*=w.multiply,d*=w.multiply,u*=w.multiply}s.push(y),i.push({sampleName:a,start:c,end:l,startLoop:d,endLoop:u,sampleRate:m,originalPitch:h,pitchCorrection:f,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,m;for(l=0,d=e.length;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 F(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(m=>this.createNoteInfo(e,m,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"),m=this.getModGenAmount(s,"attackModEnv"),h=this.getModGenAmount(s,"holdModEnv"),f=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**(m/1200),modHold:2**(h/1200)*2**((60-v)*this.getModGenAmount(s,"keynumToModEnvHold")/1200),modDecay:2**(f/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:F.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 m=e.createElement("div");switch(m.className=this.items[u],this.items[u]){case"mute":{const h=e.createElement("div");h.className="form-check form-check-inline";const f=e.createElement("input");f.ariaLabel=`Ch.${l+1} Mute`,f.setAttribute("type","checkbox"),f.className="form-check-input",f.id="mute"+l+"ch",f.value=l.toString(),f.addEventListener("change",p=>{this.mute(l,p.target.checked)},!1),h.appendChild(f);const b=e.createElement("label");b.className="form-check-label",b.textContent=(l+1).toString(),b.setAttribute("for","mute"+l+"ch"),h.appendChild(b),m.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",((f,b)=>p=>{const y=d.querySelector(".program select");f.bankChange(b,p.target.value),f.programChange(b,parseInt(y.value))})(this,l),!1),m.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",((f,b)=>p=>{f.programChange(b,p.target.value)})(this,l),!1),m.appendChild(h);break}case"volume":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Volume`,h.innerText="100",m.appendChild(h);break}case"expression":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Expression`,h.innerText="127",m.appendChild(h);break}case"pitchBendSensitivity":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Pitch Bend Sensitivity`,h.innerText="2",m.appendChild(h);break}case"reverbDepth":{const h=document.createElement("var");h.ariaLabel=`Ch.${l+1} Reverb Depth`,h.innerText="40",m.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 f=e.createElement("div");f.className="progress-bar",h.appendChild(f),m.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 f=e.createElement("div");f.className="progress-bar progress-bar-animated",h.appendChild(f),m.appendChild(h);break}case"keys":{for(let h=0;h<127;h++){const f=e.createElement("div"),b=h%12;f.className="key "+([1,3,6,8,10].includes(b)?"semitone":"tone"),m.appendChild(f),f.addEventListener(s,((p,y,w)=>k=>{k.preventDefault(),p.drag=!0,p.noteOn(y,w,127)})(this,l,h)),f.addEventListener("mouseover",((p,y,w)=>k=>{k.preventDefault(),p.drag&&p.noteOn(y,w,127)})(this,l,h)),f.addEventListener("mouseout",((p,y,w)=>k=>{k.preventDefault(),p.noteOff(y,w)})(this,l,h)),f.addEventListener(i,((p,y,w)=>k=>{k.preventDefault(),p.drag=!1,p.noteOff(y,w)})(this,l,h))}break}}d.appendChild(m)}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 m=t.querySelector(`.header .${u}`),h=t.querySelector(`.channel .${u}`);m.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]===void 0){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 Ae(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 _{static CACHE_NAME="wml";constructor(e,t,n,s){this.url=e,this.cache=n,this.callback=s,this.alert=document.createElement("div"),this.alert.className="alert alert-warning",this.message=document.createElement("p"),this.message.innerText="Now Loading...",this.progressOuter=document.createElement("div"),this.progressOuter.className="progress",this.progressOuter.role="progressbar",this.progressOuter.ariaLabel="Loading Progress",this.progressOuter.ariaValueMin="0",this.progressOuter.ariaValueNow="0",this.progressOuter.ariaValueMax="100",this.progress=document.createElement("div"),this.progress.className="progress-bar",this.progressOuter.appendChild(this.progress),this.alert.appendChild(this.message),this.alert.appendChild(this.progressOuter),t.appendChild(this.alert)}onProgress(e,t){const n=Math.floor(e/t*100);this.progress.style.width=`${n}%`,this.progress.innerText=`${n}%`}onComplete(e){this.alert.className="alert alert-info",this.message.innerText="Initializing...",this.progress.className="progress-bar progress-bar-striped progress-bar-animated",this.progress.style.width="100%",this.callback(new Uint8Array(e))}onError(e=void 0){requestAnimationFrame(()=>{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(_.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:m}=await o.read();if(u)break;c.push(m),a+=m.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)}}class fe{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 _(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 Ue(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===void 0)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 _e extends fe{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 te={version:"0.6.3",date:"2024-02-08T02:08:31.573Z"},$={version:te.version,build:te.date,WebMidiLink:fe,WebMidiApi:_e,Parser:F};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-PADGV00H.js.map diff --git a/assets/index-PADGV00H.js.map b/assets/index-PADGV00H.js.map deleted file mode 100644 index dedc6c9..0000000 --- a/assets/index-PADGV00H.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index-PADGV00H.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/sound_font_synth_note.js","../../node_modules/@logue/reverb/dist/Reverb.es.js","../../src/riff.js","../../src/sf2.js","../../src/sound_font_synth.js","../../src/loader.js","../../src/wml.js","../../src/web_midi_api.js","../../src/meta.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).replace(/[!'()*]/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 keyValueSep = 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), keyValueSep, 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.replace(/\\+/g, ' ') : 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 = {encode: true,\n\t\tstrict: true,\n\t\tarrayFormat: 'none',\n\t\tarrayFormatSeparator: ',', ...options};\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\tif (queryString) {\n\t\tqueryString = `?${queryString}`;\n\t}\n\n\tlet hash = getHash(object.url);\n\tif (object.fragmentIdentifier) {\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","/**\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 * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * volume: number;\n * panpot: 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 * @type {{\n * channel: number;\n * key: number;\n * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * volume: number;\n * panpot: number;\n * }}\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 /**\n * @type {{\n * channel: number;\n * key: number;\n * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * volume: number;\n * panpot: number;\n * }}\n */\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(\n 0,\n this.buffer.length + instrument['end']\n );\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 =\n 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 parseFloat(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 /**\n * @type {{\n * channel: number;\n * key: number;\n * sample: Uint8Array;\n * basePlaybackRate: number;\n * loopStart: number;\n * loopEnd: number;\n * volume: number;\n * panpot: number;\n * }}\n */\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 =\n 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","/**\n * @logue/reverb\n *\n * @description JavaScript Reverb effect class\n * @author Logue \n * @copyright 2019-2023 By Masashi Yoshikawa All rights reserved.\n * @license MIT\n * @version 1.3.7\n * @see {@link https://github.com/logue/Reverb.js}\n */\n\nconst g = 23283064365386963e-26;\nclass F {\n float(e = 1) {\n return this.int() * g * e;\n }\n probability(e) {\n return this.float() < e;\n }\n norm(e = 1) {\n return (this.int() * g - 0.5) * 2 * e;\n }\n normMinMax(e, s) {\n const i = this.minmax(e, s);\n return this.float() < 0.5 ? i : -i;\n }\n minmax(e, s) {\n return this.float() * (s - e) + e;\n }\n minmaxInt(e, s) {\n e |= 0;\n const i = (s | 0) - e;\n return i ? e + this.int() % i : e;\n }\n minmaxUint(e, s) {\n e >>>= 0;\n const i = (s >>> 0) - e;\n return i ? e + this.int() % i : e;\n }\n}\nconst m = Math.random;\nclass T extends F {\n int() {\n return m() * 4294967296 >>> 0;\n }\n float(e = 1) {\n return m() * e;\n }\n norm(e = 1) {\n return (m() - 0.5) * 2 * e;\n }\n}\nconst k = new T(), x = {\n noise: \"white\",\n scale: 1,\n peaks: 2,\n randomAlgorithm: k,\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}, w = {\n version: \"1.3.7\",\n date: \"2024-01-29T10:30:54.595Z\"\n}, d = {\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}, p = {\n bins: 2,\n scale: 1,\n rnd: k\n}, N = (t, e, s) => {\n const i = new Array(t);\n for (let n = 0; n < t; n++)\n i[n] = s.norm(e);\n return i;\n}, v = (t) => t.reduce((e, s) => e + s, 0);\nfunction* G(t, e) {\n const s = [t[Symbol.iterator](), e[Symbol.iterator]()];\n for (let i = 0; ; i ^= 1) {\n const n = s[i].next();\n if (n.done)\n return;\n yield n.value;\n }\n}\nfunction* b(t) {\n const { bins: e, scale: s, rnd: i } = {\n ...p,\n ...t\n }, n = N(e, s, i);\n n.forEach((r, l) => n[l] = l & 1 ? r : -r);\n const a = 1 / e;\n let o = v(n);\n for (let r = 0, l = -1; ; ++r >= e && (r = 0))\n o -= n[r], o += n[r] = l * i.norm(s), l ^= 4294967294, yield l * o * a;\n}\nconst C = (t) => G(b(t), b(t)), E = (t) => {\n let e = 32;\n return t &= -t, t && e--, t & 65535 && (e -= 16), t & 16711935 && (e -= 8), t & 252645135 && (e -= 4), t & 858993459 && (e -= 2), t & 1431655765 && (e -= 1), e;\n};\nfunction* j(t) {\n const { bins: e, scale: s, rnd: i } = {\n ...p,\n bins: 8,\n ...t\n }, n = N(e, s, i), a = 1 / e;\n let o = v(n);\n for (let r = 0; ; r = r + 1 >>> 0) {\n const l = E(r) % e;\n o -= n[l], o += n[l] = i.norm(s), yield o * a;\n }\n}\nfunction* y(t) {\n const { bins: e, scale: s, rnd: i } = {\n ...p,\n ...t\n }, n = N(e, s, i), a = 1 / e;\n let o = v(n);\n for (let r = 0; ; ++r >= e && (r = 0))\n o -= n[r], o += n[r] = i.norm(s), yield o * a;\n}\nconst M = (t) => G(y(t), y(t));\nfunction* R(t) {\n const { scale: e, rnd: s } = { ...p, ...t };\n for (; ; )\n yield s.norm(e);\n}\nconst S = (t, e) => t != null && typeof t[e] == \"function\", Q = (t) => S(t, \"xform\") ? t.xform() : t, q = (t) => t != null && typeof t[Symbol.iterator] == \"function\";\nclass u {\n value;\n constructor(e) {\n this.value = e;\n }\n deref() {\n return this.value;\n }\n}\nconst D = (t) => new u(t), L = (t) => t instanceof u, B = (t) => t instanceof u ? t : new u(t), I = (t) => t instanceof u ? t.deref() : t, O = (t, e) => [t, (s) => s, e];\nfunction U(t) {\n return t ? [...t] : O(\n () => [],\n (e, s) => (e.push(s), e)\n );\n}\nfunction* z(t, e) {\n const s = Q(t)(U()), i = s[1], n = s[2];\n for (let a of e) {\n const o = n([], a);\n if (L(o)) {\n yield* I(i(o.deref()));\n return;\n }\n o.length && (yield* o);\n }\n yield* I(i([]));\n}\nconst P = (t, e) => [t[0], t[1], e];\nfunction A(t, e) {\n return q(e) ? z(A(t), e) : (s) => {\n const i = s[2];\n let n = t;\n return P(\n s,\n (a, o) => --n > 0 ? i(a, o) : n === 0 ? B(i(a, o)) : D(a)\n );\n };\n}\nclass h {\n /** Version strings */\n static version = w.version;\n /** Build date */\n static build = w.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 = R;\n /**\n * Constructor\n *\n * @param ctx - Root AudioContext\n * @param options - Configure\n */\n constructor(e, s) {\n this.ctx = e, this.options = Object.assign(x, s), 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 (!h.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 (!h.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 (!h.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 (!h.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 (!h.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 (!h.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 d.blue:\n this.noise = b;\n break;\n case d.green:\n this.noise = C;\n break;\n case d.pink:\n this.noise = j;\n break;\n case d.red:\n case d.brown:\n this.noise = y;\n break;\n case d.violet:\n this.noise = M;\n break;\n default:\n this.noise = R;\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, s, i) {\n return (e - s) * (e - i) <= 0;\n }\n /** Utility function for building an impulse response from the module parameters. */\n buildImpulse() {\n const e = this.ctx.sampleRate, s = Math.max(e * this.options.time, 1), i = e * this.options.delay, n = this.ctx.createBuffer(2, s, e), a = new Float32Array(s), o = new Float32Array(s), r = this.getNoise(s), l = this.getNoise(s);\n for (let c = 0; c < s; c++) {\n let f = 0;\n c < i ? (a[c] = 0, o[c] = 0, f = this.options.reverse ?? !1 ? s - (c - i) : c - i) : f = this.options.reverse ?? !1 ? s - c : c, a[c] = (r[c] ?? 0) * (1 - f / s) ** this.options.decay, o[c] = (l[c] ?? 0) * (1 - f / s) ** this.options.decay;\n }\n n.getChannelData(0).set(a), n.getChannelData(1).set(o), this.convolverNode.buffer = n;\n }\n /**\n * Noise source\n *\n * @param duration - length of IR.\n */\n getNoise(e) {\n return [\n ...A(\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 h as default\n};\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 !== void 0 ? optParams.padding : true;\n /** @type {boolean} */\n this.bigEndian =\n optParams.bigEndian !== void 0 ? 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: sampleName,\n start: start,\n end: end,\n startLoop: startLoop,\n endLoop: endLoop,\n sampleRate: sampleRate,\n originalPitch: originalPitch,\n pitchCorrection: pitchCorrection,\n sampleLink: sampleLink,\n sampleType: 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: sample,\n multiply: 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 === void 0) {\n // Amount\n output.push({\n type: key,\n value: {\n code: 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 === void 0) {\n output.push({\n type: key,\n value: {\n code: 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'] !== void 0\n ? presetGenerator.generator['instrument'].amount\n : presetModulator.modulator['instrument'] !== void 0\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: 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: modgen,\n modgenInfo: modgenInfo,\n };\n }\n}\n","import SynthesizerNote from './sound_font_synth_note';\nimport Reverb from '@logue/reverb';\nimport Parser from './sf2';\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: 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 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 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] === void 0) {\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').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","/**\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","import Synthesizer from './sound_font_synth';\nimport Loader from './loader';\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 return;\n }\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 === void 0) {\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","// This file is auto-generated by the build system.\nconst meta = {\n version: '0.6.3',\n date: '2024-02-08T02:08:31.573Z',\n};\nexport default meta;\n","import WebMidiLink from './wml';\nimport WebMidiApi from './web_midi_api';\nimport Parser from './sf2';\nimport Meta from './meta.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","keyValueSep","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","SynthesizerNote","ctx","destination","instrument","now","volDelay","modDelay","volAttack","modAttack","volHold","modHold","volDecay","modDecay","loopStart","loopEnd","startTime","pan","sample","buffer","bufferSource","output","panner","volume","outputGain","baseFreq","peekFreq","sustainFreq","modulator","val","release","volEndTimeTmp","volEndTime","modEndTime","playbackRate","computed","start","peekPitch","expression","pitchBend","g","F","s","m","T","k","w","d","p","N","t","n","v","G","r","l","C","E","j","y","M","R","S","Q","q","u","D","L","B","I","O","U","z","P","A","h","c","f","Riff","optParams","length","ip","size","RiffChunk","chunk","type","offset","Parser","parser","data","signature","presetHeader","presetZone","instrumentZone","samples","sampleHeader","sampleName","end","startLoop","endLoop","sampleRate","originalPitch","pitchCorrection","sampleLink","sampleType","adjust","newSample","il","multiply","code","zone","bagIndex","bagIndexEnd","zoneInfo","instrumentGenerator","instrumentModulator","jl","preset","presetGenerator","presetModulator","modgen","_zone","indexStart","indexEnd","zoneModGen","modgenInfo","info","Synthesizer","Reverb","entry","initAudioContext","emptySource","mode","modeElement","element","presets","instruments","banks","bank","bankNumber","presetNumber","presetName","programSet","generator","volSustain","volRelease","modSustain","modRelease","scale","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","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","e","Loader","placeholder","cache","callback","current","total","percentCompleted","error","cached","response","cloned","contentLength","reader","receivedLength","chunks","done","chunksAll","position","WebMidiLink","readyElem","ev","msg","command","hex","manufacturerId","device","model","GsPart","GsKey","GsValue","XgKey","XgPart","messages","ret","str","WebMidiApi","meta","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,CAAa,GAAK,CAAA,EAGxC,OAAOQ,CACP,CACF,CAEA,SAASG,GAAyBH,EAAO,CAExC,MAAMI,EAAa,CAClB,SAAU,KACV,SAAU,IACZ,EAEC,IAAIC,EAAQZ,EAAa,KAAKO,CAAK,EACnC,KAAOK,GAAO,CACb,GAAI,CAEHD,EAAWC,EAAM,CAAC,CAAC,EAAI,mBAAmBA,EAAM,CAAC,CAAC,CACrD,MAAU,CACP,MAAMC,EAASP,GAAOM,EAAM,CAAC,CAAC,EAE1BC,IAAWD,EAAM,CAAC,IACrBD,EAAWC,EAAM,CAAC,CAAC,EAAIC,EAExB,CAEDD,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e,EACrBmG,EAAS,UAAU,OAAO,SAAS,CACpC,EACD,EACZ,EAGUE,EAAe,iBAAiB,SAAU7C,GAAK,CAC7CyC,EAAI,aAAazC,EAAE,OAAO,QAAU,OAAS,OAAO,CAChE,CAAW,CAUF,EACD,EACR,EAEM,OAAO,iBACL,aACA,IAAM,CACJ,MAAMtP,EAAM8R,EAAG,MAAM,OAAO,SAAS,IAAI,EACrC9R,GACF+R,EAAI,MAAM/R,CAAG,CAEhB,EACD,EACD","x_google_ignoreList":[0,1,2,3,5]} \ No newline at end of file diff --git a/index.html b/index.html index 88f103b..01c5e63 100644 --- a/index.html +++ b/index.html @@ -22,8 +22,8 @@ gtag('js', new Date()); gtag('config', 'G-2Y2FW3QEG4'); - - + +