UNPKG

@magenta/music

Version:

Make music with machine learning, in the browser.

1 lines 218 kB
!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.transcription=t(require("@tensorflow/tfjs")):e.transcription=t(e.tf)}(self,(function(__WEBPACK_EXTERNAL_MODULE__2__){return function(e){var t={};function n(r){if(t[r])return t[r].exports;var o=t[r]={i:r,l:!1,exports:{}};return e[r].call(o.exports,o,o.exports,n),o.l=!0,o.exports}return n.m=e,n.c=t,n.d=function(e,t,r){n.o(e,t)||Object.defineProperty(e,t,{enumerable:!0,get:r})},n.r=function(e){"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})},n.t=function(e,t){if(1&t&&(e=n(e)),8&t)return e;if(4&t&&"object"==typeof e&&e&&e.__esModule)return e;var r=Object.create(null);if(n.r(r),Object.defineProperty(r,"default",{enumerable:!0,value:e}),2&t&&"string"!=typeof e)for(var o in e)n.d(r,o,function(t){return e[t]}.bind(null,o));return r},n.n=function(e){var t=e&&e.__esModule?function(){return e.default}:function(){return e};return n.d(t,"a",t),t},n.o=function(e,t){return Object.prototype.hasOwnProperty.call(e,t)},n.p="",n(n.s=184)}([,,function(e,t){e.exports=__WEBPACK_EXTERNAL_MODULE__2__},,,,,,,,function(e,t,n){"use strict";n.d(t,"a",(function(){return o}));var r=n(35),o=r.tensorflow.magenta.NoteSequence},,function(e,t,n){"use strict";n.r(t),n.d(t,"Level",(function(){return r})),n.d(t,"verbosity",(function(){return i})),n.d(t,"setVerbosity",(function(){return a})),n.d(t,"log",(function(){return s})),n.d(t,"logWithDuration",(function(){return u}));var r,o=n(15);!function(e){e[e.NONE=0]="NONE",e[e.WARN=5]="WARN",e[e.INFO=10]="INFO",e[e.DEBUG=20]="DEBUG"}(r||(r={}));let i=10;function a(e){e=e}function s(e,t="Magenta.js",n=10){if(0===n)throw Error("Logging level cannot be NONE.");if(i>=n){(5===n?console.warn:console.log)(`%c ${t} `,"background:magenta; color:white",e)}}function u(e,t,n="Magenta.js",r=10){s(`${e} in ${((o.d.now()-t)/1e3).toPrecision(3)}s`,n,r)}},,,function(e,t,n){"use strict";(function(e){n.d(t,"a",(function(){return o})),n.d(t,"d",(function(){return i})),n.d(t,"c",(function(){return a})),n.d(t,"b",(function(){return u}));const r=function(){if("undefined"!=typeof globalThis)return globalThis;if("undefined"!=typeof self)return self;if("undefined"!=typeof window)return window;if(void 0!==e)return e;throw new Error("cannot find the global object")}(),o=r.fetch.bind(r),i=r.performance,a=(r.navigator,!!r.webkitOfflineAudioContext),s=void 0!==r.WorkerGlobalScope;function u(e){if(e=a?44100:e,s)throw new Error("Cannot use offline audio context in a web worker.");const t=r.webkitOfflineAudioContext;return a?new t(1,e,e):new r.OfflineAudioContext(1,e,e)}}).call(this,n(21))},,,function(e,t,n){"use strict";(function(e){var r=t;function o(e,t,n){for(var r=Object.keys(t),o=0;o<r.length;++o)void 0!==e[r[o]]&&n||(e[r[o]]=t[r[o]]);return e}function i(e){function t(e,n){if(!(this instanceof t))return new t(e,n);Object.defineProperty(this,"message",{get:function(){return e}}),Error.captureStackTrace?Error.captureStackTrace(this,t):Object.defineProperty(this,"stack",{value:(new Error).stack||""}),n&&o(this,n)}return(t.prototype=Object.create(Error.prototype)).constructor=t,Object.defineProperty(t.prototype,"name",{get:function(){return e}}),t.prototype.toString=function(){return this.name+": "+this.message},t}r.asPromise=n(51),r.base64=n(52),r.EventEmitter=n(53),r.float=n(54),r.inquire=n(55),r.utf8=n(56),r.pool=n(57),r.LongBits=n(58),r.isNode=Boolean(void 0!==e&&e&&e.process&&e.process.versions&&e.process.versions.node),r.global=r.isNode&&e||"undefined"!=typeof window&&window||"undefined"!=typeof self&&self||this,r.emptyArray=Object.freeze?Object.freeze([]):[],r.emptyObject=Object.freeze?Object.freeze({}):{},r.isInteger=Number.isInteger||function(e){return"number"==typeof e&&isFinite(e)&&Math.floor(e)===e},r.isString=function(e){return"string"==typeof e||e instanceof String},r.isObject=function(e){return e&&"object"==typeof e},r.isset=r.isSet=function(e,t){var n=e[t];return!(null==n||!e.hasOwnProperty(t))&&("object"!=typeof n||(Array.isArray(n)?n.length:Object.keys(n).length)>0)},r.Buffer=function(){try{var e=r.inquire("buffer").Buffer;return e.prototype.utf8Write?e:null}catch(e){return null}}(),r._Buffer_from=null,r._Buffer_allocUnsafe=null,r.newBuffer=function(e){return"number"==typeof e?r.Buffer?r._Buffer_allocUnsafe(e):new r.Array(e):r.Buffer?r._Buffer_from(e):"undefined"==typeof Uint8Array?e:new Uint8Array(e)},r.Array="undefined"!=typeof Uint8Array?Uint8Array:Array,r.Long=r.global.dcodeIO&&r.global.dcodeIO.Long||r.global.Long||r.inquire("long"),r.key2Re=/^true|false|0|1$/,r.key32Re=/^-?(?:0|[1-9][0-9]*)$/,r.key64Re=/^(?:[\\x00-\\xff]{8}|-?(?:0|[1-9][0-9]*))$/,r.longToHash=function(e){return e?r.LongBits.from(e).toHash():r.LongBits.zeroHash},r.longFromHash=function(e,t){var n=r.LongBits.fromHash(e);return r.Long?r.Long.fromBits(n.lo,n.hi,t):n.toNumber(Boolean(t))},r.merge=o,r.lcFirst=function(e){return e.charAt(0).toLowerCase()+e.substring(1)},r.newError=i,r.ProtocolError=i("ProtocolError"),r.oneOfGetter=function(e){for(var t={},n=0;n<e.length;++n)t[e[n]]=1;return function(){for(var e=Object.keys(this),n=e.length-1;n>-1;--n)if(1===t[e[n]]&&void 0!==this[e[n]]&&null!==this[e[n]])return e[n]}},r.oneOfSetter=function(e){return function(t){for(var n=0;n<e.length;++n)e[n]!==t&&delete this[e[n]]}},r.toJSONOptions={longs:String,enums:String,bytes:String,json:!0},r._configure=function(){var e=r.Buffer;e?(r._Buffer_from=e.from!==Uint8Array.from&&e.from||function(t,n){return new e(t,n)},r._Buffer_allocUnsafe=e.allocUnsafe||function(t){return new e(t)}):r._Buffer_from=r._Buffer_allocUnsafe=null}}).call(this,n(21))},,function(e,t,n){"use strict";n.d(t,"e",(function(){return l})),n.d(t,"d",(function(){return f})),n.d(t,"f",(function(){return p})),n.d(t,"i",(function(){return h})),n.d(t,"j",(function(){return m})),n.d(t,"a",(function(){return y})),n.d(t,"h",(function(){return b})),n.d(t,"b",(function(){return v})),n.d(t,"g",(function(){return _})),n.d(t,"c",(function(){return N}));var r=n(2),o=n(43),i=n(30),a=n(74),s=n(15),u=n(12);const c=Object(s.b)(16e3);async function l(e){return Object(s.a)(e).then(e=>e.arrayBuffer()).then(e=>c.decodeAudioData(e))}async function f(e){const t=new FileReader;return new Promise((n,r)=>{t.onerror=()=>{t.abort(),r(new DOMException("Something went wrong reading that file."))},t.onload=()=>{n(t.result)},t.readAsArrayBuffer(e)}).then(e=>c.decodeAudioData(e))}function p(e,t){t.power||(t.power=2);const n=function(e,t){const n=t.nFft||2048,r=t.winLength||n,o=t.hopLength||Math.floor(r/4);let i=v(r);i=b(i,n);const a=function(e,t,n){const r=Math.floor((e.length-t)/n)+1,o=Array.from({length:r},(e,n)=>new Float32Array(t));for(let i=0;i<r;i++){const r=i*n,a=e.slice(r,r+t);o[i].set(a),a.length}return o}(e=function(e,t){const n=w(e,t);for(let e=0;e<t;e++)n[e]=n[2*t-e],n[n.length-e-1]=n[n.length-2*t+e-1];return n}(e,Math.floor(n/2)),n,o),s=[],u=a.length,c=n+2;for(let e=0;e<u;e++){const t=new Float32Array(c);s[e]=t}for(let e=0;e<u;e++){const t=S(y(a[e],i));s[e].set(t.slice(0,c))}return s}(e,t),[r,o]=function(e,t){const n=e.map(e=>function(e,t){return e.map(e=>Math.pow(e,t))}(function(e){const t=new Float32Array(e.length/2);for(let n=0;n<e.length/2;n++)t[n]=Math.sqrt(e[2*n]*e[2*n]+e[2*n+1]*e[2*n+1]);return t}(e),t)),r=e[0].length-1;return[n,r]}(n,t.power);t.nFft=o;return function(e,t){const n=[];for(let r=0;r<e.length;r++)n[r]=g(e[r],t);return n}(r,function(e){const t=e.fMin||0,n=e.fMax||e.sampleRate/2,r=e.nMels||128,o=e.nFft||2048,i=function(e,t){return A(0,e/2,Math.floor(1+t/2))}(e.sampleRate,o),a=function(e,t,n){const r=O(t),o=O(n),i=A(r,o,e);return i.map(e=>function(e){return 700*(Math.exp(e/1125)-1)}(e))}(r+2,t,n),s=function(e){const t=new Float32Array(e.length-1);for(let n=0;n<e.length;n++)t[n]=e[n+1]-e[n];return t}(a),u=function(e,t){const n=[];for(let r=0;r<e.length;r++)n[r]=new Float32Array(t.length);for(let r=0;r<e.length;r++)for(let o=0;o<t.length;o++)n[r][o]=e[r]-t[o];return n}(a,i),c=u[0].length,l=[];for(let e=0;e<r;e++){l[e]=new Float32Array(c);for(let t=0;t<u[e].length;t++){const n=-u[e][t]/s[e],r=u[e+2][t]/s[e+1],o=Math.max(0,Math.min(n,r));l[e][t]=o}}for(let e=0;e<l.length;e++){const t=2/(a[2+e]-a[e]);l[e]=l[e].map(e=>e*t)}return l}(t))}function h(e,t=1e-10,n=80){const r=e.length,o=e[0].length,i=[];for(let e=0;e<r;e++)i[e]=new Float32Array(o);for(let n=0;n<r;n++)for(let r=0;r<o;r++){const o=e[n][r];i[n][r]=10*Math.log10(Math.max(t,o))}if(n){if(n<0)throw new Error("topDb must be non-negative.");for(let e=0;e<r;e++){const t=i[e].reduce((e,t)=>Math.max(e,t));for(let r=0;r<o;r++)i[e][r]=Math.max(i[e][r],t-n)}}return i}function d(e){if(1===e.numberOfChannels)return e.getChannelData(0);if(2!==e.numberOfChannels)throw Error(e.numberOfChannels+" channel audio is not supported.");const t=e.getChannelData(0),n=e.getChannelData(1),r=new Float32Array(e.length);for(let o=0;o<e.length;++o)r[o]=(t[o]+n[o])/2;return r}async function m(e,t=16e3){if(e.sampleRate===t)return d(e);const n=e.sampleRate,r=e.length*t/n;if(s.c){u.log("Safari does not support WebAudio resampling, so this may be slow.","O&F",5);const t=d(e),n=new Float32Array(r);return a(i(n,[r]),i(t,[t.length])),n}{const n=new OfflineAudioContext(e.numberOfChannels,e.duration*t,t),r=n.createBufferSource();return r.buffer=e,r.connect(n.destination),r.start(),n.startRendering().then(e=>e.getChannelData(0))}}function g(e,t){if(e.length!==t[0].length)throw new Error(`Each entry in filterbank should have dimensions matching FFT. |mags| = ${e.length}, |filterbank[0]| = ${t[0].length}.`);const n=new Float32Array(t.length);for(let r=0;r<t.length;r++){const o=y(e,t[r]);n[r]=o.reduce((e,t)=>e+t)}return n}function y(e,t){if(e.length!==t.length)return console.error(`Buffer length ${e.length} != window length ${t.length}.`),null;const n=new Float32Array(e.length);for(let r=0;r<e.length;r++)n[r]=t[r]*e[r];return n}function b(e,t){if(e.length>t)throw new Error("Data is longer than length.");const n=Math.floor((t-e.length)/2);return w(e,[n,t-e.length-n])}function w(e,t){let n,r;"object"==typeof t?[n,r]=t:n=r=t;const o=new Float32Array(e.length+n+r);return o.set(e,n),o}function S(e){const t=new o(e.length),n=t.createComplexArray(),r=t.toComplexArray(e);return t.transform(n,r),n}function v(e){const t=new Float32Array(e);for(let n=0;n<e;n++)t[n]=.5*(1-Math.cos(2*Math.PI*n/(e-1)));return t}function A(e,t,n){const r=(t-e)/(n-1),o=new Float32Array(n);for(let t=0;t<n;t++)o[t]=e+r*t;return o}function _(e){let t=r.sub(e,69);return t=r.div(t,12),t=r.pow(2,t),t=r.mul(440,t),t}async function N(e){let t=r.sub(r.div(r.log(e),r.log(2)),r.div(r.log(440),r.log(2)));t=r.mul(12,t),t=r.add(t,69);return await t.array()}function O(e){return 1125*Math.log(1+e/700)}},function(e,t){var n;n=function(){return this}();try{n=n||new Function("return this")()}catch(e){"object"==typeof window&&(n=window)}e.exports=n},,,,,,,,,function(e,t,n){var r=n(84),o=n(85),i="undefined"!=typeof Float64Array;function a(e,t){return e[0]-t[0]}function s(){var e,t=this.stride,n=new Array(t.length);for(e=0;e<n.length;++e)n[e]=[Math.abs(t[e]),e];n.sort(a);var r=new Array(n.length);for(e=0;e<r.length;++e)r[e]=n[e][1];return r}function u(e,t){var n=["View",t,"d",e].join("");t<0&&(n="View_Nil"+e);var o="generic"===e;if(-1===t){var i="function "+n+"(a){this.data=a;};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return -1};proto.size=0;proto.dimension=-1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function(){return new "+n+"(this.data);};proto.get=proto.set=function(){};proto.pick=function(){return null};return function construct_"+n+"(a){return new "+n+"(a);}";return new Function(i)()}if(0===t){i="function "+n+"(a,d) {this.data = a;this.offset = d};var proto="+n+".prototype;proto.dtype='"+e+"';proto.index=function(){return this.offset};proto.dimension=0;proto.size=1;proto.shape=proto.stride=proto.order=[];proto.lo=proto.hi=proto.transpose=proto.step=function "+n+"_copy() {return new "+n+"(this.data,this.offset)};proto.pick=function "+n+"_pick(){return TrivialArray(this.data);};proto.valueOf=proto.get=function "+n+"_get(){return "+(o?"this.data.get(this.offset)":"this.data[this.offset]")+"};proto.set=function "+n+"_set(v){return "+(o?"this.data.set(this.offset,v)":"this.data[this.offset]=v")+"};return function construct_"+n+"(a,b,c,d){return new "+n+"(a,d)}";return new Function("TrivialArray",i)(c[e][0])}i=["'use strict'"];var a=r(t),u=a.map((function(e){return"i"+e})),l="this.offset+"+a.map((function(e){return"this.stride["+e+"]*i"+e})).join("+"),f=a.map((function(e){return"b"+e})).join(","),p=a.map((function(e){return"c"+e})).join(",");i.push("function "+n+"(a,"+f+","+p+",d){this.data=a","this.shape=["+f+"]","this.stride=["+p+"]","this.offset=d|0}","var proto="+n+".prototype","proto.dtype='"+e+"'","proto.dimension="+t),i.push("Object.defineProperty(proto,'size',{get:function "+n+"_size(){return "+a.map((function(e){return"this.shape["+e+"]"})).join("*"),"}})"),1===t?i.push("proto.order=[0]"):(i.push("Object.defineProperty(proto,'order',{get:"),t<4?(i.push("function "+n+"_order(){"),2===t?i.push("return (Math.abs(this.stride[0])>Math.abs(this.stride[1]))?[1,0]:[0,1]}})"):3===t&&i.push("var s0=Math.abs(this.stride[0]),s1=Math.abs(this.stride[1]),s2=Math.abs(this.stride[2]);if(s0>s1){if(s1>s2){return [2,1,0];}else if(s0>s2){return [1,2,0];}else{return [1,0,2];}}else if(s0>s2){return [2,0,1];}else if(s2>s1){return [0,1,2];}else{return [0,2,1];}}})")):i.push("ORDER})")),i.push("proto.set=function "+n+"_set("+u.join(",")+",v){"),o?i.push("return this.data.set("+l+",v)}"):i.push("return this.data["+l+"]=v}"),i.push("proto.get=function "+n+"_get("+u.join(",")+"){"),o?i.push("return this.data.get("+l+")}"):i.push("return this.data["+l+"]}"),i.push("proto.index=function "+n+"_index(",u.join(),"){return "+l+"}"),i.push("proto.hi=function "+n+"_hi("+u.join(",")+"){return new "+n+"(this.data,"+a.map((function(e){return["(typeof i",e,"!=='number'||i",e,"<0)?this.shape[",e,"]:i",e,"|0"].join("")})).join(",")+","+a.map((function(e){return"this.stride["+e+"]"})).join(",")+",this.offset)}");var h=a.map((function(e){return"a"+e+"=this.shape["+e+"]"})),d=a.map((function(e){return"c"+e+"=this.stride["+e+"]"}));i.push("proto.lo=function "+n+"_lo("+u.join(",")+"){var b=this.offset,d=0,"+h.join(",")+","+d.join(","));for(var m=0;m<t;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){d=i"+m+"|0;b+=c"+m+"*d;a"+m+"-=d}");i.push("return new "+n+"(this.data,"+a.map((function(e){return"a"+e})).join(",")+","+a.map((function(e){return"c"+e})).join(",")+",b)}"),i.push("proto.step=function "+n+"_step("+u.join(",")+"){var "+a.map((function(e){return"a"+e+"=this.shape["+e+"]"})).join(",")+","+a.map((function(e){return"b"+e+"=this.stride["+e+"]"})).join(",")+",c=this.offset,d=0,ceil=Math.ceil");for(m=0;m<t;++m)i.push("if(typeof i"+m+"==='number'){d=i"+m+"|0;if(d<0){c+=b"+m+"*(a"+m+"-1);a"+m+"=ceil(-a"+m+"/d)}else{a"+m+"=ceil(a"+m+"/d)}b"+m+"*=d}");i.push("return new "+n+"(this.data,"+a.map((function(e){return"a"+e})).join(",")+","+a.map((function(e){return"b"+e})).join(",")+",c)}");var g=new Array(t),y=new Array(t);for(m=0;m<t;++m)g[m]="a[i"+m+"]",y[m]="b[i"+m+"]";i.push("proto.transpose=function "+n+"_transpose("+u+"){"+u.map((function(e,t){return e+"=("+e+"===undefined?"+t+":"+e+"|0)"})).join(";"),"var a=this.shape,b=this.stride;return new "+n+"(this.data,"+g.join(",")+","+y.join(",")+",this.offset)}"),i.push("proto.pick=function "+n+"_pick("+u+"){var a=[],b=[],c=this.offset");for(m=0;m<t;++m)i.push("if(typeof i"+m+"==='number'&&i"+m+">=0){c=(c+this.stride["+m+"]*i"+m+")|0}else{a.push(this.shape["+m+"]);b.push(this.stride["+m+"])}");return i.push("var ctor=CTOR_LIST[a.length+1];return ctor(this.data,a,b,c)}"),i.push("return function construct_"+n+"(data,shape,stride,offset){return new "+n+"(data,"+a.map((function(e){return"shape["+e+"]"})).join(",")+","+a.map((function(e){return"stride["+e+"]"})).join(",")+",offset)}"),new Function("CTOR_LIST","ORDER",i.join("\n"))(c[e],s)}var c={float32:[],float64:[],int8:[],int16:[],int32:[],uint8:[],uint16:[],uint32:[],array:[],uint8_clamped:[],bigint64:[],biguint64:[],buffer:[],generic:[]};e.exports=function(e,t,n,r){if(void 0===e)return(0,c.array[0])([]);"number"==typeof e&&(e=[e]),void 0===t&&(t=[e.length]);var a=t.length;if(void 0===n){n=new Array(a);for(var s=a-1,l=1;s>=0;--s)n[s]=l,l*=t[s]}if(void 0===r){r=0;for(s=0;s<a;++s)n[s]<0&&(r-=(t[s]-1)*n[s])}for(var f=function(e){if(o(e))return"buffer";if(i)switch(Object.prototype.toString.call(e)){case"[object Float64Array]":return"float64";case"[object Float32Array]":return"float32";case"[object Int8Array]":return"int8";case"[object Int16Array]":return"int16";case"[object Int32Array]":return"int32";case"[object Uint8Array]":return"uint8";case"[object Uint16Array]":return"uint16";case"[object Uint32Array]":return"uint32";case"[object Uint8ClampedArray]":return"uint8_clamped";case"[object BigInt64Array]":return"bigint64";case"[object BigUint64Array]":return"biguint64"}return Array.isArray(e)?"array":"generic"}(e),p=c[f];p.length<=a+1;)p.push(u(f,p.length-1));return(0,p[a+1])(e,t,n,r)}},,,function(e,t,n){"use strict";e.exports=f;var r,o=n(18),i=o.LongBits,a=o.base64,s=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 f(){this.len=0,this.head=new u(c,0,0),this.tail=this.head,this.states=null}var p=function(){return o.Buffer?function(){return(f.create=function(){return new r})()}:function(){return new f}};function h(e,t,n){t[n]=255&e}function d(e,t){this.len=e,this.next=void 0,this.val=t}function m(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}f.create=p(),f.alloc=function(e){return new o.Array(e)},o.Array!==Array&&(f.alloc=o.pool(f.alloc,o.Array.prototype.subarray)),f.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},f.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},f.prototype.int32=function(e){return e<0?this._push(m,10,i.fromNumber(e)):this.uint32(e)},f.prototype.sint32=function(e){return this.uint32((e<<1^e>>31)>>>0)},f.prototype.uint64=function(e){var t=i.from(e);return this._push(m,t.length(),t)},f.prototype.int64=f.prototype.uint64,f.prototype.sint64=function(e){var t=i.from(e).zzEncode();return this._push(m,t.length(),t)},f.prototype.bool=function(e){return this._push(h,1,e?1:0)},f.prototype.fixed32=function(e){return this._push(g,4,e>>>0)},f.prototype.sfixed32=f.prototype.fixed32,f.prototype.fixed64=function(e){var t=i.from(e);return this._push(g,4,t.lo)._push(g,4,t.hi)},f.prototype.sfixed64=f.prototype.fixed64,f.prototype.float=function(e){return this._push(o.float.writeFloatLE,4,e)},f.prototype.double=function(e){return this._push(o.float.writeDoubleLE,8,e)};var y=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]};f.prototype.bytes=function(e){var t=e.length>>>0;if(!t)return this._push(h,1,0);if(o.isString(e)){var n=f.alloc(t=a.length(e));a.decode(e,n,0),e=n}return this.uint32(t)._push(y,t,e)},f.prototype.string=function(e){var t=s.length(e);return t?this.uint32(t)._push(s.write,t,e):this._push(h,1,0)},f.prototype.fork=function(){return this.states=new l(this),this.head=this.tail=new u(c,0,0),this.len=0,this},f.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},f.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},f.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},f._configure=function(e){r=e,f.create=p(),r._configure()}},function(e,t,n){"use strict";e.exports=u;var r,o=n(18),i=o.LongBits,a=o.utf8;function s(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")},f=function(){return o.Buffer?function(e){return(u.create=function(e){return o.Buffer.isBuffer(e)?new r(e):l(e)})(e)}:l};function p(){var e=new i(0,0),t=0;if(!(this.len-this.pos>4)){for(;t<3;++t){if(this.pos>=this.len)throw s(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 s(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 h(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 s(this,8);return new i(h(this.buf,this.pos+=4),h(this.buf,this.pos+=4))}u.create=f(),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,s(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)|0},u.prototype.bool=function(){return 0!==this.uint32()},u.prototype.fixed32=function(){if(this.pos+4>this.len)throw s(this,4);return h(this.buf,this.pos+=4)},u.prototype.sfixed32=function(){if(this.pos+4>this.len)throw s(this,4);return 0|h(this.buf,this.pos+=4)},u.prototype.float=function(){if(this.pos+4>this.len)throw s(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 s(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 s(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 a.read(e,0,e.length)},u.prototype.skip=function(e){if("number"==typeof e){if(this.pos+e>this.len)throw s(this,e);this.pos+=e}else do{if(this.pos>=this.len)throw s(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=f(),r._configure();var t=o.Long?"toLong":"toNumber";o.merge(u.prototype,{int64:function(){return p.call(this)[t](!1)},uint64:function(){return p.call(this)[t](!0)},sint64:function(){return p.call(this).zzDecode()[t](!1)},fixed64:function(){return d.call(this)[t](!0)},sfixed64:function(){return d.call(this)[t](!1)}})}},function(e,t,n){"use strict";var r,o,i=n(49),a=i.Reader,s=i.Writer,u=i.util,c=i.roots.default||(i.roots.default={});c.tensorflow=((o={}).magenta=((r={}).NoteSequence=function(){function e(e){if(this.timeSignatures=[],this.keySignatures=[],this.tempos=[],this.notes=[],this.pitchBends=[],this.controlChanges=[],this.partInfos=[],this.textAnnotations=[],this.sectionAnnotations=[],this.sectionGroups=[],e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}var t,n;return e.prototype.id="",e.prototype.filename="",e.prototype.referenceNumber=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.collectionName="",e.prototype.ticksPerQuarter=0,e.prototype.timeSignatures=u.emptyArray,e.prototype.keySignatures=u.emptyArray,e.prototype.tempos=u.emptyArray,e.prototype.notes=u.emptyArray,e.prototype.totalTime=0,e.prototype.totalQuantizedSteps=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.pitchBends=u.emptyArray,e.prototype.controlChanges=u.emptyArray,e.prototype.partInfos=u.emptyArray,e.prototype.sourceInfo=null,e.prototype.textAnnotations=u.emptyArray,e.prototype.sectionAnnotations=u.emptyArray,e.prototype.sectionGroups=u.emptyArray,e.prototype.quantizationInfo=null,e.prototype.subsequenceInfo=null,e.prototype.sequenceMetadata=null,e.create=function(t){return new e(t)},e.encode=function(e,t){if(t||(t=s.create()),null!=e.id&&e.hasOwnProperty("id")&&t.uint32(10).string(e.id),null!=e.filename&&e.hasOwnProperty("filename")&&t.uint32(18).string(e.filename),null!=e.collectionName&&e.hasOwnProperty("collectionName")&&t.uint32(26).string(e.collectionName),null!=e.ticksPerQuarter&&e.hasOwnProperty("ticksPerQuarter")&&t.uint32(32).int32(e.ticksPerQuarter),null!=e.timeSignatures&&e.timeSignatures.length)for(var n=0;n<e.timeSignatures.length;++n)c.tensorflow.magenta.NoteSequence.TimeSignature.encode(e.timeSignatures[n],t.uint32(42).fork()).ldelim();if(null!=e.keySignatures&&e.keySignatures.length)for(n=0;n<e.keySignatures.length;++n)c.tensorflow.magenta.NoteSequence.KeySignature.encode(e.keySignatures[n],t.uint32(50).fork()).ldelim();if(null!=e.tempos&&e.tempos.length)for(n=0;n<e.tempos.length;++n)c.tensorflow.magenta.NoteSequence.Tempo.encode(e.tempos[n],t.uint32(58).fork()).ldelim();if(null!=e.notes&&e.notes.length)for(n=0;n<e.notes.length;++n)c.tensorflow.magenta.NoteSequence.Note.encode(e.notes[n],t.uint32(66).fork()).ldelim();if(null!=e.totalTime&&e.hasOwnProperty("totalTime")&&t.uint32(73).double(e.totalTime),null!=e.pitchBends&&e.pitchBends.length)for(n=0;n<e.pitchBends.length;++n)c.tensorflow.magenta.NoteSequence.PitchBend.encode(e.pitchBends[n],t.uint32(82).fork()).ldelim();if(null!=e.controlChanges&&e.controlChanges.length)for(n=0;n<e.controlChanges.length;++n)c.tensorflow.magenta.NoteSequence.ControlChange.encode(e.controlChanges[n],t.uint32(90).fork()).ldelim();if(null!=e.partInfos&&e.partInfos.length)for(n=0;n<e.partInfos.length;++n)c.tensorflow.magenta.NoteSequence.PartInfo.encode(e.partInfos[n],t.uint32(98).fork()).ldelim();if(null!=e.sourceInfo&&e.hasOwnProperty("sourceInfo")&&c.tensorflow.magenta.NoteSequence.SourceInfo.encode(e.sourceInfo,t.uint32(106).fork()).ldelim(),null!=e.textAnnotations&&e.textAnnotations.length)for(n=0;n<e.textAnnotations.length;++n)c.tensorflow.magenta.NoteSequence.TextAnnotation.encode(e.textAnnotations[n],t.uint32(114).fork()).ldelim();if(null!=e.quantizationInfo&&e.hasOwnProperty("quantizationInfo")&&c.tensorflow.magenta.NoteSequence.QuantizationInfo.encode(e.quantizationInfo,t.uint32(122).fork()).ldelim(),null!=e.totalQuantizedSteps&&e.hasOwnProperty("totalQuantizedSteps")&&t.uint32(128).int64(e.totalQuantizedSteps),null!=e.subsequenceInfo&&e.hasOwnProperty("subsequenceInfo")&&c.tensorflow.magenta.NoteSequence.SubsequenceInfo.encode(e.subsequenceInfo,t.uint32(138).fork()).ldelim(),null!=e.referenceNumber&&e.hasOwnProperty("referenceNumber")&&t.uint32(144).int64(e.referenceNumber),null!=e.sequenceMetadata&&e.hasOwnProperty("sequenceMetadata")&&c.tensorflow.magenta.SequenceMetadata.encode(e.sequenceMetadata,t.uint32(154).fork()).ldelim(),null!=e.sectionAnnotations&&e.sectionAnnotations.length)for(n=0;n<e.sectionAnnotations.length;++n)c.tensorflow.magenta.NoteSequence.SectionAnnotation.encode(e.sectionAnnotations[n],t.uint32(162).fork()).ldelim();if(null!=e.sectionGroups&&e.sectionGroups.length)for(n=0;n<e.sectionGroups.length;++n)c.tensorflow.magenta.NoteSequence.SectionGroup.encode(e.sectionGroups[n],t.uint32(170).fork()).ldelim();return t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new c.tensorflow.magenta.NoteSequence;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.id=e.string();break;case 2:r.filename=e.string();break;case 18:r.referenceNumber=u.Long?e.int64().toNumber():e.int64();break;case 3:r.collectionName=e.string();break;case 4:r.ticksPerQuarter=e.int32();break;case 5:r.timeSignatures&&r.timeSignatures.length||(r.timeSignatures=[]),r.timeSignatures.push(c.tensorflow.magenta.NoteSequence.TimeSignature.decode(e,e.uint32()));break;case 6:r.keySignatures&&r.keySignatures.length||(r.keySignatures=[]),r.keySignatures.push(c.tensorflow.magenta.NoteSequence.KeySignature.decode(e,e.uint32()));break;case 7:r.tempos&&r.tempos.length||(r.tempos=[]),r.tempos.push(c.tensorflow.magenta.NoteSequence.Tempo.decode(e,e.uint32()));break;case 8:r.notes&&r.notes.length||(r.notes=[]),r.notes.push(c.tensorflow.magenta.NoteSequence.Note.decode(e,e.uint32()));break;case 9:r.totalTime=e.double();break;case 16:r.totalQuantizedSteps=u.Long?e.int64().toNumber():e.int64();break;case 10:r.pitchBends&&r.pitchBends.length||(r.pitchBends=[]),r.pitchBends.push(c.tensorflow.magenta.NoteSequence.PitchBend.decode(e,e.uint32()));break;case 11:r.controlChanges&&r.controlChanges.length||(r.controlChanges=[]),r.controlChanges.push(c.tensorflow.magenta.NoteSequence.ControlChange.decode(e,e.uint32()));break;case 12:r.partInfos&&r.partInfos.length||(r.partInfos=[]),r.partInfos.push(c.tensorflow.magenta.NoteSequence.PartInfo.decode(e,e.uint32()));break;case 13:r.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.decode(e,e.uint32());break;case 14:r.textAnnotations&&r.textAnnotations.length||(r.textAnnotations=[]),r.textAnnotations.push(c.tensorflow.magenta.NoteSequence.TextAnnotation.decode(e,e.uint32()));break;case 20:r.sectionAnnotations&&r.sectionAnnotations.length||(r.sectionAnnotations=[]),r.sectionAnnotations.push(c.tensorflow.magenta.NoteSequence.SectionAnnotation.decode(e,e.uint32()));break;case 21:r.sectionGroups&&r.sectionGroups.length||(r.sectionGroups=[]),r.sectionGroups.push(c.tensorflow.magenta.NoteSequence.SectionGroup.decode(e,e.uint32()));break;case 15:r.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.decode(e,e.uint32());break;case 17:r.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.decode(e,e.uint32());break;case 19:r.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.decode(e,e.uint32());break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.id&&e.hasOwnProperty("id")&&!u.isString(e.id))return"id: string expected";if(null!=e.filename&&e.hasOwnProperty("filename")&&!u.isString(e.filename))return"filename: string expected";if(null!=e.referenceNumber&&e.hasOwnProperty("referenceNumber")&&!(u.isInteger(e.referenceNumber)||e.referenceNumber&&u.isInteger(e.referenceNumber.low)&&u.isInteger(e.referenceNumber.high)))return"referenceNumber: integer|Long expected";if(null!=e.collectionName&&e.hasOwnProperty("collectionName")&&!u.isString(e.collectionName))return"collectionName: string expected";if(null!=e.ticksPerQuarter&&e.hasOwnProperty("ticksPerQuarter")&&!u.isInteger(e.ticksPerQuarter))return"ticksPerQuarter: integer expected";if(null!=e.timeSignatures&&e.hasOwnProperty("timeSignatures")){if(!Array.isArray(e.timeSignatures))return"timeSignatures: array expected";for(var t=0;t<e.timeSignatures.length;++t)if(n=c.tensorflow.magenta.NoteSequence.TimeSignature.verify(e.timeSignatures[t]))return"timeSignatures."+n}if(null!=e.keySignatures&&e.hasOwnProperty("keySignatures")){if(!Array.isArray(e.keySignatures))return"keySignatures: array expected";for(t=0;t<e.keySignatures.length;++t)if(n=c.tensorflow.magenta.NoteSequence.KeySignature.verify(e.keySignatures[t]))return"keySignatures."+n}if(null!=e.tempos&&e.hasOwnProperty("tempos")){if(!Array.isArray(e.tempos))return"tempos: array expected";for(t=0;t<e.tempos.length;++t)if(n=c.tensorflow.magenta.NoteSequence.Tempo.verify(e.tempos[t]))return"tempos."+n}if(null!=e.notes&&e.hasOwnProperty("notes")){if(!Array.isArray(e.notes))return"notes: array expected";for(t=0;t<e.notes.length;++t)if(n=c.tensorflow.magenta.NoteSequence.Note.verify(e.notes[t]))return"notes."+n}if(null!=e.totalTime&&e.hasOwnProperty("totalTime")&&"number"!=typeof e.totalTime)return"totalTime: number expected";if(null!=e.totalQuantizedSteps&&e.hasOwnProperty("totalQuantizedSteps")&&!(u.isInteger(e.totalQuantizedSteps)||e.totalQuantizedSteps&&u.isInteger(e.totalQuantizedSteps.low)&&u.isInteger(e.totalQuantizedSteps.high)))return"totalQuantizedSteps: integer|Long expected";if(null!=e.pitchBends&&e.hasOwnProperty("pitchBends")){if(!Array.isArray(e.pitchBends))return"pitchBends: array expected";for(t=0;t<e.pitchBends.length;++t)if(n=c.tensorflow.magenta.NoteSequence.PitchBend.verify(e.pitchBends[t]))return"pitchBends."+n}if(null!=e.controlChanges&&e.hasOwnProperty("controlChanges")){if(!Array.isArray(e.controlChanges))return"controlChanges: array expected";for(t=0;t<e.controlChanges.length;++t)if(n=c.tensorflow.magenta.NoteSequence.ControlChange.verify(e.controlChanges[t]))return"controlChanges."+n}if(null!=e.partInfos&&e.hasOwnProperty("partInfos")){if(!Array.isArray(e.partInfos))return"partInfos: array expected";for(t=0;t<e.partInfos.length;++t)if(n=c.tensorflow.magenta.NoteSequence.PartInfo.verify(e.partInfos[t]))return"partInfos."+n}if(null!=e.sourceInfo&&e.hasOwnProperty("sourceInfo")&&(n=c.tensorflow.magenta.NoteSequence.SourceInfo.verify(e.sourceInfo)))return"sourceInfo."+n;if(null!=e.textAnnotations&&e.hasOwnProperty("textAnnotations")){if(!Array.isArray(e.textAnnotations))return"textAnnotations: array expected";for(t=0;t<e.textAnnotations.length;++t)if(n=c.tensorflow.magenta.NoteSequence.TextAnnotation.verify(e.textAnnotations[t]))return"textAnnotations."+n}if(null!=e.sectionAnnotations&&e.hasOwnProperty("sectionAnnotations")){if(!Array.isArray(e.sectionAnnotations))return"sectionAnnotations: array expected";for(t=0;t<e.sectionAnnotations.length;++t)if(n=c.tensorflow.magenta.NoteSequence.SectionAnnotation.verify(e.sectionAnnotations[t]))return"sectionAnnotations."+n}if(null!=e.sectionGroups&&e.hasOwnProperty("sectionGroups")){if(!Array.isArray(e.sectionGroups))return"sectionGroups: array expected";for(t=0;t<e.sectionGroups.length;++t){var n;if(n=c.tensorflow.magenta.NoteSequence.SectionGroup.verify(e.sectionGroups[t]))return"sectionGroups."+n}}return null!=e.quantizationInfo&&e.hasOwnProperty("quantizationInfo")&&(n=c.tensorflow.magenta.NoteSequence.QuantizationInfo.verify(e.quantizationInfo))?"quantizationInfo."+n:null!=e.subsequenceInfo&&e.hasOwnProperty("subsequenceInfo")&&(n=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.verify(e.subsequenceInfo))?"subsequenceInfo."+n:null!=e.sequenceMetadata&&e.hasOwnProperty("sequenceMetadata")&&(n=c.tensorflow.magenta.SequenceMetadata.verify(e.sequenceMetadata))?"sequenceMetadata."+n:null},e.fromObject=function(e){if(e instanceof c.tensorflow.magenta.NoteSequence)return e;var t=new c.tensorflow.magenta.NoteSequence;if(null!=e.id&&(t.id=String(e.id)),null!=e.filename&&(t.filename=String(e.filename)),null!=e.referenceNumber&&(u.Long?(t.referenceNumber=u.Long.fromValue(e.referenceNumber)).unsigned=!1:"string"==typeof e.referenceNumber?t.referenceNumber=parseInt(e.referenceNumber,10):"number"==typeof e.referenceNumber?t.referenceNumber=e.referenceNumber:"object"==typeof e.referenceNumber&&(t.referenceNumber=new u.LongBits(e.referenceNumber.low>>>0,e.referenceNumber.high>>>0).toNumber())),null!=e.collectionName&&(t.collectionName=String(e.collectionName)),null!=e.ticksPerQuarter&&(t.ticksPerQuarter=0|e.ticksPerQuarter),e.timeSignatures){if(!Array.isArray(e.timeSignatures))throw TypeError(".tensorflow.magenta.NoteSequence.timeSignatures: array expected");t.timeSignatures=[];for(var n=0;n<e.timeSignatures.length;++n){if("object"!=typeof e.timeSignatures[n])throw TypeError(".tensorflow.magenta.NoteSequence.timeSignatures: object expected");t.timeSignatures[n]=c.tensorflow.magenta.NoteSequence.TimeSignature.fromObject(e.timeSignatures[n])}}if(e.keySignatures){if(!Array.isArray(e.keySignatures))throw TypeError(".tensorflow.magenta.NoteSequence.keySignatures: array expected");for(t.keySignatures=[],n=0;n<e.keySignatures.length;++n){if("object"!=typeof e.keySignatures[n])throw TypeError(".tensorflow.magenta.NoteSequence.keySignatures: object expected");t.keySignatures[n]=c.tensorflow.magenta.NoteSequence.KeySignature.fromObject(e.keySignatures[n])}}if(e.tempos){if(!Array.isArray(e.tempos))throw TypeError(".tensorflow.magenta.NoteSequence.tempos: array expected");for(t.tempos=[],n=0;n<e.tempos.length;++n){if("object"!=typeof e.tempos[n])throw TypeError(".tensorflow.magenta.NoteSequence.tempos: object expected");t.tempos[n]=c.tensorflow.magenta.NoteSequence.Tempo.fromObject(e.tempos[n])}}if(e.notes){if(!Array.isArray(e.notes))throw TypeError(".tensorflow.magenta.NoteSequence.notes: array expected");for(t.notes=[],n=0;n<e.notes.length;++n){if("object"!=typeof e.notes[n])throw TypeError(".tensorflow.magenta.NoteSequence.notes: object expected");t.notes[n]=c.tensorflow.magenta.NoteSequence.Note.fromObject(e.notes[n])}}if(null!=e.totalTime&&(t.totalTime=Number(e.totalTime)),null!=e.totalQuantizedSteps&&(u.Long?(t.totalQuantizedSteps=u.Long.fromValue(e.totalQuantizedSteps)).unsigned=!1:"string"==typeof e.totalQuantizedSteps?t.totalQuantizedSteps=parseInt(e.totalQuantizedSteps,10):"number"==typeof e.totalQuantizedSteps?t.totalQuantizedSteps=e.totalQuantizedSteps:"object"==typeof e.totalQuantizedSteps&&(t.totalQuantizedSteps=new u.LongBits(e.totalQuantizedSteps.low>>>0,e.totalQuantizedSteps.high>>>0).toNumber())),e.pitchBends){if(!Array.isArray(e.pitchBends))throw TypeError(".tensorflow.magenta.NoteSequence.pitchBends: array expected");for(t.pitchBends=[],n=0;n<e.pitchBends.length;++n){if("object"!=typeof e.pitchBends[n])throw TypeError(".tensorflow.magenta.NoteSequence.pitchBends: object expected");t.pitchBends[n]=c.tensorflow.magenta.NoteSequence.PitchBend.fromObject(e.pitchBends[n])}}if(e.controlChanges){if(!Array.isArray(e.controlChanges))throw TypeError(".tensorflow.magenta.NoteSequence.controlChanges: array expected");for(t.controlChanges=[],n=0;n<e.controlChanges.length;++n){if("object"!=typeof e.controlChanges[n])throw TypeError(".tensorflow.magenta.NoteSequence.controlChanges: object expected");t.controlChanges[n]=c.tensorflow.magenta.NoteSequence.ControlChange.fromObject(e.controlChanges[n])}}if(e.partInfos){if(!Array.isArray(e.partInfos))throw TypeError(".tensorflow.magenta.NoteSequence.partInfos: array expected");for(t.partInfos=[],n=0;n<e.partInfos.length;++n){if("object"!=typeof e.partInfos[n])throw TypeError(".tensorflow.magenta.NoteSequence.partInfos: object expected");t.partInfos[n]=c.tensorflow.magenta.NoteSequence.PartInfo.fromObject(e.partInfos[n])}}if(null!=e.sourceInfo){if("object"!=typeof e.sourceInfo)throw TypeError(".tensorflow.magenta.NoteSequence.sourceInfo: object expected");t.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.fromObject(e.sourceInfo)}if(e.textAnnotations){if(!Array.isArray(e.textAnnotations))throw TypeError(".tensorflow.magenta.NoteSequence.textAnnotations: array expected");for(t.textAnnotations=[],n=0;n<e.textAnnotations.length;++n){if("object"!=typeof e.textAnnotations[n])throw TypeError(".tensorflow.magenta.NoteSequence.textAnnotations: object expected");t.textAnnotations[n]=c.tensorflow.magenta.NoteSequence.TextAnnotation.fromObject(e.textAnnotations[n])}}if(e.sectionAnnotations){if(!Array.isArray(e.sectionAnnotations))throw TypeError(".tensorflow.magenta.NoteSequence.sectionAnnotations: array expected");for(t.sectionAnnotations=[],n=0;n<e.sectionAnnotations.length;++n){if("object"!=typeof e.sectionAnnotations[n])throw TypeError(".tensorflow.magenta.NoteSequence.sectionAnnotations: object expected");t.sectionAnnotations[n]=c.tensorflow.magenta.NoteSequence.SectionAnnotation.fromObject(e.sectionAnnotations[n])}}if(e.sectionGroups){if(!Array.isArray(e.sectionGroups))throw TypeError(".tensorflow.magenta.NoteSequence.sectionGroups: array expected");for(t.sectionGroups=[],n=0;n<e.sectionGroups.length;++n){if("object"!=typeof e.sectionGroups[n])throw TypeError(".tensorflow.magenta.NoteSequence.sectionGroups: object expected");t.sectionGroups[n]=c.tensorflow.magenta.NoteSequence.SectionGroup.fromObject(e.sectionGroups[n])}}if(null!=e.quantizationInfo){if("object"!=typeof e.quantizationInfo)throw TypeError(".tensorflow.magenta.NoteSequence.quantizationInfo: object expected");t.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.fromObject(e.quantizationInfo)}if(null!=e.subsequenceInfo){if("object"!=typeof e.subsequenceInfo)throw TypeError(".tensorflow.magenta.NoteSequence.subsequenceInfo: object expected");t.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.fromObject(e.subsequenceInfo)}if(null!=e.sequenceMetadata){if("object"!=typeof e.sequenceMetadata)throw TypeError(".tensorflow.magenta.NoteSequence.sequenceMetadata: object expected");t.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.fromObject(e.sequenceMetadata)}return t},e.toObject=function(e,t){t||(t={});var n={};if((t.arrays||t.defaults)&&(n.timeSignatures=[],n.keySignatures=[],n.tempos=[],n.notes=[],n.pitchBends=[],n.controlChanges=[],n.partInfos=[],n.textAnnotations=[],n.sectionAnnotations=[],n.sectionGroups=[]),t.defaults){if(n.id="",n.filename="",n.collectionName="",n.ticksPerQuarter=0,n.totalTime=0,n.sourceInfo=null,n.quantizationInfo=null,u.Long){var r=new u.Long(0,0,!1);n.totalQuantizedSteps=t.longs===String?r.toString():t.longs===Number?r.toNumber():r}else n.totalQuantizedSteps=t.longs===String?"0":0;n.subsequenceInfo=null,u.Long?(r=new u.Long(0,0,!1),n.referenceNumber=t.longs===String?r.toString():t.longs===Number?r.toNumber():r):n.referenceNumber=t.longs===String?"0":0,n.sequenceMetadata=null}if(null!=e.id&&e.hasOwnProperty("id")&&(n.id=e.id),null!=e.filename&&e.hasOwnProperty("filename")&&(n.filename=e.filename),null!=e.collectionName&&e.hasOwnProperty("collectionName")&&(n.collectionName=e.collectionName),null!=e.ticksPerQuarter&&e.hasOwnProperty("ticksPerQuarter")&&(n.ticksPerQuarter=e.ticksPerQuarter),e.timeSignatures&&e.timeSignatures.length){n.timeSignatures=[];for(var o=0;o<e.timeSignatures.length;++o)n.timeSignatures[o]=c.tensorflow.magenta.NoteSequence.TimeSignature.toObject(e.timeSignatures[o],t)}if(e.keySignatures&&e.keySignatures.length)for(n.keySignatures=[],o=0;o<e.keySignatures.length;++o)n.keySignatures[o]=c.tensorflow.magenta.NoteSequence.KeySignature.toObject(e.keySignatures[o],t);if(e.tempos&&e.tempos.length)for(n.tempos=[],o=0;o<e.tempos.length;++o)n.tempos[o]=c.tensorflow.magenta.NoteSequence.Tempo.toObject(e.tempos[o],t);if(e.notes&&e.notes.length)for(n.notes=[],o=0;o<e.notes.length;++o)n.notes[o]=c.tensorflow.magenta.NoteSequence.Note.toObject(e.notes[o],t);if(null!=e.totalTime&&e.hasOwnProperty("totalTime")&&(n.totalTime=t.json&&!isFinite(e.totalTime)?String(e.totalTime):e.totalTime),e.pitchBends&&e.pitchBends.length)for(n.pitchBends=[],o=0;o<e.pitchBends.length;++o)n.pitchBends[o]=c.tensorflow.magenta.NoteSequence.PitchBend.toObject(e.pitchBends[o],t);if(e.controlChanges&&e.controlChanges.length)for(n.controlChanges=[],o=0;o<e.controlChanges.length;++o)n.controlChanges[o]=c.tensorflow.magenta.NoteSequence.ControlChange.toObject(e.controlChanges[o],t);if(e.partInfos&&e.partInfos.length)for(n.partInfos=[],o=0;o<e.partInfos.length;++o)n.partInfos[o]=c.tensorflow.magenta.NoteSequence.PartInfo.toObject(e.partInfos[o],t);if(null!=e.sourceInfo&&e.hasOwnProperty("sourceInfo")&&(n.sourceInfo=c.tensorflow.magenta.NoteSequence.SourceInfo.toObject(e.sourceInfo,t)),e.textAnnotations&&e.textAnnotations.length)for(n.textAnnotations=[],o=0;o<e.textAnnotations.length;++o)n.textAnnotations[o]=c.tensorflow.magenta.NoteSequence.TextAnnotation.toObject(e.textAnnotations[o],t);if(null!=e.quantizationInfo&&e.hasOwnProperty("quantizationInfo")&&(n.quantizationInfo=c.tensorflow.magenta.NoteSequence.QuantizationInfo.toObject(e.quantizationInfo,t)),null!=e.totalQuantizedSteps&&e.hasOwnProperty("totalQuantizedSteps")&&("number"==typeof e.totalQuantizedSteps?n.totalQuantizedSteps=t.longs===String?String(e.totalQuantizedSteps):e.totalQuantizedSteps:n.totalQuantizedSteps=t.longs===String?u.Long.prototype.toString.call(e.totalQuantizedSteps):t.longs===Number?new u.LongBits(e.totalQuantizedSteps.low>>>0,e.totalQuantizedSteps.high>>>0).toNumber():e.totalQuantizedSteps),null!=e.subsequenceInfo&&e.hasOwnProperty("subsequenceInfo")&&(n.subsequenceInfo=c.tensorflow.magenta.NoteSequence.SubsequenceInfo.toObject(e.subsequenceInfo,t)),null!=e.referenceNumber&&e.hasOwnProperty("referenceNumber")&&("number"==typeof e.referenceNumber?n.referenceNumber=t.longs===String?String(e.referenceNumber):e.referenceNumber:n.referenceNumber=t.longs===String?u.Long.prototype.toString.call(e.referenceNumber):t.longs===Number?new u.LongBits(e.referenceNumber.low>>>0,e.referenceNumber.high>>>0).toNumber():e.referenceNumber),null!=e.sequenceMetadata&&e.hasOwnProperty("sequenceMetadata")&&(n.sequenceMetadata=c.tensorflow.magenta.SequenceMetadata.toObject(e.sequenceMetadata,t)),e.sectionAnnotations&&e.sectionAnnotations.length)for(n.sectionAnnotations=[],o=0;o<e.sectionAnnotations.length;++o)n.sectionAnnotations[o]=c.tensorflow.magenta.NoteSequence.SectionAnnotation.toObject(e.sectionAnnotations[o],t);if(e.sectionGroups&&e.sectionGroups.length)for(n.sectionGroups=[],o=0;o<e.sectionGroups.length;++o)n.sectionGroups[o]=c.tensorflow.magenta.NoteSequence.SectionGroup.toObject(e.sectionGroups[o],t);return n},e.prototype.toJSON=function(){return this.constructor.toObject(this,i.util.toJSONOptions)},e.Note=function(){function e(e){if(e)for(var t=Object.keys(e),n=0;n<t.length;++n)null!=e[t[n]]&&(this[t[n]]=e[t[n]])}return e.prototype.pitch=0,e.prototype.pitchName=0,e.prototype.velocity=0,e.prototype.startTime=0,e.prototype.quantizedStartStep=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.endTime=0,e.prototype.quantizedEndStep=u.Long?u.Long.fromBits(0,0,!1):0,e.prototype.numerator=0,e.prototype.denominator=0,e.prototype.instrument=0,e.prototype.program=0,e.prototype.isDrum=!1,e.prototype.part=0,e.prototype.voice=0,e.create=function(t){return new e(t)},e.encode=function(e,t){return t||(t=s.create()),null!=e.pitch&&e.hasOwnProperty("pitch")&&t.uint32(8).int32(e.pitch),null!=e.velocity&&e.hasOwnProperty("velocity")&&t.uint32(16).int32(e.velocity),null!=e.startTime&&e.hasOwnProperty("startTime")&&t.uint32(25).double(e.startTime),null!=e.endTime&&e.hasOwnProperty("endTime")&&t.uint32(33).double(e.endTime),null!=e.numerator&&e.hasOwnProperty("numerator")&&t.uint32(40).int32(e.numerator),null!=e.denominator&&e.hasOwnProperty("denominator")&&t.uint32(48).int32(e.denominator),null!=e.instrument&&e.hasOwnProperty("instrument")&&t.uint32(56).int32(e.instrument),null!=e.program&&e.hasOwnProperty("program")&&t.uint32(64).int32(e.program),null!=e.isDrum&&e.hasOwnProperty("isDrum")&&t.uint32(72).bool(e.isDrum),null!=e.part&&e.hasOwnProperty("part")&&t.uint32(80).int32(e.part),null!=e.pitchName&&e.hasOwnProperty("pitchName")&&t.uint32(88).int32(e.pitchName),null!=e.voice&&e.hasOwnProperty("voice")&&t.uint32(96).int32(e.voice),null!=e.quantizedStartStep&&e.hasOwnProperty("quantizedStartStep")&&t.uint32(104).int64(e.quantizedStartStep),null!=e.quantizedEndStep&&e.hasOwnProperty("quantizedEndStep")&&t.uint32(112).int64(e.quantizedEndStep),t},e.encodeDelimited=function(e,t){return this.encode(e,t).ldelim()},e.decode=function(e,t){e instanceof a||(e=a.create(e));for(var n=void 0===t?e.len:e.pos+t,r=new c.tensorflow.magenta.NoteSequence.Note;e.pos<n;){var o=e.uint32();switch(o>>>3){case 1:r.pitch=e.int32();break;case 11:r.pitchName=e.int32();break;case 2:r.velocity=e.int32();break;case 3:r.startTime=e.double();break;case 13:r.quantizedStartStep=u.Long?e.int64().toNumber():e.int64();break;case 4:r.endTime=e.double();break;case 14:r.quantizedEndStep=u.Long?e.int64().toNumber():e.int64();break;case 5:r.numerator=e.int32();break;case 6:r.denominator=e.int32();break;case 7:r.instrument=e.int32();break;case 8:r.program=e.int32();break;case 9:r.isDrum=e.bool();break;case 10:r.part=e.int32();break;case 12:r.voice=e.int32();break;default:e.skipType(7&o)}}return r},e.decodeDelimited=function(e){return e instanceof a||(e=new a(e)),this.decode(e,e.uint32())},e.verify=function(e){if("object"!=typeof e||null===e)return"object expected";if(null!=e.pitch&&e.hasOwnProperty("pitch")&&!u.isInteger(e.pitch))return"pitch: integer expected";if(null!=e.pitchName&&e.hasOwnProperty("pitchName"))switch(e.pitchName){default:return"pitchName: enum value expected";case 0:case 1:case 2:case 3:case 4:case 5:case 6:case 7:case 8:case 9:case 10:case 11:case 12:case 13:case 14:case 15:case 16:case 17:case 18:case 19:case 20:case 21:case 22:case 23:case 24:case 25:case 26:case 27:case 28:case 29:case 30:case 31:case 3