PageSourceSearch

https://conversiontab.com/build/assets/Midi-CsDqNmfP.js

js conversiontab.com collected 2026-09-24 10:08:32 UTC 32,160 bytes, 1 lines download raw bytes

1import{a as Y,c as C,g as Z}from"./_commonjsHelpers-BosuxZz1.js";function $(e,t){for(var n=0;n<t.length;n++){const i=t[n];if(typeof i!="string"&&!Array.isArray(i)){for(const a in i)if(a!=="default"&&!(a in e)){const o=Object.getOwnPropertyDescriptor(i,a);o&&Object.defineProperty(e,a,o.get?o:{enumerable:!0,get:()=>i[a]})}}}return Object.freeze(Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}))}var W={},j={};function ee(e){var t=new I(e),n=t.readChunk();if(n.id!="MThd")throw"Bad MIDI file.  Expected 'MHdr', got: '"+n.id+"'";for(var i=te(n.data),a=[],o=0;!t.eof()&&o<i.numTracks;o++){var r=t.readChunk();if(r.id!="MTrk")throw"Bad MIDI file.  Expected 'MTrk', got: '"+r.id+"'";var f=re(r.data);a.push(f)}return{header:i,tracks:a}}function te(e){var t=new I(e),n=t.readUInt16(),i=t.readUInt16(),a={format:n,numTracks:i},o=t.readUInt16();return o&32768?(a.framesPerSecond=256-(o>>8),a.ticksPerFrame=o&255):a.ticksPerBeat=o,a}function re(e){for(var t=new I(e),n=[];!t.eof();){var i=o();n.push(i)}return n;var a;function o(){var r={};r.deltaTime=t.readVarInt();var f=t.readUInt8();if((f&240)===240)if(f===255){r.meta=!0;var c=t.readUInt8(),u=t.readVarInt();switch(c){case 0:if(r.type="sequenceNumber",u!==2)throw"Expected length for sequenceNumber event is 2, got "+u;return r.number=t.readUInt16(),r;case 1:return r.type="text",r.text=t.readString(u),r;case 2:return r.type="copyrightNotice",r.text=t.readString(u),r;case 3:return r.type="trackName",r.text=t.readString(u),r;case 4:return r.type="instrumentName",r.text=t.readString(u),r;case 5:return r.type="lyrics",r.text=t.readString(u),r;case 6:return r.type="marker",r.text=t.readString(u),r;case 7:return r.type="cuePoint",r.text=t.readString(u),r;case 32:if(r.type="channelPrefix",u!=1)throw"Expected length for channelPrefix event is 1, got "+u;return r.channel=t.readUInt8(),r;case 33:if(r.type="portPrefix",u!=1)throw"Expected length for portPrefix event is 1, got "+u;return r.port=t.readUInt8(),r;case 47:if(r.type="endOfTrack",u!=0)throw"Expected length for endOfTrack event is 0, got "+u;return r;case 81:if(r.type="setTempo",u!=3)throw"Expected length for setTempo event is 3, got "+u;return r.microsecondsPerBeat=t.readUInt24(),r;case 84:if(r.type="smpteOffset",u!=5)throw"Expected length for smpteOffset event is 5, got "+u;var y=t.readUInt8(),p={0:24,32:25,64:29,96:30};return r.frameRate=p[y&96],r.hour=y&31,r.min=t.readUInt8(),r.sec=t.readUInt8(),r.frame=t.readUInt8(),r.subFrame=t.readUInt8(),r;case 88:if(r.type="timeSignature",u!=2&&u!=4)throw"Expected length for timeSignature event is 4 or 2, got "+u;return r.numerator=t.readUInt8(),r.denominator=1<<t.readUInt8(),u===4?(r.metronome=t.readUInt8(),r.thirtyseconds=t.readUInt8()):(r.metronome=36,r.thirtyseconds=8),r;case 89:if(r.type="keySignature",u!=2)throw"Expected length for keySignature event is 2, got "+u;return r.key=t.readInt8(),r.scale=t.readUInt8(),r;case 127:return r.type="sequencerSpecific",r.data=t.readBytes(u),r;default:return r.type="unknownMeta",r.data=t.readBytes(u),r.metatypeByte=c,r}}else if(f==240){r.type="sysEx";var u=t.readVarInt();return r.data=t.readBytes(u),r}else if(f==247){r.type="endSysEx";var u=t.readVarInt();return r.data=t.readBytes(u),r}else throw"Unrecognised MIDI event type byte: "+f;else{var s;if(f&128)s=t.readUInt8(),a=f;else{if(a===null)throw"Running status byte encountered before status byte";s=f,f=a,r.running=!0}var h=f>>4;switch(r.channel=f&15,h){case 8:return r.type="noteOff",r.noteNumber=s,r.velocity=t.readUInt8(),r;case 9:var m=t.readUInt8();return r.type=m===0?"noteOff":"noteOn",r.noteNumber=s,r.velocity=m,m===0&&(r.byte9=!0),r;case 10:return r.type="noteAftertouch",r.noteNumber=s,r.amount=t.readUInt8(),r;case 11:return r.type="controller",r.controllerType=s,r.value=t.readUInt8(),r;case 12:return r.type="programChange",r.programNumber=s,r;case 13:return r.type="channelAftertouch",r.amount=s,r;case 14:return r.type="pitchBend",r.value=s+(t.readUInt8()<<7)-8192,r;default:throw"Unrecognised MIDI event type: "+h}}}}function I(e){this.buffer=e,this.bufferLen=this.buffer.length,this.pos=0}I.prototype.eof=function(){return this.pos>=this.bufferLen};I.prototype.readUInt8=function(){var e=this.buffer[this.pos];return this.pos+=1,e};I.prototype.readInt8=function(){var e=this.readUInt8();return e&128?e-256:e};I.prototype.readUInt16=function(){var e=this.readUInt8(),t=this.readUInt8();return(e<<8)+t};I.prototype.readInt16=function(){var e=this.readUInt16();return e&32768?e-65536:e};I.prototype.readUInt24=function(){var e=this.readUInt8(),t=this.readUInt8(),n=this.readUInt8();return(e<<16)+(t<<8)+n};I.prototype.readInt24=function(){var e=this.readUInt24();return e&8388608?e-16777216:e};I.prototype.readUInt32=function(){var e=this.readUInt8(),t=this.readUInt8(),n=this.readUInt8(),i=this.readUInt8();return(e<<24)+(t<<16)+(n<<8)+i};I.prototype.readBytes=function(e){var t=this.buffer.slice(this.pos,this.pos+e);return this.pos+=e,t};I.prototype.readString=function(e){var t=this.readBytes(e);return String.fromCharCode.apply(null,t)};I.prototype.readVarInt=function(){for(var e=0;!this.eof();){var t=this.readUInt8();if(t&128)e+=t&127,e<<=7;else return e+t}return e};I.prototype.readChunk=function(){var e=this.readString(4),t=this.readUInt32(),n=this.readBytes(t);return{id:e,length:t,data:n}};var ne=ee;function ie(e,t){if(typeof e!="object")throw"Invalid MIDI data";t=t||{};var n=e.header||{},i=e.tracks||[],a,o=i.length,r=new g;for(ae(r,n,o),a=0;a<o;a++)oe(r,i[a],t);return r.buffer}function ae(e,t,n){var i=t.format==null?1:t.format,a=128;t.timeDivision?a=t.timeDivision:t.ticksPerFrame&&t.framesPerSecond?a=-(t.framesPerSecond&255)<<8|t.ticksPerFrame&255:t.ticksPerBeat&&(a=t.ticksPerBeat&32767);var o=new g;o.writeUInt16(i),o.writeUInt16(n),o.writeUInt16(a),e.writeChunk("MThd",o.buffer)}function oe(e,t,n){var i=new g,a,o=t.length,r=null;for(a=0;a<o;a++)(n.running===!1||!n.running&&!t[a].running)&&(r=null),r=se(i,t[a],r,n.useByte9ForNoteOff);e.writeChunk("MTrk",i.buffer)}function se(e,t,n,i){var a=t.type,o=t.deltaTime,r=t.text||"",f=t.data||[],c=null;switch(e.writeVarInt(o),a){case"sequenceNumber":e.writeUInt8(255),e.writeUInt8(0),e.writeVarInt(2),e.writeUInt16(t.number);break;case"text":e.writeUInt8(255),e.writeUInt8(1),e.writeVarInt(r.length),e.writeString(r);break;case"copyrightNotice":e.writeUInt8(255),e.writeUInt8(2),e.writeVarInt(r.length),e.writeString(r);break;case"trackName":e.writeUInt8(255),e.writeUInt8(3),e.writeVarInt(r.length),e.writeString(r);break;case"instrumentName":e.writeUInt8(255),e.writeUInt8(4),e.writeVarInt(r.length),e.writeString(r);break;case"lyrics":e.writeUInt8(255),e.writeUInt8(5),e.writeVarInt(r.length),e.writeString(r);break;case"marker":e.writeUInt8(255),e.writeUInt8(6),e.writeVarInt(r.length),e.writeString(r);break;case"cuePoint":e.writeUInt8(255),e.writeUInt8(7),e.writeVarInt(r.length),e.writeString(r);break;case"channelPrefix":e.writeUInt8(255),e.writeUInt8(32),e.writeVarInt(1),e.writeUInt8(t.channel);break;case"portPrefix":e.writeUInt8(255),e.writeUInt8(33),e.writeVarInt(1),e.writeUInt8(t.port);break;case"endOfTrack":e.writeUInt8(255),e.writeUInt8(47),e.writeVarInt(0);break;case"setTempo":e.writeUInt8(255),e.writeUInt8(81),e.writeVarInt(3),e.writeUInt24(t.microsecondsPerBeat);break;case"smpteOffset":e.writeUInt8(255),e.writeUInt8(84),e.writeVarInt(5);var u={24:0,25:32,29:64,30:96},y=t.hour&31|u[t.frameRate];e.writeUInt8(y),e.writeUInt8(t.min),e.writeUInt8(t.sec),e.writeUInt8(t.frame),e.writeUInt8(t.subFrame);break;case"timeSignature":e.writeUInt8(255),e.writeUInt8(88),e.writeVarInt(4),e.writeUInt8(t.numerator);var p=Math.floor(Math.log(t.denominator)/Math.LN2)&255;e.writeUInt8(p),e.writeUInt8(t.metronome),e.writeUInt8(t.thirtyseconds||8);break;case"keySignature":e.writeUInt8(255),e.writeUInt8(89),e.writeVarInt(2),e.writeInt8(t.key),e.writeUInt8(t.scale);break;case"sequencerSpecific":e.writeUInt8(255),e.writeUInt8(127),e.writeVarInt(f.length),e.writeBytes(f);break;case"unknownMeta":t.metatypeByte!=null&&(e.writeUInt8(255),e.writeUInt8(t.metatypeByte),e.writeVarInt(f.length),e.writeBytes(f));break;case"sysEx":e.writeUInt8(240),e.writeVarInt(f.length),e.writeBytes(f);break;
1case"endSysEx":e.writeUInt8(247),e.writeVarInt(f.length),e.writeBytes(f);break;case"noteOff":var s=i!==!1&&t.byte9||i&&t.velocity==0?144:128;c=s|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.velocity);break;case"noteOn":c=144|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.velocity);break;case"noteAftertouch":c=160|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.noteNumber),e.writeUInt8(t.amount);break;case"controller":c=176|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.controllerType),e.writeUInt8(t.value);break;case"programChange":c=192|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.programNumber);break;case"channelAftertouch":c=208|t.channel,c!==n&&e.writeUInt8(c),e.writeUInt8(t.amount);break;case"pitchBend":c=224|t.channel,c!==n&&e.writeUInt8(c);var h=8192+t.value,m=h&127,b=h>>7&127;e.writeUInt8(m),e.writeUInt8(b);break;default:throw"Unrecognized event type: "+a}return c}function g(){this.buffer=[]}g.prototype.writeUInt8=function(e){this.buffer.push(e&255)};g.prototype.writeInt8=g.prototype.writeUInt8;g.prototype.writeUInt16=function(e){var t=e>>8&255,n=e&255;this.writeUInt8(t),this.writeUInt8(n)};g.prototype.writeInt16=g.prototype.writeUInt16;g.prototype.writeUInt24=function(e){var t=e>>16&255,n=e>>8&255,i=e&255;this.writeUInt8(t),this.writeUInt8(n),this.writeUInt8(i)};g.prototype.writeInt24=g.prototype.writeUInt24;g.prototype.writeUInt32=function(e){var t=e>>24&255,n=e>>16&255,i=e>>8&255,a=e&255;this.writeUInt8(t),this.writeUInt8(n),this.writeUInt8(i),this.writeUInt8(a)};g.prototype.writeInt32=g.prototype.writeUInt32;g.prototype.writeBytes=function(e){this.buffer=this.buffer.concat(Array.prototype.slice.call(e,0))};g.prototype.writeString=function(e){var t,n=e.length,i=[];for(t=0;t<n;t++)i.push(e.codePointAt(t));this.writeBytes(i)};g.prototype.writeVarInt=function(e){if(e<0)throw"Cannot write negative variable-length integer";if(e<=127)this.writeUInt8(e);else{var t=e,n=[];for(n.push(t&127),t>>=7;t;){var i=t&127|128;n.push(i),t>>=7}this.writeBytes(n.reverse())}};g.prototype.writeChunk=function(e,t){this.writeString(e),this.writeUInt32(t.length),this.writeBytes(t)};var ue=ie;j.parseMidi=ne;j.writeMidi=ue;var _={},S={};Object.defineProperty(S,"__esModule",{value:!0});S.insert=S.search=void 0;function R(e,t,n){n===void 0&&(n="ticks");var i=0,a=e.length,o=a;if(a>0&&e[a-1][n]<=t)return a-1;for(;i<o;){var r=Math.floor(i+(o-i)/2),f=e[r],c=e[r+1];if(f[n]===t){for(var u=r;u<e.length;u++){var y=e[u];y[n]===t&&(r=u)}return r}else{if(f[n]<t&&c[n]>t)return r;f[n]>t?o=r:f[n]<t&&(i=r+1)}}return-1}S.search=R;function ce(e,t,n){if(n===void 0&&(n="ticks"),e.length){var i=R(e,t[n],n);e.splice(i+1,0,t)}else e.push(t)}S.insert=ce;(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.Header=e.keySignatureKeys=void 0;var t=S,n=new WeakMap;e.keySignatureKeys=["Cb","Gb","Db","Ab","Eb","Bb","F","C","G","D","A","E","B","F#","C#"];var i=function(){function a(o){var r=this;if(this.tempos=[],this.timeSignatures=[],this.keySignatures=[],this.meta=[],this.name="",n.set(this,480),o){n.set(this,o.header.ticksPerBeat),o.tracks.forEach(function(c){c.forEach(function(u){u.meta&&(u.type==="timeSignature"?r.timeSignatures.push({ticks:u.absoluteTime,timeSignature:[u.numerator,u.denominator]}):u.type==="setTempo"?r.tempos.push({bpm:6e7/u.microsecondsPerBeat,ticks:u.absoluteTime}):u.type==="keySignature"&&r.keySignatures.push({key:e.keySignatureKeys[u.key+7],scale:u.scale===0?"major":"minor",ticks:u.absoluteTime}))})});var f=0;o.tracks[0].forEach(function(c){f+=c.deltaTime,c.meta&&(c.type==="trackName"?r.name=c.text:(c.type==="text"||c.type==="cuePoint"||c.type==="marker"||c.type==="lyrics")&&r.meta.push({text:c.text,ticks:f,type:c.type}))}),this.update()}}return a.prototype.update=function(){var o=this,r=0,f=0;this.tempos.sort(function(c,u){return c.ticks-u.ticks}),this.tempos.forEach(function(c,u){var y=u>0?o.tempos[u-1].bpm:o.tempos[0].bpm,p=c.ticks/o.ppq-f,s=60/y*p;c.time=s+r,r=c.time,f+=p}),this.timeSignatures.sort(function(c,u){return c.ticks-u.ticks}),this.timeSignatures.forEach(function(c,u){var y=u>0?o.timeSignatures[u-1]:o.timeSignatures[0],p=(c.ticks-y.ticks)/o.ppq,s=p/y.timeSignature[0]/(y.timeSignature[1]/4);y.measures=y.measures||0,c.measures=s+y.measures})},a.prototype.ticksToSeconds=function(o){var r=(0,t.search)(this.tempos,o);if(r!==-1){var f=this.tempos[r],c=f.time,u=(o-f.ticks)/this.ppq;return c+60/f.bpm*u}else{var y=o/this.ppq;return 60/120*y}},a.prototype.ticksToMeasures=function(o){var r=(0,t.search)(this.timeSignatures,o);if(r!==-1){var f=this.timeSignatures[r],c=(o-f.ticks)/this.ppq;return f.measures+c/(f.timeSignature[0]/f.timeSignature[1])/4}else return o/this.ppq/4},Object.defineProperty(a.prototype,"ppq",{get:function(){return n.get(this)}
1,enumerable:!1,configurable:!0}),a.prototype.secondsToTicks=function(o){var r=(0,t.search)(this.tempos,o,"time");if(r!==-1){var f=this.tempos[r],c=f.time,u=o-c,y=u/(60/f.bpm);return Math.round(f.ticks+y*this.ppq)}else{var p=o/.5;return Math.round(p*this.ppq)}},a.prototype.toJSON=function(){return{keySignatures:this.keySignatures,meta:this.meta,name:this.name,ppq:this.ppq,tempos:this.tempos.map(function(o){return{bpm:o.bpm,ticks:o.ticks}}),timeSignatures:this.timeSignatures}},a.prototype.fromJSON=function(o){this.name=o.name,this.tempos=o.tempos.map(function(r){return Object.assign({},r)}),this.timeSignatures=o.timeSignatures.map(function(r){return Object.assign({},r)}),this.keySignatures=o.keySignatures.map(function(r){return Object.assign({},r)}),this.meta=o.meta.map(function(r){return Object.assign({},r)}),n.set(this,o.ppq),this.update()},a.prototype.setTempo=function(o){this.tempos=[{bpm:o,ticks:0}],this.update()},a}();e.Header=i})(_);var P={},G={};(function(e){Object.defineProperty(e,"__esModule",{value:!0}),e.ControlChange=e.controlChangeIds=e.controlChangeNames=void 0,e.controlChangeNames={1:"modulationWheel",2:"breath",4:"footController",5:"portamentoTime",7:"volume",8:"balance",10:"pan",64:"sustain",65:"portamentoTime",66:"sostenuto",67:"softPedal",68:"legatoFootswitch",84:"portamentoControl"},e.controlChangeIds=Object.keys(e.controlChangeNames).reduce(function(a,o){return a[e.controlChangeNames[o]]=o,a},{});var t=new WeakMap,n=new WeakMap,i=function(){function a(o,r){t.set(this,r),n.set(this,o.controllerType),this.ticks=o.absoluteTime,this.value=o.value}return Object.defineProperty(a.prototype,"number",{get:function(){return n.get(this)},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"name",{get:function(){return e.controlChangeNames[this.number]?e.controlChangeNames[this.number]:null},enumerable:!1,configurable:!0}),Object.defineProperty(a.prototype,"time",{get:function(){var o=t.get(this);return o.ticksToSeconds(this.ticks)},set:function(o){var r=t.get(this);this.ticks=r.secondsToTicks(o)},enumerable:!1,configurable:!0}),a.prototype.toJSON=function(){return{number:this.number,ticks:this.ticks,time:this.time,value:this.value}},a}();e.ControlChange=i})(G);var E={};Object.defineProperty(E,"__esModule",{value:!0});E.createControlChanges=void 0;var M=G;function fe(){return new Proxy({},{get:function(e,t){if(e[t])return e[t];if(M.controlChangeIds.hasOwnProperty(t))return e[M.controlChangeIds[t]]},set:function(e,t,n){return M.controlChangeIds.hasOwnProperty(t)?e[M.controlChangeIds[t]]=n:e[t]=n,!0}})}E.createControlChanges=fe;var V={};Object.defineProperty(V,"__esModule",{value:!0});V.PitchBend=void 0;var H=new WeakMap,he=function(){function e(t,n){H.set(this,n),this.ticks=t.absoluteTime,this.value=t.value}return Object.defineProperty(e.prototype,"time",{get:function(){var t=H.get(this);return t.ticksToSeconds(this.ticks)},set:function(t){var n=H.get(this);this.ticks=n.secondsToTicks(t)},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{ticks:this.ticks,time:this.time,value:this.value}},e}();V.PitchBend=he;var A={},w={};Object.defineProperty(w,"__esModule",{value:!0});w.DrumKitByPatchID=w.InstrumentFamilyByID=w.instrumentByPatchID=void 0;w.instrumentByPatchID=["acoustic grand piano","bright acoustic piano","electric grand piano","honky-tonk piano","electric piano 1","electric piano 2","harpsichord","clavi","celesta","glockenspiel","music box","vibraphone","marimba","xylophone","tubular bells","dulcimer","drawbar organ","percussive organ","rock organ","church organ","reed organ","accordion","harmonica","tango accordion","acoustic guitar (nylon)","acoustic guitar (steel)","electric guitar (jazz)","electric guitar (clean)","electric guitar (muted)","overdriven guitar","distortion guitar","guitar harmonics","acoustic bass","electric bass (finger)","electric bass (pick)","fretless bass","slap bass 1","slap bass 2","synth bass 1","synth bass 2","violin","viola","cello","contrabass","tremolo strings","pizzicato strings","orchestral harp","timpani","string ensemble 1","string ensemble 2","synthstrings 1","synthstrings 2","choir aahs","voice oohs","synth voice","orchestra hit","trumpet","trombone","tuba","muted trumpet","french horn","brass section","synthbrass 1","synthbrass 2","soprano sax","alto sax","tenor sax","baritone sax","oboe","english horn","bassoon","clarinet","piccolo","flute","recorder","pan flute","blown bottle","shakuhachi","whistle","ocarina","lead 1 (square)","lead 2 (sawtooth)","lead 3 (calliope)","lead 4 (chiff)","lead 5 (charang)","lead 6 (voice)","lead 7 (fifths)","lead 8 (bass + lead)","pad 1 (new age)","pad 2 (warm)","pad 3 (polysynth)","pad 4 (choir)","pad 5 (bowed)","pad 6 (metallic)","pad 7 (halo)","pad 8 (sweep)","fx 1 (rain)","fx 2 (soundtrack)","fx 3 (crystal)","fx 4 (atmosphere)","fx 5 (brightness)","fx 6 (goblins)","fx 7 (echoes)","fx 8 (sci-fi)","sitar","banjo","shamisen","koto","kalimba","bag pipe","fiddle","shanai","tinkle bell","agogo","steel drums","woodblock","taiko drum","melodic tom","synth drum","reverse cymbal","guitar fret noise","breath noise","seashore","bird tweet","telephone ring","helicopter","applause","gunshot"];w.InstrumentFamilyByID=["piano","chromatic percussion","organ","guitar","bass","strings","ensemble","brass","reed","pipe","synth lead","synth pad","synth effects","world","percussive","sound effects"];w.DrumKitByPatchID={0:"standard kit",8:"room kit",16:"power kit",24:"electronic kit",25:"tr-808 kit",32:"jazz kit",40:"brush kit",48:"orchestra kit",56:"sound fx kit"};
1Object.defineProperty(A,"__esModule",{value:!0});A.Instrument=void 0;var N=w,K=new WeakMap,le=function(){function e(t,n){if(this.number=0,K.set(this,n),this.number=0,t){var i=t.find(function(a){return a.type==="programChange"});i&&(this.number=i.programNumber)}}return Object.defineProperty(e.prototype,"name",{get:function(){return this.percussion?N.DrumKitByPatchID[this.number]:N.instrumentByPatchID[this.number]},set:function(t){var n=N.instrumentByPatchID.indexOf(t);n!==-1&&(this.number=n)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"family",{get:function(){return this.percussion?"drums":N.InstrumentFamilyByID[Math.floor(this.number/8)]},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"percussion",{get:function(){var t=K.get(this);return t.channel===9},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{family:this.family,number:this.number,name:this.name}},e.prototype.fromJSON=function(t){this.number=t.number},e}();A.Instrument=le;var D={};Object.defineProperty(D,"__esModule",{value:!0});D.Note=void 0;function de(e){var t=Math.floor(e/12)-1;return Q(e)+t.toString()}function Q(e){var t=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"],n=e%12;return t[n]}function pe(e){var t=["C","C#","D","D#","E","F","F#","G","G#","A","A#","B"];return t.indexOf(e)}var me=function(){var e=/^([a-g]{1}(?:b|#|x|bb)?)(-?[0-9]+)/i,t={cbb:-2,cb:-1,c:0,"c#":1,cx:2,dbb:0,db:1,d:2,"d#":3,dx:4,ebb:2,eb:3,e:4,"e#":5,ex:6,fbb:3,fb:4,f:5,"f#":6,fx:7,gbb:5,gb:6,g:7,"g#":8,gx:9,abb:7,ab:8,a:9,"a#":10,ax:11,bbb:9,bb:10,b:11,"b#":12,bx:13};return function(n){var i=e.exec(n),a=i[1],o=i[2],r=t[a.toLowerCase()];return r+(parseInt(o,10)+1)*12}}(),O=new WeakMap,be=function(){function e(t,n,i){O.set(this,i),this.midi=t.midi,this.velocity=t.velocity,this.noteOffVelocity=n.velocity,this.ticks=t.ticks,this.durationTicks=n.ticks-t.ticks}return Object.defineProperty(e.prototype,"name",{get:function(){return de(this.midi)},set:function(t){this.midi=me(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"octave",{get:function(){return Math.floor(this.midi/12)-1},set:function(t){var n=t-this.octave;this.midi+=n*12},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"pitch",{get:function(){return Q(this.midi)},set:function(t){this.midi=12*(this.octave+1)+pe(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"duration",{get:function(){var t=O.get(this);return t.ticksToSeconds(this.ticks+this.durationTicks)-t.ticksToSeconds(this.ticks)},set:function(t){var n=O.get(this),i=n.secondsToTicks(this.time+t);this.durationTicks=i-this.ticks},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"time",{get:function(){var t=O.get(this);return t.ticksToSeconds(this.ticks)},set:function(t){var n=O.get(this);this.ticks=n.secondsToTicks(t)},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"bars",{get:function(){var t=O.get(this);return t.ticksToMeasures(this.ticks)},enumerable:!1,configurable:!0}),e.prototype.toJSON=function(){return{duration:this.duration,durationTicks:this.durationTicks,midi:this.midi,name:this.name,ticks:this.ticks,time:this.time,velocity:this.velocity}},e}();D.Note=be;Object.defineProperty(P,"__esModule",{value:!0});P.Track=void 0;var z=S,ye=G,ge=E,ve=V,L=A,ke=D,B=new WeakMap,Ie=function(){function e(t,n){var i=this;if(this.name="",this.notes=[],this.controlChanges=(0,ge.createControlChanges)(),this.pitchBends=[],B.set(this,n),t){var a=t.find(function(s){return s.type==="trackName"});this.name=a?a.text:""}if(this.instrument=new L.Instrument(t,this),this.channel=0,t){for(var o=t.filter(function(s){return s.type==="noteOn"}),r=t.filter(function(s){return s.type==="noteOff"}),f=function(){var s=o.shift();c.channel=s.channel;var h=r.findIndex(function(b){return b.noteNumber===s.noteNumber&&b.absoluteTime>=s.absoluteTime});if(h!==-1){var m=r.splice(h,1)[0];c.addNote({durationTicks:m.absoluteTime-s.absoluteTime,midi:s.noteNumber,noteOffVelocity:m.velocity/127,ticks:s.absoluteTime,velocity:s.velocity/127})}},c=this;o.length;)f();var u=t.filter(function(s){return s.type==="controller"});u.forEach(function(s){i.addCC({number:s.controllerType,ticks:s.absoluteTime,value:s.value/127})});var y=t.filter(function(s){return s.type==="pitchBend"});
1y.forEach(function(s){i.addPitchBend({ticks:s.absoluteTime,value:s.value/Math.pow(2,13)})});var p=t.find(function(s){return s.type==="endOfTrack"});this.endOfTrackTicks=p!==void 0?p.absoluteTime:void 0}}return e.prototype.addNote=function(t){var n=B.get(this),i=new ke.Note({midi:0,ticks:0,velocity:1},{ticks:0,velocity:0},n);return Object.assign(i,t),(0,z.insert)(this.notes,i,"ticks"),this},e.prototype.addCC=function(t){var n=B.get(this),i=new ye.ControlChange({controllerType:t.number},n);return delete t.number,Object.assign(i,t),Array.isArray(this.controlChanges[i.number])||(this.controlChanges[i.number]=[]),(0,z.insert)(this.controlChanges[i.number],i,"ticks"),this},e.prototype.addPitchBend=function(t){var n=B.get(this),i=new ve.PitchBend({},n);return Object.assign(i,t),(0,z.insert)(this.pitchBends,i,"ticks"),this},Object.defineProperty(e.prototype,"duration",{get:function(){if(!this.notes.length)return 0;for(var t=this.notes[this.notes.length-1].time+this.notes[this.notes.length-1].duration,n=0;n<this.notes.length-1;n++){var i=this.notes[n].time+this.notes[n].duration;t<i&&(t=i)}return t},enumerable:!1,configurable:!0}),Object.defineProperty(e.prototype,"durationTicks",{get:function(){if(!this.notes.length)return 0;for(var t=this.notes[this.notes.length-1].ticks+this.notes[this.notes.length-1].durationTicks,n=0;n<this.notes.length-1;n++){var i=this.notes[n].ticks+this.notes[n].durationTicks;t<i&&(t=i)}return t},enumerable:!1,configurable:!0}),e.prototype.fromJSON=function(t){var n=this;this.name=t.name,this.channel=t.channel,this.instrument=new L.Instrument(void 0,this),this.instrument.fromJSON(t.instrument),t.endOfTrackTicks!==void 0&&(this.endOfTrackTicks=t.endOfTrackTicks);for(var i in t.controlChanges)t.controlChanges[i]&&t.controlChanges[i].forEach(function(a){n.addCC({number:a.number,ticks:a.ticks,value:a.value})});t.notes.forEach(function(a){n.addNote({durationTicks:a.durationTicks,midi:a.midi,ticks:a.ticks,velocity:a.velocity})})},e.prototype.toJSON=function(){for(var t={},n=0;n<127;n++)this.controlChanges.hasOwnProperty(n)&&(t[n]=this.controlChanges[n].map(function(a){return a.toJSON()}));var i={channel:this.channel,controlChanges:t,pitchBends:this.pitchBends.map(function(a){return a.toJSON()}),instrument:this.instrument.toJSON(),name:this.name,notes:this.notes.map(function(a){return a.toJSON()})};return this.endOfTrackTicks!==void 0&&(i.endOfTrackTicks=this.endOfTrackTicks),i},e}();P.Track=Ie;var J={};function xe(e){var t=[];return X(e,t),t}function X(e,t){for(var n=0;n<e.length;n++){var i=e[n];Array.isArray(i)?X(i,t):t.push(i)}}const Te=Object.freeze(Object.defineProperty({__proto__:null,flatten:xe},Symbol.toStringTag,{value:"Module"})),Ue=Y(Te);var U=C&&C.__spreadArray||function(e,t,n){if(n||arguments.length===2)for(var i=0,a=t.length,o;i<a;
1i++)(o||!(i in t))&&(o||(o=Array.prototype.slice.call(t,0,i)),o[i]=t[i]);return e.concat(o||Array.prototype.slice.call(t))};Object.defineProperty(J,"__esModule",{value:!0});J.encode=void 0;var we=j,Se=_,Oe=Ue;function Ce(e,t){return[{absoluteTime:e.ticks,channel:t,deltaTime:0,noteNumber:e.midi,type:"noteOn",velocity:Math.floor(e.velocity*127)},{absoluteTime:e.ticks+e.durationTicks,channel:t,deltaTime:0,noteNumber:e.midi,type:"noteOff",velocity:Math.floor(e.noteOffVelocity*127)}]}function Fe(e){return(0,Oe.flatten)(e.notes.map(function(t){return Ce(t,e.channel)}))}function Pe(e,t){return{absoluteTime:e.ticks,channel:t,controllerType:e.number,deltaTime:0,type:"controller",value:Math.floor(e.value*127)}}function Me(e){for(var t=[],n=0;n<127;n++)e.controlChanges.hasOwnProperty(n)&&e.controlChanges[n].forEach(function(i){t.push(Pe(i,e.channel))});return t}function Ne(e,t){return{absoluteTime:e.ticks,channel:t,deltaTime:0,type:"pitchBend",value:e.value}}function Be(e){var t=[];return e.pitchBends.forEach(function(n){t.push(Ne(n,e.channel))}),t}function _e(e){return{absoluteTime:0,channel:e.channel,deltaTime:0,programNumber:e.instrument.number,type:"programChange"}}function je(e){return{absoluteTime:0,deltaTime:0,meta:!0,text:e,type:"trackName"}}function Ee(e){return{absoluteTime:e.ticks,deltaTime:0,meta:!0,microsecondsPerBeat:Math.floor(6e7/e.bpm),type:"setTempo"}}function Ve(e){return{absoluteTime:e.ticks,deltaTime:0,denominator:e.timeSignature[1],meta:!0,metronome:24,numerator:e.timeSignature[0],thirtyseconds:8,type:"timeSignature"}}function Ae(e){var t=Se.keySignatureKeys.indexOf(e.key);return{absoluteTime:e.ticks,deltaTime:0,key:t+7,meta:!0,scale:e.scale==="major"?0:1,type:"keySignature"}}function De(e){return{absoluteTime:e.ticks,deltaTime:0,meta:!0,text:e.text,type:e.type}}function Je(e){var t={header:{format:1,numTracks:e.tracks.length+1,ticksPerBeat:e.header.ppq},tracks:U([U(U(U(U([{absoluteTime:0,deltaTime:0,meta:!0,text:e.header.n
1ame,type:"trackName"}],e.header.keySignatures.map(function(n){return Ae(n)}),!0),e.header.meta.map(function(n){return De(n)}),!0),e.header.tempos.map(function(n){return Ee(n)}),!0),e.header.timeSignatures.map(function(n){return Ve(n)}),!0)],e.tracks.map(function(n){return U(U(U([je(n.name),_e(n)],Fe(n),!0),Me(n),!0),Be(n),!0)}),!0)};return t.tracks=t.tracks.map(function(n){n=n.sort(function(a,o){return a.absoluteTime-o.absoluteTime});var i=0;return n.forEach(function(a){a.deltaTime=a.absoluteTime-i,i=a.absoluteTime,delete a.absoluteTime}),n.push({deltaTime:0,meta:!0,type:"endOfTrack"}),n}),new Uint8Array((0,we.writeMidi)(t))}J.encode=Je;(function(e){var t=C&&C.__awaiter||function(p,s,h,m){function b(l){return l instanceof h?l:new h(function(k){k(l)})}return new(h||(h=Promise))(function(l,k){function x(v){try{d(m.next(v))}catch(F){k(F)}}function T(v){try{d(m.throw(v))}catch(F){k(F)}}function d(v){v.done?l(v.value):b(v.value).then(x,T)}d((m=m.apply(p,s||[])).next())})},n=C&&C.__generator||function(p,s){var h={label:0,sent:function(){if(l[0]&1)throw l[1];return l[1]},trys:[],ops:[]},m,b,l,k;return k={next:x(0),throw:x(1),return:x(2)},typeof Symbol=="function"&&(k[Symbol.iterator]=function(){return this}),k;function x(d){return function(v){return T([d,v])}}function T(d){if(m)throw new TypeError("Generator is already executing.");for(;h;)try{if(m=1,b&&(l=d[0]&2?b.return:d[0]?b.throw||((l=b.return)&&l.call(b),0):b.next)&&!(l=l.call(b,d[1])).done)return l;
1switch(b=0,l&&(d=[d[0]&2,l.value]),d[0]){case 0:case 1:l=d;break;case 4:return h.label++,{value:d[1],done:!1};case 5:h.label++,b=d[1],d=[0];continue;case 7:d=h.ops.pop(),h.trys.pop();continue;default:if(l=h.trys,!(l=l.length>0&&l[l.length-1])&&(d[0]===6||d[0]===2)){h=0;continue}if(d[0]===3&&(!l||d[1]>l[0]&&d[1]<l[3])){h.label=d[1];break}if(d[0]===6&&h.label<l[1]){h.label=l[1],l=d;break}if(l&&h.label<l[2]){h.label=l[2],h.ops.push(d);break}l[2]&&h.ops.pop(),h.trys.pop();continue}d=s.call(p,h)}catch(v){d=[6,v],b=0}finally{m=l=0}if(d[0]&5)throw d[1];return{value:d[0]?d[1]:void 0,done:!0}}};Object.defineProperty(e,"__esModule",{value:!0}),e.Header=e.Track=e.Midi=void 0;var i=j,a=_,o=P,r=J,f=function(){function p(s){var h=this,m=null;if(s){var b=s instanceof ArrayBuffer?new Uint8Array(s):s;m=(0,i.parseMidi)(b),m.tracks.forEach(function(l){var k=0;l.forEach(function(x){k+=x.deltaTime,x.absoluteTime=k})}),m.tracks=y(m.tracks)}this.header=new a.Header(m),this.tracks=[],s&&(this.tracks=m.tracks.map(function(l){return new o.Track(l,h.header)}),m.header.format===1&&this.tracks[0].duration===0&&this.tracks.shift())}return p.fromUrl=function(s){return t(this,void 0,void 0,function(){var h,m;return n(this,function(b){switch(b.label){case 0:return[4,fetch(s)];case 1:return h=b.sent(),h.ok?[4,h.arrayBuffer()]:[3,3];case 2:return m=b.sent(),[2,new p(m)];case 3:throw new Error("Could not load '".concat(s,"'"))}})})},Object.defineProperty(p.prototype,"name",{get:function(){return this.header.name},set:function(s){this.header.name=s},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"duration",{get:function(){var s=this.tracks.map(function(h){return h.duration});return Math.max.apply(Math,s)},enumerable:!1,configurable:!0}),Object.defineProperty(p.prototype,"durationTicks",{get:function(){var s=this.tracks.map(function(h){return h.durationTicks});return Math.max.apply(Math,s)},enumerable:!1,configurable:!0}),p.prototype.addTrack=function(){var s=new o.Track(void 0,this.header);return this.tracks.push(s),s},p.prototype.toArray=function(){return(0,r.encode)(this)},p.prototype.toJSON=function(){return{header:this.header.toJSON(),tracks:this.tracks.map(function(s){return s.toJSON()})}},p.prototype.fromJSON=function(s){var h=this;this.header=new a.Header,this.header.fromJSON(s.header),this.tracks=s.tracks.map(function(m){var b=new o.Track(void 0,h.header);return b.fromJSON(m),b})},p.prototype.clone=function(){var s=new p;return s.fromJSON(this.toJSON()),s},p}();e.Midi=f;var c=P;Object.defineProperty(e,"Track",{enumerable:!0,get:function(){return c.Track}});var u=_;Object.defineProperty(e,"Header",{enumerable:!0,get:function(){return u.Header}});function y(p){for(var s=[],h=0;h<p.length;h++)for(var m=s.length,b=new Map,l=Array(16).fill(0),k=0,x=p[h];k<x.length;k++){var T=x[k],d=m,v=T.channel;if(v!==void 0){T.type==="programChange"&&(l[v]=T.programNumber);var F=l[v],q="".concat(F," ").concat(v);b.has(q)?d=b.get(q):(d=m+b.size,b.set(q,d))}s[d]||s.push([]),s[d].push(T)}return s}})(W);const qe=Z(W),ze=$({__proto__:null,default:qe},[W]);export{ze as M};

Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.