museaikit
Version:
A powerful music-focused AI toolkit
1 lines • 161 kB
JavaScript
!function(e,t){"object"==typeof exports&&"object"==typeof module?module.exports=t(require("@tensorflow/tfjs")):"function"==typeof define&&define.amd?define(["tf"],t):"object"==typeof exports?exports.music_vae=t(require("@tensorflow/tfjs")):e.music_vae=t(e.tf)}(self,(__WEBPACK_EXTERNAL_MODULE__6364__=>(()=>{"use strict";var __webpack_modules__={381:e=>{e.exports={}},488:(e,t,n)=>{n.d(t,{converterFromSpec:()=>l});var r=n(6364),o=n(1758),i=n(5447),s=n(8171),a=n(584),u=n(3920),c=n(2596);function l(e){switch(e.type){case"MelodyConverter":return new h(e.args);case"MelodyRhythmConverter":return new _(e.args);case"MelodyShapeConverter":return new y(e.args);case"DrumsConverter":return new m(e.args);case"DrumRollConverter":return new f(e.args);case"TrioConverter":return new S(e.args);case"TrioRhythmConverter":return new P(e.args);case"DrumsOneHotConverter":return new d(e.args);case"MultitrackConverter":return new b(e.args);case"GrooveConverter":return new w(e.args);default:throw new Error(`Unknown DataConverter type: ${e}`)}}class p{numSteps;numSegments;NUM_SPLITS=0;SEGMENTED_BY_TRACK=!1;constructor(e){this.numSteps=e.numSteps,this.numSegments=e.numSegments}tensorSteps(e){return r.scalar(e.shape[0],"int32")}}class m extends p{pitchClasses;pitchToClass;depth;endTensor;constructor(e){super(e),this.pitchClasses=e.pitchClasses||i.DEFAULT_DRUM_PITCH_CLASSES,this.pitchToClass=new Map;for(let e=0;e<this.pitchClasses.length;++e)this.pitchClasses[e].forEach((t=>{this.pitchToClass.set(t,e)}));this.depth=this.pitchClasses.length+1}toTensor(e){c.assertIsQuantizedSequence(e);const t=this.numSteps||e.totalQuantizedSteps,n=r.buffer([t,this.pitchClasses.length+1],"int32");for(let e=0;e<t;++e)n.set(1,e,-1);return e.notes.forEach((e=>{n.set(1,e.quantizedStartStep,this.pitchToClass.get(e.pitch)),n.set(0,e.quantizedStartStep,-1)})),n.toTensor()}async toNoteSequence(e,t,n){const r=c.createQuantizedNoteSequence(t,n),i=e.argMax(1),s=await i.data();i.dispose();for(let e=0;e<s.length;++e)for(let t=0;t<this.pitchClasses.length;t++)s[e]>>t&1&&r.notes.push(o.A.Note.create({pitch:this.pitchClasses[t][0],quantizedStartStep:e,quantizedEndStep:e+1,isDrum:!0}));return r.totalQuantizedSteps=s.length,r}}class f extends m{async toNoteSequence(e,t,n){const r=c.createQuantizedNoteSequence(t,n),i=await e.data();for(let t=0;t<e.shape[0];++t){const e=i.slice(t*this.pitchClasses.length,(t+1)*this.pitchClasses.length);for(let n=0;n<e.length;++n)e[n]&&r.notes.push(o.A.Note.create({pitch:this.pitchClasses[n][0],quantizedStartStep:t,quantizedEndStep:t+1,isDrum:!0}))}return r.totalQuantizedSteps=e.shape[0],r}}class d extends m{constructor(e){super(e),this.depth=Math.pow(2,this.pitchClasses.length)}toTensor(e){c.assertIsRelativeQuantizedSequence(e);const t=this.numSteps||e.totalQuantizedSteps,n=Array(t).fill(0);for(const{pitch:t,quantizedStartStep:r}of e.notes)n[r]+=Math.pow(2,this.pitchToClass.get(t));return r.tidy((()=>r.oneHot(r.tensor1d(n,"int32"),this.depth)))}}class h extends p{minPitch;maxPitch;ignorePolyphony;depth;endTensor;NOTE_OFF=1;FIRST_PITCH=2;constructor(e){super(e),this.minPitch=e.minPitch,this.maxPitch=e.maxPitch,this.ignorePolyphony=e.ignorePolyphony,this.depth=e.maxPitch-e.minPitch+1+this.FIRST_PITCH}toTensor(e){const t=a.Melody.fromNoteSequence(e,this.minPitch,this.maxPitch,this.ignorePolyphony,this.numSteps);return r.tidy((()=>r.oneHot(r.tensor(t.events,[t.events.length],"int32"),this.depth)))}async toNoteSequence(e,t,n){const r=e.argMax(1),o=await r.data();r.dispose();return new a.Melody(o,this.minPitch,this.maxPitch).toNoteSequence(t,n)}}class g extends p{minPitch;maxPitch;ignorePolyphony;melodyControl;depth;endTensor;constructor(e,t){super(e),this.minPitch=e.minPitch,this.maxPitch=e.maxPitch,this.ignorePolyphony=e.ignorePolyphony,this.melodyControl=t,this.depth=t.depth}toTensor(e){const t=a.Melody.fromNoteSequence(e,this.minPitch,this.maxPitch,this.ignorePolyphony,this.numSteps);return this.melodyControl.extract(t)}}class _ extends g{constructor(e){super(e,new a.MelodyRhythm)}async toNoteSequence(e,t,n){const r=c.createQuantizedNoteSequence(t,n),s=await e.data();for(let e=0;e<s.length;++e)s[e]&&r.notes.push(o.A.Note.create({pitch:i.DEFAULT_DRUM_PITCH_CLASSES[1][0],quantizedStartStep:e,quantizedEndStep:e+1,isDrum:!0}));return r.totalQuantizedSteps=s.length,r}}class y extends g{constructor(e){super(e,new a.MelodyShape)}async toNoteSequence(e,t,n){const r=c.createQuantizedNoteSequence(t,n),i=e.argMax(1),a=await i.data();i.dispose();let u=Math.round((this.maxPitch+this.minPitch)/2);for(let e=0;e<a.length;++e){switch(a[e]){case 0:u-=1,u<this.minPitch&&(u=this.minPitch,s.log("Pitch range exceeded when creating NoteSequence from shape.","MelodyShapeConverter"));break;case 2:u+=1,u>this.maxPitch&&(u=this.maxPitch,s.log("Pitch range exceeded when creating NoteSequence from shape.","MelodyShapeConverter"))}r.notes.push(o.A.Note.create({pitch:u,quantizedStartStep:e,quantizedEndStep:e+1}))}return r.totalQuantizedSteps=a.length,r}}class S extends p{melConverter;bassConverter;drumsConverter;depth;endTensor;NUM_SPLITS=3;MEL_PROG_RANGE=[0,31];BASS_PROG_RANGE=[32,39];constructor(e){super(e),e.melArgs.numSteps=e.numSteps,e.bassArgs.numSteps=e.numSteps,e.drumsArgs.numSteps=e.numSteps,this.melConverter=new h(e.melArgs),this.bassConverter=new h(e.bassArgs),this.drumsConverter=new d(e.drumsArgs),this.depth=this.melConverter.depth+this.bassConverter.depth+this.drumsConverter.depth}toTensor(e){c.assertIsQuantizedSequence(e);const t=c.clone(e),n=c.clone(e),o=c.clone(e);return t.notes=e.notes.filter((e=>!e.isDrum&&e.program>=this.MEL_PROG_RANGE[0]&&e.program<=this.MEL_PROG_RANGE[1])),n.notes=e.notes.filter((e=>!e.isDrum&&e.program>=this.BASS_PROG_RANGE[0]&&e.program<=this.BASS_PROG_RANGE[1])),o.notes=e.notes.filter((e=>e.isDrum)),r.tidy((()=>r.concat([this.melConverter.toTensor(t),this.bassConverter.toTensor(n),this.drumsConverter.toTensor(o)],-1)))}async toNoteSequence(e,t,n){const o=r.split(e,[this.melConverter.depth,this.bassConverter.depth,this.drumsConverter.depth],-1),i=await this.melConverter.toNoteSequence(o[0],t,n);i.notes.forEach((e=>{e.instrument=0,e.program=0}));const s=await this.bassConverter.toNoteSequence(o[1],t,n);i.notes.push(...s.notes.map((e=>(e.instrument=1,e.program=this.BASS_PROG_RANGE[0],e))));const a=await this.drumsConverter.toNoteSequence(o[2],t,n);return i.notes.push(...a.notes.map((e=>(e.instrument=2,e)))),o.forEach((e=>e.dispose())),i}}class P extends p{trioConverter;depth;endTensor;NUM_SPLITS=3;constructor(e){super(e),this.trioConverter=new S(e),this.depth=3}toTensor(e){return r.tidy((()=>{const t=this.trioConverter.toTensor(e),n=r.split(t,[this.trioConverter.melConverter.depth,this.trioConverter.bassConverter.depth,this.trioConverter.drumsConverter.depth],1),o=r.argMax(n[0],1),i=r.argMax(n[1],1),s=r.argMax(n[2],1),a=r.greater(o,1),u=r.greater(i,1),c=r.greater(s,0);return r.stack([a,u,c],1)}))}async toNoteSequence(e,t,n){const s=r.split(e,3,1),a=await Promise.all(s.map((e=>e.data()))),u=c.createQuantizedNoteSequence(t,n);for(let e=0;e<this.numSteps;++e)a[0][e]&&u.notes.push(o.A.Note.create({pitch:72,quantizedStartStep:e,quantizedEndStep:e+1,instrument:0,program:0})),a[1][e]&&u.notes.push(o.A.Note.create({pitch:36,quantizedStartStep:e,quantizedEndStep:e+1,instrument:1,program:32})),a[2][e]&&u.notes.push(o.A.Note.create({pitch:i.DEFAULT_DRUM_PITCH_CLASSES[1][0],quantizedStartStep:e,quantizedEndStep:e+1,instrument:2,isDrum:!0}));return u.totalQuantizedSteps=this.numSteps,u}}class b extends p{SEGMENTED_BY_TRACK=!0;stepsPerQuarter;totalSteps;numVelocityBins;minPitch;maxPitch;numPitches;performanceEventDepth;numPrograms;endToken;depth;endTensor;constructor(e){super(e),this.stepsPerQuarter=e.stepsPerQuarter,this.totalSteps=e.totalSteps,this.numVelocityBins=e.numVelocityBins,this.minPitch=e.minPitch?e.minPitch:i.MIN_MIDI_PITCH,this.maxPitch=e.maxPitch?e.maxPitch:i.MAX_MIDI_PITCH,this.numPitches=this.maxPitch-this.minPitch+1,this.performanceEventDepth=2*this.numPitches+this.totalSteps+this.numVelocityBins,this.numPrograms=i.MAX_MIDI_PROGRAM-i.MIN_MIDI_PROGRAM+2,this.endToken=this.performanceEventDepth+this.numPrograms,this.depth=this.endToken+1,this.endTensor=r.tidy((()=>r.oneHot(r.tensor1d([this.endToken],"int32"),this.depth).as1D()))}trackToTensor(e){const t=this.numSteps/this.numSegments;let n;if(e){for(;e.events.length>t-2;)e.events.pop();n=r.buffer([e.events.length+2],"int32"),n.set(this.performanceEventDepth+(e.isDrum?this.numPrograms-1:e.program),0),e.events.forEach(((e,t)=>{switch(e.type){case"note-on":n.set(e.pitch-this.minPitch,t+1);break;case"note-off":n.set(this.numPitches+e.pitch-this.minPitch,t+1);break;case"time-shift":n.set(2*this.numPitches+e.steps-1,t+1);break;case"velocity-change":n.set(2*this.numPitches+this.totalSteps+e.velocityBin-1,t+1);break;default:throw new Error(`Unrecognized performance event: ${e}`)}})),n.set(this.endToken,e.events.length+1)}else n=r.buffer([1],"int32",new Int32Array([this.endToken]));return r.tidy((()=>{const e=r.oneHot(n.toTensor(),this.depth);return e.pad([[0,t-e.shape[0]],[0,0]])}))}toTensor(e){if(c.assertIsRelativeQuantizedSequence(e),e.quantizationInfo.stepsPerQuarter!==this.stepsPerQuarter)throw new Error(`Steps per quarter note mismatch: ${e.quantizationInfo.stepsPerQuarter} != ${this.stepsPerQuarter}`);const t=c.clone(e);t.notes=e.notes.filter((e=>e.pitch>=this.minPitch&&e.pitch<=this.maxPitch));const n=new Set(t.notes.map((e=>e.instrument))),o=Array.from(n).map((e=>u.Performance.fromNoteSequence(t,this.totalSteps,this.numVelocityBins,e))).sort(((e,t)=>t.isDrum?-1:e.isDrum?1:e.program-t.program));for(;o.length>this.numSegments;)o.pop();for(o.forEach((e=>e.setNumSteps(this.totalSteps)));o.length<this.numSegments;)o.push(void 0);return r.tidy((()=>r.concat(o.map((e=>this.trackToTensor(e))),0)))}tokensToTrack(e){const t=e.indexOf(this.endToken),n=t>=0?t:e.length,r=e.slice(0,n),o=r.filter((e=>e<this.performanceEventDepth)),i=r.filter((e=>e>=this.performanceEventDepth)),[s,a]=i.length?i[0]-this.performanceEventDepth<this.numPrograms-1?[i[0]-this.performanceEventDepth,!1]:[0,!0]:[0,!1],c=Array.from(o).map((e=>{if(e<this.numPitches)return{type:"note-on",pitch:this.minPitch+e};if(e<2*this.numPitches)return{type:"note-off",pitch:this.minPitch+e-this.numPitches};if(e<2*this.numPitches+this.totalSteps)return{type:"time-shift",steps:e-2*this.numPitches+1};if(e<2*this.numPitches+this.totalSteps+this.numVelocityBins)return{type:"velocity-change",velocityBin:e-2*this.numPitches-this.totalSteps+1};throw new Error(`Invalid performance event token: ${e}`)}));return new u.Performance(c,this.totalSteps,this.numVelocityBins,s,a)}async toNoteSequence(e,t=this.stepsPerQuarter,n){const o=c.createQuantizedNoteSequence(t,n);o.totalQuantizedSteps=this.totalSteps;const i=r.tidy((()=>r.split(e.argMax(1),this.numSegments)));return(await Promise.all(i.map((async e=>{const t=await e.data(),n=this.tokensToTrack(t);return e.dispose(),n})))).forEach(((e,t)=>{e.setNumSteps(this.totalSteps),o.notes.push(...e.toNoteSequence(t).notes)})),o}}class w extends p{stepsPerQuarter;humanize;tapify;pitchClasses;pitchToClass;depth;endTensor;splitInstruments;TAPIFY_CHANNEL=3;constructor(e){super(e),this.stepsPerQuarter=e.stepsPerQuarter||i.DEFAULT_STEPS_PER_QUARTER,this.pitchClasses=e.pitchClasses||i.DEFAULT_DRUM_PITCH_CLASSES,this.pitchToClass=new Map;for(let e=0;e<this.pitchClasses.length;++e)this.pitchClasses[e].forEach((t=>{this.pitchToClass.set(t,e)}));this.humanize=e.humanize||!1,this.tapify=e.tapify||!1,this.splitInstruments=e.splitInstruments||!1,this.depth=3}toTensor(e){const t=c.isRelativeQuantizedSequence(e)?e:c.quantizeNoteSequence(e,this.stepsPerQuarter),n=this.numSteps,o=t.tempos&&t.tempos.length?t.tempos[0].qpm:i.DEFAULT_QUARTERS_PER_MINUTE,s=60/o/this.stepsPerQuarter,a=[];for(let e=0;e<n;++e)a.push(new Map);t.notes.forEach((e=>{if(!this.tapify&&!this.pitchToClass.has(e.pitch))return;const t=e.quantizedStartStep;if(t>=a.length)throw Error(`Model does not support sequences with more than ${n} steps (${n*s} seconds at qpm ${o}).`);const r=this.tapify?this.TAPIFY_CHANNEL:this.pitchToClass.get(e.pitch);(!a[t].has(r)||a[t].get(r).velocity<e.velocity)&&a[t].set(r,e)}));const u=this.pitchClasses.length,l=r.buffer([n,u]),p=r.buffer([n,u]),m=r.buffer([n,u]);function f(e){if(void 0===e.startTime)return 0;const t=e.startTime;return 2*(e.quantizedStartStep*s-t)/s}for(let e=0;e<n;++e)for(let t=0;t<u;++t){const n=a[e].get(t);l.set(n?1:0,e,t),this.humanize||this.tapify||p.set(n?n.velocity/i.MAX_MIDI_VELOCITY:0,e,t),this.humanize||m.set(n?f(n):0,e,t)}return r.tidy((()=>{const e=l.toTensor(),t=p.toTensor(),o=m.toTensor(),i=this.splitInstruments?n*u:n;return r.concat([e.as2D(i,-1),t.as2D(i,-1),o.as2D(i,-1)],1)}))}async toNoteSequence(e,t,n=i.DEFAULT_QUARTERS_PER_MINUTE){if(t&&t!==this.stepsPerQuarter)throw Error("`stepsPerQuarter` is set by the model.");t=this.stepsPerQuarter;const r=this.splitInstruments?e.shape[0]/this.pitchClasses.length:e.shape[0],s=60/n/this.stepsPerQuarter,a=o.A.create({totalTime:r*s,tempos:[{qpm:n}]}),u=await e.data();function c(e,t,n){return Math.min(Math.max(e,t),n)}const l=this.pitchClasses.length;for(let e=0;e<r;++e){const t=u.slice(e*l*this.depth,(e+1)*l*this.depth);for(let n=0;n<l;++n){const r=t[this.splitInstruments?n*this.depth:n],u=t[this.splitInstruments?n*this.depth+1:l+n],p=t[this.splitInstruments?n*this.depth+2:2*l+n];if(r>.5){const t=c(Math.round(u*i.MAX_MIDI_VELOCITY),i.MIN_MIDI_VELOCITY,i.MAX_MIDI_VELOCITY),r=c(p/2,-.5,.5);a.notes.push(o.A.Note.create({pitch:this.pitchClasses[n][0],startTime:(e-r)*s,endTime:(e-r+1)*s,velocity:t,isDrum:!0}))}}}return a}}},584:(e,t,n)=>{n.d(t,{Melody:()=>s,MelodyRhythm:()=>a,MelodyShape:()=>u});var r=n(6364),o=n(1758),i=n(2596);class s{events;minPitch;maxPitch;constructor(e,t,n){this.events=e,this.minPitch=t,this.maxPitch=n}static fromNoteSequence(e,t,n,r=!0,o){i.assertIsQuantizedSequence(e);const a=e.notes.sort(((e,t)=>e.quantizedStartStep===t.quantizedStartStep?t.pitch-e.pitch:e.quantizedStartStep-t.quantizedStartStep)),u=new Int32Array(o||e.totalQuantizedSteps);let c=-1;return a.forEach((e=>{if(e.quantizedStartStep===c){if(r)return;throw new Error("`NoteSequence` is not monophonic.")}if(e.pitch<t||e.pitch>n)throw Error(`\`NoteSequence\` has a pitch outside of the valid range: ${e.pitch}`);u[e.quantizedStartStep]=e.pitch-t+2,u[e.quantizedEndStep]=1,c=e.quantizedStartStep})),new s(u,t,n)}toNoteSequence(e,t){const n=i.createQuantizedNoteSequence(e,t);let r=null;for(let e=0;e<this.events.length;++e){const t=this.events[e];switch(t){case 0:break;case 1:r&&(r.quantizedEndStep=e,n.notes.push(r),r=null);break;default:r&&(r.quantizedEndStep=e,n.notes.push(r)),r=o.A.Note.create({pitch:t-2+this.minPitch,quantizedStartStep:e})}}return r&&(r.quantizedEndStep=this.events.length,n.notes.push(r)),n.totalQuantizedSteps=this.events.length,n}}class a{depth=1;extract(e){const t=e.events.length,n=r.buffer([t,1]);for(let r=0;r<t;++r)n.set(e.events[r]>=2?1:0,r,0);return n.toTensor().as2D(t,1)}}class u{depth=3;extract(e){const t=e.events.length,n=r.buffer([t,3]);let o=null,i=null;for(let r=0;r<t;++r)if(e.events[r]>=2){if(null!==o){let t;0===n.get(o,0)&&0===n.get(o,1)&&0===n.get(o,2)&&(o=-1),t=e.events[r]<i?0:e.events[r]>i?2:1;for(let e=r;e>o;--e)n.set(1,e,t)}o=r,i=e.events[r]}if(o!==t-1)if(null===o||0===n.get(o,0)&&0===n.get(o,1)&&0===n.get(o,2))for(let e=0;e<t;++e)n.set(1,e,1);else for(let e=t-1;e>o;--e)for(let t=0;t<3;t++)n.set(n.get(o,t),e,t);return n.toTensor().as2D(t,3)}}},955:(e,t,n)=>{n.r(t),n.d(t,{userAgent:()=>r});const r=""},1137:(e,t,n)=>{e.exports=u;var r,o=n(5382),i=o.LongBits,s=o.utf8;function a(e,t){return RangeError("index out of range: "+e.pos+" + "+(t||1)+" > "+e.len)}function u(e){this.buf=e,this.pos=0,this.len=e.length}var c,l="undefined"!=typeof Uint8Array?function(e){if(e instanceof Uint8Array||Array.isArray(e))return new u(e);throw Error("illegal buffer")}:function(e){if(Array.isArray(e))return new u(e);throw Error("illegal buffer")},p=function(){return o.Buffer?function(e){return(u.create=function(e){return o.Buffer.isBuffer(e)?new r(e):l(e)})(e)}:l};function m(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw a(this);if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e}return e.lo=(e.lo|(127&this.buf[this.pos++])<<7*t)>>>0,e}for(;t<4;++t)if(e.lo=(e.lo|(127&this.buf[this.pos])<<7*t)>>>0,this.buf[this.pos++]<128)return e;if(e.lo=(e.lo|(127&this.buf[this.pos])<<28)>>>0,e.hi=(e.hi|(127&this.buf[this.pos])>>4)>>>0,this.buf[this.pos++]<128)return e;if(t=0,this.len-this.pos>4){for(;t<5;++t)if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}else for(;t<5;++t){if(this.pos>=this.len)throw a(this);if(e.hi=(e.hi|(127&this.buf[this.pos])<<7*t+3)>>>0,this.buf[this.pos++]<128)return e}throw Error("invalid varint encoding")}function f(e,t){return(e[t-4]|e[t-3]<<8|e[t-2]<<16|e[t-1]<<24)>>>0}function d(){if(this.pos+8>this.len)throw a(this,8);return new i(f(this.buf,this.pos+=4),f(this.buf,this.pos+=4))}u.create=p(),u.prototype._slice=o.Array.prototype.subarray||o.Array.prototype.slice,u.prototype.uint32=(c=4294967295,function(){if(c=(127&this.buf[this.pos])>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<7)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<14)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(127&this.buf[this.pos])<<21)>>>0,this.buf[this.pos++]<128)return c;if(c=(c|(15&this.buf[this.pos])<<28)>>>0,this.buf[this.pos++]<128)return c;if((this.pos+=5)>this.len)throw this.pos=this.len,a(this,10);return c}),u.prototype.int32=function(){return 0|this.uint32()},u.prototype.sint32=function(){var e=this.uint32();return e>>>1^-(1&e)},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw a(this,4);return f(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw a(this,4);return 0|f(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw a(this,4);var e=o.float.readFloatLE(this.buf,this.pos);return this.pos+=4,e},u.prototype.double=function(){if(this.pos+8>this.len)throw a(this,4);var e=o.float.readDoubleLE(this.buf,this.pos);return this.pos+=8,e},u.prototype.bytes=function(){var e=this.uint32(),t=this.pos,n=this.pos+e;if(n>this.len)throw a(this,e);return this.pos+=e,Array.isArray(this.buf)?this.buf.slice(t,n):t===n?new this.buf.constructor(0):this._slice.call(this.buf,t,n)},u.prototype.string=function(){var e=this.bytes();return s.read(e,0,e.length)},u.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw a(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw a(this)}while(128&this.buf[this.pos++]);return this},u.prototype.skipType=function(e){switch(e){case 0:this.skip();break;case 1:this.skip(8);break;case 2:this.skip(this.uint32());break;case 3:for(;4!=(e=7&this.uint32());)this.skipType(e);break;case 5:this.skip(4);break;default:throw Error("invalid wire type "+e+" at offset "+this.pos)}return this},u._configure=function(e){r=e,u.create=p(),r._configure();var t=o.Long?"toLong":"toNumber";o.merge(u.prototype,{int64:function(){return m.call(this)[t](!1)},uint64:function(){return m.call(this)[t](!0)},sint64:function(){return m.call(this).zzDecode()[t](!1)},fixed64:function(){return d.call(this)[t](!0)},sfixed64:function(){return d.call(this)[t](!1)}})}},1758:(e,t,n)=>{n.d(t,{A:()=>o});var r=n(7151),o=r.tensorflow.magenta.NoteSequence},1925:module=>{function inquire(moduleName){try{var mod=eval("quire".replace(/^/,"re"))(moduleName);if(mod&&(mod.length||Object.keys(mod).length))return mod}catch(e){}return null}module.exports=inquire},1979:(e,t)=>{var n=t;n.length=function(e){var t=e.length;if(!t)return 0;for(var n=0;--t%4>1&&"="===e.charAt(t);)++n;return Math.ceil(3*e.length)/4-n};for(var r=new Array(64),o=new Array(123),i=0;i<64;)o[r[i]=i<26?i+65:i<52?i+71:i<62?i-4:i-59|43]=i++;n.encode=function(e,t,n){for(var o,i=null,s=[],a=0,u=0;t<n;){var c=e[t++];switch(u){case 0:s[a++]=r[c>>2],o=(3&c)<<4,u=1;break;case 1:s[a++]=r[o|c>>4],o=(15&c)<<2,u=2;break;case 2:s[a++]=r[o|c>>6],s[a++]=r[63&c],u=0}a>8191&&((i||(i=[])).push(String.fromCharCode.apply(String,s)),a=0)}return u&&(s[a++]=r[o],s[a++]=61,1===u&&(s[a++]=61)),i?(a&&i.push(String.fromCharCode.apply(String,s.slice(0,a))),i.join("")):String.fromCharCode.apply(String,s.slice(0,a))};var s="invalid encoding";n.decode=function(e,t,n){for(var r,i=n,a=0,u=0;u<e.length;){var c=e.charCodeAt(u++);if(61===c&&a>1)break;if(void 0===(c=o[c]))throw Error(s);switch(a){case 0:r=c,a=1;break;case 1:t[n++]=r<<2|(48&c)>>4,r=c,a=2;break;case 2:t[n++]=(15&r)<<4|(60&c)>>2,r=c,a=3;break;case 3:t[n++]=(3&r)<<6|c,a=0}}if(1===a)throw Error(s);return n-i},n.test=function(e){return/^(?:[A-Za-z0-9+/]{4})*(?:[A-Za-z0-9+/]{2}==|[A-Za-z0-9+/]{3}=)?$/.test(e)}},2596:(e,t,n)=>{n.d(t,{assertIsQuantizedSequence:()=>_,assertIsRelativeQuantizedSequence:()=>S,clone:()=>p,createQuantizedNoteSequence:()=>P,isRelativeQuantizedSequence:()=>y,quantizeNoteSequence:()=>h});var r=n(1758),o=n(5447);const i=.5;class s extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class a extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class u extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class c extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class l extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}function p(e){return r.A.decode(r.A.encode(e).finish())}function m(e,t,n=i){const r=e*t;return Math.floor(r+(1-n))}function f(e){return e.controlChanges.concat(e.textAnnotations)}function d(e){if(e.tempos&&0!==e.tempos.length){if(e.tempos.sort(((e,t)=>e.time-t.time)),0!==e.tempos[0].time&&e.tempos[0].qpm!==o.DEFAULT_QUARTERS_PER_MINUTE)throw new c(`NoteSequence has an implicit tempo change from initial ${o.DEFAULT_QUARTERS_PER_MINUTE} qpm to ${e.tempos[0].qpm} qpm at ${e.tempos[0].time} seconds.`);for(let t=1;t<e.tempos.length;t++)if(e.tempos[t].qpm!==e.tempos[0].qpm)throw new c(`NoteSequence has at least one tempo change from ${e.tempos[0].qpm} qpm to ${e.tempos[t].qpm}qpm at ${e.tempos[t].time} seconds.`)}}function h(e,t){const n=p(e);if(n.quantizationInfo=r.A.QuantizationInfo.create({stepsPerQuarter:t}),n.timeSignatures.length>0){if(n.timeSignatures.sort(((e,t)=>e.time-t.time)),0!==n.timeSignatures[0].time&&(4!==n.timeSignatures[0].numerator||4!==n.timeSignatures[0].denominator))throw new s(`NoteSequence has an implicit change from initial 4/4 time signature to ${n.timeSignatures[0].numerator}/${n.timeSignatures[0].denominator} at ${n.timeSignatures[0].time} seconds.`);for(let e=1;e<n.timeSignatures.length;e++){const t=n.timeSignatures[e];if(t.numerator!==n.timeSignatures[0].numerator||t.denominator!==n.timeSignatures[0].denominator)throw new s(`NoteSequence has at least one time signature change from ${n.timeSignatures[0].numerator}/${n.timeSignatures[0].denominator} to ${t.numerator}/${t.denominator} at ${t.time} seconds`)}n.timeSignatures[0].time=0,n.timeSignatures=[n.timeSignatures[0]]}else{const e=r.A.TimeSignature.create({numerator:4,denominator:4,time:0});n.timeSignatures.push(e)}const i=n.timeSignatures[0];if(!(c=i.denominator)||c&c-1)throw new a(`Denominator is not a power of 2. Time signature: ${i.numerator}/${i.denominator}`);var c;if(0===i.numerator)throw new a(`Numerator is 0. Time signature: ${i.numerator}/${i.denominator}`);if(n.tempos.length>0)d(n),n.tempos[0].time=0,n.tempos=[n.tempos[0]];else{const e=r.A.Tempo.create({qpm:o.DEFAULT_QUARTERS_PER_MINUTE,time:0});n.tempos.push(e)}const l=function(e,t){return e*t/60}(t,n.tempos[0].qpm);return n.totalQuantizedSteps=m(e.totalTime,l),function(e,t){for(const n of e.notes){if(n.quantizedStartStep=m(n.startTime,t),n.quantizedEndStep=m(n.endTime,t),n.quantizedEndStep===n.quantizedStartStep&&(n.quantizedEndStep+=1),n.quantizedStartStep<0||n.quantizedEndStep<0)throw new u(`Got negative note time: start_step = ${n.quantizedStartStep}, end_step = ${n.quantizedEndStep}`);n.quantizedEndStep>e.totalQuantizedSteps&&(e.totalQuantizedSteps=n.quantizedEndStep)}f(e).forEach((e=>{if(e.quantizedStep=m(e.time,t),e.quantizedStep<0)throw new u(`Got negative event time: step = ${e.quantizedStep}`)}))}(n,l),n}function g(e){return e.quantizationInfo&&(e.quantizationInfo.stepsPerQuarter>0||e.quantizationInfo.stepsPerSecond>0)}function _(e){if(!g(e))throw new l(`NoteSequence ${e.id} is not quantized (missing quantizationInfo)`)}function y(e){return e.quantizationInfo&&e.quantizationInfo.stepsPerQuarter>0}function S(e){if(!y(e))throw new l(`NoteSequence ${e.id} is not quantized or is quantized based on absolute timing`)}function P(e=o.DEFAULT_STEPS_PER_QUARTER,t=o.DEFAULT_QUARTERS_PER_MINUTE){return r.A.create({quantizationInfo:{stepsPerQuarter:e},tempos:[{qpm:t}]})}},2971:(e,t)=>{var n=t;n.length=function(e){for(var t=0,n=0,r=0;r<e.length;++r)(n=e.charCodeAt(r))<128?t+=1:n<2048?t+=2:55296==(64512&n)&&56320==(64512&e.charCodeAt(r+1))?(++r,t+=4):t+=3;return t},n.read=function(e,t,n){if(n-t<1)return"";for(var r,o=null,i=[],s=0;t<n;)(r=e[t++])<128?i[s++]=r:r>191&&r<224?i[s++]=(31&r)<<6|63&e[t++]:r>239&&r<365?(r=((7&r)<<18|(63&e[t++])<<12|(63&e[t++])<<6|63&e[t++])-65536,i[s++]=55296+(r>>10),i[s++]=56320+(1023&r)):i[s++]=(15&r)<<12|(63&e[t++])<<6|63&e[t++],s>8191&&((o||(o=[])).push(String.fromCharCode.apply(String,i)),s=0);return o?(s&&o.push(String.fromCharCode.apply(String,i.slice(0,s))),o.join("")):String.fromCharCode.apply(String,i.slice(0,s))},n.write=function(e,t,n){for(var r,o,i=n,s=0;s<e.length;++s)(r=e.charCodeAt(s))<128?t[n++]=r:r<2048?(t[n++]=r>>6|192,t[n++]=63&r|128):55296==(64512&r)&&56320==(64512&(o=e.charCodeAt(s+1)))?(r=65536+((1023&r)<<10)+(1023&o),++s,t[n++]=r>>18|240,t[n++]=r>>12&63|128,t[n++]=r>>6&63|128,t[n++]=63&r|128):(t[n++]=r>>12|224,t[n++]=r>>6&63|128,t[n++]=63&r|128);return n-i}},3474:e=>{function t(){this._listeners={}}e.exports=t,t.prototype.on=function(e,t,n){return(this._listeners[e]||(this._listeners[e]=[])).push({fn:t,ctx:n||this}),this},t.prototype.off=function(e,t){if(void 0===e)this._listeners={};else if(void 0===t)this._listeners[e]=[];else for(var n=this._listeners[e],r=0;r<n.length;)n[r].fn===t?n.splice(r,1):++r;return this},t.prototype.emit=function(e){var t=this._listeners[e];if(t){for(var n=[],r=1;r<arguments.length;)n.push(arguments[r++]);for(r=0;r<t.length;)t[r].fn.apply(t[r++].ctx,n)}return this}},3576:(e,t,n)=>{n.d(t,{chordEncoderFromType:()=>re});var r=n(6364),o="C C# Db D D# Eb E F F# Gb G G# Ab A A# Bb B".split(" "),i=function(e){return"string"!=typeof e?o.slice():o.filter((function(t){var n=t[1]||" ";return-1!==e.indexOf(n)}))},s=(i(" #"),i(" b"),/^([a-gA-G]?)(#{1,}|b{1,}|x{1,}|)(-?\d*)\s*(.*)$/);function a(e){"string"!=typeof e&&(e="");var t=s.exec(e);return[t[1].toUpperCase(),t[2].replace(/x/g,"##"),t[3],t[4]]}var u=Object.freeze({pc:null,name:null,step:null,alt:null,oct:null,octStr:null,chroma:null,midi:null,freq:null}),c=[0,2,4,5,7,9,11],l=function(e,t){return void 0===t&&(t={}),function(n){return t[n]||(t[n]=e(n))}}((function(e){var t=a(e);if(""===t[0]||""!==t[3])return u;var n=t[0],r=t[1],o=t[2],i={letter:n,acc:r,octStr:o,pc:n+r,name:n+r+o,step:(n.charCodeAt(0)+3)%7,alt:"b"===r[0]?-r.length:r.length,oct:o.length?+o:null,chroma:0,midi:null,freq:null};return i.chroma=(c[i.step]+i.alt+120)%12,i.midi=null!==i.oct?c[i.step]+i.alt+12*(i.oct+1):null,i.freq=p(i.midi),Object.freeze(i)})),p=function(e,t){return void 0===t&&(t=440),"number"==typeof e?Math.pow(2,(e-69)/12)*t:null},m=(Math.log(2),Math.log(440),function(e){return l(e).chroma}),f=function(e,t){return Array(t+1).join(e)},d=function(e,t){void 0===e&&(e={}),void 0===t&&(t=null);var n=t?Object.assign({},l(t),e):e,r=n.step,o=n.alt,i=n.oct;if("number"!=typeof r)return null;var s=function(e){return"CDEFGAB"[e]}(r);if(!s)return null;var a=s+function(e){return function(e,t){return"number"!=typeof e?"":t(e)}(e,(function(e){return e<0?f("b",-e):f("#",e)}))}(o);return i||0===i?a+i:a};var h=new RegExp("^([-+]?\\d+)(d{1,4}|m|M|P|A{1,4})|(AA|A|P|M|m|d|dd)([-+]?\\d+)$"),g=[0,2,4,5,7,9,11],_="PMMPPMM",y=("1P 2m 2M 3m 3M 4P 5P 6m 6M 7m 7M 8P".split(" "),Object.freeze({name:null,num:null,q:null,step:null,alt:null,dir:null,type:null,simple:null,semitones:null,chroma:null,oct:null})),S=function(e){return(Math.abs(e)-1)%7},P=function(e){var t=function(e){var t=h.exec(""+e);return null===t?null:t[1]?[t[1],t[2]]:[t[4],t[3]]}(e);if(null===t)return y;var n,r,o={num:0,q:"d",name:"",type:"M",step:0,dir:-1,simple:1,alt:0,oct:0,semitones:0,chroma:0,ic:0};return o.num=+t[0],o.q=t[1],o.step=S(o.num),o.type=_[o.step],"M"===o.type&&"P"===o.q?y:(o.name=""+o.num+o.q,o.dir=o.num<0?-1:1,o.simple=8===o.num||-8===o.num?o.num:o.dir*(o.step+1),o.alt=(n=o.type,"M"===(r=o.q)&&"M"===n||"P"===r&&"P"===n?0:"m"===r&&"M"===n?-1:/^A+$/.test(r)?r.length:/^d+$/.test(r)?"P"===n?-r.length:-r.length-1:null),o.oct=Math.floor((Math.abs(o.num)-1)/7),o.semitones=o.dir*(g[o.step]+o.alt+12*o.oct),o.chroma=(o.dir*(g[o.step]+o.alt)%12+12)%12,Object.freeze(o))},b={};function w(e){return"string"!=typeof e?y:b[e]||(b[e]=P(e))}"P m M m M P d P m M m M".split(" ");var M=[0,2,4,-1,1,3,5],N=M.map((function(e){return Math.floor(7*e/12)})),v=[3,0,4,1,5,2,6];var A=function(e,t,n){var r=v[function(e){var t=(e+1)%7;return t<0?7+t:t}(e)],o=Math.floor((e+1)/7);return void 0===t?{step:r,alt:o,dir:n}:{step:r,alt:o,oct:t+4*o+N[r],dir:n}},q=function(e){return function(e,t){return void 0===t&&(t={}),function(n){return t[n]||(t[n]=e(n))}}((function(t){var n=e(t);return null===n.name?null:function(e){var t=e.step,n=e.alt,r=e.oct,o=e.dir;void 0===o&&(o=1);var i=M[t]+7*n;return null===r?[o*i]:[o*i,o*(r-N[t]-4*n)]}(n)}))},O=q(l),T=q(w);function I(e,t){if(1===arguments.length)return function(t){return I(e,t)};var n=O(e),r=T(t);if(null===n||null===r)return null;var o=1===n.length?[n[0]+r[0]]:[n[0]+r[0],n[1]+r[1]];return d(A(o[0],o[1]))}const E=JSON.parse('{"chromatic":["1P 2m 2M 3m 3M 4P 4A 5P 6m 6M 7m 7M"],"lydian":["1P 2M 3M 4A 5P 6M 7M"],"major":["1P 2M 3M 4P 5P 6M 7M",["ionian"]],"mixolydian":["1P 2M 3M 4P 5P 6M 7m",["dominant"]],"dorian":["1P 2M 3m 4P 5P 6M 7m"],"aeolian":["1P 2M 3m 4P 5P 6m 7m",["minor"]],"phrygian":["1P 2m 3m 4P 5P 6m 7m"],"locrian":["1P 2m 3m 4P 5d 6m 7m"],"melodic minor":["1P 2M 3m 4P 5P 6M 7M"],"melodic minor second mode":["1P 2m 3m 4P 5P 6M 7m"],"lydian augmented":["1P 2M 3M 4A 5A 6M 7M"],"lydian dominant":["1P 2M 3M 4A 5P 6M 7m",["lydian b7"]],"melodic minor fifth mode":["1P 2M 3M 4P 5P 6m 7m",["hindu","mixolydian b6M"]],"locrian #2":["1P 2M 3m 4P 5d 6m 7m",["half-diminished"]],"altered":["1P 2m 3m 3M 5d 6m 7m",["super locrian","diminished whole tone","pomeroy"]],"harmonic minor":["1P 2M 3m 4P 5P 6m 7M"],"phrygian dominant":["1P 2m 3M 4P 5P 6m 7m",["spanish","phrygian major"]],"half-whole diminished":["1P 2m 3m 3M 4A 5P 6M 7m",["dominant diminished"]],"diminished":["1P 2M 3m 4P 5d 6m 6M 7M",["whole-half diminished"]],"major pentatonic":["1P 2M 3M 5P 6M",["pentatonic"]],"lydian pentatonic":["1P 3M 4A 5P 7M",["chinese"]],"mixolydian pentatonic":["1P 3M 4P 5P 7m",["indian"]],"locrian pentatonic":["1P 3m 4P 5d 7m",["minor seven flat five pentatonic"]],"minor pentatonic":["1P 3m 4P 5P 7m"],"minor six pentatonic":["1P 3m 4P 5P 6M"],"minor hexatonic":["1P 2M 3m 4P 5P 7M"],"flat three pentatonic":["1P 2M 3m 5P 6M",["kumoi"]],"flat six pentatonic":["1P 2M 3M 5P 6m"],"major flat two pentatonic":["1P 2m 3M 5P 6M"],"whole tone pentatonic":["1P 3M 5d 6m 7m"],"ionian pentatonic":["1P 3M 4P 5P 7M"],"lydian #5P pentatonic":["1P 3M 4A 5A 7M"],"lydian dominant pentatonic":["1P 3M 4A 5P 7m"],"minor #7M pentatonic":["1P 3m 4P 5P 7M"],"super locrian pentatonic":["1P 3m 4d 5d 7m"],"in-sen":["1P 2m 4P 5P 7m"],"iwato":["1P 2m 4P 5d 7m"],"hirajoshi":["1P 2M 3m 5P 6m"],"kumoijoshi":["1P 2m 4P 5P 6m"],"pelog":["1P 2m 3m 5P 6m"],"vietnamese 1":["1P 3m 4P 5P 6m"],"vietnamese 2":["1P 3m 4P 5P 7m"],"prometheus":["1P 2M 3M 4A 6M 7m"],"prometheus neopolitan":["1P 2m 3M 4A 6M 7m"],"ritusen":["1P 2M 4P 5P 6M"],"scriabin":["1P 2m 3M 5P 6M"],"piongio":["1P 2M 4P 5P 6M 7m"],"major blues":["1P 2M 3m 3M 5P 6M"],"minor blues":["1P 3m 4P 5d 5P 7m",["blues"]],"composite blues":["1P 2M 3m 3M 4P 5d 5P 6M 7m"],"augmented":["1P 2A 3M 5P 5A 7M"],"augmented heptatonic":["1P 2A 3M 4P 5P 5A 7M"],"dorian #4":["1P 2M 3m 4A 5P 6M 7m"],"lydian diminished":["1P 2M 3m 4A 5P 6M 7M"],"whole tone":["1P 2M 3M 4A 5A 7m"],"leading whole tone":["1P 2M 3M 4A 5A 7m 7M"],"lydian minor":["1P 2M 3M 4A 5P 6m 7m"],"locrian major":["1P 2M 3M 4P 5d 6m 7m",["arabian"]],"neopolitan":["1P 2m 3m 4P 5P 6m 7M"],"neopolitan minor":["1P 2m 3m 4P 5P 6m 7M"],"neopolitan major":["1P 2m 3m 4P 5P 6M 7M",["dorian b2"]],"neopolitan major pentatonic":["1P 3M 4P 5d 7m"],"romanian minor":["1P 2M 3m 5d 5P 6M 7m"],"double harmonic lydian":["1P 2m 3M 4A 5P 6m 7M"],"harmonic major":["1P 2M 3M 4P 5P 6m 7M"],"double harmonic major":["1P 2m 3M 4P 5P 6m 7M",["gypsy"]],"egyptian":["1P 2M 4P 5P 7m"],"hungarian minor":["1P 2M 3m 4A 5P 6m 7M"],"hungarian major":["1P 2A 3M 4A 5P 6M 7m"],"oriental":["1P 2m 3M 4P 5d 6M 7m"],"spanish heptatonic":["1P 2m 3m 3M 4P 5P 6m 7m"],"flamenco":["1P 2m 3m 3M 4A 5P 7m"],"balinese":["1P 2m 3m 4P 5P 6m 7M"],"todi raga":["1P 2m 3m 4A 5P 6m 7M"],"malkos raga":["1P 3m 4P 6m 7m"],"kafi raga":["1P 3m 3M 4P 5P 6M 7m 7M"],"purvi raga":["1P 2m 3M 4P 4A 5P 6m 7M"],"persian":["1P 2m 3M 4P 5d 6m 7M"],"bebop":["1P 2M 3M 4P 5P 6M 7m 7M"],"bebop dominant":["1P 2M 3M 4P 5P 6M 7m 7M"],"bebop minor":["1P 2M 3m 3M 4P 5P 6M 7m"],"bebop major":["1P 2M 3M 4P 5P 5A 6M 7M"],"bebop locrian":["1P 2m 3m 4P 5d 5P 6m 7m"],"minor bebop":["1P 2M 3m 4P 5P 6m 7m 7M"],"mystery #1":["1P 2m 3M 5d 6m 7m"],"enigmatic":["1P 2m 3M 5d 6m 7m 7M"],"minor six diminished":["1P 2M 3m 4P 5P 6m 6M 7M"],"ionian augmented":["1P 2M 3M 4P 5A 6M 7M"],"lydian #9":["1P 2m 3M 4A 5P 6M 7M"],"ichikosucho":["1P 2M 3M 4P 5d 5P 6M 7M"],"six tone symmetric":["1P 2m 3M 4P 5A 6M"]}'),j=JSON.parse('{"4":["1P 4P 7m 10m",["quartal"]],"5":["1P 5P"],"7":["1P 3M 5P 7m",["Dominant","Dom"]],"9":["1P 3M 5P 7m 9M",["79"]],"11":["1P 5P 7m 9M 11P"],"13":["1P 3M 5P 7m 9M 13M",["13_"]],"64":["5P 8P 10M"],"M":["1P 3M 5P",["Major",""]],"M#5":["1P 3M 5A",["augmented","maj#5","Maj#5","+","aug"]],"M#5add9":["1P 3M 5A 9M",["+add9"]],"M13":["1P 3M 5P 7M 9M 13M",["maj13","Maj13"]],"M13#11":["1P 3M 5P 7M 9M 11A 13M",["maj13#11","Maj13#11","M13+4","M13#4"]],"M6":["1P 3M 5P 13M",["6"]],"M6#11":["1P 3M 5P 6M 11A",["M6b5","6#11","6b5"]],"M69":["1P 3M 5P 6M 9M",["69"]],"M69#11":["1P 3M 5P 6M 9M 11A"],"M7#11":["1P 3M 5P 7M 11A",["maj7#11","Maj7#11","M7+4","M7#4"]],"M7#5":["1P 3M 5A 7M",["maj7#5","Maj7#5","maj9#5","M7+"]],"M7#5sus4":["1P 4P 5A 7M"],"M7#9#11":["1P 3M 5P 7M 9A 11A"],"M7add13":["1P 3M 5P 6M 7M 9M"],"M7b5":["1P 3M 5d 7M"],"M7b6":["1P 3M 6m 7M"],"M7b9":["1P 3M 5P 7M 9m"],"M7sus4":["1P 4P 5P 7M"],"M9":["1P 3M 5P 7M 9M",["maj9","Maj9"]],"M9#11":["1P 3M 5P 7M 9M 11A",["maj9#11","Maj9#11","M9+4","M9#4"]],"M9#5":["1P 3M 5A 7M 9M",["Maj9#5"]],"M9#5sus4":["1P 4P 5A 7M 9M"],"M9b5":["1P 3M 5d 7M 9M"],"M9sus4":["1P 4P 5P 7M 9M"],"Madd9":["1P 3M 5P 9M",["2","add9","add2"]],"Maj7":["1P 3M 5P 7M",["maj7","M7"]],"Mb5":["1P 3M 5d"],"Mb6":["1P 3M 13m"],"Msus2":["1P 2M 5P",["add9no3","sus2"]],"Msus4":["1P 4P 5P",["sus","sus4"]],"Maddb9":["1P 3M 5P 9m"],"11b9":["1P 5P 7m 9m 11P"],"13#11":["1P 3M 5P 7m 9M 11A 13M",["13+4","13#4"]],"13#9":["1P 3M 5P 7m 9A 13M",["13#9_"]],"13#9#11":["1P 3M 5P 7m 9A 11A 13M"],"13b5":["1P 3M 5d 6M 7m 9M"],"13b9":["1P 3M 5P 7m 9m 13M"],"13b9#11":["1P 3M 5P 7m 9m 11A 13M"],"13no5":["1P 3M 7m 9M 13M"],"13sus4":["1P 4P 5P 7m 9M 13M",["13sus"]],"69#11":["1P 3M 5P 6M 9M 11A"],"7#11":["1P 3M 5P 7m 11A",["7+4","7#4","7#11_","7#4_"]],"7#11b13":["1P 3M 5P 7m 11A 13m",["7b5b13"]],"7#5":["1P 3M 5A 7m",["+7","7aug","aug7"]],"7#5#9":["1P 3M 5A 7m 9A",["7alt","7#5#9_","7#9b13_"]],"7#5b9":["1P 3M 5A 7m 9m"],"7#5b9#11":["1P 3M 5A 7m 9m 11A"],"7#5sus4":["1P 4P 5A 7m"],"7#9":["1P 3M 5P 7m 9A",["7#9_"]],"7#9#11":["1P 3M 5P 7m 9A 11A",["7b5#9"]],"7#9#11b13":["1P 3M 5P 7m 9A 11A 13m"],"7#9b13":["1P 3M 5P 7m 9A 13m"],"7add6":["1P 3M 5P 7m 13M",["67","7add13"]],"7b13":["1P 3M 7m 13m"],"7b5":["1P 3M 5d 7m"],"7b6":["1P 3M 5P 6m 7m"],"7b9":["1P 3M 5P 7m 9m"],"7b9#11":["1P 3M 5P 7m 9m 11A",["7b5b9"]],"7b9#9":["1P 3M 5P 7m 9m 9A"],"7b9b13":["1P 3M 5P 7m 9m 13m"],"7b9b13#11":["1P 3M 5P 7m 9m 11A 13m",["7b9#11b13","7b5b9b13"]],"7no5":["1P 3M 7m"],"7sus4":["1P 4P 5P 7m",["7sus"]],"7sus4b9":["1P 4P 5P 7m 9m",["susb9","7susb9","7b9sus","7b9sus4","phryg"]],"7sus4b9b13":["1P 4P 5P 7m 9m 13m",["7b9b13sus4"]],"9#11":["1P 3M 5P 7m 9M 11A",["9+4","9#4","9#11_","9#4_"]],"9#11b13":["1P 3M 5P 7m 9M 11A 13m",["9b5b13"]],"9#5":["1P 3M 5A 7m 9M",["9+"]],"9#5#11":["1P 3M 5A 7m 9M 11A"],"9b13":["1P 3M 7m 9M 13m"],"9b5":["1P 3M 5d 7m 9M"],"9no5":["1P 3M 7m 9M"],"9sus4":["1P 4P 5P 7m 9M",["9sus"]],"m":["1P 3m 5P"],"m#5":["1P 3m 5A",["m+","mb6"]],"m11":["1P 3m 5P 7m 9M 11P",["_11"]],"m11A 5":["1P 3m 6m 7m 9M 11P"],"m11b5":["1P 3m 7m 12d 2M 4P",["h11","_11b5"]],"m13":["1P 3m 5P 7m 9M 11P 13M",["_13"]],"m6":["1P 3m 4P 5P 13M",["_6"]],"m69":["1P 3m 5P 6M 9M",["_69"]],"m7":["1P 3m 5P 7m",["minor7","_","_7"]],"m7#5":["1P 3m 6m 7m"],"m7add11":["1P 3m 5P 7m 11P",["m7add4"]],"m7b5":["1P 3m 5d 7m",["half-diminished","h7","_7b5"]],"m9":["1P 3m 5P 7m 9M",["_9"]],"m9#5":["1P 3m 6m 7m 9M"],"m9b5":["1P 3m 7m 12d 2M",["h9","-9b5"]],"mMaj7":["1P 3m 5P 7M",["mM7","_M7"]],"mMaj7b6":["1P 3m 5P 6m 7M",["mM7b6"]],"mM9":["1P 3m 5P 7M 9M",["mMaj9","-M9"]],"mM9b6":["1P 3m 5P 6m 7M 9M",["mMaj9b6"]],"mb6M7":["1P 3m 6m 7M"],"mb6b9":["1P 3m 6m 9m"],"o":["1P 3m 5d",["mb5","dim"]],"o7":["1P 3m 5d 13M",["diminished","m6b5","dim7"]],"o7M7":["1P 3m 5d 6M 7M"],"oM7":["1P 3m 5d 7M"],"sus24":["1P 2M 4P 5P",["sus4add9"]],"+add#9":["1P 3M 5A 9A"],"madd4":["1P 3m 4P 5P"],"madd9":["1P 3m 5P 9M"]}');var z=function(e){return m(e)||function(e){return w(e).chroma}(e)||0};function k(e){if(D(e))return e;if(!Array.isArray(e))return"";var t=[0,0,0,0,0,0,0,0,0,0,0,0];return e.map(z).forEach((function(e){t[e]=1})),t.join("")}var x=/^[01]{12}$/;function D(e){return x.test(e)}"1P 2m 2M 3m 3M 4P 5d 5P 6m 6M 7m 7M".split(" ");var C,L,R,B=function(e){var t=Object.keys(e).sort(),n=[],r=[],o=function(e,t,o){n[e]=t,r[o]=r[o]||[],r[o].push(e)};t.forEach((function(t){var n=e[t][0].split(" "),r=e[t][1],i=k(n);o(t,n,i),r&&r.forEach((function(e){return o(e,n,i)}))}));var i=Object.keys(n).sort(),s=function(e){return n[e]};return s.names=function(e){return"string"==typeof e?(r[e]||[]).slice():(!0===e?i:t).slice()},s},F=B(E),Q=B(j),G=(C=F,L=Q,(R=function(e){return C(e)||L(e)}).names=function(e){return C.names(e).concat(L.names(e))},Object.freeze({name:null,intervals:[],names:[],chroma:null,setnum:null}));F.names;Q.names;var U=Object.freeze({name:null,names:[],intervals:[],chroma:null,setnum:null}),H=function(e,t){return void 0===t&&(t={}),function(n){return t[n]||(t[n]=e(n))}}((function(e){var t=Q(e);if(!t)return U;var n={intervals:t,name:e};return n.chroma=k(t),n.setnum=parseInt(n.chroma,2),n.names=Q.names(n.chroma),n})),V=function(e){return H(J(e)[1]).intervals};var $=function(e){return void 0!==Q(J(e)[1])},W=/^(6|64|7|9|11|13)$/;function J(e){var t=a(e);return""===t[0]?["",e]:"A"===t[0]&&"ug"===t[3]?["","aug"]:W.test(t[2])?[t[0]+t[1],t[2]+t[3]]:[t[0]+t[1]+t[2],t[3]]}var K=n(5447);const Y=[["1P","3M","5P"],["1P","3m","5P"],["1P","3M","5A"],["1P","3m","5d"]];var X;!function(e){e[e.Major=0]="Major",e[e.Minor=1]="Minor",e[e.Augmented=2]="Augmented",e[e.Diminished=3]="Diminished",e[e.Other=4]="Other"}(X||(X={}));class Z extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class ee extends Error{constructor(e){super(e),Object.setPrototypeOf(this,new.target.prototype)}}class te{static pitches(e){if(!J(e)[0]||!$(e))throw new Z(`Unrecognized chord symbol: ${e}`);return function(e,t){if(t)return H(t).intervals.map(I(e));var n=J(e),r=n[0],o=n[1];return H(o).intervals.map(I(r))}(e).map(m)}static root(e){const t=J(e)[0];if(!t)throw new Z(`Chord symbol has unknown root: ${e}`);return m(t)}static quality(e){if(!$(e))throw new Z(`Unrecognized chord symbol: ${e}`);const t=V(e),n=Y.map((e=>e.every((e=>t.includes(e))))),r=n.indexOf(!0),o=n.lastIndexOf(!0);return r>=0&&r===o?r:X.Other}}class ne{encodeProgression(e,t){const n=e.map((e=>this.encode(e))),o=Array.from(Array(t).keys()).map((e=>Math.floor(e*n.length/t)));return r.stack(o.map((e=>n[e])))}}function re(e){switch(e){case"MajorMinorChordEncoder":return new oe;case"TriadChordEncoder":return new ie;case"PitchChordEncoder":return new se;default:throw new Error(`Unknown chord encoder type: ${e}`)}}class oe extends ne{depth=1+2*K.NUM_PITCH_CLASSES;index(e){if(e===K.NO_CHORD)return 0;const t=te.root(e),n=1+te.quality(e)*K.NUM_PITCH_CLASSES+t;if(n>=this.depth)throw new ee(`Chord is neither major nor minor: ${e}`);return n}encode(e){return r.tidy((()=>r.oneHot(r.tensor1d([this.index(e)],"int32"),this.depth).as1D()))}}class ie extends ne{depth=1+4*K.NUM_PITCH_CLASSES;index(e){if(e===K.NO_CHORD)return 0;const t=te.root(e),n=1+te.quality(e)*K.NUM_PITCH_CLASSES+t;if(n>=this.depth)throw new ee(`Chord is not a standard triad: ${e}`);return n}encode(e){return r.tidy((()=>r.oneHot(r.tensor1d([this.index(e)],"int32"),this.depth).as1D()))}}class se extends ne{depth=1+3*K.NUM_PITCH_CLASSES;encode(e){return r.tidy((()=>{if(e===K.NO_CHORD)return r.oneHot(r.tensor1d([0],"int32"),this.depth).as1D();const t=te.root(e),n=r.oneHot(r.tensor1d([t],"int32"),K.NUM_PITCH_CLASSES).as1D(),o=r.buffer([K.NUM_PITCH_CLASSES]);te.pitches(e).forEach((e=>o.set(1,e)));const i=o.toTensor().as1D(),s=n;return r.concat1d([r.tensor1d([0]),n,i,s])}))}}},3918:(e,t,n)=>{n.r(t),n.d(t,{now:()=>o,timing:()=>i});const r=global.process.hrtime(),o=()=>{const e=global.process.hrtime(r);return e[0]+e[1]/1e9},i={navigationStart:Date.now()}},3920:(e,t,n)=>{n.d(t,{Performance:()=>a});var r=n(1758),o=n(5447),i=n(2596),s=n(8171);class a{events;maxShiftSteps;numVelocityBins;program;isDrum;constructor(e,t,n,r,o){this.events=e,this.maxShiftSteps=t,this.numVelocityBins=n,this.program=r,this.isDrum=o}static fromNoteSequence(e,t,n,r){i.assertIsQuantizedSequence(e);const s=e.notes.filter(((e,t)=>void 0===r||e.instrument===r)),u=s.sort(((e,t)=>e.startTime===t.startTime?e.pitch-t.pitch:e.startTime-t.startTime)),c=u.map(((e,t)=>({step:e.quantizedStartStep,index:t,isOffset:0}))),l=u.map(((e,t)=>({step:e.quantizedEndStep,index:t,isOffset:1}))),p=c.concat(l).sort(((e,t)=>e.step===t.step?e.index===t.index?e.isOffset-t.isOffset:e.index-t.index:e.step-t.step)),m=n?Math.ceil((o.MIDI_VELOCITIES-1)/n):void 0,f=[];let d=0,h=n;for(const e of p){if(e.step>d){for(;e.step>d+t;)f.push({type:"time-shift",steps:t}),d+=t;f.push({type:"time-shift",steps:e.step-d}),d=e.step}if(e.isOffset)f.push({type:"note-off",pitch:u[e.index].pitch});else{if(m){const t=Math.floor((u[e.index].velocity-o.MIN_MIDI_VELOCITY-1)/m)+1;t!==h&&(f.push({type:"velocity-change",velocityBin:t}),h=t)}f.push({type:"note-on",pitch:u[e.index].pitch})}}const g=!!s.some((e=>e.isDrum))&&(!s.some((e=>!e.isDrum))||void 0),_=Array.from(new Set(s.map((e=>e.program)))),y=g||1!==_.length?void 0:_[0],S=new a(f,t,n,y,g);return S.setNumSteps(e.totalQuantizedSteps),S}getNumSteps(){return this.events.filter((e=>"time-shift"===e.type)).map((e=>e.steps)).reduce(((e,t)=>e+t),0)}setNumSteps(e){let t=this.getNumSteps();if(t<e){if(this.events.length){const n=this.events[this.events.length-1];if("time-shift"===n.type){const r=Math.min(e-t,this.maxShiftSteps-n.steps);n.steps+=r,t+=r}}for(;t<e;)t+this.maxShiftSteps>e?(this.events.push({type:"time-shift",steps:e-t}),t=e):(this.events.push({type:"time-shift",steps:this.maxShiftSteps}),t+=this.maxShiftSteps)}else if(t>e)for(;this.events.length&&t>e;){const n=this.events[this.events.length-1];"time-shift"===n.type?t-n.steps<e?(n.steps-=t-e,t=e):(this.events.pop(),t-=n.steps):this.events.pop()}}toNoteSequence(e){const t=this.numVelocityBins?Math.ceil((o.MIDI_VELOCITIES-1)/this.numVelocityBins):void 0,n=r.A.create();let i,a=0;const u=new Map;for(let e=o.MIN_MIDI_PITCH;e<=o.MAX_MIDI_PITCH;++e)u.set(e,[]);for(const c of this.events)switch(c.type){case"note-on":u.get(c.pitch).push([a,i]);break;case"note-off":{const t=u.get(c.pitch);if(t.length){const[o,i]=t.shift();a>o?n.notes.push(r.A.Note.create({pitch:c.pitch,velocity:i,instrument:e,quantizedStartStep:o,quantizedEndStep:a,program:this.program,isDrum:this.isDrum})):s.log(`Ignoring zero-length note: (pitch = ${c.pitch}, step = ${a})`,"Performance")}else s.log(`Ignoring note-off with no previous note-on:(pitch = ${c.pitch}, step = ${a})`,"Performance");break}case"time-shift":a+=c.steps;break;case"velocity-change":if(!t)throw new Error(`Unexpected velocity change event: ${c}`);i=o.MIN_MIDI_VELOCITY+(c.velocityBin-1)*t+1;break;default:throw new Error(`Unrecognized performance event: ${c}`)}return u.forEach(((t,o)=>{for(const[i,u]of t)a>i?n.notes.push(r.A.Note.create({pitch:o,velocity:u,instrument:e,quantizedStartStep:i,quantizedEndStep:a,program:this.program,isDrum:this.isDrum})):s.log(`Ignoring zero-length note: (pitch = ${o}, step = ${a})`,"Performance")})),n.totalQuantizedSteps=a,n}}},4010:(e,t,n)=>{e.exports=i;var r=n(1137);(i.prototype=Object.create(r.prototype)).constructor=i;var o=n(5382);function i(e){r.call(this,e)}i._configure=function(){o.Buffer&&(i.prototype._slice=o.Buffer.prototype.slice)},i.prototype.string=function(){var e=this.uint32();return this.buf.utf8Slice?this.buf.utf8Slice(this.pos,this.pos=Math.min(this.pos+e,this.len)):this.buf.toString("utf-8",this.pos,this.pos=Math.min(this.pos+e,this.len))},i._configure()},4110:(e,t,n)=>{e.exports=n(7134)},4226:e=>{e.exports=function(e,t,n){var r=n||8192,o=r>>>1,i=null,s=r;return function(n){if(n<1||n>o)return e(n);s+n>r&&(i=e(r),s=0);var a=t.call(i,s,s+=n);return 7&s&&(s=1+(7|s)),a}}},4301:(e,t,n)=>{e.exports=p;var r,o=n(5382),i=o.LongBits,s=o.base64,a=o.utf8;function u(e,t,n){this.fn=e,this.len=t,this.next=void 0,this.val=n}function c(){}function l(e){this.head=e.head,this.tail=e.tail,this.len=e.len,this.next=e.states}function p(){this.len=0,this.head=new u(c,0,0),this.tail=this.head,this.states=null}var m=function(){return o.Buffer?function(){return(p.create=function(){return new r})()}:function(){return new p}};function f(e,t,n){t[n]=255&e}function d(e,t){this.len=e,this.next=void 0,this.val=t}function h(e,t,n){for(;e.hi;)t[n++]=127&e.lo|128,e.lo=(e.lo>>>7|e.hi<<25)>>>0,e.hi>>>=7;for(;e.lo>127;)t[n++]=127&e.lo|128,e.lo=e.lo>>>7;t[n++]=e.lo}function g(e,t,n){t[n]=255&e,t[n+1]=e>>>8&255,t[n+2]=e>>>16&255,t[n+3]=e>>>24}p.create=m(),p.alloc=function(e){return new o.Array(e)},o.Array!==Array&&(p.alloc=o.pool(p.alloc,o.Array.prototype.subarray)),p.prototype._push=function(e,t,n){return this.tail=this.tail.next=new u(e,t,n),this.len+=t,this},d.prototype=Object.create(u.prototype),d.prototype.fn=function(e,t,n){for(;e>127;)t[n++]=127&e|128,e>>>=7;t[n]=e},p.prototype.uint32=function(e){return this.len+=(this.tail=this.tail.next=new d((e>>>=0)<128?1:e<16384?2:e<2097152?3:e<268435456?4:5,e)).len,this},p.prototype.int32=function(e){return e<0?this._push(h,10,i.fromNumber(e)):this.uint32(e)},p.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},p.prototype.uint64=function(e){var t=i.from(e);return this._push(h,t.length(),t)},p.prototype.int64=p.prototype.uint64,p.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(h,t.length(),t)},p.prototype.bool=function(e){return this._push(f,1,e?1:0)},p.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},p.prototype.sfixed32=p.prototype.fixed32,p.prototype.fixed64=function(e){var t=i.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},p.prototype.sfixed64=p.prototype.fixed64,p.prototype.float=function(e){return this._push(o.float.writeFloatLE,4,e)},p.prototype.double=function(e){return this._push(o.float.writeDoubleLE,8,e)};var _=o.Array.prototype.set?function(e,t,n){t.set(e,n)}:function(e,t,n){for(var r=0;r<e.length;++r)t[n+r]=e[r]};p.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(f,1,0);if(o.isString(e)){var n=p.alloc(t=s.length(e));s.decode(e,n,0),e=n}return this.uint32(t)._push(_,t,e)},p.prototype.string=function(e){var t=a.length(e);return t?this.uint32(t)._push(a.write,t,e):this._push(f,1,0)},p.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new u(c,0,0),this.len=0,this},p.prototype.reset=function(){return this.states?(this.head=this.states.head,this.tail=this.states.tail,this.len=this.states.len,this.states=this.states.next):(this.head=this.tail=new u(c,0,0),this.len=0),this},p.prototype.ldelim=function(){var e=this.head,t=this.tail,n=this.len;return this.reset().uint32(n),n&&(this.tail.next=e.next,this.tail=t,this.len+=n),this},p.prototype.finish=function(){for(var e=this.head.next,t=this.constructor.alloc(this.len),n=0;e;)e.fn(e.val,t,n),n+=e.len,e=e.next;return t},p._configure=function(e){r=e,p.create=m(),r._configure()}},4447:(e,t,n)=>{e.exports=o;var r=n(5382);function o(e,t,n){if("function"!=typeof e)throw TypeError("rpcImpl must be a function");r.EventEmitter.call(this),this.rpcImpl=e,this.requestDelimited=Boolean(t),this.responseDelimited=Boolean(n)}(o.prototype=Object.create(r.EventEmitter.prototype)).constructor=o,o.prototype.rpcCall=function e(t,n,o,i,s){if(!i)throw TypeError("request must be specified");var a=this;if(!s)return r.asPromise(e,a,t,n,o,i);if(a.rpcImpl)try{return a.rpcImpl(t,n[a.requestDelimited?"encodeDelimited":"encode"](i).finish(),(function(e,n){if(e)return a.emit("error",e,t),s(e);if(null!==n){if(!(n instanceof o))try{n=o[a.responseDelimited?"decodeDelimited":"decode"](n)}catch(e){return a.emit("error",e,t),s(e)}return a.emit("data",n,t),s(null,n)}a.end(!0)}))}catch(e){return a.emit("error",e,t),void setTimeout((function(){s(e)}),0)}else setTimeout((function(){s(Error(