json-midi-encoder
Version:
This module encodes a JSON representation of MIDI data into a binary MIDI file.
21 lines (16 loc) • 25.2 kB
JavaScript
(function (global, factory) {
typeof exports === 'object' && typeof module !== 'undefined' ? factory(exports, require('json-midi-encoder-broker')) :
typeof define === 'function' && define.amd ? define(['exports', 'json-midi-encoder-broker'], factory) :
(global = typeof globalThis !== 'undefined' ? globalThis : global || self, factory(global.jsonMidiEncoder = {}, global.jsonMidiEncoderBroker));
})(this, (function (exports, jsonMidiEncoderBroker) { 'use strict';
// This is the minified and stringified code of the json-midi-encoder-worker package.
var worker = "(()=>{var t={45:(t,e,r)=>{var n=r(738).default;t.exports=function(t,e){if(\"object\"!=n(t)||!t)return t;var r=t[Symbol.toPrimitive];if(void 0!==r){var o=r.call(t,e||\"default\");if(\"object\"!=n(o))return o;throw new TypeError(\"@@toPrimitive must return a primitive value.\")}return(\"string\"===e?String:Number)(t)},t.exports.__esModule=!0,t.exports.default=t.exports},79:t=>{t.exports=function(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n},t.exports.__esModule=!0,t.exports.default=t.exports},122:(t,e,r)=>{var n=r(79);t.exports=function(t,e){if(t){if(\"string\"==typeof t)return n(t,e);var r={}.toString.call(t).slice(8,-1);return\"Object\"===r&&t.constructor&&(r=t.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(t):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?n(t,e):void 0}},t.exports.__esModule=!0,t.exports.default=t.exports},156:t=>{t.exports=function(t,e){var r=null==t?null:\"undefined\"!=typeof Symbol&&t[Symbol.iterator]||t[\"@@iterator\"];if(null!=r){var n,o,i,a,u=[],s=!0,c=!1;try{if(i=(r=r.call(t)).next,0===e){if(Object(r)!==r)return;s=!1}else for(;!(s=(n=i.call(r)).done)&&(u.push(n.value),u.length!==e);s=!0);}catch(t){c=!0,o=t}finally{try{if(!s&&null!=r.return&&(a=r.return(),Object(a)!==a))return}finally{if(c)throw o}}return u}},t.exports.__esModule=!0,t.exports.default=t.exports},293:t=>{function e(t,e,r,n,o,i,a){try{var u=t[i](a),s=u.value}catch(t){return void r(t)}u.done?e(s):Promise.resolve(s).then(n,o)}t.exports=function(t){return function(){var r=this,n=arguments;return new Promise((function(o,i){var a=t.apply(r,n);function u(t){e(a,o,i,u,s,\"next\",t)}function s(t){e(a,o,i,u,s,\"throw\",t)}u(void 0)}))}},t.exports.__esModule=!0,t.exports.default=t.exports},389:function(t,e){!function(t){\"use strict\";var e=function(t){return function(e){var r=t(e);return e.add(r),r}},r=function(t){return function(e,r){return t.set(e,r),r}},n=void 0===Number.MAX_SAFE_INTEGER?9007199254740991:Number.MAX_SAFE_INTEGER,o=536870912,i=2*o,a=function(t,e){return function(r){var a=e.get(r),u=void 0===a?r.size:a<i?a+1:0;if(!r.has(u))return t(r,u);if(r.size<o){for(;r.has(u);)u=Math.floor(Math.random()*i);return t(r,u)}if(r.size>n)throw new Error(\"Congratulations, you created a collection of unique numbers which uses all available integers!\");for(;r.has(u);)u=Math.floor(Math.random()*n);return t(r,u)}},u=new WeakMap,s=r(u),c=a(s,u),f=e(c);t.addUniqueNumber=f,t.generateUniqueNumber=c}(e)},390:function(t,e,r){!function(t,e){\"use strict\";var r=function(t){var e=new ArrayBuffer(t);return{arrayBuffer:e,dataView:new DataView(e)}},n=function(t,e,n){var o=r(14),i=o.arrayBuffer,a=o.dataView;return a.setUint32(0,1297377380),a.setUint32(4,6),a.setUint16(8,e),a.setUint16(10,n.length),a.setUint16(12,t),i},o=function(t){var e=t.reduce((function(t,e){return t+e.byteLength}),0);return t.reduce((function(t,e){var r=t.offset,n=t.uint8Array;return n.set(new Uint8Array(e),r),{offset:r+e.byteLength,uint8Array:n}}),{offset:0,uint8Array:new Uint8Array(e)}).uint8Array.buffer};function i(t,e){var r=\"undefined\"!=typeof Symbol&&t[Symbol.iterator]||t[\"@@iterator\"];if(!r){if(Array.isArray(t)||(r=a(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var i,u=!0,s=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return u=t.done,t},e:function(t){s=!0,i=t},f:function(){try{u||null==r.return||r.return()}finally{if(s)throw i}}}}function a(t,e){if(t){if(\"string\"==typeof t)return u(t,e);var r={}.toString.call(t).slice(8,-1);return\"Object\"===r&&t.constructor&&(r=t.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(t):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?u(t,e):void 0}}function u(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var s=function(t){var n=r(8),a=n.arrayBuffer,u=n.dataView,s=[a],c=0;u.setUint32(0,1297379947);var f,l=i(t);try{for(l.s();!(f=l.n()).done;){var d=f.value,p=e.writeVariableLengthQuantity(d.delta);try{var h=e.encode(d);c+=p.byteLength+h.byteLength,s.push(p,h)}catch(e){if(e.message.match(/Unencodable\\smessage\\swith\\sa\\sdelta\\sof\\s[0-9]+\\./)){var v=t.indexOf(d);throw new Error(\"Unencodable message at index \".concat(v,\".\"))}throw e}}}catch(t){l.e(t)}finally{l.f()}return u.setUint32(4,c),o(s)};function c(t,e){var r=\"undefined\"!=typeof Symbol&&t[Symbol.iterator]||t[\"@@iterator\"];if(!r){if(Array.isArray(t)||(r=f(t))||e){r&&(t=r);var n=0,o=function(){};return{s:o,n:function(){return n>=t.length?{done:!0}:{done:!1,value:t[n++]}},e:function(t){throw t},f:o}}throw new TypeError(\"Invalid attempt to iterate non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")}var i,a=!0,u=!1;return{s:function(){r=r.call(t)},n:function(){var t=r.next();return a=t.done,t},e:function(t){u=!0,i=t},f:function(){try{a||null==r.return||r.return()}finally{if(u)throw i}}}}function f(t,e){if(t){if(\"string\"==typeof t)return l(t,e);var r={}.toString.call(t).slice(8,-1);return\"Object\"===r&&t.constructor&&(r=t.constructor.name),\"Map\"===r||\"Set\"===r?Array.from(t):\"Arguments\"===r||/^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(r)?l(t,e):void 0}}function l(t,e){(null==e||e>t.length)&&(e=t.length);for(var r=0,n=Array(e);r<e;r++)n[r]=t[r];return n}var d=function(t){var e=t.division,r=t.format,i=t.tracks,a=[];try{a.push(n(e,r,i))}catch(t){throw new Error(\"The given JSON object seems to be invalid.\")}var u,f=c(i);try{for(f.s();!(u=f.n()).done;){var l=u.value;try{a.push(s(l))}catch(t){if(t.message.match(/Unencodable\\sevent\\sat\\sposition\\s[0-9]+\\./)){var d=i.indexOf(l);throw new Error(\"\".concat(t.message.slice(0,-1),\" of the track at index \").concat(d,\".\"))}throw t}}}catch(t){f.e(t)}finally{f.f()}return o(a)};t.createWorker(self,{encode:function(t){var e=t.midiFile,r=d(e);return{result:r,transferables:[r]}}})}(r(623),r(963))},623:function(t,e,r){!function(t,e,r,n,o){\"use strict\";var i={INTERNAL_ERROR:-32603,INVALID_PARAMS:-32602,METHOD_NOT_FOUND:-32601},a=function(t,e){return Object.assign(new Error(t),{status:e})},u=function(t){return a('The requested method called \"'.concat(t,'\" is not supported.'),i.METHOD_NOT_FOUND)},s=function(t){return a('The handler of the method called \"'.concat(t,'\" returned no required result.'),i.INTERNAL_ERROR)},c=function(t){return a('The handler of the method called \"'.concat(t,'\" returned an unexpected result.'),i.INTERNAL_ERROR)},f=function(t){return a('The specified parameter called \"portId\" with the given value \"'.concat(t,'\" does not identify a port connected to this worker.'),i.INVALID_PARAMS)},l=function(t,n){return function(){var o=e(r.mark((function e(o){var i,a,f,l,d,p,h,v,y,m,g,w,b;return r.wrap((function(e){for(;;)switch(e.prev=e.next){case 0:if(i=o.data,a=i.id,f=i.method,l=i.params,d=n[f],e.prev=2,void 0!==d){e.next=5;break}throw u(f);case 5:if(void 0!==(p=void 0===l?d():d(l))){e.next=8;break}throw s(f);case 8:if(!(p instanceof Promise)){e.next=14;break}return e.next=11,p;case 11:e.t0=e.sent,e.next=15;break;case 14:e.t0=p;case 15:if(h=e.t0,null!==a){e.next=21;break}if(void 0===h.result){e.next=19;break}throw c(f);case 19:e.next=25;break;case 21:if(void 0!==h.result){e.next=23;break}throw c(f);case 23:v=h.result,y=h.transferables,m=void 0===y?[]:y,t.postMessage({id:a,result:v},m);case 25:e.next=31;break;case 27:e.prev=27,e.t1=e.catch(2),g=e.t1.message,w=e.t1.status,b=void 0===w?-32603:w,t.postMessage({error:{code:b,message:g},id:a});case 31:case\"end\":return e.stop()}}),e,null,[[2,27]])})));return function(t){return o.apply(this,arguments)}}()},d=function(){return new Promise((function(t){var e=new ArrayBuffer(0),r=new MessageChannel,n=r.port1,o=r.port2;n.onmessage=function(e){var r=e.data;return t(null!==r)},o.postMessage(e,[e])}))};function p(t,e){var r=Object.keys(t);if(Object.getOwnPropertySymbols){var n=Object.getOwnPropertySymbols(t);e&&(n=n.filter((function(e){return Object.getOwnPropertyDescriptor(t,e).enumerable}))),r.push.apply(r,n)}return r}function h(t){for(var e=1;e<arguments.length;e++){var r=null!=arguments[e]?arguments[e]:{};e%2?p(Object(r),!0).forEach((function(e){n(t,e,r[e])})):Object.getOwnPropertyDescriptors?Object.defineProperties(t,Object.getOwnPropertyDescriptors(r)):p(Object(r)).forEach((function(e){Object.defineProperty(t,e,Object.getOwnPropertyDescriptor(r,e))}))}return t}var v=new Map,y=function(t,n,i){return h(h({},n),{},{connect:function(e){var r=e.port;r.start();var i=t(r,n),a=o.generateUniqueNumber(v);return v.set(a,(function(){i(),r.close(),v.delete(a)})),{result:a}},disconnect:function(t){var e=t.portId,r=v.get(e);if(void 0===r)throw f(e);return r(),{result:null}},isSupported:function(){var t=e(r.mark((function t(){var e,n;return r.wrap((function(t){for(;;)switch(t.prev=t.next){case 0:return t.next=2,d();case 2:if(!t.sent){t.next=14;break}if(!((e=i())instanceof Promise)){t.next=11;break}return t.next=8,e;case 8:t.t0=t.sent,t.next=12;break;case 11:t.t0=e;case 12:return n=t.t0,t.abrupt(\"return\",{result:n});case 14:return t.abrupt(\"return\",{result:!1});case 15:case\"end\":return t.stop()}}),t)})));function n(){return t.apply(this,arguments)}return n}()})},m=function(t,e){var r=y(m,e,arguments.length>2&&void 0!==arguments[2]?arguments[2]:function(){return!0}),n=l(t,r);return t.addEventListener(\"message\",n),function(){return t.removeEventListener(\"message\",n)}};t.createWorker=m,t.isSupported=d}(e,r(293),r(756),r(693),r(389))},633:(t,e,r)=>{var n=r(738).default;function o(){\"use strict\";t.exports=o=function(){return r},t.exports.__esModule=!0,t.exports.default=t.exports;var e,r={},i=Object.prototype,a=i.hasOwnProperty,u=Object.defineProperty||function(t,e,r){t[e]=r.value},s=\"function\"==typeof Symbol?Symbol:{},c=s.iterator||\"@@iterator\",f=s.asyncIterator||\"@@asyncIterator\",l=s.toStringTag||\"@@toStringTag\";function d(t,e,r){return Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}),t[e]}try{d({},\"\")}catch(e){d=function(t,e,r){return t[e]=r}}function p(t,e,r,n){var o=e&&e.prototype instanceof b?e:b,i=Object.create(o.prototype),a=new M(n||[]);return u(i,\"_invoke\",{value:N(t,r,a)}),i}function h(t,e,r){try{return{type:\"normal\",arg:t.call(e,r)}}catch(t){return{type:\"throw\",arg:t}}}r.wrap=p;var v=\"suspendedStart\",y=\"suspendedYield\",m=\"executing\",g=\"completed\",w={};function b(){}function x(){}function U(){}var O={};d(O,c,(function(){return this}));var _=Object.getPrototypeOf,E=_&&_(_(T([])));E&&E!==i&&a.call(E,c)&&(O=E);var S=U.prototype=b.prototype=Object.create(O);function A(t){[\"next\",\"throw\",\"return\"].forEach((function(e){d(t,e,(function(t){return this._invoke(e,t)}))}))}function L(t,e){function r(o,i,u,s){var c=h(t[o],t,i);if(\"throw\"!==c.type){var f=c.arg,l=f.value;return l&&\"object\"==n(l)&&a.call(l,\"__await\")?e.resolve(l.__await).then((function(t){r(\"next\",t,u,s)}),(function(t){r(\"throw\",t,u,s)})):e.resolve(l).then((function(t){f.value=t,u(f)}),(function(t){return r(\"throw\",t,u,s)}))}s(c.arg)}var o;u(this,\"_invoke\",{value:function(t,n){function i(){return new e((function(e,o){r(t,n,e,o)}))}return o=o?o.then(i,i):i()}})}function N(t,r,n){var o=v;return function(i,a){if(o===m)throw Error(\"Generator is already running\");if(o===g){if(\"throw\"===i)throw a;return{value:e,done:!0}}for(n.method=i,n.arg=a;;){var u=n.delegate;if(u){var s=k(u,n);if(s){if(s===w)continue;return s}}if(\"next\"===n.method)n.sent=n._sent=n.arg;else if(\"throw\"===n.method){if(o===v)throw o=g,n.arg;n.dispatchException(n.arg)}else\"return\"===n.method&&n.abrupt(\"return\",n.arg);o=m;var c=h(t,r,n);if(\"normal\"===c.type){if(o=n.done?g:y,c.arg===w)continue;return{value:c.arg,done:n.done}}\"throw\"===c.type&&(o=g,n.method=\"throw\",n.arg=c.arg)}}}function k(t,r){var n=r.method,o=t.iterator[n];if(o===e)return r.delegate=null,\"throw\"===n&&t.iterator.return&&(r.method=\"return\",r.arg=e,k(t,r),\"throw\"===r.method)||\"return\"!==n&&(r.method=\"throw\",r.arg=new TypeError(\"The iterator does not provide a '\"+n+\"' method\")),w;var i=h(o,t.iterator,r.arg);if(\"throw\"===i.type)return r.method=\"throw\",r.arg=i.arg,r.delegate=null,w;var a=i.arg;return a?a.done?(r[t.resultName]=a.value,r.next=t.nextLoc,\"return\"!==r.method&&(r.method=\"next\",r.arg=e),r.delegate=null,w):a:(r.method=\"throw\",r.arg=new TypeError(\"iterator result is not an object\"),r.delegate=null,w)}function P(t){var e={tryLoc:t[0]};1 in t&&(e.catchLoc=t[1]),2 in t&&(e.finallyLoc=t[2],e.afterLoc=t[3]),this.tryEntries.push(e)}function j(t){var e=t.completion||{};e.type=\"normal\",delete e.arg,t.completion=e}function M(t){this.tryEntries=[{tryLoc:\"root\"}],t.forEach(P,this),this.reset(!0)}function T(t){if(t||\"\"===t){var r=t[c];if(r)return r.call(t);if(\"function\"==typeof t.next)return t;if(!isNaN(t.length)){var o=-1,i=function r(){for(;++o<t.length;)if(a.call(t,o))return r.value=t[o],r.done=!1,r;return r.value=e,r.done=!0,r};return i.next=i}}throw new TypeError(n(t)+\" is not iterable\")}return x.prototype=U,u(S,\"constructor\",{value:U,configurable:!0}),u(U,\"constructor\",{value:x,configurable:!0}),x.displayName=d(U,l,\"GeneratorFunction\"),r.isGeneratorFunction=function(t){var e=\"function\"==typeof t&&t.constructor;return!!e&&(e===x||\"GeneratorFunction\"===(e.displayName||e.name))},r.mark=function(t){return Object.setPrototypeOf?Object.setPrototypeOf(t,U):(t.__proto__=U,d(t,l,\"GeneratorFunction\")),t.prototype=Object.create(S),t},r.awrap=function(t){return{__await:t}},A(L.prototype),d(L.prototype,f,(function(){return this})),r.AsyncIterator=L,r.async=function(t,e,n,o,i){void 0===i&&(i=Promise);var a=new L(p(t,e,n,o),i);return r.isGeneratorFunction(e)?a:a.next().then((function(t){return t.done?t.value:a.next()}))},A(S),d(S,l,\"Generator\"),d(S,c,(function(){return this})),d(S,\"toString\",(function(){return\"[object Generator]\"})),r.keys=function(t){var e=Object(t),r=[];for(var n in e)r.push(n);return r.reverse(),function t(){for(;r.length;){var n=r.pop();if(n in e)return t.value=n,t.done=!1,t}return t.done=!0,t}},r.values=T,M.prototype={constructor:M,reset:function(t){if(this.prev=0,this.next=0,this.sent=this._sent=e,this.done=!1,this.delegate=null,this.method=\"next\",this.arg=e,this.tryEntries.forEach(j),!t)for(var r in this)\"t\"===r.charAt(0)&&a.call(this,r)&&!isNaN(+r.slice(1))&&(this[r]=e)},stop:function(){this.done=!0;var t=this.tryEntries[0].completion;if(\"throw\"===t.type)throw t.arg;return this.rval},dispatchException:function(t){if(this.done)throw t;var r=this;function n(n,o){return u.type=\"throw\",u.arg=t,r.next=n,o&&(r.method=\"next\",r.arg=e),!!o}for(var o=this.tryEntries.length-1;o>=0;--o){var i=this.tryEntries[o],u=i.completion;if(\"root\"===i.tryLoc)return n(\"end\");if(i.tryLoc<=this.prev){var s=a.call(i,\"catchLoc\"),c=a.call(i,\"finallyLoc\");if(s&&c){if(this.prev<i.catchLoc)return n(i.catchLoc,!0);if(this.prev<i.finallyLoc)return n(i.finallyLoc)}else if(s){if(this.prev<i.catchLoc)return n(i.catchLoc,!0)}else{if(!c)throw Error(\"try statement without catch or finally\");if(this.prev<i.finallyLoc)return n(i.finallyLoc)}}}},abrupt:function(t,e){for(var r=this.tryEntries.length-1;r>=0;--r){var n=this.tryEntries[r];if(n.tryLoc<=this.prev&&a.call(n,\"finallyLoc\")&&this.prev<n.finallyLoc){var o=n;break}}o&&(\"break\"===t||\"continue\"===t)&&o.tryLoc<=e&&e<=o.finallyLoc&&(o=null);var i=o?o.completion:{};return i.type=t,i.arg=e,o?(this.method=\"next\",this.next=o.finallyLoc,w):this.complete(i)},complete:function(t,e){if(\"throw\"===t.type)throw t.arg;return\"break\"===t.type||\"continue\"===t.type?this.next=t.arg:\"return\"===t.type?(this.rval=this.arg=t.arg,this.method=\"return\",this.next=\"end\"):\"normal\"===t.type&&e&&(this.next=e),w},finish:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.finallyLoc===t)return this.complete(r.completion,r.afterLoc),j(r),w}},catch:function(t){for(var e=this.tryEntries.length-1;e>=0;--e){var r=this.tryEntries[e];if(r.tryLoc===t){var n=r.completion;if(\"throw\"===n.type){var o=n.arg;j(r)}return o}}throw Error(\"illegal catch attempt\")},delegateYield:function(t,r,n){return this.delegate={iterator:T(t),resultName:r,nextLoc:n},\"next\"===this.method&&(this.arg=e),w}},r}t.exports=o,t.exports.__esModule=!0,t.exports.default=t.exports},693:(t,e,r)=>{var n=r(736);t.exports=function(t,e,r){return(e=n(e))in t?Object.defineProperty(t,e,{value:r,enumerable:!0,configurable:!0,writable:!0}):t[e]=r,t},t.exports.__esModule=!0,t.exports.default=t.exports},715:(t,e,r)=>{var n=r(987),o=r(156),i=r(122),a=r(752);t.exports=function(t,e){return n(t)||o(t,e)||i(t,e)||a()},t.exports.__esModule=!0,t.exports.default=t.exports},736:(t,e,r)=>{var n=r(738).default,o=r(45);t.exports=function(t){var e=o(t,\"string\");return\"symbol\"==n(e)?e:e+\"\"},t.exports.__esModule=!0,t.exports.default=t.exports},738:t=>{function e(r){return t.exports=e=\"function\"==typeof Symbol&&\"symbol\"==typeof Symbol.iterator?function(t){return typeof t}:function(t){return t&&\"function\"==typeof Symbol&&t.constructor===Symbol&&t!==Symbol.prototype?\"symbol\":typeof t},t.exports.__esModule=!0,t.exports.default=t.exports,e(r)}t.exports=e,t.exports.__esModule=!0,t.exports.default=t.exports},752:t=>{t.exports=function(){throw new TypeError(\"Invalid attempt to destructure non-iterable instance.\\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.\")},t.exports.__esModule=!0,t.exports.default=t.exports},756:(t,e,r)=>{var n=r(633)();t.exports=n;try{regeneratorRuntime=n}catch(t){\"object\"==typeof globalThis?globalThis.regeneratorRuntime=n:Function(\"r\",\"regeneratorRuntime = r\")(n)}},963:function(t,e,r){!function(t,e){\"use strict\";var r=function(t){return void 0!==t.channelPrefix},n=function(t){return void 0!==t.channelPressure},o=function(t){return void 0!==t.controlChange},i=function(t){return void 0!==t.copyrightNotice},a=function(t){return void 0!==t.cuePoint&&void 0===t.metaTypeByte},u=function(t){return void 0!==t.deviceName},s=function(t){return void 0!==t.endOfTrack},c=function(t){return void 0!==t.instrumentName},f=function(t){return void 0!==t.keyPressure},l=function(t){return void 0!==t.keySignature},d=function(t){return void 0!==t.lyric},p=function(t){return void 0!==t.marker},h=function(t){return void 0!==t.midiPort},v=function(t){return void 0!==t.noteOff},y=function(t){return void 0!==t.noteOn},m=function(t){return void 0!==t.pitchBend},g=function(t){return void 0!==t.programChange},w=function(t){return void 0!==t.programName},b=function(t){return void 0!==t.sequencerSpecificData},x=function(t){return void 0!==t.setTempo},U=function(t){return void 0!==t.smpteOffset},O=function(t){return void 0!==t.sysex},_=function(t){return void 0!==t.text&&void 0===t.metaTypeByte},E=function(t){return void 0!==t.timeSignature},S=function(t){return void 0!==t.trackName},A=function(t){return void 0!==t.metaTypeByte},L=function(t,e,L,N){return function(k){if(r(k)){var P=t(4),j=P.arrayBuffer,M=P.dataView;return M.setUint8(0,255),M.setUint8(1,32),M.setUint8(2,1),M.setUint8(3,k.channelPrefix),j}if(n(k)){var T=t(2),B=T.arrayBuffer,V=T.dataView;return V.setUint8(0,13|15&k.channel),V.setUint8(1,k.channelPressure.pressure),B}if(o(k)){var I=t(3),R=I.arrayBuffer,D=I.dataView;return D.setUint8(0,176|15&k.channel),D.setUint8(1,k.controlChange.type),D.setUint8(2,k.controlChange.value),R}if(i(k))return e(k,2,\"copyrightNotice\");if(a(k))return e(k,7,\"cuePoint\");if(u(k))return e(k,9,\"deviceName\");if(s(k)){var F=t(3),q=F.arrayBuffer,C=F.dataView;return C.setUint8(0,255),C.setUint8(1,47),C.setUint8(2,0),q}if(c(k))return e(k,4,\"instrumentName\");if(f(k)){var G=t(3),Q=G.arrayBuffer,z=G.dataView;return z.setUint8(0,10|15&k.channel),z.setUint8(1,k.keyPressure.noteNumber),z.setUint8(2,k.keyPressure.pressure),Q}if(l(k)){var W=t(5),$=W.arrayBuffer,H=W.dataView;return H.setUint8(0,255),H.setUint8(1,89),H.setUint8(2,2),H.setUint8(3,k.keySignature.key),H.setUint8(4,k.keySignature.scale),$}if(d(k))return e(k,5,\"lyric\");if(p(k))return e(k,6,\"marker\");if(h(k)){var X=t(4),Y=X.arrayBuffer,J=X.dataView;return J.setUint8(0,255),J.setUint8(1,33),J.setUint8(2,1),J.setUint8(3,k.midiPort),Y}if(v(k)){var K=t(3),Z=K.arrayBuffer,tt=K.dataView;return tt.setUint8(0,128|15&k.channel),tt.setUint8(1,k.noteOff.noteNumber),tt.setUint8(2,k.noteOff.velocity),Z}if(y(k)){var et=t(3),rt=et.arrayBuffer,nt=et.dataView;return nt.setUint8(0,144|15&k.channel),nt.setUint8(1,k.noteOn.noteNumber),nt.setUint8(2,k.noteOn.velocity),rt}if(m(k)){var ot=t(3),it=ot.arrayBuffer,at=ot.dataView;return at.setUint8(0,224|15&k.channel),at.setUint8(1,127&k.pitchBend),at.setUint8(2,k.pitchBend>>7),it}if(g(k)){var ut=t(2),st=ut.arrayBuffer,ct=ut.dataView;return ct.setUint8(0,192|15&k.channel),ct.setUint8(1,k.programChange.programNumber),st}if(w(k))return e(k,8,\"programName\");if(b(k)){var ft=t(2),lt=ft.arrayBuffer,dt=ft.dataView;dt.setUint8(0,255),dt.setUint8(1,127);for(var pt=k.sequencerSpecificData.length/2,ht=N(pt),vt=t(pt),yt=vt.arrayBuffer,mt=vt.dataView,gt=0;gt<k.sequencerSpecificData.length;gt+=2)mt.setUint8(gt/2,parseInt(k.sequencerSpecificData.slice(gt,gt+2),16));return L([lt,ht,yt])}if(x(k)){var wt=t(6),bt=wt.arrayBuffer,xt=wt.dataView;return xt.setUint8(0,255),xt.setUint8(1,81),xt.setUint8(2,3),xt.setUint8(3,k.setTempo.microsecondsPerQuarter>>16),xt.setUint8(4,k.setTempo.microsecondsPerQuarter>>8),xt.setUint8(5,k.setTempo.microsecondsPerQuarter),bt}if(U(k)){var Ut,Ot=t(8),_t=Ot.arrayBuffer,Et=Ot.dataView;if(24===k.smpteOffset.frameRate)Ut=0;else if(25===k.smpteOffset.frameRate)Ut=32;else if(29===k.smpteOffset.frameRate)Ut=64;else{if(30!==k.smpteOffset.frameRate)throw new Error;Ut=96}return Et.setUint8(0,255),Et.setUint8(1,84),Et.setUint8(2,5),Et.setUint8(3,k.smpteOffset.hour|Ut),Et.setUint8(4,k.smpteOffset.minutes),Et.setUint8(5,k.smpteOffset.seconds),Et.setUint8(6,k.smpteOffset.frame),Et.setUint8(7,k.smpteOffset.subFrame),_t}if(O(k)){var St=t(1),At=St.arrayBuffer;St.dataView.setUint8(0,240);for(var Lt=k.sysex.length/2,Nt=N(Lt),kt=t(Lt),Pt=kt.arrayBuffer,jt=kt.dataView,Mt=0;Mt<k.sysex.length;Mt+=2)jt.setUint8(Mt/2,parseInt(k.sysex.slice(Mt,Mt+2),16));return L([At,Nt,Pt])}if(E(k)){for(var Tt=t(7),Bt=Tt.arrayBuffer,Vt=Tt.dataView,It=k.timeSignature.denominator,Rt=0;It>1;)It/=2,Rt+=1;return Vt.setUint8(0,255),Vt.setUint8(1,88),Vt.setUint8(2,4),Vt.setUint8(3,k.timeSignature.numerator),Vt.setUint8(4,Rt),Vt.setUint8(5,k.timeSignature.metronome),Vt.setUint8(6,k.timeSignature.thirtyseconds),Bt}if(A(k))return e(k,parseInt(k.metaTypeByte,16),\"text\");if(_(k))return e(k,1,\"text\");if(S(k))return e(k,3,\"trackName\");throw new Error('Unencodable event with a delta of \"'.concat(k.delta,'\".'))}},N=function(t,e,r,n){return function(o,i,a){var u=t(2),s=u.arrayBuffer,c=u.dataView;c.setUint8(0,255),c.setUint8(1,i);var f=r.encode(o[a]).buffer,l=n(f.byteLength);return e([s,l,f])}},k=function(t){return function(e){for(var r=Math.max(1,Math.floor(Math.log(e)/Math.log(2)/7)+1),n=t(r),o=n.arrayBuffer,i=n.dataView,a=1;a<r;a+=1)i.setUint8(r-1-a,e>>7*a&127|128);return i.setUint8(r-1,127&e),o}},P=function(t){var e=new ArrayBuffer(t);return{arrayBuffer:e,dataView:new DataView(e)}},j=function(t){var r=t.reduce((function(t,e){return t+e.byteLength}),0),n=t.reduce((function(t,r){var n=e(t,2),o=n[0],i=n[1];return i.set(new Uint8Array(r),o),[o+r.byteLength,i]}),[0,new Uint8Array(r)]);return e(n,2)[1].buffer},M=k(P),T=L(P,N(P,j,new TextEncoder,M),j,M);t.encode=T,t.writeVariableLengthQuantity=M}(e,r(715))},987:t=>{t.exports=function(t){if(Array.isArray(t))return t},t.exports.__esModule=!0,t.exports.default=t.exports}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}r.n=t=>{var e=t&&t.__esModule?()=>t.default:()=>t;return r.d(e,{a:e}),e},r.d=(t,e)=>{for(var n in e)r.o(e,n)&&!r.o(t,n)&&Object.defineProperty(t,n,{enumerable:!0,get:e[n]})},r.o=(t,e)=>Object.prototype.hasOwnProperty.call(t,e),(()=>{\"use strict\";r(390)})()})();"; // tslint:disable-line:max-line-length
var blob = new Blob([worker], {
type: 'application/javascript; charset=utf-8'
});
var url = URL.createObjectURL(blob);
var jsonMidiEncoder = jsonMidiEncoderBroker.load(url);
var encode = jsonMidiEncoder.encode;
URL.revokeObjectURL(url);
exports.encode = encode;
}));