-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathdtm_min.js
7 lines (7 loc) · 192 KB
/
dtm_min.js
1
2
3
4
5
6
7
!function(){function globalEval(a){eval.call(null,a)}function assert(a,b){a||abort("Assertion failed: "+b)}function getCFunc(ident){var func=Module["_"+ident];if(!func)try{func=eval("_"+ident)}catch(e){}return assert(func,"Cannot call unknown function "+ident+" (perhaps LLVM optimizations or closure removed it?)"),func}function setValue(a,b,c){switch(c=c||"i8","*"===c.charAt(c.length-1)&&(c="i32"),c){case"i1":HEAP8[a>>0]=b;break;case"i8":HEAP8[a>>0]=b;break;case"i16":HEAP16[a>>1]=b;break;case"i32":HEAP32[a>>2]=b;break;case"i64":tempI64=[b>>>0,(tempDouble=b,+Math_abs(tempDouble)>=1?tempDouble>0?(0|Math_min(+Math_floor(tempDouble/4294967296),4294967295))>>>0:~~+Math_ceil((tempDouble-+(~~tempDouble>>>0))/4294967296)>>>0:0)],HEAP32[a>>2]=tempI64[0],HEAP32[a+4>>2]=tempI64[1];break;case"float":HEAPF32[a>>2]=b;break;case"double":HEAPF64[a>>3]=b;break;default:abort("invalid type for setValue: "+c)}}function getValue(a,b){switch(b=b||"i8","*"===b.charAt(b.length-1)&&(b="i32"),b){case"i1":return HEAP8[a>>0];case"i8":return HEAP8[a>>0];case"i16":return HEAP16[a>>1];case"i32":return HEAP32[a>>2];case"i64":return HEAP32[a>>2];case"float":return HEAPF32[a>>2];case"double":return HEAPF64[a>>3];default:abort("invalid type for setValue: "+b)}return null}function allocate(a,b,c,d){var e,f;"number"==typeof a?(e=!0,f=a):(e=!1,f=a.length);var g,h="string"==typeof b?b:null;if(g=c==ALLOC_NONE?d:["function"==typeof _malloc?_malloc:Runtime.staticAlloc,Runtime.stackAlloc,Runtime.staticAlloc,Runtime.dynamicAlloc][void 0===c?ALLOC_STATIC:c](Math.max(f,h?1:b.length)),e){var i,d=g;for(assert(0==(3&g)),i=g+(-4&f);i>d;d+=4)HEAP32[d>>2]=0;for(i=g+f;i>d;)HEAP8[d++>>0]=0;return g}if("i8"===h)return a.subarray||a.slice?HEAPU8.set(a,g):HEAPU8.set(new Uint8Array(a),g),g;for(var j,k,l,m=0;f>m;){var n=a[m];"function"==typeof n&&(n=Runtime.getFunctionIndex(n)),j=h||b[m],0!==j?("i64"==j&&(j="i32"),setValue(g+m,n,j),l!==j&&(k=Runtime.getNativeTypeSize(j),l=j),m+=k):m++}return g}function getMemory(a){return staticSealed?"undefined"!=typeof _sbrk&&!_sbrk.called||!runtimeInitialized?Runtime.dynamicAlloc(a):_malloc(a):Runtime.staticAlloc(a)}function Pointer_stringify(a,b){if(0===b||!a)return"";for(var c,d=0,e=0;;){if(c=HEAPU8[a+e>>0],d|=c,0==c&&!b)break;if(e++,b&&e==b)break}b||(b=e);var f="";if(128>d){for(var g,h=1024;b>0;)g=String.fromCharCode.apply(String,HEAPU8.subarray(a,a+Math.min(b,h))),f=f?f+g:g,a+=h,b-=h;return f}return Module.UTF8ToString(a)}function AsciiToString(a){for(var b="";;){var c=HEAP8[a++>>0];if(!c)return b;b+=String.fromCharCode(c)}}function stringToAscii(a,b){return writeAsciiToMemory(a,b,!1)}function UTF8ArrayToString(a,b){for(var c,d,e,f,g,h,i="";;){if(c=a[b++],!c)return i;if(128&c)if(d=63&a[b++],192!=(224&c))if(e=63&a[b++],224==(240&c)?c=(15&c)<<12|d<<6|e:(f=63&a[b++],240==(248&c)?c=(7&c)<<18|d<<12|e<<6|f:(g=63&a[b++],248==(252&c)?c=(3&c)<<24|d<<18|e<<12|f<<6|g:(h=63&a[b++],c=(1&c)<<30|d<<24|e<<18|f<<12|g<<6|h))),65536>c)i+=String.fromCharCode(c);else{var j=c-65536;i+=String.fromCharCode(55296|j>>10,56320|1023&j)}else i+=String.fromCharCode((31&c)<<6|d);else i+=String.fromCharCode(c)}}function UTF8ToString(a){return UTF8ArrayToString(HEAPU8,a)}function stringToUTF8Array(a,b,c,d){if(!(d>0))return 0;for(var e=c,f=c+d-1,g=0;g<a.length;++g){var h=a.charCodeAt(g);if(h>=55296&&57343>=h&&(h=65536+((1023&h)<<10)|1023&a.charCodeAt(++g)),127>=h){if(c>=f)break;b[c++]=h}else if(2047>=h){if(c+1>=f)break;b[c++]=192|h>>6,b[c++]=128|63&h}else if(65535>=h){if(c+2>=f)break;b[c++]=224|h>>12,b[c++]=128|h>>6&63,b[c++]=128|63&h}else if(2097151>=h){if(c+3>=f)break;b[c++]=240|h>>18,b[c++]=128|h>>12&63,b[c++]=128|h>>6&63,b[c++]=128|63&h}else if(67108863>=h){if(c+4>=f)break;b[c++]=248|h>>24,b[c++]=128|h>>18&63,b[c++]=128|h>>12&63,b[c++]=128|h>>6&63,b[c++]=128|63&h}else{if(c+5>=f)break;b[c++]=252|h>>30,b[c++]=128|h>>24&63,b[c++]=128|h>>18&63,b[c++]=128|h>>12&63,b[c++]=128|h>>6&63,b[c++]=128|63&h}}return b[c]=0,c-e}function stringToUTF8(a,b,c){return stringToUTF8Array(a,HEAPU8,b,c)}function lengthBytesUTF8(a){for(var b=0,c=0;c<a.length;++c){var d=a.charCodeAt(c);d>=55296&&57343>=d&&(d=65536+((1023&d)<<10)|1023&a.charCodeAt(++c)),127>=d?++b:b+=2047>=d?2:65535>=d?3:2097151>=d?4:67108863>=d?5:6}return b}function demangle(a){var b=!!Module.___cxa_demangle;if(b){try{var c=_malloc(a.length);writeStringToMemory(a.substr(1),c);var d=_malloc(4),e=Module.___cxa_demangle(c,0,0,d);if(0===getValue(d,"i32")&&e)return Pointer_stringify(e)}catch(f){}finally{c&&_free(c),d&&_free(d),e&&_free(e)}return a}return Runtime.warnOnce("warning: build with -s DEMANGLE_SUPPORT=1 to link in libcxxabi demangling"),a}function demangleAll(a){return a.replace(/__Z[\w\d_]+/g,function(a){var b=demangle(a);return a===b?a:a+" ["+b+"]"})}function jsStackTrace(){var a=new Error;if(!a.stack){try{throw new Error(0)}catch(b){a=b}if(!a.stack)return"(no stack trace available)"}return a.stack.toString()}function stackTrace(){var a=jsStackTrace();return Module.extraStackTrace&&(a+="\n"+Module.extraStackTrace()),demangleAll(a)}function alignMemoryPage(a){return a%4096>0&&(a+=4096-a%4096),a}function updateGlobalBufferViews(){Module.HEAP8=HEAP8=new Int8Array(buffer),Module.HEAP16=HEAP16=new Int16Array(buffer),Module.HEAP32=HEAP32=new Int32Array(buffer),Module.HEAPU8=HEAPU8=new Uint8Array(buffer),Module.HEAPU16=HEAPU16=new Uint16Array(buffer),Module.HEAPU32=HEAPU32=new Uint32Array(buffer),Module.HEAPF32=HEAPF32=new Float32Array(buffer),Module.HEAPF64=HEAPF64=new Float64Array(buffer)}function abortOnCannotGrowMemory(){abort("Cannot enlarge memory arrays. Either (1) compile with -s TOTAL_MEMORY=X with X higher than the current value "+TOTAL_MEMORY+", (2) compile with -s ALLOW_MEMORY_GROWTH=1 which adjusts the size at runtime but prevents some optimizations, (3) set Module.TOTAL_MEMORY to a higher value before the program runs, or if you want malloc to return NULL (0) instead of this abort, compile with -s ABORTING_MALLOC=0 ")}function enlargeMemory(){abortOnCannotGrowMemory()}function callRuntimeCallbacks(a){for(;a.length>0;){var b=a.shift();if("function"!=typeof b){var c=b.func;"number"==typeof c?void 0===b.arg?Runtime.dynCall("v",c):Runtime.dynCall("vi",c,[b.arg]):c(void 0===b.arg?null:b.arg)}else b()}}function preRun(){if(Module.preRun)for("function"==typeof Module.preRun&&(Module.preRun=[Module.preRun]);Module.preRun.length;)addOnPreRun(Module.preRun.shift());callRuntimeCallbacks(__ATPRERUN__)}function ensureInitRuntime(){runtimeInitialized||(runtimeInitialized=!0,callRuntimeCallbacks(__ATINIT__))}function preMain(){callRuntimeCallbacks(__ATMAIN__)}function exitRuntime(){callRuntimeCallbacks(__ATEXIT__),runtimeExited=!0}function postRun(){if(Module.postRun)for("function"==typeof Module.postRun&&(Module.postRun=[Module.postRun]);Module.postRun.length;)addOnPostRun(Module.postRun.shift());callRuntimeCallbacks(__ATPOSTRUN__)}function addOnPreRun(a){__ATPRERUN__.unshift(a)}function addOnInit(a){__ATINIT__.unshift(a)}function addOnPreMain(a){__ATMAIN__.unshift(a)}function addOnExit(a){__ATEXIT__.unshift(a)}function addOnPostRun(a){__ATPOSTRUN__.unshift(a)}function intArrayFromString(a,b,c){var d=c>0?c:lengthBytesUTF8(a)+1,e=new Array(d),f=stringToUTF8Array(a,e,0,e.length);return b&&(e.length=f),e}function intArrayToString(a){for(var b=[],c=0;c<a.length;c++){var d=a[c];d>255&&(d&=255),b.push(String.fromCharCode(d))}return b.join("")}function writeStringToMemory(a,b,c){for(var d=intArrayFromString(a,c),e=0;e<d.length;){var f=d[e];HEAP8[b+e>>0]=f,e+=1}}function writeArrayToMemory(a,b){for(var c=0;c<a.length;c++)HEAP8[b++>>0]=a[c]}function writeAsciiToMemory(a,b,c){for(var d=0;d<a.length;++d)HEAP8[b++>>0]=a.charCodeAt(d);c||(HEAP8[b>>0]=0)}function addRunDependency(){runDependencies++,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies)}function removeRunDependency(){if(runDependencies--,Module.monitorRunDependencies&&Module.monitorRunDependencies(runDependencies),0==runDependencies&&(null!==runDependencyWatcher&&(clearInterval(runDependencyWatcher),runDependencyWatcher=null),dependenciesFulfilled)){var a=dependenciesFulfilled;dependenciesFulfilled=null,a()}}function _sbrk(a){var b=_sbrk;b.called||(DYNAMICTOP=alignMemoryPage(DYNAMICTOP),b.called=!0,assert(Runtime.dynamicAlloc),b.alloc=Runtime.dynamicAlloc,Runtime.dynamicAlloc=function(){abort("cannot dynamically allocate, sbrk now has control")});var c=DYNAMICTOP;if(0!=a){var d=b.alloc(a);if(!d)return-1>>>0}return c}function _pthread_cleanup_push(a,b){__ATEXIT__.push(function(){Runtime.dynCall("vi",a,[b])}),_pthread_cleanup_push.level=__ATEXIT__.length}function ___lock(){}function _emscripten_memcpy_big(a,b,c){return HEAPU8.set(HEAPU8.subarray(b,b+c),a),a}function _pthread_cleanup_pop(){assert(_pthread_cleanup_push.level==__ATEXIT__.length,"cannot pop if something else added meanwhile!"),__ATEXIT__.pop(),_pthread_cleanup_push.level=__ATEXIT__.length}function _abort(){Module.abort()}function ___syscall140(a,b){SYSCALLS.varargs=b;try{var c=SYSCALLS.getStreamFromFD(),d=SYSCALLS.get(),e=SYSCALLS.get(),f=SYSCALLS.get(),g=SYSCALLS.get(),h=e;return assert(0===d),FS.llseek(c,h,g),HEAP32[f>>2]=c.position,c.getdents&&0===h&&0===g&&(c.getdents=null),0}catch(i){return"undefined"!=typeof FS&&i instanceof FS.ErrnoError||abort(i),-i.errno}}function ___syscall146(a,b){SYSCALLS.varargs=b;try{var c=SYSCALLS.get(),d=SYSCALLS.get(),e=SYSCALLS.get(),f=0;___syscall146.buffer||(___syscall146.buffers=[null,[],[]],___syscall146.printChar=function(a,b){var c=___syscall146.buffers[a];assert(c),0===b||10===b?((1===a?Module.print:Module.printErr)(UTF8ArrayToString(c,0)),c.length=0):c.push(b)});for(var g=0;e>g;g++){for(var h=HEAP32[d+8*g>>2],i=HEAP32[d+(8*g+4)>>2],j=0;i>j;j++)___syscall146.printChar(c,HEAPU8[h+j]);f+=i}return f}catch(k){return"undefined"!=typeof FS&&k instanceof FS.ErrnoError||abort(k),-k.errno}}function ___syscall54(a,b){SYSCALLS.varargs=b;try{return 0}catch(c){return"undefined"!=typeof FS&&c instanceof FS.ErrnoError||abort(c),-c.errno}}function ___unlock(){}function ___syscall6(a,b){SYSCALLS.varargs=b;try{var c=SYSCALLS.getStreamFromFD();return FS.close(c),0}catch(d){return"undefined"!=typeof FS&&d instanceof FS.ErrnoError||abort(d),-d.errno}}function invoke_ii(a,b){try{return Module.dynCall_ii(a,b)}catch(c){if("number"!=typeof c&&"longjmp"!==c)throw c;asm.setThrew(1,0)}}function invoke_iiii(a,b,c,d){try{return Module.dynCall_iiii(a,b,c,d)}catch(e){if("number"!=typeof e&&"longjmp"!==e)throw e;asm.setThrew(1,0)}}function invoke_vi(a,b){try{Module.dynCall_vi(a,b)}catch(c){if("number"!=typeof c&&"longjmp"!==c)throw c;asm.setThrew(1,0)}}function ExitStatus(a){this.name="ExitStatus",this.message="Program terminated with exit("+a+")",this.status=a}function run(a){function b(){Module.calledRun||(Module.calledRun=!0,ABORT||(ensureInitRuntime(),preMain(),Module.onRuntimeInitialized&&Module.onRuntimeInitialized(),Module._main&&shouldRunNow&&Module.callMain(a),postRun()))}a=a||Module.arguments,null===preloadStartTime&&(preloadStartTime=Date.now()),runDependencies>0||(preRun(),runDependencies>0||Module.calledRun||(Module.setStatus?(Module.setStatus("Running..."),setTimeout(function(){setTimeout(function(){Module.setStatus("")},1),b()},1)):b()))}function exit(a,b){if(!b||!Module.noExitRuntime)throw Module.noExitRuntime||(ABORT=!0,EXITSTATUS=a,STACKTOP=initialStackTop,exitRuntime(),Module.onExit&&Module.onExit(a)),ENVIRONMENT_IS_NODE?process.exit(a):ENVIRONMENT_IS_SHELL&&"function"==typeof quit&&quit(a),new ExitStatus(a)}function abort(a){void 0!==a?(Module.print(a),Module.printErr(a),a=JSON.stringify(a)):a="",ABORT=!0,EXITSTATUS=1;var b="\nIf this abort() is unexpected, build with -s ASSERTIONS=1 which can give more information.",c="abort("+a+") at "+stackTrace()+b;throw abortDecorators&&abortDecorators.forEach(function(b){c=b(c,a)}),c}function isNaNfast(a){return a!==a}function isEmpty(a){return"undefined"==typeof a?!0:null===a?!0:"number"==typeof a&&isNaNfast(a)}function isNumber(a){return"number"==typeof a&&!isNaNfast(a)}function isInteger(a){return isNumber(a)?Number.isInteger(a):!1}function isString(a){return"string"==typeof a}function toString(a){return isNumber(a)?a.toString():a}function isBoolean(a){return"boolean"==typeof a}function isFunction(a){return"function"==typeof a&&!a.hasOwnProperty("meta")}function isPromise(a){return isObject(a)?a.constructor===Promise?!0:void 0:!1}function isObject(a){return"object"==typeof a&&null!==a}function isFile(a){return"File"===a.constructor.name}function isURL(a,b){return isString(b)?a.endsWith(b):a.startsWith("http")}function isDataURL(a){return a.startsWith("data:")}function isSingleVal(a){return!(isArray(a)||isDtmObj(a)||isFunction(a)||isEmpty(a))}function isArray(a){return Array.isArray(a)||isFloat32Array(a)}function isFloat32Array(a){var b=!1;return isEmpty(a)||a.constructor===Float32Array&&a.length>0&&(b=!0),b}function isNumArray(a){var b=!1;return isArray(a)&&!isFloat32Array(a)&&a.length>0&&(b=a.every(function(a){return isNumber(a)})),b}function isParsableNumArray(a){var b=!1;return isStringArray(a)&&(b=a.every(function(a){return!isNaNfast(parseFloat(a))})),b}function isObjArray(a){var b=!1;return isArray(a)&&a.length>0&&(b=a.every(function(a){return isObject(a)&&!isDtmObj(a)})),b}function isNumOrFloat32Array(a){return isFloat32Array(a)||isNumArray(a)}function isMixedArray(a){return!(!isArray(a)||isStringArray(a)||isBoolArray(a)||isNumOrFloat32Array(a)||isNestedArray(a)||isNestedWithDtmArray(a))}function isNestedArray(a){var b=!1;if(isArray(a))for(var c=0,d=a.length;d>c;c++)if(isArray(a[c]))return!0;return b}function isNestedWithDtmArray(a){var b=!1;return isArray(a)&&(b=a.some(function(a){return isDtmArray(a)})),b}function getMaxArrayDepth(a){if(isArray(a)){for(var b=1,c=[],d=0,e=a.length;e>d;d++)isArray(a[d])?c.push(getMaxArrayDepth(a[d])):isDtmArray(a[d])&&c.push(getMaxDtmArrayDepth(a[d]));return c.length>0&&(b+=Math.max.apply(this,c)),b}return 0}function getMaxDtmArrayDepth(a){if(isDtmArray(a)){var b=1,c=[];return isNestedDtmArray(a)&&a.each(function(a){isDtmArray(a)&&c.push(getMaxDtmArrayDepth(a))}),c.length>0&&(b+=Math.max.apply(this,c)),b}return 0}function getMaxDepth(a){var b,c,d,e;if(isArray(a)){for(b=1,c=[],d=0,e=a.length;e>d;d++)(isArray(a[d])||isDtmArray(a[d]))&&c.push(getMaxDepth(a[d]));return c.length>0&&(b+=Math.max.apply(this,c)),b}return isDtmArray(a)?a.params.depth:0}function isDtmObj(a){return isObject(a)||"function"==typeof a?a.hasOwnProperty("meta"):!1}function isDtmSynth(a){return(isObject(a)||"function"==typeof a)&&a.hasOwnProperty("meta")?"dtm.synth"===a.meta.type||"dtm.music"===a.meta.type:!1}function isDtmData(a){return(isObject(a)||"function"==typeof a)&&a.hasOwnProperty("meta")?"dtm.data"===a.meta.type||"dtm.generator"===a.meta.type:!1}function isNestedDtmData(a){return isDtmData(a)?a.every(function(a){return isDtmData(a)}):!1}function isNumDtmData(a){return isDtmData(a)&&isNumOrFloat32Array(a.get())}function isNestedNumDtmData(a){return isNestedDtmData(a)&&a.get().every(function(a){return isNumDtmData(a)})}function isDtmArray(a){return(isObject(a)||"function"==typeof a)&&a.hasOwnProperty("meta")?-1!==["dtm.array","dtm.data","dtm.generator"].indexOf(a.meta.type):!1}function isNestedDtmArray(a){return isDtmArray(a)?a.params.nested:!1}function isNumDtmArray(a){return isDtmArray(a)&&isNumOrFloat32Array(a.get())}function isNestedNumDtmArray(a){return isNestedDtmArray(a)&&a.get().every(function(a){return isNumDtmArray(a)})}function isStringArray(a){var b=!1;return isArray(a)&&(b=a.every(function(a){return isString(a)})),b}function isBoolArray(a){var b=!1;return isArray(a)&&(b=a.every(function(a){return isBoolean(a)})),b}function hasMissingValues(a){return a.some(function(a){return isEmpty(a)})}function arrayCompare(){}function objCompare(a,b){var c=!1;return isFunction(a)&&isFunction(b)?a.toString()===b.toString():isObject(a)&&isObject(b)?JSON.stringify(a)===JSON.stringify(b):c}function argsToArray(a){for(var b=[],c=0;c<a.length;c++)b[c]=a[c];return b}function argsForEach(a,b){for(var c=0,d=a.length;d>c;c++)b.apply(this,a[c])}function argIsSingleArray(a){return 1===a.length&&isArray(a[0])}function argsAreSingleVals(a){var b=!1;if(!argIsSingleArray(a)&&a.length>0){var c=argsToArray(a);b=c.every(function(a){return isSingleVal(a)})}return b}function toFloat32Array(a){if(isNumber(a))return new Float32Array([a]);if(!isDtmObj(a))return isNumOrFloat32Array(a)?isFloat32Array(a)?a:new Float32Array(a):null;if(isDtmArray(a)){if(isNumArray(a.get()))return new Float32Array(a.get());if(isFloat32Array(a.get()))return a.get();if(isNestedWithDtmArray(a.get()))return toFloat32Array(a.get("next"))}else if("dtm.model"===a.meta.type)return new Float32Array(a.get())}function fromFloat32Array(a){return Array.prototype.slice.call(a)}function Float32Concat(a,b){var c=a.length,d=new Float32Array(c+b.length);return d.set(a),d.set(b,c),d}function concat(a,b){return isFloat32Array(a)||isFloat32Array(b)?(isNumber(a)&&(a=new Float32Array([a])),isNumber(b)&&(b=new Float32Array([b])),Float32Concat(a,b)):a.concat(b)}function flatten(a){for(var b=[],c=0,d=a.length;d>c;c++)b=isArray(a[c])?concat(b,flatten(a[c])):concat(b,a[c]);return b}function Float32Splice(a,b,c){console.log(a.length-c);var d=new Float32Array(a.length-c),e=Array.prototype.slice.call(a);return e.splice(b,c),d.set(e),d}function splice(a,b,c){return isFloat32Array(a)?Float32Splice(a,b,c):(a.splice(b,c),a)}function truncateDigits(a){var b=10;return Math.round(a*Math.pow(10,b))/Math.pow(10,b)}function Float32Map(a,b){for(var c=new Float32Array(a.length),d=0,e=a.length;e>d;d++)c[d]=b(a[d]);return c}function deferCallback(a,b){var c=0;return isNumber(b)&&b>0&&(c=b),isFunction(a)?function(){var b=arguments;setTimeout(function(){a.apply(this,b)},c)}:void 0}function cloneArray(a){return isArray(a)||isFloat32Array(a)?a.slice(0):void 0}function print(a){return isNestedDtmArray(a)||isNestedWithDtmArray(a)?a.forEach(function(a){console.log(a.get("name"),a.get())}):isDtmArray(a)?console.log(a.get("name"),a.get()):console.log(a),a}function objForEach(a,b){var c=[];if("object"==typeof a){for(var d in a)a.hasOwnProperty(d)&&"function"==typeof b&&c.push(b(a[d],d));return c}}function numProperties(a){var b=0;return isObject(a)&&objForEach(a,function(){b++}),b}function loadBuffer(a){var b={};return actx.decodeAudioData(a,function(a){b=a}),b}function loadFileObject(a,b){var c=new FileReader,d=a.type.split("/");"text"===d[0]?c.readAsText(a):"image"===d[0]?c.readAsDataURL(a):"audio"===d[0]&&c.readAsArrayBuffer(a),c.onload=function(a){b(a.target.result)}}function getMin(a){return isNumOrFloat32Array(a)?Math.min.apply(this,a):void 0}function getMax(a){return isNumOrFloat32Array(a)?Math.max.apply(this,a):void 0}function mean(a){return isNumOrFloat32Array(a)?sum(a)/a.length:void 0}function centroid(a){if(1===a.length)return.5;for(var b=0,c=0,d=a.length;d>c;c++)b+=a[c]*c;return b/sum(a)/(a.length-1)}function mode(a){for(var b=unique(a),c=0,d=0,e=null,f=countOccurrences(a),g=0,h=b.length;h>g;g++)d=f[b[g]],d>c&&(e=b[g],c=d);return e}function median(a){var b=a.sort(),c=a.length;return 0===mod(c,2)?(b[c/2-1]+b[c/2])/2:b[Math.floor(c/2)]}function midrange(a){var b=getMax(a),c=getMin(a);return(b+c)/2}function sum(a){return isNestedWithDtmArray(a)?sum(a.map(function(a){return sum(a.get())})):a.reduce(function(a,b){return a+b})}function variance(a){for(var b=mean(a),c=[],d=0,e=a.length;e>d;d++)c[d]=Math.pow(b-a[d],2);return sum(c)/(a.length-1)}function std(a){return Math.sqrt(variance(a))}function pvar(a){for(var b=mean(a),c=[],d=0,e=a.length;e>d;d++)c[d]=Math.pow(b-a[d],2);return mean(c)}function pstd(a){return Math.sqrt(pvar(a))}function meanSquare(a){for(var b=[],c=0,d=a.length;d>c;c++)b[c]=Math.pow(a[c],2);return mean(b)}function rms(a){for(var b=[],c=0,d=a.length;d>c;c++)b[c]=Math.pow(a[c],2);return Math.sqrt(mean(b))}function unique(a){for(var b=[],c=0,d=a.length;d>c;c++)-1===b.indexOf(a[c])&&b.push(a[c]);return b}function histo(a){for(var b=[],c=cloneArray(a),d=countOccurrences(a),e=0,f=c.length;f>e;e++)b[e]=d[c[e]];return b}function countOccurrences(a){for(var b={},c=0,d=a.length;d>c;c++)b.hasOwnProperty(a[c])?b[a[c]]++:b[a[c]]=1;return b}function listClasses(a){return unique(a).sort()}function uniformity(a){return listClasses(a).length/a.length}function intersection(a,b){return a.filter(function(a){return-1!==b.indexOf(a)})}function rescale(a,b,c,d){d=d||!1;var e=a*(c-b)+b;return d&&(e=Math.round(e)),e}function expCurve(a,b){return b=1>=b?1.000001:b,(Math.exp(a*Math.log(b))-1)/(b-1)}function logCurve(a,b){return b=1>=b?1.000001:b,Math.log(a*(b-1)+1)/Math.log(b)}function mtof(a){return 440*Math.pow(2,(a-69)/12)}function ftom(a){return 12*Math.log2(a/440)+69}function pq(a,b,c){var d={0:["do","d"],1:["di","ra"],2:["re","r"],3:["ri","me"],4:["mi","m","fe"],5:["fa","f"],6:["fi","se"],7:["sol","s"],8:["si","le"],9:["la","l"],10:["li","te"],11:["ti","t","de"]},e=[];isNumOrFloat32Array(b)?e=b:isStringArray(b)?b.forEach(function(a){objForEach(d,function(b,c){b.indexOf(a.toLowerCase())>-1&&e.push(parseInt(c))})}):isArray(b)||(e=[0,1,2,3,4,5,6,7,8,9,10,11]),isEmpty(c)&&(c=!1);var f=mod(a,12),g=a-f,h=Math.floor(f/12*e.length),i=0;return c||(i=mod(a,1)),g+e[h]+i}function mod(a,b){return(a%b+b)%b}function randi(a,b){var c,d;return isNumber(a)||isNumber(b)?isNumber(a)&&!isNumber(b)?(c=0,d=a):isNumber(a)&&isNumber(b)&&(c=a,d=b):(c=0,d=1),Math.floor(Math.random()*(d-c)+c)}function random(a,b){var c,d;return isNumber(a)||isNumber(b)?isNumber(a)&&!isNumber(b)?(c=0,d=a):isNumber(a)&&isNumber(b)&&(c=a,d=b):(c=0,d=1),Math.random()*(d-c)+c}function levenshteinDistance(a,b){if(0===a.length)return b.length;if(0===b.length)return a.length;var c=a[0]!==b[0]?1:0;return Math.min(levenshteinDistance(a.substr(1),b)+1,levenshteinDistance(b.substr(1),a)+1,levenshteinDistance(a.substr(1),b.substr(1))+c)}function alloc(a){var b=new Float32Array(a),c=Module._malloc(b.byteLength),d=new Float32Array(Module.HEAPF32.buffer,c,b.length);d.set(b)}function free(a){Module._free(a)}function clone(a){return Object.assign({},a)}function jsonp(a){var b="jsonp_callback_"+Math.round(1e5*Math.random());window[b]=function(a){delete window[b],document.body.removeChild(c);var d=Object.keys(a);d.forEach(function(b){"response"!==b&&console.log(a[b])})};var c=document.createElement("script");c.src=a+(a.indexOf("?")>=0?"&":"?")+"callback="+b,document.body.appendChild(c)}function ajaxGet(a){var b=new XMLHttpRequest;b.open("GET",a,!0),b.setRequestHeader("Accept","text/xml"),b.setRequestHeader("Content-Type","application/html"),b.setRequestHeader("Access-Control-Allow-Origin","*"),b.setRequestHeader("Access-Control-Allow-Methods","GET, POST, PUT"),b.setRequestHeader("Access-Control-Allow-Headers","X-Requested-With");var c=a.split(".").pop();switch(c){case"txt":case"csv":break;case"json":break;case"wav":case"aif":case"aiff":case"ogg":case"mp3":b.responseType="arraybuffer";break;case"html":b.responseType="document";break;default:b.responseType="blob"}b.onreadystatechange=function(){4==b.readyState&&200==b.status&&console.log(b.response)},b.send()}function morphFixed(a,b,c){isNumber(c)||(c=.5);for(var d=[],e=0,f=a.length;f>e;e++)d[e]=(b[e]-a[e])*c+a[e];return d}function mapNested(a,b,c){return isNestedDtmArray(a)?(isEmpty(c)&&(c=b.callee),a.each(function(a){c.apply(a,b)}),a):null}function Data(){function a(){return a.clone.apply(a,arguments)}if(a.__proto__=Data.prototype,a.val=[],a.length=0,a.params={name:"",parent:null,original:null,id:Math.random(),trace:!1,interceptor:{},targets:{},processFn:null,isTarget:!1,attachedFn:null,nested:!1,depth:1},a.meta={type:"dtm.data",getParams:function(){return a.params},addParams:function(b){return objForEach(b,function(b,c){a.params[c]=b}),a},setOriginal:function(b){return a.params.original=b,a},setInterceptor:function(b){return a.params.interceptor.get=b,a}},Object.defineProperty(a,"length",{enumerable:!1,writable:!0,configurable:!0,value:0}),Object.defineProperty(a,"name",{enumerable:!1,writable:!0,configurable:!0,value:""}),this.__proto__=Data.prototype,Data.prototype.traceGlobal){var b=a;a=new Proxy(a,a.params.interceptor),a.toString=Function.prototype.toString.bind(b)}return a.forEach=a.foreach=a.each=new Each(a),a.map=new Map(a),a.g=a.group=a.b=a.block=new Block(a),a.flatten=a.ug=a.ungroup=a.ub=a.unblock=new UnBlock(a),a.f=a.fit=new Fit(a),a.s=a.str=a.stretch=new Stretch(a),a.fft=new FFT(a),a}function Each(a){function b(c){var d,e=a.length;if(isNestedDtmArray(a))for(d=0;e>d;d++)c(b.data.val[d],d,b.data);else for(d=0;e>d;d++)c(dtm.data(b.data.val[d]),d,b.data);return b.data}return b.data=a,b.__proto__=Each.prototype,b}function Map(a){function b(b){var c,d=a.length,e=new Array(d);if(isNestedDtmArray(a)){for(c=0;d>c;c++)e[c]=b(a.val[c],c,a);return a.val=e,a}for(c=0;d>c;c++)e[c]=b(dtm.data(a.val[c]),c,a);return a.set(e).flatten()}return b.data=a,b.__proto__=Map.prototype,b}function Block(a){function b(b,c,d,e){!isInteger(b)||1>b?b=1:b>this.length&&(b=this.length),(!isInteger(c)||1>c)&&(c=b),isEmpty(d)&&(d="rectangular"),isString(e)||(e="wrap");for(var f=[],g=Math.floor((a.length-b)/c)+1,h=0;g>h;h++)f[h]=dtm.data(a.val.slice(h*c,h*c+b)).parent(a).label((h*c).toString()),"rectangular"!==d&&f[h].window(d);return a.set(f)}return b.data=a,b.__proto__=Block.prototype,b}function UnBlock(a){function b(){if(isNestedDtmArray(a)){for(var b=[],c=0,d=a.val.length;d>c;c++)isDtmArray(a.val[c])&&(b=concat(b,a.val[c].val));return isNumArray(b)&&(b=toFloat32Array(b)),a.params.depth--,1===a.params.depth&&(a.params.nested=!1),a.set(b)}return a}return b.data=a,b.__proto__=UnBlock.prototype,b}function Fit(a){function b(b,c){if(isNestedDtmArray(a))return a.map(function(a){return a.fit(b,c)});if(isDtmArray(b)&&(b=b.val),isArray(b)&&b.length>1){var d=1e3/(a.length*b.length);return d=Math.round(d),1>d&&(d=1),a.fit(a.length*b.length*d,c).block.into(b.length).map(function(a,d){return a.fit(b[d],c)}).unblock()}return a.set(dtm.transform.fit(a.val,b,c))}return b.data=a,b.__proto__=Fit.prototype,b}function Stretch(a){function b(b,c){return isNestedDtmArray(a)?a.map(function(a){return a.stretch(b,c)}):(isDtmArray(b)&&(b=b.val),isArray(b)&&b.length>1?a.fit(a.length*b.length,c).block.into(b.length).map(function(a,d){return a.stretch(b[d]/b.length,c)}).unblock():a.set(dtm.transform.stretch(a.val,b,c)))}return b.data=a,b.__proto__=Stretch.prototype,b}function FFT(a){function b(){return a.set(dtm.transform.fft(a.val))}return b.__proto__=FFT.prototype,b.data=a,b}function Instr(){function a(a){return argsAreSingleVals(a)?argsToArray(a):0===a.length?null:1===a.length?a[0]:void 0}var b={dur:.1},c=dtm.music()["for"](b.dur).rep().amp(dtm.decay().expc(10));return c.pitch=function(){var b=a(arguments);return b&&c.note(dtm.model("unipolar")(b).range(60,90).block()),c},c.speed=function(){var b=a(arguments);return b&&c.interval(dtm.model("unipolar")(b).range(.5,.05).block()),c},c}function Model(){}function Music(){function a(){return a.clone()}return a.params={mode:"wavetable",sr:44100,dur:{base:null,auto:!0},interval:{base:null,auto:!0},bpm:null,time:null,offset:null,repeat:{max:0,current:0,resetNext:!0,nextTime:null},iteration:0,sequence:null,onNoteCallback:[],offNoteCallback:[],interp:"step",baseTime:0,voiceId:Math.random(),startTime:0,phase:0,phasor:{base:null},playing:!1,data:null,wavetable:null,rendered:null,tabLen:1024,lengthFixed:!1,source:"sine",type:"synth",promise:null,pending:!1,amp:{base:null},note:{base:null,isFinal:!0},freq:{base:null,isFinal:!1},pitch:{base:null,isFinal:!1},pan:{base:null},curve:!1,offline:!1,rtFxOnly:!0,named:[],monitor:{state:!1,grab:null,block:1024}},a.nodes={src:null,amp:null,pan:null,out:null,fx:[{}],pFx:[{}],rtSrc:null,phasor:null,itvSrc:null,monitor:null},a.meta={type:"dtm.music",setParams:function(b){return a.params=b,a},setNodes:function(b){return a.nodes=b,a},deferIncr:1},a.__proto__=Music.prototype,a}function getInterval(a){return this.params.interval.base.get(a).get(0)*(240*this.params.time.get(a).get(0)/this.params.bpm.get(a).get(0))}function typeCheck(a){return isNestedDtmArray(a)?a:isFunction(a)?a:toFloat32Array(a)}function check(a,b){return isInteger(b)||(b=3),isNumber(a)||(isNumDtmArray(a)||isNumOrFloat32Array(a)||isNestedArray(a)||isNestedWithDtmArray(a)||isNestedNumDtmArray(a))&&getMaxDepth(a)<=b}function convert(a){return isArray(a)&&1===a.length?convert(a[0]):isNestedNumDtmArray(a)?a:dtm.data(isNestedWithDtmArray(a)?a:isNumDtmArray(a)?[a]:isNestedArray(a)?a:isNumOrFloat32Array(a)?[a]:[toFloat32Array(a)])}function convertShallow(a){return isArray(a)&&1===a.length?convertShallow(a[0]):isNestedNumDtmArray(a)?a:isNestedWithDtmArray(a)?dtm.data.apply(this,a):isNumDtmArray(a)?a().block(1):isNestedArray(a)?dtm.data(a):isNumOrFloat32Array(a)?dtm.data(a).block(1):dtm.data([toFloat32Array(a)])}function MIDI(){function a(){return a}return a.params={},a.__proto__=MIDI.prototype,a}var Module;Module||(Module=("undefined"!=typeof EM?EM:null)||{});var moduleOverrides={};for(var key in Module)Module.hasOwnProperty(key)&&(moduleOverrides[key]=Module[key]);var ENVIRONMENT_IS_WEB=!1,ENVIRONMENT_IS_WORKER=!1,ENVIRONMENT_IS_NODE=!1,ENVIRONMENT_IS_SHELL=!1;if(Module.ENVIRONMENT)if("WEB"===Module.ENVIRONMENT)ENVIRONMENT_IS_WEB=!0;else if("WORKER"===Module.ENVIRONMENT)ENVIRONMENT_IS_WORKER=!0;else if("NODE"===Module.ENVIRONMENT)ENVIRONMENT_IS_NODE=!0;else{if("SHELL"!==Module.ENVIRONMENT)throw new Error("The provided Module['ENVIRONMENT'] value is not valid. It must be one of: WEB|WORKER|NODE|SHELL.");ENVIRONMENT_IS_SHELL=!0}else ENVIRONMENT_IS_WEB="object"==typeof window,ENVIRONMENT_IS_WORKER="function"==typeof importScripts,ENVIRONMENT_IS_NODE="object"==typeof process&&"function"==typeof require&&!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER,ENVIRONMENT_IS_SHELL=!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_NODE&&!ENVIRONMENT_IS_WORKER;if(ENVIRONMENT_IS_NODE){Module.print||(Module.print=console.log),Module.printErr||(Module.printErr=console.warn);var nodeFS,nodePath;Module.read=function(a,b){nodeFS||(nodeFS=require("fs")),nodePath||(nodePath=require("path")),a=nodePath.normalize(a);var c=nodeFS.readFileSync(a);return b?c:c.toString()},Module.readBinary=function(a){var b=Module.read(a,!0);return b.buffer||(b=new Uint8Array(b)),assert(b.buffer),b},Module.load=function(a){globalEval(read(a))},Module.thisProgram||(Module.thisProgram=process.argv.length>1?process.argv[1].replace(/\\/g,"/"):"unknown-program"),Module.arguments=process.argv.slice(2),"undefined"!=typeof module&&(module.exports=Module),process.on("uncaughtException",function(a){if(!(a instanceof ExitStatus))throw a}),Module.inspect=function(){return"[Emscripten Module object]"}}else if(ENVIRONMENT_IS_SHELL)Module.print||(Module.print=print),"undefined"!=typeof printErr&&(Module.printErr=printErr),Module.read="undefined"!=typeof read?read:function(){throw"no read() available (jsc?)"},Module.readBinary=function(a){if("function"==typeof readbuffer)return new Uint8Array(readbuffer(a));var b=read(a,"binary");return assert("object"==typeof b),b},"undefined"!=typeof scriptArgs?Module.arguments=scriptArgs:"undefined"!=typeof arguments&&(Module.arguments=arguments);else{if(!ENVIRONMENT_IS_WEB&&!ENVIRONMENT_IS_WORKER)throw"Unknown runtime environment. Where are we?";if(Module.read=function(a){var b=new XMLHttpRequest;return b.open("GET",a,!1),b.send(null),b.responseText},Module.readAsync=function(a,b,c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.responseType="arraybuffer",d.onload=function(){200==d.status||0==d.status&&d.response?b(d.response):c()},d.onerror=c,d.send(null)},"undefined"!=typeof arguments&&(Module.arguments=arguments),"undefined"!=typeof console)Module.print||(Module.print=function(a){console.log(a)}),Module.printErr||(Module.printErr=function(a){console.warn(a)});else{var TRY_USE_DUMP=!1;Module.print||(Module.print=TRY_USE_DUMP&&"undefined"!=typeof dump?function(a){dump(a)}:function(){})}ENVIRONMENT_IS_WORKER&&(Module.load=importScripts),"undefined"==typeof Module.setWindowTitle&&(Module.setWindowTitle=function(a){document.title=a})
}!Module.load&&Module.read&&(Module.load=function(a){globalEval(Module.read(a))}),Module.print||(Module.print=function(){}),Module.printErr||(Module.printErr=Module.print),Module.arguments||(Module.arguments=[]),Module.thisProgram||(Module.thisProgram="./this.program"),Module.print=Module.print,Module.printErr=Module.printErr,Module.preRun=[],Module.postRun=[];for(var key in moduleOverrides)moduleOverrides.hasOwnProperty(key)&&(Module[key]=moduleOverrides[key]);moduleOverrides=void 0;var Runtime={setTempRet0:function(a){tempRet0=a},getTempRet0:function(){return tempRet0},stackSave:function(){return STACKTOP},stackRestore:function(a){STACKTOP=a},getNativeTypeSize:function(a){switch(a){case"i1":case"i8":return 1;case"i16":return 2;case"i32":return 4;case"i64":return 8;case"float":return 4;case"double":return 8;default:if("*"===a[a.length-1])return Runtime.QUANTUM_SIZE;if("i"===a[0]){var b=parseInt(a.substr(1));return assert(b%8===0),b/8}return 0}},getNativeFieldSize:function(a){return Math.max(Runtime.getNativeTypeSize(a),Runtime.QUANTUM_SIZE)},STACK_ALIGN:16,prepVararg:function(a,b){return"double"===b||"i64"===b?7&a&&(assert(4===(7&a)),a+=4):assert(0===(3&a)),a},getAlignSize:function(a,b,c){return c||"i64"!=a&&"double"!=a?a?Math.min(b||(a?Runtime.getNativeFieldSize(a):0),Runtime.QUANTUM_SIZE):Math.min(b,8):8},dynCall:function(a,b,c){return c&&c.length?Module["dynCall_"+a].apply(null,[b].concat(c)):Module["dynCall_"+a].call(null,b)},functionPointers:[],addFunction:function(a){for(var b=0;b<Runtime.functionPointers.length;b++)if(!Runtime.functionPointers[b])return Runtime.functionPointers[b]=a,2*(1+b);throw"Finished up all reserved function pointers. Use a higher value for RESERVED_FUNCTION_POINTERS."},removeFunction:function(a){Runtime.functionPointers[(a-2)/2]=null},warnOnce:function(a){Runtime.warnOnce.shown||(Runtime.warnOnce.shown={}),Runtime.warnOnce.shown[a]||(Runtime.warnOnce.shown[a]=1,Module.printErr(a))},funcWrappers:{},getFuncWrapper:function(a,b){assert(b),Runtime.funcWrappers[b]||(Runtime.funcWrappers[b]={});var c=Runtime.funcWrappers[b];return c[a]||(c[a]=1===b.length?function(){return Runtime.dynCall(b,a)}:2===b.length?function(c){return Runtime.dynCall(b,a,[c])}:function(){return Runtime.dynCall(b,a,Array.prototype.slice.call(arguments))}),c[a]},getCompilerSetting:function(){throw"You must build with -s RETAIN_COMPILER_SETTINGS=1 for Runtime.getCompilerSetting or emscripten_get_compiler_setting to work"},stackAlloc:function(a){var b=STACKTOP;return STACKTOP=STACKTOP+a|0,STACKTOP=STACKTOP+15&-16,b},staticAlloc:function(a){var b=STATICTOP;return STATICTOP=STATICTOP+a|0,STATICTOP=STATICTOP+15&-16,b},dynamicAlloc:function(a){var b=DYNAMICTOP;if(DYNAMICTOP=DYNAMICTOP+a|0,DYNAMICTOP=DYNAMICTOP+15&-16,DYNAMICTOP>=TOTAL_MEMORY){var c=enlargeMemory();if(!c)return DYNAMICTOP=b,0}return b},alignMemory:function(a,b){var c=a=Math.ceil(a/(b?b:16))*(b?b:16);return c},makeBigInt:function(a,b,c){var d=c?+(a>>>0)+4294967296*+(b>>>0):+(a>>>0)+4294967296*+(0|b);return d},GLOBAL_BASE:8,QUANTUM_SIZE:4,__dummy__:0};Module.Runtime=Runtime;var ABORT=!1,EXITSTATUS=0,cwrap,ccall;!function(){function parseJSFunc(a){var b=a.toString().match(sourceRegex).slice(1);return{arguments:b[0],body:b[1],returnValue:b[2]}}function ensureJSsource(){if(!JSsource){JSsource={};for(var a in JSfuncs)JSfuncs.hasOwnProperty(a)&&(JSsource[a]=parseJSFunc(JSfuncs[a]))}}var JSfuncs={stackSave:function(){Runtime.stackSave()},stackRestore:function(){Runtime.stackRestore()},arrayToC:function(a){var b=Runtime.stackAlloc(a.length);return writeArrayToMemory(a,b),b},stringToC:function(a){var b=0;return null!==a&&void 0!==a&&0!==a&&(b=Runtime.stackAlloc((a.length<<2)+1),writeStringToMemory(a,b)),b}},toC={string:JSfuncs.stringToC,array:JSfuncs.arrayToC};ccall=function(a,b,c,d,e){var f=getCFunc(a),g=[],h=0;if(d)for(var i=0;i<d.length;i++){var j=toC[c[i]];j?(0===h&&(h=Runtime.stackSave()),g[i]=j(d[i])):g[i]=d[i]}var k=f.apply(null,g);if("string"===b&&(k=Pointer_stringify(k)),0!==h){if(e&&e.async)return void EmterpreterAsync.asyncFinalizers.push(function(){Runtime.stackRestore(h)});Runtime.stackRestore(h)}return k};var sourceRegex=/^function\s*[a-zA-Z$_0-9]*\s*\(([^)]*)\)\s*{\s*([^*]*?)[\s;]*(?:return\s*(.*?)[;\s]*)?}$/,JSsource=null;cwrap=function cwrap(ident,returnType,argTypes){argTypes=argTypes||[];var cfunc=getCFunc(ident),numericArgs=argTypes.every(function(a){return"number"===a}),numericRet="string"!==returnType;if(numericRet&&numericArgs)return cfunc;var argNames=argTypes.map(function(a,b){return"$"+b}),funcstr="(function("+argNames.join(",")+") {",nargs=argTypes.length;if(!numericArgs){ensureJSsource(),funcstr+="var stack = "+JSsource.stackSave.body+";";for(var i=0;nargs>i;i++){var arg=argNames[i],type=argTypes[i];if("number"!==type){var convertCode=JSsource[type+"ToC"];funcstr+="var "+convertCode.arguments+" = "+arg+";",funcstr+=convertCode.body+";",funcstr+=arg+"=("+convertCode.returnValue+");"}}}var cfuncname=parseJSFunc(function(){return cfunc}).returnValue;if(funcstr+="var ret = "+cfuncname+"("+argNames.join(",")+");",!numericRet){var strgfy=parseJSFunc(function(){return Pointer_stringify}).returnValue;funcstr+="ret = "+strgfy+"(ret);"}return numericArgs||(ensureJSsource(),funcstr+=JSsource.stackRestore.body.replace("()","(stack)")+";"),funcstr+="return ret})",eval(funcstr)}}(),Module.ccall=ccall,Module.cwrap=cwrap,Module.setValue=setValue,Module.getValue=getValue;var ALLOC_NORMAL=0,ALLOC_STACK=1,ALLOC_STATIC=2,ALLOC_DYNAMIC=3,ALLOC_NONE=4;Module.ALLOC_NORMAL=ALLOC_NORMAL,Module.ALLOC_STACK=ALLOC_STACK,Module.ALLOC_STATIC=ALLOC_STATIC,Module.ALLOC_DYNAMIC=ALLOC_DYNAMIC,Module.ALLOC_NONE=ALLOC_NONE,Module.allocate=allocate,Module.getMemory=getMemory,Module.Pointer_stringify=Pointer_stringify,Module.AsciiToString=AsciiToString,Module.stringToAscii=stringToAscii,Module.UTF8ArrayToString=UTF8ArrayToString,Module.UTF8ToString=UTF8ToString,Module.stringToUTF8Array=stringToUTF8Array,Module.stringToUTF8=stringToUTF8,Module.lengthBytesUTF8=lengthBytesUTF8,Module.stackTrace=stackTrace;for(var HEAP,buffer,HEAP8,HEAPU8,HEAP16,HEAPU16,HEAP32,HEAPU32,HEAPF32,HEAPF64,STATIC_BASE=0,STATICTOP=0,staticSealed=!1,STACK_BASE=0,STACKTOP=0,STACK_MAX=0,DYNAMIC_BASE=0,DYNAMICTOP=0,TOTAL_STACK=Module.TOTAL_STACK||5242880,TOTAL_MEMORY=Module.TOTAL_MEMORY||16777216,totalMemory=65536;TOTAL_MEMORY>totalMemory||2*TOTAL_STACK>totalMemory;)16777216>totalMemory?totalMemory*=2:totalMemory+=16777216;if(totalMemory!==TOTAL_MEMORY&&(TOTAL_MEMORY=totalMemory),buffer=Module.buffer?Module.buffer:new ArrayBuffer(TOTAL_MEMORY),updateGlobalBufferViews(),HEAP32[0]=255,255!==HEAPU8[0]||0!==HEAPU8[3])throw"Typed arrays 2 must be run on a little-endian system";Module.HEAP=HEAP,Module.buffer=buffer,Module.HEAP8=HEAP8,Module.HEAP16=HEAP16,Module.HEAP32=HEAP32,Module.HEAPU8=HEAPU8,Module.HEAPU16=HEAPU16,Module.HEAPU32=HEAPU32,Module.HEAPF32=HEAPF32,Module.HEAPF64=HEAPF64;var __ATPRERUN__=[],__ATINIT__=[],__ATMAIN__=[],__ATEXIT__=[],__ATPOSTRUN__=[],runtimeInitialized=!1,runtimeExited=!1;Module.addOnPreRun=addOnPreRun,Module.addOnInit=addOnInit,Module.addOnPreMain=addOnPreMain,Module.addOnExit=addOnExit,Module.addOnPostRun=addOnPostRun,Module.intArrayFromString=intArrayFromString,Module.intArrayToString=intArrayToString,Module.writeStringToMemory=writeStringToMemory,Module.writeArrayToMemory=writeArrayToMemory,Module.writeAsciiToMemory=writeAsciiToMemory,Math.imul&&-5===Math.imul(4294967295,5)||(Math.imul=function(a,b){var c=a>>>16,d=65535&a,e=b>>>16,f=65535&b;return d*f+(c*f+d*e<<16)|0}),Math.imul=Math.imul,Math.clz32||(Math.clz32=function(a){a>>>=0;for(var b=0;32>b;b++)if(a&1<<31-b)return b;return 32}),Math.clz32=Math.clz32,Math.trunc||(Math.trunc=function(a){return 0>a?Math.ceil(a):Math.floor(a)}),Math.trunc=Math.trunc;var Math_abs=Math.abs,Math_cos=Math.cos,Math_sin=Math.sin,Math_tan=Math.tan,Math_acos=Math.acos,Math_asin=Math.asin,Math_atan=Math.atan,Math_atan2=Math.atan2,Math_exp=Math.exp,Math_log=Math.log,Math_sqrt=Math.sqrt,Math_ceil=Math.ceil,Math_floor=Math.floor,Math_pow=Math.pow,Math_imul=Math.imul,Math_fround=Math.fround,Math_min=Math.min,Math_clz32=Math.clz32,Math_trunc=Math.trunc,runDependencies=0,runDependencyWatcher=null,dependenciesFulfilled=null;Module.addRunDependency=addRunDependency,Module.removeRunDependency=removeRunDependency,Module.preloadedImages={},Module.preloadedAudios={};var ASM_CONSTS=[];STATIC_BASE=8,STATICTOP=STATIC_BASE+1712,__ATINIT__.push(),allocate([5,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,1,0,0,0,2,0,0,0,164,2,0,0,0,4,0,0,0,0,0,0,0,0,0,0,1,0,0,0,0,0,0,0,0,0,0,0,0,0,0,10,255,255,255,255,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,8,0,0,0],"i8",ALLOC_NONE,Runtime.GLOBAL_BASE);var tempDoublePtr=STATICTOP;STATICTOP+=16,Module._memset=_memset,Module._memcpy=_memcpy,Module._pthread_self=_pthread_self;var SYSCALLS={varargs:0,get:function(){SYSCALLS.varargs+=4;var a=HEAP32[SYSCALLS.varargs-4>>2];return a},getStr:function(){var a=Pointer_stringify(SYSCALLS.get());return a},get64:function(){var a=SYSCALLS.get(),b=SYSCALLS.get();return assert(a>=0?0===b:-1===b),a},getZero:function(){assert(0===SYSCALLS.get())}};__ATEXIT__.push(function(){var a=Module._fflush;a&&a(0);var b=___syscall146.printChar;if(b){var c=___syscall146.buffers;c[1].length&&b(1,10),c[2].length&&b(2,10)}}),STACK_BASE=STACKTOP=Runtime.alignMemory(STATICTOP),staticSealed=!0,STACK_MAX=STACK_BASE+TOTAL_STACK,DYNAMIC_BASE=DYNAMICTOP=Runtime.alignMemory(STACK_MAX),Module.asmGlobalArg={Math:Math,Int8Array:Int8Array,Int16Array:Int16Array,Int32Array:Int32Array,Uint8Array:Uint8Array,Uint16Array:Uint16Array,Uint32Array:Uint32Array,Float32Array:Float32Array,Float64Array:Float64Array,NaN:0/0,Infinity:1/0},Module.asmLibraryArg={abort:abort,assert:assert,invoke_ii:invoke_ii,invoke_iiii:invoke_iiii,invoke_vi:invoke_vi,_pthread_cleanup_pop:_pthread_cleanup_pop,___lock:___lock,_abort:_abort,_pthread_cleanup_push:_pthread_cleanup_push,___syscall6:___syscall6,_sbrk:_sbrk,___syscall140:___syscall140,_emscripten_memcpy_big:_emscripten_memcpy_big,___syscall54:___syscall54,___unlock:___unlock,___syscall146:___syscall146,STACKTOP:STACKTOP,STACK_MAX:STACK_MAX,tempDoublePtr:tempDoublePtr,ABORT:ABORT};var asm=function(a,b,c){"use asm";function d(a){a|=0;var b=0;return b=S,S=S+a|0,S=S+15&-16,b|0}function e(){return S|0}function f(a){a|=0,S=a}function g(a,b){a|=0,b|=0,S=a,T=b}function h(a,b){a|=0,b|=0,V||(V=a,W=b)}function i(a){a|=0,X=a}function j(){return X|0}function k(a,b,c,d){a|=0,b|=0,c=+c,d=+d;var e=0,f=0,g=0;if(d==c?c>0&c<=1?(f=0,d=1):c>1?(f=c+-1,d=1):(f=c,d=1):(f=c,d-=c),(b|0)>0){e=0;do g=a+(e<<2)|0,R[g>>2]=(+R[g>>2]-f)/d,e=e+1|0;while((e|0)!=(b|0))}}function l(a,b){a|=0,b|=0;var c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0;if(i=S,f=p(b,0,0,0)|0,g=p(b,1,0,0)|0,c=S,S=S+((1*(b<<3)|0)+15&-16)|0,h=S,S=S+((1*(b<<3)|0)+15&-16)|0,d=(b|0)>0,!d)return r(f,c,h),E(f),E(g),void(S=i);e=0;do Q[c+(e<<3)>>2]=Q[a+(e<<2)>>2],R[c+(e<<3)+4>>2]=0,e=e+1|0;while((e|0)!=(b|0));if(r(f,c,h),!d)return E(f),E(g),void(S=i);c=0;do k=+R[h+(c<<3)>>2],j=+R[h+(c<<3)+4>>2],R[a+(c<<2)>>2]=+Z(+(k*k+j*j)),c=c+1|0;while((c|0)!=(b|0));E(f),E(g),S=i}function m(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0;if(m=S,j=p(c,0,0,0)|0,k=p(c,1,0,0)|0,e=S,S=S+((1*(c<<3)|0)+15&-16)|0,g=S,S=S+((1*(c<<3)|0)+15&-16)|0,h=S,S=S+((1*(c<<3)|0)+15&-16)|0,l=S,S=S+((1*(c<<3)|0)+15&-16)|0,i=(c|0)>0){f=0;do Q[e+(f<<3)>>2]=Q[a+(f<<2)>>2],R[e+(f<<3)+4>>2]=0,f=f+1|0;while((f|0)!=(c|0));if(r(j,e,g),i){e=0;do R[h+(e<<3)>>2]=+R[g+(e<<3)>>2]*+R[b+(e<<2)>>2],R[h+(e<<3)+4>>2]=0,e=e+1|0;while((e|0)!=(c|0));if(r(k,h,l),!i)return E(j),E(k),void(S=m);d=+(c|0),e=0;do R[a+(e<<2)>>2]=+R[l+(e<<3)>>2]/d,e=e+1|0;while((e|0)!=(c|0));return E(j),E(k),void(S=m)}}else r(j,e,g);r(k,h,l),E(j),E(k),S=m}function n(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0;if(k=S,h=(b|0)/2|0,j=p(b,0,0,0)|0,f=S,S=S+((1*(b<<3)|0)+15&-16)|0,i=S,S=S+((1*(b<<3)|0)+15&-16)|0,(b|0)>0){g=0;do Q[f+(g<<3)>>2]=Q[a+(g<<2)>>2],R[f+(g<<3)+4>>2]=0,g=g+1|0;while((g|0)!=(b|0));if(r(j,f,i),(b|0)>1){f=0,e=0,d=0;do l=+R[i+(f<<3)>>2],l*=l,e+=l,d+=+(f|0)*l,f=f+1|0;while((f|0)<(h|0))}else e=0,d=0}else r(j,f,i),e=0,d=0;return E(j),S=k,+(+(c|0)*(d/e)/+(b|0))}function o(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;p=S,m=b+-1|0,d=c+-1|0,n=ab(d,m)|0,o=S,S=S+((1*(n+1<<2)|0)+15&-16)|0;do if((b|0)>1){if(l=+(d|0),(c|0)<=1){Q[o>>2]=Q[a+(m<<2)>>2],d=0;break}for(b=(ab(d,b+-2|0)|0)+c|0,h=+R[a>>2],e=0,k=0;;){for(k=k+1|0,i=h,h=+R[a+(k<<2)>>2],g=h-i,f=e,j=0;;){if(R[o+(f<<2)>>2]=i+ +(j|0)/l*g,j=j+1|0,(j|0)==(d|0))break;f=f+1|0}if((k|0)==(m|0))break;e=d+e|0}b=b+-1|0,e=m,f=9}else b=0,e=0,f=9;while(0);if((f|0)==9)if(Q[o+(b<<2)>>2]=Q[a+(e<<2)>>2],(c|0)>1){b=0;do Q[a+(b<<2)>>2]=Q[o+((ab(b,m)|0)<<2)>>2],b=b+1|0;while((b|0)!=(d|0))}else d=0;Q[a+(d<<2)>>2]=Q[o+(n<<2)>>2],S=p}function p(a,b,c,d){a|=0,b|=0,c|=0,d|=0;var e=0,f=0,g=0,h=0;if(e=(a<<3)+264|0,d?(c=c?(Q[d>>2]|0)>>>0<e>>>0?0:c:0,Q[d>>2]=e,g=c):g=D(e)|0,!g)return g|0;Q[g>>2]=a,d=g+4|0,Q[d>>2]=b,f=+(a|0);a:do if((a|0)>0)for(e=b,c=0;;){if(h=+(c|0)*-6.283185307179586/f,h=(e|0)==0?h:-h,R[g+264+(c<<3)>>2]=+$(+h),R[g+264+(c<<3)+4>>2]=+_(+h),c=c+1|0,(c|0)==(a|0))break a;e=Q[d>>2]|0}while(0);for(f=+Y(+ +Z(+f)),e=a,d=g+8|0,c=4;;){a:do if((e|0)%(c|0)|0)for(;;){switch(c|0){case 4:c=2;break;case 2:c=3;break;default:c=c+2|0}if(c=+(c|0)>f?e:c,!((e|0)%(c|0)|0))break a}while(0);if(e=(e|0)/(c|0)|0,Q[d>>2]=c,Q[d+4>>2]=e,(e|0)<=1)break;d=d+8|0}return g|0}function q(a,b,c,d,e,f){a|=0,b|=0,c|=0,d|=0,e|=0,f|=0;var g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,r=0,s=0,t=0,u=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0;if(u=Q[e>>2]|0,j=e+8|0,v=Q[e+4>>2]|0,o=a+((ab(v,u)|0)<<3)|0,(v|0)==1)for(h=ab(d,c)|0,g=a,e=b;;){if(r=e,s=Q[r+4>>2]|0,t=g,Q[t>>2]=Q[r>>2],Q[t+4>>2]=s,g=g+8|0,(g|0)==(o|0))break;e=e+(h<<3)|0}else for(h=ab(u,c)|0,i=ab(d,c)|0,g=a,e=b;;){if(q(g,e,h,d,j,f),g=g+(v<<3)|0,(g|0)==(o|0))break;e=e+(i<<3)|0}switch(u|0){case 2:for(h=a,i=v,g=a+(v<<3)|0,e=f+264|0;;){if(l=+R[g>>2],w=+R[e>>2],a=g+4|0,k=+R[a>>2],n=+R[e+4>>2],m=l*w-k*n,n=w*k+l*n,R[g>>2]=+R[h>>2]-m,v=h+4|0,R[a>>2]=+R[v>>2]-n,R[h>>2]=m+ +R[h>>2],R[v>>2]=n+ +R[v>>2],i=i+-1|0,!i)break;h=h+8|0,g=g+8|0,e=e+(c<<3)|0}return;case 3:for(d=v<<1,k=+R[f+264+((ab(v,c)|0)<<3)+4>>2],i=f+264|0,j=c<<1,e=a,g=v,h=i;;){if(f=e+(v<<3)|0,l=+R[f>>2],m=+R[h>>2],a=e+(v<<3)+4|0,z=+R[a>>2],x=+R[h+4>>2],y=l*m-z*x,x=m*z+l*x,t=e+(d<<3)|0,l=+R[t>>2],z=+R[i>>2],u=e+(d<<3)+4|0,m=+R[u>>2],n=+R[i+4>>2],w=l*z-m*n,n=z*m+l*n,l=y+w,m=x+n,R[f>>2]=+R[e>>2]-l*.5,s=e+4|0,R[a>>2]=+R[s>>2]-m*.5,w=k*(y-w),n=k*(x-n),R[e>>2]=l+ +R[e>>2],R[s>>2]=m+ +R[s>>2],R[t>>2]=n+ +R[f>>2],R[u>>2]=+R[a>>2]-w,R[f>>2]=+R[f>>2]-n,R[a>>2]=w+ +R[a>>2],g=g+-1|0,!g)break;e=e+8|0,h=h+(c<<3)|0,i=i+(j<<3)|0}return;case 4:if(d=v<<1,b=v*3|0,e=f+264|0,o=c<<1,p=c*3|0,Q[f+4>>2]|0){for(g=a,h=v,i=e,j=e;;){if(u=g+(v<<3)|0,m=+R[u>>2],n=+R[i>>2],f=g+(v<<3)+4|0,y=+R[f>>2],l=+R[i+4>>2],k=m*n-y*l,l=n*y+m*l,r=g+(d<<3)|0,m=+R[r>>2],y=+R[j>>2],s=g+(d<<3)+4|0,n=+R[s>>2],w=+R[j+4>>2],x=m*y-n*w,w=y*n+m*w,a=g+(b<<3)|0,m=+R[a>>2],n=+R[e>>2],A=g+(b<<3)+4|0,y=+R[A>>2],z=+R[e+4>>2],C=m*n-y*z,z=n*y+m*z,m=+R[g>>2],y=m-x,t=g+4|0,n=+R[t>>2],B=n-w,m=x+m,R[g>>2]=m,n=w+n,R[t>>2]=n,w=k+C,x=l+z,C=k-C,z=l-z,R[r>>2]=m-w,R[s>>2]=n-x,R[g>>2]=w+ +R[g>>2],R[t>>2]=x+ +R[t>>2],R[u>>2]=y-z,R[f>>2]=B+C,R[a>>2]=y+z,R[A>>2]=B-C,h=h+-1|0,!h)break;g=g+8|0,i=i+(c<<3)|0,j=j+(o<<3)|0,e=e+(p<<3)|0}return}for(g=a,h=v,i=e,j=e;;){if(t=g+(v<<3)|0,k=+R[t>>2],l=+R[i>>2],u=g+(v<<3)+4|0,w=+R[u>>2],B=+R[i+4>>2],C=k*l-w*B,B=l*w+k*B,A=g+(d<<3)|0,k=+R[A>>2],w=+R[j>>2],r=g+(d<<3)+4|0,l=+R[r>>2],m=+R[j+4>>2],n=k*w-l*m,m=w*l+k*m,f=g+(b<<3)|0,k=+R[f>>2],l=+R[e>>2],a=g+(b<<3)+4|0,w=+R[a>>2],x=+R[e+4>>2],z=k*l-w*x,x=l*w+k*x,k=+R[g>>2],w=k-n,s=g+4|0,l=+R[s>>2],y=l-m,k=n+k,R[g>>2]=k,l=m+l,R[s>>2]=l,m=C+z,n=B+x,z=C-z,x=B-x,R[A>>2]=k-m,R[r>>2]=l-n,R[g>>2]=m+ +R[g>>2],R[s>>2]=n+ +R[s>>2],R[t>>2]=w+x,R[u>>2]=y-z,R[f>>2]=w-x,R[a>>2]=y+z,h=h+-1|0,!h)break;g=g+8|0,i=i+(c<<3)|0,j=j+(o<<3)|0,e=e+(p<<3)|0}return;case 5:if(A=ab(v,c)|0,k=+R[f+264+(A<<3)>>2],l=+R[f+264+(A<<3)+4>>2],A=ab(v,c<<1)|0,m=+R[f+264+(A<<3)>>2],n=+R[f+264+(A<<3)+4>>2],(v|0)<=0)return;for(h=c*3|0,i=a,j=a+(v<<3)|0,d=a+(v<<1<<3)|0,b=a+(v*3<<3)|0,e=a+(v<<2<<3)|0,g=0;;){if(H=+R[i>>2],s=i+4|0,F=+R[s>>2],y=+R[j>>2],r=ab(g,c)|0,B=+R[f+264+(r<<3)>>2],t=j+4|0,M=+R[t>>2],I=+R[f+264+(r<<3)+4>>2],G=y*B-M*I,I=B*M+y*I,y=+R[d>>2],r=ab(g<<1,c)|0,M=+R[f+264+(r<<3)>>2],a=d+4|0,B=+R[a>>2],L=+R[f+264+(r<<3)+4>>2],J=y*M-B*L,L=M*B+y*L,y=+R[b>>2],r=ab(h,g)|0,B=+R[f+264+(r<<3)>>2],A=b+4|0,M=+R[A>>2],w=+R[f+264+(r<<3)+4>>2],C=y*B-M*w,w=B*M+y*w,y=+R[e>>2],r=ab(g<<2,c)|0,M=+R[f+264+(r<<3)>>2],u=e+4|0,B=+R[u>>2],z=+R[f+264+(r<<3)+4>>2],x=y*M-B*z,z=M*B+y*z,y=G+x,B=I+z,x=G-x,z=I-z,I=J+C,G=L+w,C=J-C,w=L-w,R[i>>2]=H+(I+y),R[s>>2]=F+(G+B),L=m*I+(H+k*y),J=m*G+(F+k*B),M=n*w+l*z,K=-(l*x)-n*C,R[j>>2]=L-M,R[t>>2]=J-K,R[e>>2]=M+L,R[u>>2]=K+J,y=k*I+(H+m*y),B=k*G+(F+m*B),z=l*w-n*z,C=n*x-l*C,R[d>>2]=z+y,R[a>>2]=C+B,R[b>>2]=y-z,R[A>>2]=B-C,g=g+1|0,(g|0)==(v|0))break;i=i+8|0,j=j+8|0,d=d+8|0,b=b+8|0,e=e+8|0}return;default:r=Q[f>>2]|0,t=D(u<<3)|0;a:do if((v|0)>0?(u|0)>0:0){if((u|0)>1)s=0;else for(j=0;;){for(e=j,g=0;;){if(f=a+(e<<3)|0,c=Q[f+4>>2]|0,A=t+(g<<3)|0,Q[A>>2]=Q[f>>2],Q[A+4>>2]=c,g=g+1|0,(g|0)==(u|0))break;e=e+v|0}for(g=t,e=Q[g>>2]|0,g=Q[g+4>>2]|0,h=j,i=0;;){if(A=a+(h<<3)|0,Q[A>>2]=e,Q[A+4>>2]=g,i=i+1|0,(i|0)==(u|0))break;h=h+v|0}if(j=j+1|0,(j|0)==(v|0))break a}do{for(e=s,g=0;;){if(o=a+(e<<3)|0,p=Q[o+4>>2]|0,A=t+(g<<3)|0,Q[A>>2]=Q[o>>2],Q[A+4>>2]=p,g=g+1|0,(g|0)==(u|0))break;e=e+v|0}for(g=t,e=Q[g>>2]|0,g=Q[g+4>>2]|0,Q[U>>2]=e,k=+R[U>>2],d=s,o=0;;){h=a+(d<<3)|0,i=h,Q[i>>2]=e,Q[i+4>>2]=g,i=ab(d,c)|0,j=a+(d<<3)+4|0,l=k,m=+R[j>>2],b=1,p=0;do A=p+i|0,p=A-((A|0)<(r|0)?0:r)|0,L=+R[t+(b<<3)>>2],J=+R[f+264+(p<<3)>>2],K=+R[t+(b<<3)+4>>2],M=+R[f+264+(p<<3)+4>>2],l+=L*J-K*M,R[h>>2]=l,m+=J*K+L*M,R[j>>2]=m,b=b+1|0;while((b|0)!=(u|0));if(o=o+1|0,(o|0)==(u|0))break;d=d+v|0}s=s+1|0}while((s|0)!=(v|0))}while(0);return void E(t)}}function r(a,b,c){return a|=0,b|=0,c|=0,(b|0)==(c|0)?(c=D(Q[a>>2]<<3)|0,q(c,b,1,1,a+8|0,a),H(b|0,c|0,Q[a>>2]<<3|0)|0,void E(c)):void q(c,b,1,1,a+8|0,a)}function s(a){a|=0;var b=0,c=0;return b=S,S=S+16|0,c=b,Q[c>>2]=Q[a+60>>2],a=t(gb(6,c|0)|0)|0,S=b,a|0}function t(a){return a|=0,a>>>0>4294963200&&(Q[(u()|0)>>2]=0-a,a=-1),a|0}function u(){var a=0;return a=Q[31]|0?Q[(I()|0)+64>>2]|0:168,a|0}function v(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0;for(o=S,S=S+48|0,l=o+16|0,k=o,d=o+32|0,m=a+28|0,e=Q[m>>2]|0,Q[d>>2]=e,n=a+20|0,e=(Q[n>>2]|0)-e|0,Q[d+4>>2]=e,Q[d+8>>2]=b,Q[d+12>>2]=c,i=a+60|0,j=a+44|0,b=2,e=e+c|0;;){if(Q[31]|0?(fb(1,a|0),Q[k>>2]=Q[i>>2],Q[k+4>>2]=d,Q[k+8>>2]=b,g=t(mb(146,k|0)|0)|0,cb(0)):(Q[l>>2]=Q[i>>2],Q[l+4>>2]=d,Q[l+8>>2]=b,g=t(mb(146,l|0)|0)|0),(e|0)==(g|0)){e=6;break}if((g|0)<0){e=8;break}e=e-g|0,f=Q[d+4>>2]|0,g>>>0<=f>>>0?(b|0)==2?(Q[m>>2]=(Q[m>>2]|0)+g,h=f,b=2):h=f:(h=Q[j>>2]|0,Q[m>>2]=h,Q[n>>2]=h,h=Q[d+12>>2]|0,g=g-f|0,d=d+8|0,b=b+-1|0),Q[d>>2]=(Q[d>>2]|0)+g,Q[d+4>>2]=h-g}return(e|0)==6?(l=Q[j>>2]|0,Q[a+16>>2]=l+(Q[a+48>>2]|0),a=l,Q[m>>2]=a,Q[n>>2]=a):(e|0)==8&&(Q[a+16>>2]=0,Q[m>>2]=0,Q[n>>2]=0,Q[a>>2]=Q[a>>2]|32,c=(b|0)==2?0:c-(Q[d+4>>2]|0)|0),S=o,c|0}function w(a){a|=0,Q[a+68>>2]|0||x(a)}function x(a){a|=0}function y(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0;return e=S,S=S+32|0,f=e,d=e+20|0,Q[f>>2]=Q[a+60>>2],Q[f+4>>2]=0,Q[f+8>>2]=b,Q[f+12>>2]=d,Q[f+16>>2]=c,(t(ib(140,f|0)|0)|0)<0?(Q[d>>2]=-1,a=-1):a=Q[d>>2]|0,S=e,a|0}function z(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0;return e=S,S=S+80|0,d=e,Q[a+36>>2]=3,((Q[a>>2]&64|0)==0?(Q[d>>2]=Q[a+60>>2],Q[d+4>>2]=21505,Q[d+8>>2]=e+12,kb(54,d|0)|0):0)&&(P[a+75>>0]=-1),d=v(a,b,c)|0,S=e,d|0}function A(a){return a|=0,0}function B(a){a|=0;var b=0,c=0;do if(a){if((Q[a+76>>2]|0)<=-1){b=C(a)|0;break}c=(A(a)|0)==0,b=C(a)|0,c||x(a)}else{if(b=Q[30]|0?B(Q[30]|0)|0:0,db(152),a=Q[37]|0)do c=(Q[a+76>>2]|0)>-1?A(a)|0:0,(Q[a+20>>2]|0)>>>0>(Q[a+28>>2]|0)>>>0&&(b=C(a)|0|b),c|0&&x(a),a=Q[a+56>>2]|0;while((a|0)!=0);lb(152)}while(0);return b|0}function C(a){a|=0;var b=0,c=0,d=0,e=0,f=0,g=0;return b=a+20|0,f=a+28|0,((Q[b>>2]|0)>>>0>(Q[f>>2]|0)>>>0?(ob[Q[a+36>>2]&3](a,0,0)|0,(Q[b>>2]|0)==0):0)?b=-1:(g=a+4|0,c=Q[g>>2]|0,d=a+8|0,e=Q[d>>2]|0,c>>>0<e>>>0&&ob[Q[a+40>>2]&3](a,c-e|0,1)|0,Q[a+16>>2]=0,Q[f>>2]=0,Q[b>>2]=0,Q[d>>2]=0,Q[g>>2]=0,b=0),b|0}function D(a){a|=0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0,q=0,r=0,s=0,t=0,v=0,w=0,x=0,y=0,z=0,A=0,B=0,C=0,D=0,E=0,F=0,G=0,H=0,I=0,J=0,K=0,L=0,M=0,N=0;N=S,S=S+16|0,n=N;do if(a>>>0<245){if(o=a>>>0<11?16:a+11&-8,a=o>>>3,i=Q[43]|0,b=i>>>a,b&3|0){b=(b&1^1)+a|0,c=212+(b<<1<<2)|0,d=c+8|0,e=Q[d>>2]|0,f=e+8|0,g=Q[f>>2]|0;do if((c|0)!=(g|0)){if(g>>>0<(Q[47]|0)>>>0&&eb(),a=g+12|0,(Q[a>>2]|0)==(e|0)){Q[a>>2]=c,Q[d>>2]=g;break}eb()}else Q[43]=i&~(1<<b);while(0);return M=b<<3,Q[e+4>>2]=M|3,M=e+M+4|0,Q[M>>2]=Q[M>>2]|1,M=f,S=N,M|0}if(g=Q[45]|0,o>>>0>g>>>0){if(b|0){c=2<<a,c=b<<a&(c|0-c),c=(c&0-c)+-1|0,h=c>>>12&16,c>>>=h,e=c>>>5&8,c>>>=e,f=c>>>2&4,c>>>=f,d=c>>>1&2,c>>>=d,b=c>>>1&1,b=(e|h|f|d|b)+(c>>>b)|0,c=212+(b<<1<<2)|0,d=c+8|0,f=Q[d>>2]|0,h=f+8|0,e=Q[h>>2]|0;do if((c|0)!=(e|0)){if(e>>>0<(Q[47]|0)>>>0&&eb(),a=e+12|0,(Q[a>>2]|0)==(f|0)){Q[a>>2]=c,Q[d>>2]=e,j=Q[45]|0;break}eb()}else Q[43]=i&~(1<<b),j=g;while(0);return g=(b<<3)-o|0,Q[f+4>>2]=o|3,d=f+o|0,Q[d+4>>2]=g|1,Q[d+g>>2]=g,j|0&&(e=Q[48]|0,b=j>>>3,c=212+(b<<1<<2)|0,a=Q[43]|0,b=1<<b,a&b?(a=c+8|0,b=Q[a>>2]|0,b>>>0<(Q[47]|0)>>>0?eb():(k=a,l=b)):(Q[43]=a|b,k=c+8|0,l=c),Q[k>>2]=e,Q[l+12>>2]=e,Q[e+8>>2]=l,Q[e+12>>2]=c),Q[45]=g,Q[48]=d,M=h,S=N,M|0}if(a=Q[44]|0){for(c=(a&0-a)+-1|0,L=c>>>12&16,c>>>=L,K=c>>>5&8,c>>>=K,M=c>>>2&4,c>>>=M,b=c>>>1&2,c>>>=b,d=c>>>1&1,d=Q[476+((K|L|M|b|d)+(c>>>d)<<2)>>2]|0,c=(Q[d+4>>2]&-8)-o|0,b=d;;){if(a=Q[b+16>>2]|0,!a&&(a=Q[b+20>>2]|0,!a)){i=d;break}b=(Q[a+4>>2]&-8)-o|0,M=b>>>0<c>>>0,c=M?b:c,b=a,d=M?a:d}f=Q[47]|0,i>>>0<f>>>0&&eb(),h=i+o|0,i>>>0>=h>>>0&&eb(),g=Q[i+24>>2]|0,d=Q[i+12>>2]|0;do if((d|0)==(i|0)){if(b=i+20|0,a=Q[b>>2]|0,!a&&(b=i+16|0,a=Q[b>>2]|0,!a)){m=0;break}for(;;)if(d=a+20|0,e=Q[d>>2]|0,e|0)a=e,b=d;else{if(d=a+16|0,e=Q[d>>2]|0,!e)break;a=e,b=d}if(!(b>>>0<f>>>0)){Q[b>>2]=0,m=a;break}eb()}else{if(e=Q[i+8>>2]|0,e>>>0<f>>>0&&eb(),a=e+12|0,(Q[a>>2]|0)!=(i|0)&&eb(),b=d+8|0,(Q[b>>2]|0)==(i|0)){Q[a>>2]=d,Q[b>>2]=e,m=d;break}eb()}while(0);do if(g|0){if(a=Q[i+28>>2]|0,b=476+(a<<2)|0,(i|0)==(Q[b>>2]|0)){if(Q[b>>2]=m,!m){Q[44]=Q[44]&~(1<<a);break}}else if(g>>>0<(Q[47]|0)>>>0&&eb(),a=g+16|0,(Q[a>>2]|0)==(i|0)?Q[a>>2]=m:Q[g+20>>2]=m,!m)break;b=Q[47]|0,m>>>0<b>>>0&&eb(),Q[m+24>>2]=g,a=Q[i+16>>2]|0;do if(a|0){if(!(a>>>0<b>>>0)){Q[m+16>>2]=a,Q[a+24>>2]=m;break}eb()}while(0);if(a=Q[i+20>>2]|0,a|0){if(!(a>>>0<(Q[47]|0)>>>0)){Q[m+20>>2]=a,Q[a+24>>2]=m;break}eb()}}while(0);return c>>>0<16?(M=c+o|0,Q[i+4>>2]=M|3,M=i+M+4|0,Q[M>>2]=Q[M>>2]|1):(Q[i+4>>2]=o|3,Q[h+4>>2]=c|1,Q[h+c>>2]=c,a=Q[45]|0,a|0&&(e=Q[48]|0,b=a>>>3,d=212+(b<<1<<2)|0,a=Q[43]|0,b=1<<b,a&b?(a=d+8|0,b=Q[a>>2]|0,b>>>0<(Q[47]|0)>>>0?eb():(p=a,q=b)):(Q[43]=a|b,p=d+8|0,q=d),Q[p>>2]=e,Q[q+12>>2]=e,Q[e+8>>2]=q,Q[e+12>>2]=d),Q[45]=c,Q[48]=h),M=i+8|0,S=N,M|0}}}else if(a>>>0<=4294967231){if(a=a+11|0,o=a&-8,i=Q[44]|0){c=0-o|0,a>>>=8,a?o>>>0>16777215?h=31:(q=(a+1048320|0)>>>16&8,F=a<<q,p=(F+520192|0)>>>16&4,F<<=p,h=(F+245760|0)>>>16&2,h=14-(p|q|h)+(F<<h>>>15)|0,h=o>>>(h+7|0)&1|h<<1):h=0,b=Q[476+(h<<2)>>2]|0;a:do if(b)for(e=c,a=0,f=o<<((h|0)==31?0:25-(h>>>1)|0),g=b,b=0;;){if(d=Q[g+4>>2]&-8,c=d-o|0,c>>>0<e>>>0){if((d|0)==(o|0)){a=g,b=g,F=90;break a}b=g}else c=e;if(d=Q[g+20>>2]|0,g=Q[g+16+(f>>>31<<2)>>2]|0,a=(d|0)==0|(d|0)==(g|0)?a:d,d=(g|0)==0){F=86;break}e=c,f<<=d&1^1}else a=0,b=0,F=86;while(0);if((F|0)==86){if((a|0)==0&(b|0)==0){if(a=2<<h,a=i&(a|0-a),!a)break;q=(a&0-a)+-1|0,l=q>>>12&16,q>>>=l,k=q>>>5&8,q>>>=k,m=q>>>2&4,q>>>=m,p=q>>>1&2,q>>>=p,a=q>>>1&1,a=Q[476+((k|l|m|p|a)+(q>>>a)<<2)>>2]|0}a?F=90:(h=c,i=b)}if((F|0)==90)for(;;)if(F=0,q=(Q[a+4>>2]&-8)-o|0,d=q>>>0<c>>>0,c=d?q:c,b=d?a:b,d=Q[a+16>>2]|0,d|0)a=d,F=90;else{if(a=Q[a+20>>2]|0,!a){h=c,i=b;break}F=90}if((i|0)!=0?h>>>0<((Q[45]|0)-o|0)>>>0:0){e=Q[47]|0,i>>>0<e>>>0&&eb(),g=i+o|0,i>>>0>=g>>>0&&eb(),f=Q[i+24>>2]|0,c=Q[i+12>>2]|0;do if((c|0)==(i|0)){if(b=i+20|0,a=Q[b>>2]|0,!a&&(b=i+16|0,a=Q[b>>2]|0,!a)){s=0;break}for(;;)if(c=a+20|0,d=Q[c>>2]|0,d|0)a=d,b=c;else{if(c=a+16|0,d=Q[c>>2]|0,!d)break;a=d,b=c}if(!(b>>>0<e>>>0)){Q[b>>2]=0,s=a;break}eb()}else{if(d=Q[i+8>>2]|0,d>>>0<e>>>0&&eb(),a=d+12|0,(Q[a>>2]|0)!=(i|0)&&eb(),b=c+8|0,(Q[b>>2]|0)==(i|0)){Q[a>>2]=c,Q[b>>2]=d,s=c;break}eb()}while(0);do if(f|0){if(a=Q[i+28>>2]|0,b=476+(a<<2)|0,(i|0)==(Q[b>>2]|0)){if(Q[b>>2]=s,!s){Q[44]=Q[44]&~(1<<a);break}}else if(f>>>0<(Q[47]|0)>>>0&&eb(),a=f+16|0,(Q[a>>2]|0)==(i|0)?Q[a>>2]=s:Q[f+20>>2]=s,!s)break;b=Q[47]|0,s>>>0<b>>>0&&eb(),Q[s+24>>2]=f,a=Q[i+16>>2]|0;do if(a|0){if(!(a>>>0<b>>>0)){Q[s+16>>2]=a,Q[a+24>>2]=s;break}eb()}while(0);if(a=Q[i+20>>2]|0,a|0){if(!(a>>>0<(Q[47]|0)>>>0)){Q[s+20>>2]=a,Q[a+24>>2]=s;break}eb()}}while(0);do if(h>>>0>=16){if(Q[i+4>>2]=o|3,Q[g+4>>2]=h|1,Q[g+h>>2]=h,a=h>>>3,h>>>0<256){c=212+(a<<1<<2)|0,b=Q[43]|0,a=1<<a,b&a?(a=c+8|0,b=Q[a>>2]|0,b>>>0<(Q[47]|0)>>>0?eb():(v=a,w=b)):(Q[43]=b|a,v=c+8|0,w=c),Q[v>>2]=g,Q[w+12>>2]=g,Q[g+8>>2]=w,Q[g+12>>2]=c;break}if(a=h>>>8,a?h>>>0>16777215?c=31:(L=(a+1048320|0)>>>16&8,M=a<<L,K=(M+520192|0)>>>16&4,M<<=K,c=(M+245760|0)>>>16&2,c=14-(K|L|c)+(M<<c>>>15)|0,c=h>>>(c+7|0)&1|c<<1):c=0,d=476+(c<<2)|0,Q[g+28>>2]=c,a=g+16|0,Q[a+4>>2]=0,Q[a>>2]=0,a=Q[44]|0,b=1<<c,!(a&b)){Q[44]=a|b,Q[d>>2]=g,Q[g+24>>2]=d,Q[g+12>>2]=g,Q[g+8>>2]=g;break}for(e=h<<((c|0)==31?0:25-(c>>>1)|0),a=Q[d>>2]|0;;){if((Q[a+4>>2]&-8|0)==(h|0)){c=a,F=148;break}if(b=a+16+(e>>>31<<2)|0,c=Q[b>>2]|0,!c){F=145;break}e<<=1,a=c}if((F|0)==145){if(!(b>>>0<(Q[47]|0)>>>0)){Q[b>>2]=g,Q[g+24>>2]=a,Q[g+12>>2]=g,Q[g+8>>2]=g;break}eb()}else if((F|0)==148){if(a=c+8|0,b=Q[a>>2]|0,M=Q[47]|0,b>>>0>=M>>>0&c>>>0>=M>>>0){Q[b+12>>2]=g,Q[a>>2]=g,Q[g+8>>2]=b,Q[g+12>>2]=c,Q[g+24>>2]=0;break}eb()}}else M=h+o|0,Q[i+4>>2]=M|3,M=i+M+4|0,Q[M>>2]=Q[M>>2]|1;while(0);return M=i+8|0,S=N,M|0}}}else o=-1;while(0);if(c=Q[45]|0,c>>>0>=o>>>0)return a=c-o|0,b=Q[48]|0,a>>>0>15?(M=b+o|0,Q[48]=M,Q[45]=a,Q[M+4>>2]=a|1,Q[M+a>>2]=a,Q[b+4>>2]=o|3):(Q[45]=0,Q[48]=0,Q[b+4>>2]=c|3,M=b+c+4|0,Q[M>>2]=Q[M>>2]|1),M=b+8|0,S=N,M|0;if(a=Q[46]|0,a>>>0>o>>>0)return K=a-o|0,Q[46]=K,M=Q[49]|0,L=M+o|0,Q[49]=L,Q[L+4>>2]=K|1,Q[M+4>>2]=o|3,M=M+8|0,S=N,M|0;if(Q[161]|0||(Q[163]=4096,Q[162]=4096,Q[164]=-1,Q[165]=-1,Q[166]=0,Q[154]=0,w=n&-16^1431655768,Q[n>>2]=w,Q[161]=w),g=o+48|0,f=Q[163]|0,h=o+47|0,e=f+h|0,f=0-f|0,i=e&f,i>>>0<=o>>>0)return M=0,S=N,M|0;if(a=Q[153]|0,a|0?(v=Q[151]|0,w=v+i|0,w>>>0<=v>>>0|w>>>0>a>>>0):0)return M=0,S=N,M|0;a:do if(Q[154]&4)F=188;else{a=Q[49]|0;b:do if(a){for(c=620;;){if(b=Q[c>>2]|0,b>>>0<=a>>>0?(r=c+4|0,(b+(Q[r>>2]|0)|0)>>>0>a>>>0):0){d=c,c=r;break}if(c=Q[c+8>>2]|0,!c){F=171;break b}}if(a=e-(Q[46]|0)&f,a>>>0<2147483647)if(b=hb(a|0)|0,(b|0)==((Q[d>>2]|0)+(Q[c>>2]|0)|0)){if((b|0)!=-1){g=b,e=a,F=191;break a}}else F=181}else F=171;while(0);do if(((F|0)==171?(t=hb(0)|0,(t|0)!=-1):0)&&(a=t,b=Q[162]|0,c=b+-1|0,a=c&a?i-a+(c+a&0-b)|0:i,b=Q[151]|0,c=b+a|0,a>>>0>o>>>0&a>>>0<2147483647)){if(w=Q[153]|0,w|0?c>>>0<=b>>>0|c>>>0>w>>>0:0)break;if(b=hb(a|0)|0,(b|0)==(t|0)){g=t,e=a,F=191;break a}F=181}while(0);b:do if((F|0)==181){c=0-a|0;do if(g>>>0>a>>>0&(a>>>0<2147483647&(b|0)!=-1)?(x=Q[163]|0,x=h-a+x&0-x,x>>>0<2147483647):0){if((hb(x|0)|0)==-1){hb(c|0)|0;break b}a=x+a|0;break}while(0);if((b|0)!=-1){g=b,e=a,F=191;break a}}while(0);Q[154]=Q[154]|4,F=188}while(0);if(((((F|0)==188?i>>>0<2147483647:0)?(y=hb(i|0)|0,z=hb(0)|0,y>>>0<z>>>0&((y|0)!=-1&(z|0)!=-1)):0)?(A=z-y|0,A>>>0>(o+40|0)>>>0):0)&&(g=y,e=A,F=191),(F|0)==191){a=(Q[151]|0)+e|0,Q[151]=a,a>>>0>(Q[152]|0)>>>0&&(Q[152]=a),h=Q[49]|0;do if(h){d=620;do{if(a=Q[d>>2]|0,b=d+4|0,c=Q[b>>2]|0,(g|0)==(a+c|0)){B=a,C=b,D=c,E=d,F=201;break}d=Q[d+8>>2]|0}while((d|0)!=0);if(((F|0)==201?(Q[E+12>>2]&8|0)==0:0)?h>>>0<g>>>0&h>>>0>=B>>>0:0){Q[C>>2]=D+e,M=h+8|0,M=(M&7|0)==0?0:0-M&7,L=h+M|0,M=e-M+(Q[46]|0)|0,Q[49]=L,Q[46]=M,Q[L+4>>2]=M|1,Q[L+M+4>>2]=40,Q[50]=Q[165];break}for(a=Q[47]|0,g>>>0<a>>>0?(Q[47]=g,i=g):i=a,c=g+e|0,a=620;;){if((Q[a>>2]|0)==(c|0)){b=a,F=209;break}if(a=Q[a+8>>2]|0,!a){b=620;break}}if((F|0)==209){if(!(Q[a+12>>2]&8)){Q[b>>2]=g,k=a+4|0,Q[k>>2]=(Q[k>>2]|0)+e,k=g+8|0,k=g+((k&7|0)==0?0:0-k&7)|0,a=c+8|0,a=c+((a&7|0)==0?0:0-a&7)|0,j=k+o|0,f=a-k-o|0,Q[k+4>>2]=o|3;do if((a|0)!=(h|0)){if((a|0)==(Q[48]|0)){M=(Q[45]|0)+f|0,Q[45]=M,Q[48]=j,Q[j+4>>2]=M|1,Q[j+M>>2]=M;break}if(b=Q[a+4>>2]|0,(b&3|0)==1){h=b&-8,e=b>>>3;a:do if(b>>>0>=256){g=Q[a+24>>2]|0,d=Q[a+12>>2]|0;do if((d|0)==(a|0)){if(c=a+16|0,d=c+4|0,b=Q[d>>2]|0)c=d;else if(b=Q[c>>2]|0,!b){K=0;break}for(;;)if(d=b+20|0,e=Q[d>>2]|0,e|0)b=e,c=d;else{if(d=b+16|0,e=Q[d>>2]|0,!e)break;b=e,c=d}if(!(c>>>0<i>>>0)){Q[c>>2]=0,K=b;break}eb()}else{if(e=Q[a+8>>2]|0,e>>>0<i>>>0&&eb(),b=e+12|0,(Q[b>>2]|0)!=(a|0)&&eb(),c=d+8|0,(Q[c>>2]|0)==(a|0)){Q[b>>2]=d,Q[c>>2]=e,K=d;break}eb()}while(0);if(!g)break;b=Q[a+28>>2]|0,c=476+(b<<2)|0;do{if((a|0)==(Q[c>>2]|0)){if(Q[c>>2]=K,K|0)break;Q[44]=Q[44]&~(1<<b);break a}if(g>>>0<(Q[47]|0)>>>0&&eb(),b=g+16|0,(Q[b>>2]|0)==(a|0)?Q[b>>2]=K:Q[g+20>>2]=K,!K)break a}while(0);d=Q[47]|0,K>>>0<d>>>0&&eb(),Q[K+24>>2]=g,b=a+16|0,c=Q[b>>2]|0;do if(c|0){if(!(c>>>0<d>>>0)){Q[K+16>>2]=c,Q[c+24>>2]=K;break}eb()}while(0);if(b=Q[b+4>>2]|0,!b)break;if(!(b>>>0<(Q[47]|0)>>>0)){Q[K+20>>2]=b,Q[b+24>>2]=K;break}eb()}else{c=Q[a+8>>2]|0,d=Q[a+12>>2]|0,b=212+(e<<1<<2)|0;do if((c|0)!=(b|0)){if(c>>>0<i>>>0&&eb(),(Q[c+12>>2]|0)==(a|0))break;eb()}while(0);if((d|0)==(c|0)){Q[43]=Q[43]&~(1<<e);break}do if((d|0)==(b|0))H=d+8|0;else{if(d>>>0<i>>>0&&eb(),b=d+8|0,(Q[b>>2]|0)==(a|0)){H=b;break}eb()}while(0);Q[c+12>>2]=d,Q[H>>2]=c}while(0);a=a+h|0,f=h+f|0}if(a=a+4|0,Q[a>>2]=Q[a>>2]&-2,Q[j+4>>2]=f|1,Q[j+f>>2]=f,a=f>>>3,f>>>0<256){c=212+(a<<1<<2)|0,b=Q[43]|0,a=1<<a;do if(b&a){if(a=c+8|0,b=Q[a>>2]|0,b>>>0>=(Q[47]|0)>>>0){L=a,M=b;break}eb()}else Q[43]=b|a,L=c+8|0,M=c;while(0);Q[L>>2]=j,Q[M+12>>2]=j,Q[j+8>>2]=M,Q[j+12>>2]=c;break}a=f>>>8;do if(a){if(f>>>0>16777215){c=31;break}L=(a+1048320|0)>>>16&8,M=a<<L,K=(M+520192|0)>>>16&4,M<<=K,c=(M+245760|0)>>>16&2,c=14-(K|L|c)+(M<<c>>>15)|0,c=f>>>(c+7|0)&1|c<<1}else c=0;while(0);if(d=476+(c<<2)|0,Q[j+28>>2]=c,a=j+16|0,Q[a+4>>2]=0,Q[a>>2]=0,a=Q[44]|0,b=1<<c,!(a&b)){Q[44]=a|b,Q[d>>2]=j,Q[j+24>>2]=d,Q[j+12>>2]=j,Q[j+8>>2]=j;break}for(e=f<<((c|0)==31?0:25-(c>>>1)|0),a=Q[d>>2]|0;;){if((Q[a+4>>2]&-8|0)==(f|0)){c=a,F=279;break}if(b=a+16+(e>>>31<<2)|0,c=Q[b>>2]|0,!c){F=276;break}e<<=1,a=c}if((F|0)==276){if(!(b>>>0<(Q[47]|0)>>>0)){Q[b>>2]=j,Q[j+24>>2]=a,Q[j+12>>2]=j,Q[j+8>>2]=j;break}eb()}else if((F|0)==279){if(a=c+8|0,b=Q[a>>2]|0,M=Q[47]|0,b>>>0>=M>>>0&c>>>0>=M>>>0){Q[b+12>>2]=j,Q[a>>2]=j,Q[j+8>>2]=b,Q[j+12>>2]=c,Q[j+24>>2]=0;break}eb()}}else M=(Q[46]|0)+f|0,Q[46]=M,Q[49]=j,Q[j+4>>2]=M|1;while(0);return M=k+8|0,S=N,M|0}b=620}for(;;){if(a=Q[b>>2]|0,a>>>0<=h>>>0?(G=a+(Q[b+4>>2]|0)|0,G>>>0>h>>>0):0){b=G;break}b=Q[b+8>>2]|0}f=b+-47|0,c=f+8|0,c=f+((c&7|0)==0?0:0-c&7)|0,f=h+16|0,c=c>>>0<f>>>0?h:c,a=c+8|0,d=g+8|0,d=(d&7|0)==0?0:0-d&7,M=g+d|0,d=e+-40-d|0,Q[49]=M,Q[46]=d,Q[M+4>>2]=d|1,Q[M+d+4>>2]=40,Q[50]=Q[165],d=c+4|0,Q[d>>2]=27,Q[a>>2]=Q[155],Q[a+4>>2]=Q[156],Q[a+8>>2]=Q[157],Q[a+12>>2]=Q[158],Q[155]=g,Q[156]=e,Q[158]=0,Q[157]=a,a=c+24|0;do a=a+4|0,Q[a>>2]=7;while((a+4|0)>>>0<b>>>0);if((c|0)!=(h|0)){if(g=c-h|0,Q[d>>2]=Q[d>>2]&-2,Q[h+4>>2]=g|1,Q[c>>2]=g,a=g>>>3,g>>>0<256){c=212+(a<<1<<2)|0,b=Q[43]|0,a=1<<a,b&a?(a=c+8|0,b=Q[a>>2]|0,b>>>0<(Q[47]|0)>>>0?eb():(I=a,J=b)):(Q[43]=b|a,I=c+8|0,J=c),Q[I>>2]=h,Q[J+12>>2]=h,Q[h+8>>2]=J,Q[h+12>>2]=c;break}if(a=g>>>8,a?g>>>0>16777215?c=31:(L=(a+1048320|0)>>>16&8,M=a<<L,K=(M+520192|0)>>>16&4,M<<=K,c=(M+245760|0)>>>16&2,c=14-(K|L|c)+(M<<c>>>15)|0,c=g>>>(c+7|0)&1|c<<1):c=0,e=476+(c<<2)|0,Q[h+28>>2]=c,Q[h+20>>2]=0,Q[f>>2]=0,a=Q[44]|0,b=1<<c,!(a&b)){Q[44]=a|b,Q[e>>2]=h,Q[h+24>>2]=e,Q[h+12>>2]=h,Q[h+8>>2]=h;break}for(d=g<<((c|0)==31?0:25-(c>>>1)|0),a=Q[e>>2]|0;;){if((Q[a+4>>2]&-8|0)==(g|0)){c=a,F=305;break}if(b=a+16+(d>>>31<<2)|0,c=Q[b>>2]|0,!c){F=302;break}d<<=1,a=c}if((F|0)==302){if(!(b>>>0<(Q[47]|0)>>>0)){Q[b>>2]=h,Q[h+24>>2]=a,Q[h+12>>2]=h,Q[h+8>>2]=h;
break}eb()}else if((F|0)==305){if(a=c+8|0,b=Q[a>>2]|0,M=Q[47]|0,b>>>0>=M>>>0&c>>>0>=M>>>0){Q[b+12>>2]=h,Q[a>>2]=h,Q[h+8>>2]=b,Q[h+12>>2]=c,Q[h+24>>2]=0;break}eb()}}}else{M=Q[47]|0,(M|0)==0|g>>>0<M>>>0&&(Q[47]=g),Q[155]=g,Q[156]=e,Q[158]=0,Q[52]=Q[161],Q[51]=-1,a=0;do M=212+(a<<1<<2)|0,Q[M+12>>2]=M,Q[M+8>>2]=M,a=a+1|0;while((a|0)!=32);M=g+8|0,M=(M&7|0)==0?0:0-M&7,L=g+M|0,M=e+-40-M|0,Q[49]=L,Q[46]=M,Q[L+4>>2]=M|1,Q[L+M+4>>2]=40,Q[50]=Q[165]}while(0);if(a=Q[46]|0,a>>>0>o>>>0)return K=a-o|0,Q[46]=K,M=Q[49]|0,L=M+o|0,Q[49]=L,Q[L+4>>2]=K|1,Q[M+4>>2]=o|3,M=M+8|0,S=N,M|0}return Q[(u()|0)>>2]=12,M=0,S=N,M|0}function E(a){a|=0;var b=0,c=0,d=0,e=0,f=0,g=0,h=0,i=0,j=0,k=0,l=0,m=0,n=0,o=0,p=0;if(a){c=a+-8|0,g=Q[47]|0,c>>>0<g>>>0&&eb(),a=Q[a+-4>>2]|0,b=a&3,(b|0)==1&&eb(),d=a&-8,l=c+d|0;do if(a&1)p=c,f=d;else{if(a=Q[c>>2]|0,!b)return;if(j=c+(0-a)|0,i=a+d|0,j>>>0<g>>>0&&eb(),(j|0)==(Q[48]|0)){if(a=l+4|0,b=Q[a>>2]|0,(b&3|0)!=3){p=j,f=i;break}return Q[45]=i,Q[a>>2]=b&-2,Q[j+4>>2]=i|1,void(Q[j+i>>2]=i)}if(d=a>>>3,a>>>0<256){if(b=Q[j+8>>2]|0,c=Q[j+12>>2]|0,a=212+(d<<1<<2)|0,(b|0)!=(a|0)&&(b>>>0<g>>>0&&eb(),(Q[b+12>>2]|0)!=(j|0)&&eb()),(c|0)==(b|0)){Q[43]=Q[43]&~(1<<d),p=j,f=i;break}(c|0)!=(a|0)?(c>>>0<g>>>0&&eb(),a=c+8|0,(Q[a>>2]|0)==(j|0)?e=a:eb()):e=c+8|0,Q[b+12>>2]=c,Q[e>>2]=b,p=j,f=i;break}e=Q[j+24>>2]|0,c=Q[j+12>>2]|0;do if((c|0)==(j|0)){if(b=j+16|0,c=b+4|0,a=Q[c>>2]|0)b=c;else if(a=Q[b>>2]|0,!a){h=0;break}for(;;)if(c=a+20|0,d=Q[c>>2]|0,d|0)a=d,b=c;else{if(c=a+16|0,d=Q[c>>2]|0,!d)break;a=d,b=c}if(!(b>>>0<g>>>0)){Q[b>>2]=0,h=a;break}eb()}else{if(d=Q[j+8>>2]|0,d>>>0<g>>>0&&eb(),a=d+12|0,(Q[a>>2]|0)!=(j|0)&&eb(),b=c+8|0,(Q[b>>2]|0)==(j|0)){Q[a>>2]=c,Q[b>>2]=d,h=c;break}eb()}while(0);if(e){if(a=Q[j+28>>2]|0,b=476+(a<<2)|0,(j|0)==(Q[b>>2]|0)){if(Q[b>>2]=h,!h){Q[44]=Q[44]&~(1<<a),p=j,f=i;break}}else if(e>>>0<(Q[47]|0)>>>0&&eb(),a=e+16|0,(Q[a>>2]|0)==(j|0)?Q[a>>2]=h:Q[e+20>>2]=h,!h){p=j,f=i;break}c=Q[47]|0,h>>>0<c>>>0&&eb(),Q[h+24>>2]=e,a=j+16|0,b=Q[a>>2]|0;do if(b|0){if(!(b>>>0<c>>>0)){Q[h+16>>2]=b,Q[b+24>>2]=h;break}eb()}while(0);if(a=Q[a+4>>2]|0){if(!(a>>>0<(Q[47]|0)>>>0)){Q[h+20>>2]=a,Q[a+24>>2]=h,p=j,f=i;break}eb()}else p=j,f=i}else p=j,f=i}while(0);if(p>>>0>=l>>>0&&eb(),a=l+4|0,b=Q[a>>2]|0,b&1||eb(),b&2)Q[a>>2]=b&-2,Q[p+4>>2]=f|1,Q[p+f>>2]=f;else{if((l|0)==(Q[49]|0)){if(o=(Q[46]|0)+f|0,Q[46]=o,Q[49]=p,Q[p+4>>2]=o|1,(p|0)!=(Q[48]|0))return;return Q[48]=0,void(Q[45]=0)}if((l|0)==(Q[48]|0))return o=(Q[45]|0)+f|0,Q[45]=o,Q[48]=p,Q[p+4>>2]=o|1,void(Q[p+o>>2]=o);f=(b&-8)+f|0,d=b>>>3;do if(b>>>0>=256){e=Q[l+24>>2]|0,a=Q[l+12>>2]|0;do if((a|0)==(l|0)){if(b=l+16|0,c=b+4|0,a=Q[c>>2]|0)b=c;else if(a=Q[b>>2]|0,!a){m=0;break}for(;;)if(c=a+20|0,d=Q[c>>2]|0,d|0)a=d,b=c;else{if(c=a+16|0,d=Q[c>>2]|0,!d)break;a=d,b=c}if(!(b>>>0<(Q[47]|0)>>>0)){Q[b>>2]=0,m=a;break}eb()}else{if(b=Q[l+8>>2]|0,b>>>0<(Q[47]|0)>>>0&&eb(),c=b+12|0,(Q[c>>2]|0)!=(l|0)&&eb(),d=a+8|0,(Q[d>>2]|0)==(l|0)){Q[c>>2]=a,Q[d>>2]=b,m=a;break}eb()}while(0);if(e|0){if(a=Q[l+28>>2]|0,b=476+(a<<2)|0,(l|0)==(Q[b>>2]|0)){if(Q[b>>2]=m,!m){Q[44]=Q[44]&~(1<<a);break}}else if(e>>>0<(Q[47]|0)>>>0&&eb(),a=e+16|0,(Q[a>>2]|0)==(l|0)?Q[a>>2]=m:Q[e+20>>2]=m,!m)break;c=Q[47]|0,m>>>0<c>>>0&&eb(),Q[m+24>>2]=e,a=l+16|0,b=Q[a>>2]|0;do if(b|0){if(!(b>>>0<c>>>0)){Q[m+16>>2]=b,Q[b+24>>2]=m;break}eb()}while(0);if(a=Q[a+4>>2]|0,a|0){if(!(a>>>0<(Q[47]|0)>>>0)){Q[m+20>>2]=a,Q[a+24>>2]=m;break}eb()}}}else{if(b=Q[l+8>>2]|0,c=Q[l+12>>2]|0,a=212+(d<<1<<2)|0,(b|0)!=(a|0)&&(b>>>0<(Q[47]|0)>>>0&&eb(),(Q[b+12>>2]|0)!=(l|0)&&eb()),(c|0)==(b|0)){Q[43]=Q[43]&~(1<<d);break}(c|0)!=(a|0)?(c>>>0<(Q[47]|0)>>>0&&eb(),a=c+8|0,(Q[a>>2]|0)==(l|0)?k=a:eb()):k=c+8|0,Q[b+12>>2]=c,Q[k>>2]=b}while(0);if(Q[p+4>>2]=f|1,Q[p+f>>2]=f,(p|0)==(Q[48]|0))return void(Q[45]=f)}if(a=f>>>3,f>>>0<256)return c=212+(a<<1<<2)|0,b=Q[43]|0,a=1<<a,b&a?(a=c+8|0,b=Q[a>>2]|0,b>>>0<(Q[47]|0)>>>0?eb():(n=a,o=b)):(Q[43]=b|a,n=c+8|0,o=c),Q[n>>2]=p,Q[o+12>>2]=p,Q[p+8>>2]=o,void(Q[p+12>>2]=c);a=f>>>8,a?f>>>0>16777215?c=31:(n=(a+1048320|0)>>>16&8,o=a<<n,m=(o+520192|0)>>>16&4,o<<=m,c=(o+245760|0)>>>16&2,c=14-(m|n|c)+(o<<c>>>15)|0,c=f>>>(c+7|0)&1|c<<1):c=0,d=476+(c<<2)|0,Q[p+28>>2]=c,Q[p+20>>2]=0,Q[p+16>>2]=0,a=Q[44]|0,b=1<<c;do if(a&b){for(e=f<<((c|0)==31?0:25-(c>>>1)|0),a=Q[d>>2]|0;;){if((Q[a+4>>2]&-8|0)==(f|0)){c=a,d=130;break}if(b=a+16+(e>>>31<<2)|0,c=Q[b>>2]|0,!c){d=127;break}e<<=1,a=c}if((d|0)==127){if(!(b>>>0<(Q[47]|0)>>>0)){Q[b>>2]=p,Q[p+24>>2]=a,Q[p+12>>2]=p,Q[p+8>>2]=p;break}eb()}else if((d|0)==130){if(a=c+8|0,b=Q[a>>2]|0,o=Q[47]|0,b>>>0>=o>>>0&c>>>0>=o>>>0){Q[b+12>>2]=p,Q[a>>2]=p,Q[p+8>>2]=b,Q[p+12>>2]=c,Q[p+24>>2]=0;break}eb()}}else Q[44]=a|b,Q[d>>2]=p,Q[p+24>>2]=d,Q[p+12>>2]=p,Q[p+8>>2]=p;while(0);if(p=(Q[51]|0)+-1|0,Q[51]=p,!p){for(a=628;;){if(a=Q[a>>2]|0,!a)break;a=a+8|0}Q[51]=-1}}}function F(){}function G(a,b,c){a|=0,b|=0,c|=0;var d=0,e=0,f=0,g=0;if(d=a+c|0,(c|0)>=20){if(b&=255,f=a&3,g=b|b<<8|b<<16|b<<24,e=d&-4,f)for(f=a+4-f|0;(a|0)<(f|0);)P[a>>0]=b,a=a+1|0;for(;(a|0)<(e|0);)Q[a>>2]=g,a=a+4|0}for(;(a|0)<(d|0);)P[a>>0]=b,a=a+1|0;return a-c|0}function H(a,b,c){a|=0,b|=0,c|=0;var d=0;if((c|0)>=4096)return jb(a|0,b|0,c|0)|0;if(d=a|0,(a&3)==(b&3)){for(;a&3;){if(!c)return d|0;P[a>>0]=P[b>>0]|0,a=a+1|0,b=b+1|0,c=c-1|0}for(;(c|0)>=4;)Q[a>>2]=Q[b>>2],a=a+4|0,b=b+4|0,c=c-4|0}for(;(c|0)>0;)P[a>>0]=P[b>>0]|0,a=a+1|0,b=b+1|0,c=c-1|0;return d|0}function I(){return 0}function J(a,b){return a|=0,b|=0,nb[a&1](b|0)|0}function K(a,b,c,d){return a|=0,b|=0,c|=0,d|=0,ob[a&3](b|0,c|0,d|0)|0}function L(a,b){a|=0,b|=0,pb[a&1](b|0)}function M(a){return a|=0,bb(0),0}function N(a,b,c){return a|=0,b|=0,c|=0,bb(1),0}function O(a){a|=0,bb(2)}var P=new a.Int8Array(c),Q=(new a.Int16Array(c),new a.Int32Array(c)),R=(new a.Uint8Array(c),new a.Uint16Array(c),new a.Uint32Array(c),new a.Float32Array(c)),S=(new a.Float64Array(c),b.STACKTOP|0),T=b.STACK_MAX|0,U=b.tempDoublePtr|0,V=(b.ABORT|0,0),W=0,X=(a.NaN,a.Infinity,0),Y=a.Math.floor,Z=(a.Math.abs,a.Math.sqrt),$=(a.Math.pow,a.Math.cos),_=a.Math.sin,ab=(a.Math.tan,a.Math.acos,a.Math.asin,a.Math.atan,a.Math.atan2,a.Math.exp,a.Math.log,a.Math.ceil,a.Math.imul),bb=(a.Math.min,a.Math.clz32,b.abort),cb=(b.assert,b.invoke_ii,b.invoke_iiii,b.invoke_vi,b._pthread_cleanup_pop),db=b.___lock,eb=b._abort,fb=b._pthread_cleanup_push,gb=b.___syscall6,hb=b._sbrk,ib=b.___syscall140,jb=b._emscripten_memcpy_big,kb=b.___syscall54,lb=b.___unlock,mb=b.___syscall146,nb=[M,s],ob=[N,z,y,v],pb=[O,w];return{_spectralCentroid:n,_fflush:B,_fftFilter:m,_pthread_self:I,_memset:G,_linearInterp:o,_malloc:D,_memcpy:H,_fft:l,_normalize:k,_free:E,___errno_location:u,runPostSets:F,stackAlloc:d,stackSave:e,stackRestore:f,establishStackSpace:g,setThrew:h,setTempRet0:i,getTempRet0:j,dynCall_ii:J,dynCall_iiii:K,dynCall_vi:L}}(Module.asmGlobalArg,Module.asmLibraryArg,buffer),_spectralCentroid=Module._spectralCentroid=asm._spectralCentroid,_fflush=Module._fflush=asm._fflush,_fftFilter=Module._fftFilter=asm._fftFilter,_pthread_self=Module._pthread_self=asm._pthread_self,_memset=Module._memset=asm._memset,_linearInterp=Module._linearInterp=asm._linearInterp,_malloc=Module._malloc=asm._malloc,_memcpy=Module._memcpy=asm._memcpy,_fft=Module._fft=asm._fft,_normalize=Module._normalize=asm._normalize,_free=Module._free=asm._free,___errno_location=Module.___errno_location=asm.___errno_location,runPostSets=Module.runPostSets=asm.runPostSets,dynCall_ii=Module.dynCall_ii=asm.dynCall_ii,dynCall_iiii=Module.dynCall_iiii=asm.dynCall_iiii,dynCall_vi=Module.dynCall_vi=asm.dynCall_vi;Runtime.stackAlloc=asm.stackAlloc,Runtime.stackSave=asm.stackSave,Runtime.stackRestore=asm.stackRestore,Runtime.establishStackSpace=asm.establishStackSpace,Runtime.setTempRet0=asm.setTempRet0,Runtime.getTempRet0=asm.getTempRet0,ExitStatus.prototype=new Error,ExitStatus.prototype.constructor=ExitStatus;var initialStackTop,preloadStartTime=null,calledMain=!1;dependenciesFulfilled=function a(){Module.calledRun||run(),Module.calledRun||(dependenciesFulfilled=a)},Module.callMain=Module.callMain=function(a){function b(){for(var a=0;3>a;a++)d.push(0)}a=a||[],ensureInitRuntime();var c=a.length+1,d=[allocate(intArrayFromString(Module.thisProgram),"i8",ALLOC_NORMAL)];b();for(var e=0;c-1>e;e+=1)d.push(allocate(intArrayFromString(a[e]),"i8",ALLOC_NORMAL)),b();d.push(0),d=allocate(d,"i32",ALLOC_NORMAL);try{var f=Module._main(c,d,0);exit(f,!0)}catch(g){if(g instanceof ExitStatus)return;if("SimulateInfiniteLoop"==g)return void(Module.noExitRuntime=!0);throw g&&"object"==typeof g&&g.stack&&Module.printErr("exception thrown: "+[g,g.stack]),g}finally{calledMain=!0}},Module.run=Module.run=run,Module.exit=Module.exit=exit;var abortDecorators=[];if(Module.abort=Module.abort=abort,Module.preInit)for("function"==typeof Module.preInit&&(Module.preInit=[Module.preInit]);Module.preInit.length>0;)Module.preInit.pop()();var shouldRunNow=!0;Module.noInitialRun&&(shouldRunNow=!1),run(),Float32Array.prototype.forEach||(Float32Array.prototype.forEach=function(a,b){var c,d;if(null==this)throw new TypeError(" this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=0;f>d;){var g;d in e&&(g=e[d],a.call(c,g,d,e)),d++}}),Float32Array.prototype.some||(Float32Array.prototype.some=function(a){"use strict";if(null==this)throw new TypeError("Array.prototype.some called on null or undefined");if("function"!=typeof a)throw new TypeError;for(var b=Object(this),c=b.length>>>0,d=arguments.length>=2?arguments[1]:void 0,e=0;c>e;e++)if(e in b&&a.call(d,b[e],e,b))return!0;return!1}),Float32Array.prototype.map||(Float32Array.prototype.map=function(a,b){var c,d,e;if(null==this)throw new TypeError(" this is null or not defined");var f=Object(this),g=f.length>>>0;if("function"!=typeof a)throw new TypeError(a+" is not a function");for(arguments.length>1&&(c=b),d=new Array(g),e=0;g>e;){var h,i;e in f&&(h=f[e],i=a.call(c,h,e,f),d[e]=i),e++}return d}),Float32Array.prototype.every||(Float32Array.prototype.every=function(a,b){"use strict";var c,d;if(null==this)throw new TypeError("this is null or not defined");var e=Object(this),f=e.length>>>0;if("function"!=typeof a)throw new TypeError;for(arguments.length>1&&(c=b),d=0;f>d;){var g;if(d in e){g=e[d];var h=a.call(c,g,d,e);if(!h)return!1}d++}return!0});var params={isLogging:!1},dtm={version:"0.8",log:function(a){params.isLogging&&console.log(arguments.callee.caller.name?arguments.callee.caller.name+": "+a:a)},modelColl:[],modelCallers:{},clocks:[],params:{plotter:null,printer:null,stream:!1,traced:[]},get:function(a){switch(a){case"models":return dtm.modelColl;case"modelNames":var b=[];return dtm.modelColl.forEach(function(a){b.push(a.get("name"))}),b;default:return null}},wa:{isOn:!0,useOfflineContext:!1},startWebAudio:function(){dtm.wa.isOn=!0,dtm.wa.actx=new(window.AudioContext||window.webkitAudioContext),dtm.wa.now=function(){return dtm.wa.actx.currentTime},dtm.wa.out=function(){return dtm.wa.actx.destination},dtm.wa.clMult=.01,dtm.wa.clockBuf=dtm.wa.actx.createBuffer(1,Math.round(dtm.wa.actx.sampleRate*dtm.wa.clMult),dtm.wa.actx.sampleRate)},startWebMidi:function(){isEmpty(MIDI.prototype.out)&&(navigator.requestMIDIAccess?navigator.requestMIDIAccess({sysex:!1}).then(function(a){for(var b=[],c=a.outputs.values(),d=c.next();d&&!d.done;d=c.next())b.push(d.value);MIDI.prototype.devices=b,MIDI.prototype.out=b[0];var e=Array.from(a.inputs.values());e.forEach(function(a){a.onmidimessage=MIDI.prototype.oninput})},null):console.log("Web MIDI is not supported in this browser!"))},oscParams:{isOpen:!1,port:null},startOsc:function(){dtm.osc.isOn=!0,dtm.osc.start()},"export":function(){objForEach(dtm,function(a,b){isEmpty(window[b])&&(window[b]=a)})},setPlotter:function(a){dtm.params.plotter=a},setPrinter:function(a){dtm.params.printer=a},cache:{audioStream:[]}};this.dtm=dtm,console.log("Loading DTM version "+dtm.version),dtm.util={},dtm.util.isNaNfast=isNaNfast,dtm.util.isEmpty=isEmpty,dtm.util.isNumber=isNumber,dtm.util.isInteger=isInteger,dtm.util.isString=isString,dtm.util.isBoolean=isBoolean,dtm.util.isFunction=isFunction,dtm.util.isPromise=isPromise,dtm.util.isObject=isObject,dtm.util.isSingleVal=isSingleVal,dtm.util.isArray=isArray,dtm.util.isFloat32Array=isFloat32Array,dtm.util.isNumArray=isNumArray,dtm.util.isNumOrFloat32Array=isNumOrFloat32Array,dtm.util.isParsableNumArray=isParsableNumArray,dtm.util.isObjArray=isObjArray,dtm.util.isMixedArray=isMixedArray,dtm.util.isStringArray=isStringArray,dtm.util.isBoolArray=isBoolArray,dtm.util.isNestedArray=isNestedArray,dtm.util.isNestedWithDtmArray=isNestedWithDtmArray,dtm.util.isDtmObj=isDtmObj,dtm.util.isDtmSynth=isDtmSynth,dtm.util.isDtmArray=isDtmArray,dtm.util.isNestedDtmArray=isNestedDtmArray,dtm.util.isNumDtmArray=isNumDtmArray,dtm.util.isNestedNumDtmArray=isNestedNumDtmArray,dtm.util.argIsSingleArray=argIsSingleArray,dtm.util.argsAreSingleVals=argsAreSingleVals,dtm.util.getMaxArrayDepth=getMaxArrayDepth,dtm.util.getMaxDtmArrayDepth=getMaxDtmArrayDepth,dtm.util.getMaxDepth=getMaxDepth,dtm.util.hasMissingValues=hasMissingValues,dtm.util.numProperties=numProperties,dtm.util.getMin=getMin,dtm.util.getMax=getMax,dtm.util.mean=mean,dtm.util.mode=mode,dtm.util.midrange=midrange,dtm.util.sum=sum,dtm.util.variance=variance,dtm.util.pvar=pvar,dtm.util.std=std,dtm.util.pstd=pstd,dtm.util.rms=rms,dtm.util.unique=unique,dtm.util.histo=histo,dtm.util.countBy=countOccurrences,dtm.util.listClasses=listClasses,dtm.util.uniformity=uniformity,dtm.util.intersection=intersection,dtm.util.argsToArray=argsToArray,dtm.util.toFloat32Array=toFloat32Array,dtm.util.fromFloat32Array=fromFloat32Array,dtm.util.mod=mod,dtm.util.mtof=mtof,dtm.util.ftom=ftom,dtm.util.Float32Concat=Float32Concat,dtm.util.concat=concat,dtm.util.Float32splice=Float32Splice,dtm.util.splice=splice,dtm.util.argsForEach=argsForEach,dtm.util.objForEach=objForEach,dtm.util.Float32Map=Float32Map,dtm.util.truncateDigits=truncateDigits,dtm.util.deferCallback=deferCallback,dtm.util.cloneArray=cloneArray,dtm.util.print=print,dtm.util.loadFileObject=loadFileObject,dtm.osc={type:"dtm.osc",oscPort:null,isOn:!1,isOpen:!1,callbacks:[],start:function(){return"undefined"==typeof osc||dtm.osc.isOpen?dtm.osc.isOpen&&dtm.log("OSC port is already open"):(dtm.osc.isOpen=!0,dtm.log("opening OSC port"),dtm.osc.oscPort=new osc.WebSocketPort({url:"ws://localhost:8081"}),dtm.osc.oscPort.open(),dtm.osc.oscPort.listen(),dtm.osc.oscPort.on("ready",function(){dtm.osc.oscPort.on("message",function(a){switch(a.address){case"/test":}}),dtm.osc.oscPort.on("error",function(a){throw new Error(a)})})),dtm.osc},stop:function(){return dtm.osc.oscPort&&dtm.osc.oscPort.close(1e3),dtm.osc.isOpen=!1,dtm.osc},on:function(a,b){return dtm.osc.oscPort.on("message",function(c){"/"!==a[0]&&(a="/".concat(a)),c.address==a&&b(c.args)}),dtm.osc},send:function(a,b){return"/"!==a[0]&&a.unshift("/"),b.constructor!==Array&&(b=[b]),dtm.osc.oscPort.send({address:a,args:b}),dtm.osc},clear:function(){dtm.osc.callbacks=[]}},dtm.osc.close=dtm.osc.stop,dtm.transform={normalize:function(a,b,c){if(isNumOrFloat32Array(a)){isNumber(b)||(b=getMin(a)),isNumber(c)||(c=getMax(a));var d=1;return c===b?b>0&&1>=b?b=0:b>1&&(b-=1):d=c-b,a.map(function(a){return(a-b)/d})}},fft:function(a){var b=new Float32Array(a),c=Module._malloc(b.byteLength),d=new Float32Array(Module.HEAPF32.buffer,c,b.length);return d.set(b),Module.ccall("fft",null,["number","number"],[c,b.length]),Module._free(c),d},rescale:function(a,b,c,d,e){for(var f=dtm.transform.normalize(a,d,e),g=[],h=0,i=f.length;i>h;h++)g[h]=truncateDigits(rescale(f[h],b,c));return g},expCurve:function(a,b){b=b||1;for(var c=[],d=0,e=a.length;e>d;d++)c[d]=expCurve(a[d],b);return c},logCurve:function(a,b){b=b||1;for(var c=[],d=0,e=a.length;e>d;d++)c[d]=logCurve(a[d],b);return c},fit:function(a,b,c){c=c||"linear",b=1>b?1:Math.round(b),isFloat32Array(a)&&(a=fromFloat32Array(a));var d=null;if(isNumArray(a))d=new Array(b);else{if(!isFloat32Array(a))return null;d=new Float32Array(b)}var e=0,f=b/a.length,g=a.length-1,h=b-1,i=g*h+1;switch("linear"===c&&i>104857600&&(c="step"),c){default:case"linear":var j=null;isNumArray(a)?j=new Array(i):isFloat32Array(a)&&(j=new Array(i));for(var k=0,l=0;g>l;l++)for(e=0;h>e;e++)j[k]=a[l]+(a[l+1]-a[l])*(e/h),k++;j[k]=a[l];for(var m=0;h>m;m++)d[m]=j[m*g];d[m]=j[i-1];break;case"step":case"hold":for(e=0;b>e;e++)d[e]=a[Math.floor(e/f)];break;case"zeros":case"zeroes":var n=-1;for(e=0;b>e;e++)n!==Math.floor(e/f)?(n=Math.floor(e/f),d[e]=a[n]):d[e]=0;break;case"decay":break;case"cos":case"cosine":if(a.length>=b)d=dtm.transform.fit(a,b,"linear");else for(var e=0,o=0;o<a.length-1;o++)for(var p=o*Math.ceil(b/(a.length-1)),q=a[o],r=(o+1)*Math.ceil(b/(a.length-1)),s=a[o+1],m=p;r>m;m++){var t=(m-p)/(r-1-p),u=(1-Math.cos(t*Math.PI))/2;d[e]=q*(1-u)+s*u,e++}break;case"cubic":if(a.length>=b)d=dtm.transform.fit(a,b,"linear");else for(var e=0,o=0;o<a.length-1;o++){var p=o*Math.ceil(b/(a.length-1)),q=a[o],r=(o+1)*Math.ceil(b/(a.length-1)),s=a[o+1],v=0,w=q,x=s,y=0;0===o?(v=a[a.length-1],y=a[o+2]):o===a.length-2?(v=a[o-1],y=a[0]):(v=a[o-1],y=a[o+2]);for(var z=y-x-v+w,A=v-w-z,B=x-v,C=w,m=p;r>m;m++){var D=(m-p)/(r-1-p),u=D*D;d[e]=z*D*u+A*u+B*D+C,e++}}break;case"pad":}return d},stretch:function(a,b,c){isString(c)||(c="linear");var d=Math.round(a.length*b);return 0==d&&(d=1),dtm.transform.fit(a,d,c)},ola:function(a,b,c,d,e){isNumber(b)?0>b&&(b=1):b=1,isNumber(c)&&(c=Math.round(c),c>a.length?c=a.length:1>c&&(c=1)),isNumber(d)?(d=Math.round(d),1>d&&(d=1)):d=c,isString(e)||(e="hamming");for(var f=(dtm.gen("zeros",Math.round(a.length*b)),0);f<(a.length-c)/d;f++);},limit:function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++){var g=a[e];b>g&&(g=b),g>c&&(g=c),d[e]=g}return d},fitSum:function(a,b,c){isBoolean(c)||(c=!1);var d=sum(a);0===d&&(a=dtm.transform.add(a,1e-6),d=sum(a)),c&&(b=Math.round(b));var e=dtm.transform.mult(a,1/d*b);if(c&&(e=dtm.transform.round(e),sum(e)!==b)){var f=1,g=sum(e)-b,h=0>g;if(h)for(;0>g;)e[mod(a.length-f,a.length)]++,g++,f++;else for(;g>0;)e[a.length-f]>0?(e[mod(a.length-f,a.length)]--,g--,f++):f++}return e},add:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=a[d]+b;else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=a[d]+b[d];return f},subtract:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=a[d]-b;else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=a[d]-b[d];return f},mult:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=a[d]*b;else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=a[d]*b[d];return f},div:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=a[d]/b;else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=a[d]/b[d];return f},pow:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=Math.pow(a[d],b);else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=Math.pow(a[d],b[d]);return f},powof:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=1),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=Math.pow(b,a[d]);else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=Math.pow(b[d],a[d]);return f},log:function(a,b,c){var d,e,f=null;if(isArray(a)?f=new Array(a.length):isFloat32Array(a)&&(f=new Float32Array(a.length)),isEmpty(b)&&(b=Math.E),isString(c)||(c="step"),isNumber(b))for(d=0,e=a.length;e>d;d++)f[d]=Math.log(a[d])/Math.log(b);else if(isNumOrFloat32Array(b))for(a.length>b.length?b=dtm.transform.fit(b,a.length,c):a.length<b.length&&(a=dtm.transform.fit(a,b.length,c)),d=0,e=a.length;e>d;d++)f[d]=Math.log(a[d])/Math.log(b[d]);return f},round:function(a,b){var c,d,e=null;if(isNumArray(a)?e=new Array(a.length):isFloat32Array(a)&&(e=new Float32Array(a.length)),isNumber(b))for(c=0,d=a.length;d>c;c++)e[c]=Math.round(a[c]/b)*b;else for(c=0,d=a.length;d>c;c++)e[c]=Math.round(a[c]);return e},floor:function(a){var b=null;isArray(a)?b=new Array(a.length):isFloat32Array(a)&&(b=new Float32Array(a.length));for(var c=0,d=a.length;d>c;c++)b[c]=Math.floor(a[c]);return b},ceil:function(a){var b=null;isArray(a)?b=new Array(a.length):isFloat32Array(a)&&(b=new Float32Array(a.length));for(var c=0,d=a.length;d>c;c++)b[c]=Math.ceil(a[c]);return b},hwr:function(a){var b=null;isArray(a)?b=new Array(a.length):isFloat32Array(a)&&(b=new Float32Array(a.length));for(var c=0,d=a.length;d>c;c++)b[c]=a[c]<0?0:a[c];return b},fwr:function(a){var b=null;isArray(a)?b=new Array(a.length):isFloat32Array(a)&&(b=new Float32Array(a.length));for(var c=0,d=a.length;d>c;c++)b[c]=a[c]<0?Math.abs(a[c]):a[c];return b},mod:function(a,b){var c=null;isArray(a)?c=new Array(a.length):isFloat32Array(a)&&(c=new Float32Array(a.length));for(var d=0,e=a.length;e>d;d++)c[d]=mod(a[d],b);return c},removeZeros:function(a){for(var b=[],c=0;c<a.length;c++)0!==a[c]&&b.push(a[c]);return isArray(a)?b:isFloat32Array(a)?toFloat32Array(b):void 0},diff:function(a){for(var b=[],c=1;c<a.length;c++)b.push(a[c]-a[c-1]);return isArray(a)?b:isFloat32Array(a)?toFloat32Array(b):void 0},reverse:function(a){for(var b=[],c=a.length-1;c>=0;--c)b.push(a[c]);return isArray(a)?b:isFloat32Array(a)?toFloat32Array(b):void 0},invert:function(a,b){isNumber(b)||(b=mean(a));for(var c=[],d=0,e=a.length;e>d;d++)c[d]=b-(a[d]-b);return isArray(a)?c:isFloat32Array(a)?toFloat32Array(c):void 0},shuffle:function(a){for(var b=a.length-1;b>=1;b--){var c=Math.round(Math.random()*b),d=a[c];a[c]=a[b],a[b]=d}return a},sort:function(a){var b=a.sort(function(a,b){return a>b?1:b>a?-1:0});return isFloat32Array(a)?toFloat32Array(b):b},repeat:function(a,b){var c=[];(!isInteger(b)||1>b)&&(b=1);for(var d=0;b>d;d++)c=concat(c,a);return c},truncate:function(a,b,c){var d=[];if(isEmpty(c))for(var e=0;e<a.length-b;e++)d[e]=a[e];else for(var f=0;f<a.length-(b+c);f++)d[f]=a[b+f];return d},getBlock:function(a,b,c){for(var d=[],e=0,f=0;c>f;f++)e=mod(f+b,a.length),d[f]=a[e];return d},window:function(a,b){switch(b){case"rect":case"rectangle":case"rectangular":return a}var c=0,d=null;isArray(a)?d=new Array(a.length):isFloat32Array(a)&&(d=new Float32Array(a.length));for(var e=0;e<a.length;e++)switch(c=e/(a.length-1),b){case"tri":case"triangle":case"triangular":d[e]=a[e]*(1-Math.abs(2*c-1));break;case"hamm":case"hamming":var f=.54,g=.46;d[e]=a[e]*(f-g*Math.cos(2*Math.PI*c));break;case"rect":case"rectangle":case"rectangular":default:d[e]=a[e]}return d},shift:function(a,b){for(var c=[],d=0;d<a.length;d++){var e=mod(d+b,a.length);c[d]=a[e]}return c},morph:function(a,b,c,d){isNumber(c)||(c=.5);var e=a.length,f=b.length,g=Math.round((f-e)*c+e);return morphFixed(dtm.transform.fit(a,g,d),dtm.transform.fit(b,g),c)},notesToBeats:function(a,b){for(var c=[],d=0,e=0,f=a.length;f>e;e++)for(var g=b/a[e],h=0;g>h;h++)c[d]=0===h?1:0,d++;return c},beatsToNotes:function(a,b){for(var c=[],d=1,e=0;e<a.length-1;e++)0!==a[e+1]?(c.push(b/d),d=1):d++;return c.push(b/d),c},intervalsToBeats:function(a,b){for(var c=[],d=0,e=0,f=a.length;f>e;e++)for(var g=0;g<a[e];g++)c[d]=0===g?b?b[mod(e,b.length)]:1:0,d++;return c},beatsToIntervals:function(a){for(var b=[],c=1,d=0;d<a.length-1;d++)0!==a[d+1]?(b.push(c),c=1):c++;return b.push(c),b},beatsToIndices:function(a){for(var b=[],c=0;c<a.length;c++)0!==a[c]&&b.push(c);return b},indicesToBeats:function(a,b){if(a=dtm.transform.sort(a),isNumber(b))d=b;else for(var c=0,d=1;a[a.length-1]>=d;)d=Math.pow(2,++c);for(var e=dtm.gen("const",0).size(d).get(),f=0;f<a.length&&!(a[f]>=b);f++)e[a[f]]=1;return e},calcBeatsOffset:function(a,b){for(var c=[],d=0,e=!1,f=!1,g=0;g<a.length;g++)1!==a[g]||f?1!==b[g]||e||(f=!0):e=!0,e?1===b[g]?(c.push(d),e=f=!1,d=0):d++:f&&(1===a[g]?(c.push(d),e=f=!1,d=0):d--);return c},applyOffsetToBeats:function(a,b){for(var c=dtm.gen("zeroes",a.length).get(),d=0,e=0;e<a.length;e++)1===a[e]&&(c[e+b[d]]=1,d++);return c},lreModulation:function(a,b){for(var c=[],d=0,e=0,f=0;f<a.length;f++)c[f]=0,0!==a[f]&&d++;for(var g=a.length/d,h=[],i=0;i<a.length;i++)if(0!==a[i]){var j=i-g*e;h.push(Math.round(g*e+j*(b-.5)*2)),e++}for(var k=0;k<h.length;k++){var l=h[k];0>l?l=0:l>=a.length&&(l=a.length-1),c[l]=1}return c},editDistance:function(a,b){return a.map(function(a){return levenshteinDistance(a,b)})},pitchQuantize:function(a,b,c){for(var d=[],e=0,f=a.length;f>e;e++)d[e]=pq(a[e],b,c);return d},unique:function(a){return unique(a)},classId:function(a){for(var b=[],c=listClasses(a).sort(),d={},e=0,f=c.length;f>e;e++)d[c[e]]=e;for(var g=0,h=a.length;h>g;g++)b[g]=d[a[g]];return b},stringify:function(a){for(var b=[],c=0,d=a.length;d>c;c++)b[c]=a[c].toString();return b},tonumber:function(a){for(var b=[],c=0,d=a.length;d>c;c++)b[c]=isString(a[c])?parseFloat(a[c]):isBoolean(a[c])?a[c]?1:0:0/0;return b},mtof:function(a){var b;b=isFloat32Array(a)?new Float32Array(a.length):new Array(a.length);for(var c=0,d=a.length;d>c;c++)b[c]=mtof(a[c]);return b},ftom:function(a){var b;b=isFloat32Array(a)?new Float32Array(a.length):new Array(a.length);for(var c=0,d=a.length;d>c;c++)b[c]=ftom(a[c]);return b},split:function(a,b){isString(b)||(b="");var c=[];if(isArray(a))for(var d=0,e=a.length;e>d;d++)isNumber(a[d])&&(a[d]=a[d].toString()),c=c.concat(a[d].split(b));return c},convolve:function(){}},dtm.transform.ntob=dtm.transform.notesToBeats,dtm.transform.bton=dtm.transform.beatsToNotes,dtm.transform.itob=dtm.transform.intervalsToBeats,dtm.transform.btoi=dtm.transform.beatsToIntervals,dtm.transform.abs=dtm.transform.fwr,dtm.transform.randomize=dtm.transform.shuffle,dtm.tr=dtm.transform,dtm.d=dtm.data=function(){var a=new Data;return a.set.apply(a,arguments)},dtm.data.augment=function(a){objForEach(a,function(b,c){"aliases"===c?objForEach(b,function(b,c){b.forEach(function(b){isEmpty(Data.prototype[b])||-1!==["name","call"].indexOf(c)||console.log('The function name "'+c+'" already exists! Overwriting...'),Data.prototype[b]=a[c],Each.prototype[b]=function(){var a=this.data,c=arguments;if(isNestedDtmArray(a))return a.each(function(a){a[b].apply(a,c)}),a;var d=[];return a.each(function(a){var e=dtm.data(a);d=concat(d,e[b].apply(e,c).get())}),a.set(d)},Map.prototype[b]=function(){var a=this.data,c=arguments;if(isNestedDtmArray(a))return a.map(function(a){return a[b].apply(a,c)});var d=[];return a.each(function(a){var e=dtm.data(a);d=concat(d,e[b].apply(e,c).get())}),a.set(d)}})}):isFunction(b)&&(isEmpty(Data.prototype[c])||-1!==["name","call"].indexOf(c)||console.log('The function name "'+c+'" already exists! Overwriting...'),Data.prototype[c]=b,Each.prototype[c]=function(){var a=this.data,b=arguments;if(isNestedDtmArray(a))return a.each(function(a){a[c].apply(a,b)}),a;var d=[];return a.each(function(a){var e=dtm.data(a);d=concat(d,e[c].apply(e,b).get())}),a.set(d)},Map.prototype[c]=function(){var a=this.data,b=arguments;if(isNestedDtmArray(a))return a.map(function(a){return a[c].apply(a,b)});var d=[];return a.each(function(a){var e=dtm.data(a);d=concat(d,e[c].apply(e,b).get())}),a.set(d)})})},Data.prototype=Object.create(Function.prototype),Data.prototype.traceGlobal=!1,Each.prototype=Object.create(Function.prototype),Map.prototype=Object.create(Function.prototype),Block.prototype=Object.create(Function.prototype),Block.prototype.into=function(a){var b=this.data;if(isInteger(a)){var c=Math.floor(b.length/a);return b.block(c)}return b},Block.prototype["if"]=Block.prototype.when=function(a){var b=this.data,c=[dtm.data()];return b.each(function(d,e){e>0&&a(d,e,b)?c.push(dtm.data(d.get(0))):c[c.length-1].concat(d.get(0))}),b.set(c)},Block.prototype.by=function(){var a=this.data;return a},Block.prototype.peak=Block.prototype.peaks=function(a){var b=this.data,c=b().diff(1),d=a?1:0;return b.block["if"](function(a,b){return c(b).mult(c(b+1)).get(0)<0}).unblock["if"](function(a,b){return b%2===d})},UnBlock.prototype=Object.create(Function.prototype),UnBlock.prototype["if"]=UnBlock.prototype.when=function(a){var b=this.data,c=[dtm.data().label("0")];return b.each(function(d,e){0===e||a(d,e,b)?c[c.length-1].concat(d.get()):c.push(d.label(e.toString()))}),b.set(c)},Fit.prototype=Object.create(Function.prototype),Fit.prototype.linear=Fit.prototype.line=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("linear"),a.fit.apply(a,b)},Fit.prototype.step=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("step"),a.fit.apply(a,b)},Fit.prototype.cos=Fit.prototype.cosine=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("cos"),a.fit.apply(a,b)},Fit.prototype.cub=Fit.prototype.cubic=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("cubic"),a.fit.apply(a,b)},Stretch.prototype=Object.create(Function.prototype),Stretch.prototype.linear=Stretch.prototype.line=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("linear"),a.stretch.apply(a,b)},Stretch.prototype.step=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("step"),a.stretch.apply(a,b)},Stretch.prototype.cos=Stretch.prototype.cosine=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("cos"),a.stretch.apply(a,b)},Stretch.prototype.cub=Stretch.prototype.cubic=function(){var a=this.data,b=argsToArray(arguments);return argsAreSingleVals(arguments)&&(b=[b]),b.push("cubic"),a.stretch.apply(a,b)},FFT.prototype=Object.create(Function.prototype),FFT.prototype.filter=function(a){var b=new Float32Array(this.data.val),c=Module._malloc(b.byteLength),d=new Float32Array(Module.HEAPF32.buffer,c,b.length);d.set(b);var e=new Float32Array(a.val),f=Module._malloc(e.byteLength);return new Float32Array(Module.HEAPF32.buffer,f,e.length).set(e),Module.ccall("fftFilter",null,["number","number","number"],[c,f,b.length]),Module._free(c),Module._free(f),this.data.set(d)},FFT.prototype.vsc=function(a){isNumber(a)||(a=44100);var b=new Float32Array(this.data.val),c=Module._malloc(b.byteLength),d=new Float32Array(Module.HEAPF32.buffer,c,b.length);d.set(b);var e=Module.ccall("spectralCentroid","number",["number","number","number"],[c,b.length,a]);return this.data.set(isNumber(e)?e:0),this.data},dtm.data.augment({aliases:{name:["label","key"],names:["keys","indices"],clear:["flush"],res:["residue"]},set:function(){var a=this;if(0===arguments.length)return a;if(argsAreSingleVals(arguments)){var b=argsToArray(arguments);a.val=isNumArray(b)?new Float32Array(b):b}else if(1===arguments.length)if(isNumber(arguments[0]))a.val=toFloat32Array(arguments[0]);else if(isNestedDtmArray(arguments[0]))a.val=arguments[0].get(),a.val.forEach(function(b){b.parent(a)}),a.params.nested=!0,a.params.depth+=arguments[0].params.depth;
else if(isDtmArray(arguments[0]))a=arguments[0];else if(isNumArray(arguments[0]))a.val=toFloat32Array(arguments[0]);else if(isNestedArray(arguments[0])){a.val=new Array(arguments[0].length);for(var c=1,d=0,e=arguments[0].length;e>d;d++)a.val[d]=dtm.data(arguments[0][d]).parent(a),a.val[d].params.depth>c&&(c=a.val[d].params.depth);a.params.nested=!0,a.params.depth+=c}else if(isNestedWithDtmArray(arguments[0])){a.val=new Array(arguments[0].length);for(var d=0,e=arguments[0].length;e>d;d++)a.val[d]=arguments[0][d].parent(a);a.params.nested=!0,a.params.depth=getMaxArrayDepth(a.val)}else isString(arguments[0])?(a.val=[arguments[0]],checkType(a.val)):a.val=arguments[0];else{a.val=new Array(arguments.length);var c=1;argsForEach(arguments,function(b,d){a.val[d]=isDtmArray(b)?b:dtm.data(b),a.val[d].parent(a),b.params.depth>c&&(c=a.val[d].params.depth)}),a.params.nested=!0,a.params.depth+=c}return isEmpty(a.params.original)&&(a.params.original=a.val),a.length=a.val.length,a.params.index=a.length-1,a},get:function(a){var b=this;if(isNumber(a))return isInteger(a)||(a=Math.round(a)),b.val[mod(a,b.length)];if(isArray(a)||isDtmArray(a)){for(var c=isDtmArray(a)?a.get():a,d=[],e=0,f=c.length;f>e;e++){var g=c[e];isNumber(g)?(isInteger(g)||(g=Math.round(g)),d.push(b.val[mod(g,b.length)])):isString(g)&&isNestedDtmArray(b)&&b.each(function(a){a.get("name")===g&&d.push(a)})}return isNestedDtmArray(b)?d=dtm.data(d):isFloat32Array(b.val)&&(d=toFloat32Array(d)),d}if(!isString(a))return b.val;switch(a){case"getters":case"help":case"?":return"name|key, type, len|length, min|minimum, max|maximum, extent|minmax|range, mean|avg|average, mode, median, midrange, std, pstd, var|variance, pvar, rms, cur|current|now, next, pver|previous, rand|random, idx|index, hop|step|stepSize, loc|location|relative, block (with 1|2 following numbers), blockNext, original, normal|normalize|normalized, sort|sorted, uniq|unique|uniques, classes, classID, string|stringify, numClasses|numUniques, unif|uniformity, histo|histogram".split(", ");case"methods":case"functions":return Object.keys(b);case"name":case"key":case"label":return b.params.name;case"names":case"keys":case"labels":return isNestedDtmArray(b)?b.val.map(function(a){return a.get("name")}):b.params.name;case"type":return isNumArray(b.val)?"number":isFloat32Array(b.val)?"Float32Array":isStringArray(b.val)?"string":isNestedDtmArray(b)?"nested":"mixed";case"parent":return b.params.parent;case"len":case"length":return b.length;case"size":return isNestedDtmArray(b)?{row:b.val[0].get("len"),col:b.length}:b.length;case"autolen":return b.params.autolen;case"hash":return b.params.hash;case"processed":return b.params.processed;case"nested":return b.val.map(function(a){return isDtmArray(a)?a.get():a});case"row":if(isInteger(arguments[1])&&isNestedDtmArray(b)){var h=arguments[1];return d=[],b.each(function(a){d.push(a.get(h))}),isNumArray(d)&&(d=toFloat32Array(d)),d}break;case"minimum":case"min":return getMin(b.val);case"maximum":case"max":return getMax(b.val);case"extent":case"minmax":case"range":return[getMin(b.val),getMax(b.val)];case"mean":case"average":case"avg":return mean(b.val);case"mode":return mode(b.val);case"median":return median(b.val);case"midrange":return midrange(b.val);case"standardDeviation":case"std":return std(b.val);case"pstd":return pstd(b.val);case"variance":case"var":return variance(b.val);case"populationVariance":case"pvar":return pvar(b.val);case"sumAll":case"sum":return sum(b.val);case"rms":return rms(b.val);case"pdf":break;case"entropy":return b.clone().entropy().get();case"current":case"curr":case"cur":case"now":case"moment":return b.val[b.params.index];case"next":return isEmpty(arguments[1])?(b.params.index=mod(b.params.index+b.params.step,b.length),b.val[b.params.index]):isNumber(arguments[1])&&arguments[1]>=1?(b.params.index=mod(b.params.index+b.params.step,b.length),k=dtm.transform.getBlock(b.val,b.params.index,arguments[1]),dtm.data(k)):b;case"prev":case"previous":return b.params.index=mod(b.params.index-b.params.step,array.length),b.val[b.params.index];case"palindrome":break;case"rand":case"random":return b.params.index=randi(0,b.length),b.val[b.params.index];case"urn":break;case"index":case"idx":return b.params.index;case"hop":case"hopSize":case"step":case"stepSize":return b.params.step;case"relative":case"location":case"loc":break;case"block":var i,j,k;return isArray(arguments[1])?(i=arguments[1][0],j=arguments[1][1],k=dtm.transform.getBlock(b.val,i,j),dtm.data(k)):isNumber(arguments[1])&&isNumber(arguments[2])?(i=arguments[1],j=arguments[2],k=dtm.transform.getBlock(b.val,i,j),dtm.data(k)):b.val;case"blockNext":return b.params.index=mod(b.params.index+b.params.step,b.length),k=dtm.transform.getBlock(b.val,b.params.index,arguments[1]),dtm.data(k);case"original":return b.params.original;case"normal":case"normalize":case"normalized":return isEmpty(b.params.normalized)&&(b.params.normalized=dtm.transform.normalize(b.val)),isInteger(arguments[1])?b.params.normalized[mod(arguments[1],b.length)]:b.params.normalized;case"sorted":case"sort":return dtm.transform.sort(b.val);case"uniques":case"unique":case"uniq":return dtm.transform.unique(b.val);case"classes":return listClasses(b.val);case"classID":case"classId":return dtm.transform.classId(b.val);case"string":case"stringify":return dtm.transform.stringify(b.val);case"numClasses":case"numUniques":case"numUniqs":return listClasses(b.val).length;case"unif":case"uniformity":return uniformity(b.val);case"histogram":case"histo":return histo(b.val);case"distribution":case"dist":return[];default:return params.hasOwnProperty(a)?b.params[a]:b.val}return b.val},len:function(){return isNestedDtmArray(this)?this.map(function(a){return a.length}):this.set(this.length)},clone:function(){if(0===arguments.length){var a;if(isNestedDtmArray(this)){a=new Array(this.length);for(var b=0,c=this.length;c>b;b++)a[b]=this.val[b].clone()}else a=this.val;var d=dtm.data(a).label(this.params.name);return d.meta.setOriginal(this.params.original),d.params.id=Math.random(),"string"===this.params.type&&(d.classes=this.params.classes),d}return this.column.apply(this,arguments)},name:function(a){return isString(a)&&(this.params.name=a),this},names:function(){if(isNestedDtmArray(this)){var a=this.get("keys");return this.params.depth--,1===this.params.depth&&(this.params.nested=!1),arguments.length>0&&(a=dtm.data(a).column(argsToArray(arguments)).ub()),this.set(a)}return this},parent:function(a){return isDtmArray(a)&&(this.params.parent=a),this},save:function(){return this.meta.setOriginal(this.val)},reset:function(){return this.set(this.params.original)},residue:function(){return this.set(dtm.transform.subtract(this.params.original,this.val))},clear:function(){return this.set([])}}),dtm.data.augment({aliases:{mapvalue:["mapval","mapv","mv"],eachvalue:["eachval","eachv","ev"]},mapvalue:function(a){var b,c=this.length,d=new Array(c);if(isNestedDtmArray(this)){for(b=0;c>b;b++)d[b]=a(this.val[b].val,b,this);return this.val=d,this}for(b=0;c>b;b++)d[b]=a(this.val[b],b,this);return this.set(d)},eachvalue:function(a){var b,c=this.length;if(isNestedDtmArray(this))for(b=0;c>b;b++)a(this.val[b].val,b,this);else for(b=0;c>b;b++)a(this.val[b],b,this);return this}}),dtm.data.augment({aliases:{column:["col"],select:["sel","at"],interpolate:["interp","itp"],phase:["p","scan"],mphase:["mp"]},column:function(){var a=flatten(argsToArray(arguments)),b=[],c=this;if(isNestedDtmArray(this)){for(var d="",e=0,f=a.length;f>e;e++){var g=a[e];if(isDtmArray(g))if(isNumArray(g.val))b.push(this.get(g).val);else{var h=[];g.each(function(a){var b=a.get(0);if(isString(b)){var d=c.get("keys").indexOf(b);d>-1&&h.push(d)}else isInteger(b)&&h.push(b)}),b.push(1===h.length?this.get(h[0]).val:this.get(h).val)}else if(isString(g))for(var i=0,j=this.length;j>i;i++)this.val[i].get("name")===g&&b.push(this.val[i].clone());else b.push(this.get(g))}return 1===a.length?(isDtmArray(b[b.length-1])&&(d=b[b.length-1].get("key")),dtm.data(b).ub().label(d)):dtm.data(b)}for(var e=0,f=a.length;f>e;e++){var g=a[e];b.push(this.get(g))}return 1===a.length?dtm.data(b).ub():dtm.data(b)},select:function(){var a,b=this,c=[];return argsAreSingleVals(arguments)?a=argsToArray(arguments):isNumOrFloat32Array(arguments[0])?a=arguments[0]:isDtmArray(arguments[0])&&isNumOrFloat32Array(arguments[0].get())&&(a=arguments[0].get()),isNumOrFloat32Array(a)?(a.forEach(function(a){c.push(b.val[mod(a,b.length)])}),dtm.data(c)):b},row:function(a){var b=this.get("row",a);return this.params.depth--,1===this.params.depth&&(this.params.nested=!1),this.set(b).label(a.toString())},interpolate:function(a,b){var c=this;isString(b)||(b="linear");var d=[],e=[];if(isNumber(a))e[0]=a;else if(isNumOrFloat32Array(a))e=a;else{if(!isNumDtmArray(a))return c;e=a.get()}return e.forEach(function(a){if("step"===b||"round"===b)d.push(c.val[mod(Math.round(a),c.length)]);else{var e=mod(Math.floor(a),c.length),f=mod(e+1,c.length),g=a-Math.floor(a);d.push(c.val[e]*(1-g)+c.val[f]*g)}}),dtm.data(d)},phase:function(a,b){var c=this;isString(b)||(b="linear");var d=[],e=[];if(isNumber(a))e[0]=a;else if(isNumOrFloat32Array(a))e=a;else{if(!isNumDtmArray(a))return c;e=a.get()}if(isNestedDtmArray(this))return this.col(dtm.data(e).mult(this.length).get());for(var f,g=0,h=e.length;h>g;g++)if(f=e[g],f=mod(f,1)*(c.length-1),"step"===b||"round"===b)d.push(c.val[mod(Math.round(f),c.length)]);else{var i=mod(Math.floor(f),c.length),j=mod(i+1,c.length),k=f-Math.floor(f);d.push(c.val[i]*(1-k)+c.val[j]*k)}return dtm.data(d)},mphase:function(a,b){var c=this;isString(b)||(b="linear");var d=[],e=[];if(isNumber(a))e[0]=a;else if(isNumOrFloat32Array(a))e=a;else{if(!isNumDtmArray(a))return c;e=a.get()}for(var f,g=0,h=e.length;h>g;g++)if(f=e[g],f=0===mod(Math.floor(f),2)?mod(f,1):1-mod(f,1),f*=c.length-1,"step"===b||"round"===b)d.push(c.val[mod(Math.round(f),c.length)]);else{var i=mod(Math.floor(f),c.length),j=mod(i+1,c.length),k=f-Math.floor(f);d.push(c.val[i]*(1-k)+c.val[j]*k)}return dtm.data(d)}}),dtm.data.augment({aliases:{range:["r"],normalize:["n"],unipolar:["uni","up"],bipolar:["bi","bp"],limit:["clip"],expcurve:["expc","ec"],logcurve:["logc","lc"],curve:["c"]},range:function(a,b,c,d){var e,f,g,h,i=this;if(isNestedDtmArray(i))return isNumber(c)&&isNumber(d)?(g=c,h=d):(g=1/0,h=-1/0,i.forEach(function(a){g=a.get("min")<g?a.get("min"):g,h=a.get("max")>h?a.get("max"):h})),i.map(function(c){return c.range(a,b,g,h)});if(0===arguments.length)e=0,f=1;else if(isNumber(a))1===arguments.length?(e=0,f=a):e=a;else if(isNumArray(a))a.length>=2&&(e=a[0],f=a[1]),a.length>2&&(e=getMin(a),f=getMax(a));else{if(!isDtmArray(a)||!isNumOrFloat32Array(a.get()))return i;2===a.get("len")?(e=a.get(0),f=a.get(1)):a.get("len")>2&&(e=a.get("min"),f=a.get("max"))}return isNumber(b)?f=b:isNumArray(b)&&2===b.length&&(g=b[0],h=b[1]),isNumber(c)?g=c:isNumArray(c)&&2===c.length&&(g=c[0],h=c[1]),isNumber(d)&&(h=d),i.set(dtm.transform.rescale(i.val,e,f,g,h))},normalize:function(a,b){var c,d,e,f=this;return isNestedDtmArray(f)?(isNumber(a)&&isNumber(b)?(c=a,d=b):(c=1/0,d=-1/0,f.forEach(function(a){c=a.get("min")<c?a.get("min"):c,d=a.get("max")>d?a.get("max"):d})),f.map(function(a){return a.normalize(c,d)})):(isNumber(a)&&isNumber(b)?(c=a,d=b):(isNumOrFloat32Array(a)?e=a:isDtmArray(a)&&isNumOrFloat32Array(a.get())&&(e=a.get()),isNumOrFloat32Array(e)&&(2===e.length?(c=e[0],d=e[1]):e.length>2&&(c=getMin(e),d=getMax(e)))),f.set(dtm.transform.normalize(f.val,c,d)))},unipolar:function(){return this.range(0,1)},bipolar:function(a){if(isBoolean(a)||(a=!1),a){var b=this.get("mean"),c=this.get("max")-b,d=b-this.get("min");return c>=d?this.range(-1,1,b-c,this.get("max")):this.range(-1,1,this.get("min"),b+d)}return this.range(-1,1)},limit:function(a,b){return isNumOrFloat32Array(this.val)?(a=a||0,b=b||1,this.set(dtm.transform.limit(this.get(),a,b))):this},expcurve:function(a,b,c){isEmpty(b)&&(b=this.get("min")),isEmpty(c)&&(c=this.get("max"));var d=dtm.transform.expCurve(dtm.transform.normalize(this.val,b,c),a);return this.set(dtm.transform.rescale(d,b,c))},logcurve:function(a,b,c){isEmpty(b)&&(b=this.get("min")),isEmpty(c)&&(c=this.get("max"));var d=dtm.transform.logCurve(dtm.transform.normalize(this.val,b,c),a);return this.set(dtm.transform.rescale(d,b,c))},curve:function(a,b,c){isEmpty(b)&&(b=this.get("min")),isEmpty(c)&&(c=this.get("max"));var d;if(isDtmArray(a)){if(1!==a.length)return this.block.into(a.length).map(function(b,c){return b.curve(a(c))}).unblock();a=a.get(0)}return d=a>0?dtm.transform.logCurve(dtm.transform.normalize(this.val,b,c),a+1):dtm.transform.expCurve(dtm.transform.normalize(this.val,b,c),-a+1),this.set(dtm.transform.rescale(d,b,c))}}),dtm.data.augment({aliases:{linear:["line","l"],cosine:["cos"],cubic:["cub"],slinear:["sline","sl"],scosine:["scos"],scubic:["scub"],fitsum:["fs","total"]},linear:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("linear"),this.fit.apply(this,a)},step:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("step"),this.fit.apply(this,a)},cosine:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("cos"),this.fit.apply(this,a)},cubic:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("cubic"),this.fit.apply(this,a)},slinear:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("linear"),this.stretch.apply(this,a)},sstep:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("step"),this.stretch.apply(this,a)},scosine:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("cos"),this.stretch.apply(this,a)},scubic:function(){var a=argsToArray(arguments);return argsAreSingleVals(arguments)&&(a=[a]),a.push("cubic"),this.stretch.apply(this,a)},fitsum:function(a,b){return this.set(dtm.transform.fitSum(this.val,a,b))},morph:function(a,b,c){return isNumDtmArray(a)&&(a=a.val),isNumDtmArray(b)?b=b.get(0):isNumber(b)||(b=.5),b=1-Math.abs(mod(b,2)-1),isString(c)||(c="linear"),isNumDtmArray(this)&&isNumOrFloat32Array(a)&&this.set(dtm.transform.morph(this.val,a,b,c)),this}}),dtm.data.augment({aliases:{window:["win"],transp:["t"]},nest:function(){return isDtmArray(this.val)||(this.set([dtm["this"](this.val)]),this.val[0].parent(this)),this},window:function(a){return isNestedDtmArray(this)?this.map(function(b){return b.window(a)}):this.set(dtm.transform.window(this.val,a))},ola:function(a){if((!isInteger(a)||1>a)&&(a=1),isNestedDtmArray(this)){var b=a*(this.length-1)+this.val[0].get("len"),c=new Array(b);return c.fill(0),this.val.forEach(function(b,d){b.foreach(function(b,e){c[d*a+e]+=b.get()})}),this.set(c)}return this},copy:function(a){if(isInteger(a)||(a=1),!isNestedDtmArray(this)){for(var b=[],c=0;a>c;c++)b.push(this.val);return dtm.data(b)}return this},transp:function(){if(isNestedDtmArray(this)){for(var a=[],b=0;this.val.some(function(a){return b<a.get("len")});)a.push(this.get("row",b)),b++;return this.set(a)}return this.block(1)},seg:function(a){if(isNumArray(a)||isNumDtmArray(a)){var b=[],c=a.length;isNumDtmArray(a)&&(a=a.get()),0!==a[0]&&b.push(isFloat32Array(this.val)?dtm.data(this.val.subarray(0,a[0])).label("0"):dtm.data(this.val.slice(0,a[0])).label("0"));for(var d=0;c-1>d;d++)b.push(isFloat32Array(this.val)?dtm.data(this.val.subarray(a[d],a[d+1])).label(a[d].toString()):dtm.data(this.val.slice(a[d],a[d+1])).label(a[d].toString()));return b.push(isFloat32Array(this.val)?dtm.data(this.val.subarray(a[d],this.length)).label(a[d].toString()):dtm.data(this.val.slice(a[d],this.length)).label(a[d].toString())),this.set(b)}return isInteger(a)?this:this}}),dtm.data.augment({aliases:{amp:["am","gain"],freq:["fm"]},amp:function(a){var b;return argsAreSingleVals(arguments)?b=argsToArray(arguments):isNumOrFloat32Array(a)?b=a:isNumDtmArray(a)&&(b=a.get()),this.mult(b)},freq:function(a){var b;argsAreSingleVals(arguments)?b=argsToArray(arguments):isNumOrFloat32Array(a)?b=a:isNumDtmArray(a)&&(b=a.get());var c,d=[],e=0,f=this.clone();b.length>this.length?(f.fit(b.length,"step"),c=b.length):c=f.length;for(var g,h,i,j,k=1,l=dtm.line(c).get(),m=0;c>m;m++)j=l[m],k=b[Math.floor(j*b.length)],0>k&&(e+=1/c*k,e=mod(e,1)),g=Math.floor(e*(c-1)),h=g+1,i=e*(c-1)-g,d.push(f.val[g]*(1-i)+f.val[h]*i),k>=0&&(e+=1/c*k,e=mod(e,1));return this.set(d)}}),dtm.data.augment({aliases:{add:["plus"],subtract:["minus"],multiply:["mult"],divide:["div"],reciprocal:["recip"],power:["pow","exp"],powerof:["powof"],abs:["fwr"],round:["q","quantize"],modulo:["mod"],morethan:["mt"],lessthan:["lt"]},add:function(a,b){var c=this;if(isString(b)||(b="step"),isNestedNumDtmArray(c))return c.map(function(b){return b.add(isNestedNumDtmArray(a)?a.get("next"):a)});if(isNumDtmArray(a))a=a.get();else if(isNestedNumDtmArray(a)){var d=[];return a.forEach(function(){d.push(c.get())}),c.set(d),c.map(function(b){return b.add(a.get("next"))})}return c.set(dtm.transform.add(c.val,a,b))},subtract:function(a,b){var c=this;if(isString(b)||(b="step"),isNestedNumDtmArray(c))return c.map(function(b){return b.add(isNestedNumDtmArray(a)?a.get("next"):a)});if(isNumDtmArray(a))a=a.get();else if(isNestedNumDtmArray(a)){var d=[];return a.forEach(function(){d.push(c.get())}),c.set(d),c.map(function(b){return b.add(a.get("next"))})}return c.set(dtm.transform.subtract(c.val,a,b))},multiply:function(a,b){var c=this;if(isString(b)||(b="step"),isNestedNumDtmArray(c))return c.map(function(b){return b.mult(isNestedNumDtmArray(a)?a.get("next"):a)});if(isNumDtmArray(a))a=a.get();else if(isNestedNumDtmArray(a)){var d=[];return a.forEach(function(){d.push(c.get())}),c.set(d),c.map(function(b){return b.mult(a.get("next"))})}return c.set(dtm.transform.mult(c.val,a,b))},divide:function(a,b){var c=this;if(isString(b)||(b="step"),isNestedNumDtmArray(c))return c.map(function(b){return b.divide(isNestedNumDtmArray(a)?a.get("next"):a)});if(isNumDtmArray(a))a=a.get();else if(isNestedNumDtmArray(a)){var d=[];return a.forEach(function(){d.push(c.get())}),c.set(d),c.map(function(b){return b.divide(a.get("next"))})}return c.set(dtm.transform.div(c.val,a,b))},reciprocal:function(a){isEmpty(a)&&(a=1);var b=this;return isNestedNumDtmArray(b)?b.map(function(a){return a.reciprocal()}):isNumDtmArray(b)?b.map(function(b){return a/b.get(0)}):b},power:function(a,b){return isNumDtmArray(a)&&(a=a.get()),this.set(dtm.transform.pow(this.val,a,b))},powerof:function(a,b){return isNumDtmArray(a)&&(a=a.get()),this.set(dtm.transform.powof(this.val,a,b))},log:function(a,b){return isNumDtmArray(a)&&(a=a.get()),this.set(dtm.transform.log(this.val,a,b))},round:function(a){return mapNested(this,arguments)||this.set(dtm.transform.round(this.val,a))},floor:function(){return mapNested(this,arguments)||this.set(dtm.transform.floor(this.val))},ceil:function(){return mapNested(this,arguments)||this.set(dtm.transform.ceil(this.val))},abs:function(){return mapNested(this,arguments)||this.set(dtm.transform.fwr(this.val))},hwr:function(){return mapNested(this,arguments)||this.set(dtm.transform.hwr(this.val))},modulo:function(a){return mapNested(this,arguments)||this.set(dtm.transform.mod(this.val,a))},morethan:function(a){return isNestedDtmArray(this)?this.forEach(function(b){b.morethan(a)}):this.map(function(b){return b.get(0)>a?1:0}),this},mtet:function(a){return isNestedDtmArray(this)?this.forEach(function(b){b.mtet(a)}):this.filter(function(b){return b>=a}),this},lessthan:function(a){return isNestedDtmArray(this)?this.forEach(function(b){b.lessthan(a)}):this.filter(function(b){return a>b}),this},ltet:function(a){return isNestedDtmArray(this)?this.forEach(function(b){b.ltet(a)}):this.filter(function(b){return a>=b}),this},is:function(a){1===this.length&&1===a.length},isnt:function(){},has:function(){var a=this,b=argsToArray(arguments),c=dtm.data(b).flatten(),d=!1;return c.each(function(b){d=a.some(function(a){return a===b.get(0)})?!0:d}),d}}),dtm.data.augment({aliases:{mean:["avg"],midrange:["mid"],accumulate:["accum","cuml","cum"]},min:function(a){if(isFunction(a)){var b=getMin(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.min()}):this.set(getMin(this.val))},max:function(a){if(isFunction(a)){var b=getMax(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.max()}):this.set(getMax(this.val))},extent:function(){return isNestedDtmArray(this)?this.map(function(a){return a.set(a.get("extent"))}):this.set(this.get("extent"))},mean:function(a){if(isFunction(a)){var b=mean(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.mean()}):this.set(mean(this.val))},mode:function(a){if(isFunction(a)){var b=mode(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.mode()}):this.set(mode(this.val))},median:function(a){if(isFunction(a)){var b=median(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.median()}):this.set(median(this.val))},midrange:function(a){if(isFunction(a)){var b=midrange(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.midrange()}):this.set(midrange(this.val))},centroid:function(a){if(isFunction(a)){var b=centroid(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.centroid()}):this.set(centroid(this.val))},std:function(a){if(isFunction(a)){var b=std(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.std()}):this.set(std(this.val))},pstd:function(a){if(isFunction(a)){var b=pstd(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.pstd()}):this.set(pstd(this.val))},"var":function(a){if(isFunction(a)){var b=variance(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a["var"]()}):this.set(variance(this.val))},pvar:function(a){if(isFunction(a)){var b=pvar(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.pvar()}):this.set(pvar(this.val))},rms:function(a){if(isFunction(a)){var b=rms(this.val.map(function(b){return a(b)}));return this.filter(isNestedDtmArray(this)?function(c){return a(c)===b}:function(c){return a(c)===b})}return isNestedDtmArray(this)?this.map(function(a){return a.rms()}):this.set(rms(this.val))},sum:function(){if(isNestedDtmArray(this)){var a=0;this.each(function(b){b.length>a&&(a=b.length)});for(var b=new Float32Array(a),c=0;a>c;c++)this.each(function(a){c<a.length&&isNumber(a.get(c))&&(b[c]+=a.get(c))});return this.params.depth--,1===this.params.depth&&(this.params.nested=!1),this.set(b)}var d=this.val.reduce(function(a,b){return a+b});return this.set(d)},accumulate:function(){var a=0;return this.map(function(b){return a+=b.get(0)}),this}}),dtm.data.augment({aliases:{correlation:["corr"],covariance:["covar","cov"]},diff:function(a,b){(!isInteger(a)||1>a)&&(a=0);for(var c=0;a>c;c++)this.val=dtm.transform.diff(this.val);if(isSingleVal(b))for(var c=0;a>c;c++)this.val=concat(this.val,b);return this.set(this.val)},mse:function(){if(0!==arguments.length)return this;if(!isNestedDtmArray(this)){var a=this.clone().reset();return a.get("len")!==this.get("len")&&this.fit(a.get("len"),"step"),a().subtract(this).pow(2).sum().divide(a.get("len"))}},snr:function(){if(0===arguments.length&&!isNestedDtmArray(this)){var a=this.clone().mse();return this.set(meanSquare(this.val)/a.get(0))}return this},dbsnr:function(){if(0===arguments.length&&!isNestedDtmArray(this)){var a=this.snr();return this.set(10*Math.log10(a.get(0)))}return this},dct:function(){var a=this;if(isNumDtmArray(a)){for(var b,c=[],d=0;d<a.length;d++)b=Math.sqrt(0===d?1/(4*a.length):1/(2*a.length)),c.push(2*b*sum(a.val.map(function(b,c){return b*Math.cos(Math.PI/a.length*(c+.5)*d)})));return a.set(c)}return isNestedDtmArray(a)?a.map(function(a){return a.dct()}):a},idct:function(){var a=this;if(isNumDtmArray(a)){for(var b=[],c=0;c<a.length;c++)b.push(sum(a.val.map(function(b,d){return 0===d?b/Math.sqrt(a.length):Math.sqrt(2/a.length)*b*Math.cos(Math.PI/a.length*d*(c+.5))})));return a.set(b)}return isNestedDtmArray(a)?a.map(function(a){return a.idct()}):a},fir:function(a){var b=this,c=[];argsAreSingleVals(arguments)?c=argsToArray(arguments):isNumOrFloat32Array(a)?c=a:isNumDtmArray(a)&&(c=a.get());for(var d=[],e=0;e<b.length;e++)d[e]=0,c.forEach(function(a,c){d[e]+=e-c>=0?a*b.val[e-c]:0});return b.set(d)},amdf:function(a){isNumber(a)||(a=Math.round(this.length/2));for(var b=[],c=1;a>c;c++)b.push(this().subtract(this().shift(c)).abs().mean().get(0));return this.set(b)},correlation:function(a,b){if(isNumDtmArray(this)){var c=dtm.data(),d=dtm.data(0).rep(this.get("len")),e=this.clone(),f=1;if(b===!0?f=e.get("std")*a.get("std")*(e.length-1):a===!0&&isEmpty(b)&&(f=Math.pow(e.get("std"),2)*(e.length-1)),isNumDtmArray(a)||isNumOrFloat32Array(a)){var g=isNumOrFloat32Array(a)?a.length:a.get("len");a=d().append(a).append(d),e.append(dtm["const"](0).size(g)).append(d)}else a=d().append(e).append(d),e.append(d).append(d);for(var h=0;h<e.get("len")-(this.get("len")-1);h++)c.append(e().mult(a).div(f).get("sum")),e.shift(-1);return c}return this},covariance:function(a,b){if(isNumDtmArray(this)){a=isNumDtmArray(a)?a.clone():isNumOrFloat32Array(a)?dtm.data(a):this.clone();var c=this.get("len");a.get("len")!==c&&a.fit(c,"step");for(var d=this.get("mean"),e=a.get("mean"),f=0,g=0;c>g;g++)f+=(this.get(g)-d)*(a.get(g)-e);return f/=c,(b===!0||a===!0&&isEmpty(b))&&(f/=this.get("std")*a.get("std")),this.set(f)}return this},linreg:function(){if(isNumDtmArray(this)){var a=dtm.range(this.get("len")).get("mean"),b=this.get("mean"),c=0,d=0;this.val.forEach(function(e,f){c+=(f-a)*(e-b),d+=Math.pow(f-a,2)});for(var e=c/d,f=b-e*a,g=[],h=[],i=0;i<this.get("len");i++)g.push(f+e*i),h.push(this.get(i)-g[i]);return this.set([g,h,[e,f]])}return isNestedDtmArray(this)?this.map(function(a){return a.linreg()}):this}}),dtm.data.augment({aliases:{histogram:["histo","hist"],distribution:["dist"],invert:["inv"],unique:["uniq"],classify:["class"]},histogram:function(){return this.params.type="string",this.set(toFloat32Array(histo(this.val)))},count:function(){var a=this,b=[];return objForEach(countOccurrences(a.get()),function(c,d){b.push(dtm.data(c).label(d).parent(a))}),a.set(b)},mapcount:function(){var a=this().count();return this.map(function(b){return a(b)})},distribution:function(a){if(isNestedDtmArray(this))return this;var b=a?this().round(a).count():this().count(),c=b().mult(b().flatten().sum().recip()).sortby(function(a){return a.get("key")});return this.set(c.val)},mapdist:function(a){var b=this().distribution(a);return this.map(function(a){return b(a)})},pmf:function(a,b){var c,d;isEmpty(a)&&(c=0,d=1),isEmpty(b)&&(b=(d-c)/(this.length-1));this().round(b).dist();return dtm.line(),this},cdf:function(){var a=this().dist(),b=[];return dtm.range(a.length).each(function(c,d){b.push(a(dtm.range(d+1)).flatten().sum().key(a(d).get("key")))}),this.set(b)},invert:function(){var a=this,b=a().map(function(b,c){return a().ltet(c/a.length).length/a.length});return this.set(b.val)},icdf:function(){return this.accum().range(0,1).invert()},entropy:function(a){var b=2;if(isNestedDtmArray(this))return this.map(function(a){return a.entropy()});var c=this.dist().unblock();return a===!0&&(b=c.length),1===c.length?this.set(0):c.map(function(a){return a.mult(a().log(b))}).sum().mult(-1)},unique:function(){return this.set(dtm.transform.unique(this.val))},classify:function(){return this.set(dtm.transform.classId(this.val))}}),dtm.data.augment({aliases:{shuffle:["randomize"],randomtrigger:["randtrig"]},shuffle:function(){return this.set(dtm.transform.shuffle(this.val))},randomtrigger:function(a){return isString(a)||(a="uniform"),isNestedNumDtmArray(this)?this.map(function(a){return a.randomtrigger()}):isNumDtmArray(this)?this.map(function(a){return Math.random()<=a?1:0}):this}}),dtm.data.augment({aliases:{notesToBeats:["ntob"],beatsToNotes:["bton"],intervalsToBeats:["itob"],beatsToIntervals:["btoi"],intervalsToOffsets:["itoo"],offsetsToIntervals:["otoi"],beatsToTime:["btot"],timeToBeats:["ttob"],tonumber:["tonum","num"],stringify:["tostring"],toFloat32:["tofloat32","tf32"]},mtof:function(){return this.set(dtm.transform.mtof(this.val))},ftom:function(){return this.set(dtm.transform.ftom(this.val))},freqtomel:function(){return this.div(700).add(1).log(10).mult(2595)},meltofreq:function(){return this.div(2595).powof(10).add(-1).mult(700)},notesToBeats:function(a){return a=a||4,this.set(dtm.transform.notesToBeats(this.val,a))},beatsToNotes:function(a){return a=a||4,this.set(dtm.transform.beatsToNotes(this.val,a))},intervalsToBeats:function(a){var b;return isNumDtmArray(a)?b=a.val:isNumOrFloat32Array(a)&&(b=a),this.set(dtm.transform.intervalsToBeats(this.val,b))},beatsToIntervals:function(){return this.set(dtm.transform.beatsToIntervals(this.val))},intervalsToOffsets:function(){if(isNumDtmArray(this)){var a=this,b=0,c=[];return c.push(b),a.val.forEach(function(d,e){e!==a.length-2&&(b+=d,c.push(b))}),a.set(c)}return this},offsetsToIntervals:function(){if(isNumDtmArray(this)){for(var a=this,b=[],c=a.length-1;c>0;c--)b.unshift(a.get(c)-a.get(c-1));return b.push(b[b.length-1]),a.set(b)}return this},beatsToTime:function(){return this.set(dtm.transform.beatsToIndices(this.val))},timeToBeats:function(a){return this.set(dtm.transform.indicesToBeats(this.val,a))},tonumber:function(){return isParsableNumArray(this.val)||isBoolArray(this.val)?this.set(toFloat32Array(dtm.transform.tonumber(this.val))):this},stringify:function(){return this.set(dtm.transform.stringify(this.val))},toFloat32:function(){return isNumArray(this.val)&&this.set(toFloat32Array(this.val)),this}}),dtm.data.augment({aliases:{prepend:["prep"],concat:["cat","append","app"],repeat:["rep"],fitrepeat:["fitrep","frep"],mirror:["mirr","mir"],reverse:["rev"],queue:["fifo"],reorder:["order"]},reduce:function(a){return this.set(this.val.reduce(a))},some:function(a){return this.val.some(a)},every:function(a){return isEmpty(this.val.every)?!1:this.val.every(a)},filter:function(a){return this.set(this.val.filter(a))},concat:function(a){return isEmpty(a)&&(a=[]),this.val=isDtmArray(a)?concat(this.val,a.get()):concat(this.val,a),this.set(this.val)},prepend:function(a){return isEmpty(a)&&(a=[]),this.val=isDtmArray(a)?concat(a.get(),this.val):concat(a,this.val),this.set(this.val)},repeat:function(a){return isDtmArray(a)&&1===a.get("len")&&(a=a.get(0)),isInteger(a)||(a=1),this.set(dtm.transform.repeat(this.val,a))},fitrepeat:function(a,b){return isDtmArray(a)&&1===a.get("len")&&(a=a.get(0)),isInteger(a)||(a=1),isString(b)||(b="step"),this.set(dtm.transform.fit(dtm.transform.repeat(this.val,a),this.length,b))
},pad:function(a,b){for(var c=[],d=0;b>d;d++)c.push(a);return this.concat(c)},truncate:function(a,b){return array.set(dtm.transform.truncate(array.val,a,b))},remove:function(a){var b=[],c=this.val;return argsAreSingleVals(arguments)?isNumArray(argsToArray(arguments))&&(b=argsToArray(arguments)):isNumOrFloat32Array(a)?b=a:isNumDtmArray(a)&&(b=a.get()),b.forEach(function(a){c.splice(a,1)}),this.set(c)},removeempty:function(){var a=[];return isNestedDtmArray(this)?(this.forEach(function(b){"Float32Array"===b.get(0).constructor.name?b.get(0).length>0&&a.push(b):a.push(b)}),dtm.data(a)):(this.forEach(function(b){isEmpty(b)||a.push(b)}),dtm.data(a).label(this.get("name")))},shift:function(a){return this.set(dtm.transform.shift(this.val,a))},mirror:function(){return this.concat(dtm.transform.reverse(this.val))},reverse:function(){return this.set(dtm.transform.reverse(this.val))},flip:function(a){return this.set(dtm.transform.invert(this.val,a))},queue:function(a){return isNumber(a)?(this.val.push(a),this.val.shift()):isFloat32Array(a)?(this.val=Float32Concat(this.val,a),this.val=this.val.splice(a.length)):isArray(a)?isFloat32Array(this.val)?(this.val=Float32Concat(this.val,a),this.val=Float32Splice(this.val,0,a.length)):(this.val=this.val.concat(a),this.val=this.val.splice(a.length)):isDtmArray(a)&&(this.val=this.val.concat(a.get()),this.val=this.val.splice(a.get("len"))),this.set(this.val)},find:function(a){if(isEmpty(a))return this;var b=[];if(isFunction(a))this.each(function(c,d){a(c)&&b.push(d)});else{if(!isSingleVal(a))return this;this.each(function(c,d){c.get(0)===a&&b.push(d)})}return this.set(b)},sort:function(a){return this.set(isEmpty(a)?dtm.transform.sort(this.val):this.val.sort(a))},sortby:function(a,b){isBoolean(b)||(b=!1),isFunction(a)||(a=function(a){return a});var c=this.val.sort(function(c,d){return b?a(d)-a(c):a(c)-a(d)});return this.set(c)},replace:function(a,b){return isSingleVal(b)?isSingleVal(a)?this.set(this.val.map(function(c){return c===a?b:c})):isArray(a)?this.set(this.val.map(function(c){return a.some(function(a){return a===c})?b:c})):isDtmArray(a)?this.set(this.val.map(function(c){return a.get().some(function(a){return a===c})?b:c})):isFunction(a)?this.set(this.val.map(function(c){return a(c)?b:c})):void 0:this},reorder:function(){var a;if(isDtmArray(arguments[0])?a=toFloat32Array(arguments[0]):argsAreSingleVals(arguments)?a=argsToArray(arguments):argIsSingleArray(arguments)&&(a=arguments[0]),isNumOrFloat32Array(a)){var b=new Array(a.length);a.forEach(function(a,c){b[c]=this.get(a)})}return this.set(b)}}),dtm.data.augment({aliases:{},split:function(a){return this.set(dtm.transform.split(this.val,a))},join:function(a){var b=this;isNestedDtmArray(b)&&b.map(function(b){return b.join(a)}),isString(a)||(a="");var c="";return b.each(function(d,e){c+=toString(d.get(0)),e<b.length-1&&(c+=a)}),b.set(c)},editdist:function(a){return isString(a)?this.set(dtm.transform.editDistance(this.val,a)):this}}),dtm.data.augment({aliases:{call:["do"]},type:function(){return this},size:function(){return this},call:function(a){return isFunction(a)&&(arguments.length>1,a(this)),this},process:function(a){return this.params.processFn=a,this},print:function(){return isFunction(dtm.params.printer)?dtm.params.printer.apply(this,[this].concat(argsToArray(arguments))):dtm.util.print(this),this},plot:function(){return isFunction(dtm.params.plotter)&&dtm.params.plotter.apply(this,[this].concat(argsToArray(arguments))),this}}),dtm.data.augment({aliases:{pitchquantize:["pq"]},pitchquantize:function(a){return isNestedDtmArray(this)?this.map(function(b){return b.pitchquantize(a)}):(isEmpty(a)?a=dtm.gen("range",12).get():argsAreSingleVals(arguments)?a=argsToArray(arguments):isDtmArray(a)&&isNumOrFloat32Array(a.get())?a=a.get():isNumOrFloat32Array(a),this.set(dtm.transform.pitchQuantize(this.val,a)))}}),dtm.data.augment({note:function(){var a=argsToArray(arguments);return this.freq(dtm.data(a).flatten().mtof())}}),dtm.data.augment({interleave:function(a,b,c){for(var d=b||1,e=c||1,f=[],g=Math.max(this.length,a.length)*(d+e),h=0,i=0,j=0,k=0,l=0;g>l;l++){for(k=0;d>k;k++)j=this.get(h%this.length),h++,f.push(j);for(k=0;e>k;k++)j=a.get(i%a.length),i++,f.push(j)}return this.set(f)}}),dtm.generator=function(){function a(a){return f[a].indexOf(e.type)>-1}function b(){function b(a,b,c){for(var d=new Float32Array(a),e=(c-b)/(a-1),f=0;a>f;f++)d[f]=b+e*f;return d}function f(a,b,c,d,e,f){for(var g=new Float32Array(a),h=0;a>h;h++){var i=mod(h/(a-1)+f/e,1),j=Math.sin(2*Math.PI*i*e)*d;j=(j+1)/2*(c-b)+b,g[h]=j}return g}function g(a,b,c,d,e,f){for(var g=new Float32Array(a),h=0;a>h;h++){var i=mod(h/(a-1)+f,1),j=Math.cos(2*Math.PI*i*e)*d;j=(j+1)/2*(c-b)+b,g[h]=j}return g}function h(a,b,c,d,e){for(var f=new Float32Array(a),g=0;a>g;g++){var h=Math.random()*(c-b)+b;f[g]=e?Math.floor(h)*d:h*d}return f}function i(a,b){var c;c=isNumber(b)?new Float32Array(a):new Array(a);for(var e=0;a>e;e++)c[e]=isNumOrFloat32Array(b)?toFloat32Array(b):isDtmArray(b)?b.parent(d):b;return c}function j(a,b,c){isNumber(c)||0!==c||(c=1);var e=Math.floor((b-a)/c)+1;d.length=e;for(var f=new Float32Array,g=0;e>g;g++)f[g]=a+c*g;return f}function k(a,b,c){isNumber(c)&&0!==c||(c=1),c=b>=a?Math.abs(c):-Math.abs(c);for(var d=Math.ceil(Math.abs(b-a)/Math.abs(c)),e=new Float32Array(d),f=0;d>f;f++)e[f]=a+f*c;return e}function l(a,b){var c=a.map(function(a){return mod(a+b,12)});return dtm.transform.sort(c)}function m(a,b){var c=[],d={chromatic:{names:["chromatic","chr"],values:[0,1,2,3,4,5,6,7,8,9,10,11]},major:{names:["major","maj","ionian"],values:[0,2,4,5,7,9,11]},minor:{names:["minor","min","aeolian"],values:[0,2,3,5,7,8,10]},wholetone:{names:["wholetone","whole","wt"],values:[0,2,4,6,8,10]},majpenta:{names:["penta","pent","majpenta"],values:[0,2,4,7,9]},dorian:{names:["dorian"],values:[0,2,3,5,7,9,10]},phrygian:{names:["phrygian","phry"],values:[0,1,3,5,7,8,10]},lydian:{names:["lydian","lyd"],values:[0,2,4,6,7,9,11]},mixolydian:{names:["mixolydian","mixo"],values:[0,2,4,5,7,9,10]},locrian:{names:["locrian","loc"],values:[0,1,3,5,6,8,10]}};return objForEach(d,function(d,e){isEmpty(a)?c.push(dtm.data(d.values).label(e)):-1!==d.names.indexOf(a.toLowerCase())&&(c=new Float32Array(l(d.values,b)))}),c?c:new Float32Array}function n(a){var b={"dahina tabla":[1,2.89,4.95,6.99,8.01,9.02],"bayan tabla":[1,2,3.01,4.01,4.69,5.63],"red cedar wood plate":[1,1.47,2.09,2.56],"redwood wood plate":[1,1.47,2.11,2.57],"douglas fir wood plate":[1,1.42,2.11,2.47],"uniform wooden bar":[1,2.572,4.644,6.984,9.723,12],"uniform aluminum bar":[1,2.756,5.423,8.988,13.448,18.68],xylophone:[1,3.932,9.538,16.688,24.566,31.147],"vibraphone 1":[1,3.984,10.668,17.979,23.679,33.642],"vibraphone 2":[1,3.997,9.469,15.566,20.863,29.44],"chalandi plates":[1,1.72581,5.80645,7.41935,13.91935],"tibetan bowl (180mm)":[1,2.77828,5.18099,8.16289,11.66063,15.63801,19.99],"tibetan bowl (152 mm)":[1,2.66242,4.83757,7.51592,10.64012,14.21019,18.14027],"tibetan bowl (140 mm)":[1,2.76515,5.12121,7.80681,10.78409],"wine glass":[1,2.32,4.25,6.63,9.38],"small handbell":[1,1.0019054878049,1.7936737804878,1.8009908536585,2.5201981707317,2.5224085365854,2.9907012195122,2.9940548780488,3.7855182926829,3.8061737804878,4.5689024390244,4.5754573170732,5.0296493902439,5.0455030487805,6.0759908536585,5.9094512195122,6.4124237804878,6.4430640243902,7.0826219512195,7.0923780487805,7.3188262195122,7.5551829268293],"spinel sphere with diameter of 3.6675mm":[1,1.026513174725,1.4224916858532,1.4478690202098,1.4661959580455,1.499452545408,1.7891839345101,1.8768994627782,1.9645945254541,1.9786543873113,2.0334612432847,2.1452852391916,2.1561524686621,2.2533435661294,2.2905090816065,2.3331798413917,0,2.4567715528268,2.4925556408289,2.5661806088514,2.6055768738808,2.6692760296751,2.7140956766436,2.7543617293425,2.7710411870043],"pot lid":[1,3.2,6.23,6.27,9.92,14.15]};if(isString(a))return toFloat32Array(a in b?b[a]:1);if(isInteger(a))return a=mod(a,Object.keys(b).length),toFloat32Array(b[Object.keys(b)[a]]);var c=[];return objForEach(b,function(a,b){c.push(dtm.data(a).label(b))}),c}function o(a){var b=new Float32Array(a);if(b[0]=1,a>1){b[1]=1;for(var c=2;a>c;c++)b[c]=b[c-1]+b[c-2]}return b}d.val=[];var p;switch((a("noMinMaxDir")||a("random"))&&(p=dtm.transform.sort([e.min,e.max])),e.type){case"line":case"saw":d.val=b(d.length,e.min,e.max);break;case"rise":d.val=b(d.length,p[0],p[1]);break;case"decay":case"fall":d.val=b(d.length,p[1],p[0]);break;case"adsr":case"ADSR":break;case"sin":case"sine":d.val=f(d.length,e.min,e.max,e.amp,e.cycle,c.phase);break;case"cos":case"cosine":d.val=g(d.length,e.min,e.max,e.amp,e.cycle,0);break;case"tri":case"triangle":break;case"harm":case"harmonic":break;case"rf":case"rand":case"random":d.val=h(d.length,p[0],p[1],1,!1);break;case"noise":d.val=h(d.length,p[0],p[1],e.amp,!1);break;case"ri":case"randi":d.val=h(d.length,p[0],p[1],1,!0);break;case"r":case"range":d.val=k(c.start,c.end,c.interval);break;case"seq":d.val=j(e.min,e.max);break;case"scale":d.val=m(c.scale,c.transpose);break;case"modal":case"modes":case"mode":d.val=n(c.index);break;case"fibonacci":d.val=o(d.length);break;case"zeros":case"zeroes":d.val=i(d.length,0);break;case"ones":d.val=i(d.length,1);break;case"const":d.val=i(d.length,e["const"]);break;case"string":case"str":case"s":case"characters":case"character":case"chars":case"char":case"c":d.val=e.string.split("")}d.length=d.val.length,d.meta.setOriginal(d.val)}var c={type:null,min:0,max:1,start:0,end:1,interval:null,scale:void 0,transpose:0,index:void 0,amp:1,cycle:1,phase:0,"const":0,string:"",pack:!1,typed:!0},d=dtm.data(),e=d.meta.getParams();objForEach(c,function(a,b){e[b]=a});var f={all:["line","saw","rise","decay","fall","invSaw","adsr","ADSR","seq","sequence","series","range","r","scale","chord","modal","modes","mode","fibonacci","noise","random","rand","rf","randi","ri","gauss","gaussian","gaussCurve","normal","sin","sine","cos","cosine","tri","triangle","sig","sigmoid","logistic","zeros","zeroes","ones","constant","constants","const","consts","repeat","string","str","s","text","split","character","characters","chars","char","c"],oscil:["sin","sine","cos","cosine","tri","triangle","saw","invSaw","noise","square","sq","harm","harmonic"],"const":["zeros","zeroes","ones","constant","constants","const","consts"],envelope:["rise","decay","fall","ahr"],sequence:[],noLength:["string","str","s","character","characters","chars","char","c","range","r","seq","scale","mode","chord","modal"],noRange:[],noMinMax:[],noMinMaxDir:["rise","decay","fall","noise"],random:["random","rand","rf","randi","ri"],string:["string","split","str","s","character","characters","chars","char","c","text"]};return d.type=function(a){return isString(a)&&f.all.indexOf(a)>-1&&(e.type=a),b(),d},d.size=function(a){if(isString(a)&&"a"===a[0])return e.autolen=!0,d;var c=parseInt(a);return!isNaN(c)&&c>0&&(d.length=c),b(),d},d.start=function(a){return isNumber(a)&&(c.start=a),b(),d},d.end=function(a){return isNumber(a)&&(c.end=a),b(),d},d.interval=function(a){return isNumber(a)&&(c.interval=a),b(),d},d.oscamp=function(a){var c=parseFloat(a);return isNaN(c)||(e.amp=c),b(),d},d.cycle=function(a){var c=parseFloat(a);return isNaN(c)||(e.cycle=c),b(),d},d.offset=function(a){return isNumber(a)&&(c.phase=a),b(),d},d["const"]=function(a){return isSingleVal(a)&&(e["const"]=a),b(),d},d.transpose=function(a){return isInteger(a)?c.transpose=a:isDtmArray(a)&&(c.transpose=a.get(0)),b(),d},d.length=8,arguments.length>=1&&(isObject(arguments[0])?isArray(arguments[0])||objForEach(arguments[0],function(a){e.hasOwnProperty(a)&&(e[a]=arguments[0][a])}):isString(arguments[0])&&d.type(arguments[0]),isObject(arguments[1])&&(isArray(arguments[1])||objForEach(arguments[1],function(a){e.hasOwnProperty(a)&&(e[a]=arguments[1][a])}))),arguments.length<=2&&(a("oscil")?(e.min=-1,e.max=1):(e.min=0,e.max=1)),a("envelope")&&(d.length=128),a("random")?(d.length=1,e.min=0,e.max="randi"===e.type||"ri"===e.type?2:1,arguments.length>=2&&isInteger(arguments[1])&&(d.length=arguments[1]>0?arguments[1]:1),3===arguments.length?isNumber(arguments[2])?e.max=arguments[2]:isNumOrFloat32Array(arguments[2])||isNumDtmArray(arguments[2]):4===arguments.length&&(isNumber(arguments[2])&&(e.min=arguments[2]),isNumber(arguments[3])&&(e.max=arguments[3]))):a("oscil")?(d.length=4096,2===arguments.length&&isInteger(arguments[1])&&(d.length=arguments[1]>0?arguments[1]:4096),arguments.length>=3&&(isArray(arguments[2])?1===arguments[2].length?d.oscamp(arguments[2][0]):2===arguments[2].length&&(e.min=arguments[2][0],e.max=arguments[2][1]):d.oscamp(arguments[2])),3===arguments.length&&(e.min=-1,e.max=1,d.oscamp(arguments[2])),4===arguments.length&&(isArray(arguments[3])?2===arguments[3].length&&(e.min=arguments[3][0],e.max=arguments[3][1]):(e.min=-1,e.max=1,d.cycle(arguments[3])))):arguments.length>=2&&(a("string")?isString(arguments[1])?(e.string=arguments[1],e.typed=!1):e.string=String(arguments[1]):"range"===e.type||"r"===e.type?isNumArray(arguments[1])?(1===arguments[1].length?(d.start(0),d.end(arguments[1][0])):arguments[1].length>=2&&(d.start(arguments[1][0]),d.end(arguments[1][1])),3===arguments[1].length&&d.interval(arguments[1][2])):(2===arguments.length&&isNumber(arguments[1])?(d.start(0),d.end(arguments[1])):arguments.length>=3&&(isNumber(arguments[1])&&d.start(arguments[1]),isNumber(arguments[2])&&d.end(arguments[2])),4===arguments.length&&d.interval(arguments[3])):"seq"===e.type?(e.min=arguments[1],e.max=arguments[2]):"scale"===e.type?(isString(arguments[1])&&(c.scale=arguments[1]),isInteger(arguments[2])&&(c.transpose=arguments[2])):"modal"===e.type||"modes"===e.type||"mode"===e.type?c.index=arguments[1]:a("const")?isEmpty(arguments[1])||(e["const"]=arguments[1],d.length=1):(d.size(arguments[1]),arguments.length>=3&&(isArray(arguments[2])?1===arguments[2].length?e.max=arguments[2][0]:2===arguments[2].length&&(e.min=arguments[2][0],e.max=arguments[2][1]):(3===arguments.length&&(e.min=0,e.max=arguments[2],d.oscamp(1)),arguments.length>=4&&(e.min=arguments[2],e.max=arguments[3]))))),b(),d},dtm.g=dtm.gen=dtm.generator;var generators=["line","rise","decay","fall","seq","sequence","series","range","r","noise","random","rand","rf","randi","ri","gaussian","gauss","normal","zeros","zeroes","ones","constant","constants","const","consts","repeat","string","str","sin","sine","cos","cosine","tri","triangle","saw","fibonacci","decay","scale","modal","modes","mode","sig","sigmoid","logistic"];generators.forEach(function(a){dtm[a]=function(){var b=[a].concat(argsToArray(arguments));return dtm.generator.apply(this,b)}}),dtm.parser={type:"dtm.parser",csvToJson:function(a){for(var b=a.split("\n"),c=[],d=b[0].split(","),e=1;e<b.length;e++){var f={},g=b[e].split(",");if(g.length>1){for(var h=0;h<d.length;h++){var i=g[h];isNaN(i)||(i=Number.parseFloat(i)),f[d[h]]=i}c.push(f)}}return c},csvToCols:function(a){function b(a){for(var b=a.length-1;b>0;b--)isString(a[b-1])&&isString(a[b])&&(a[b].endsWith('"')||a[b].endsWith('"'))&&(a[b-1]=a[b-1].concat(", "+a[b]),a.splice(b,1));return a}var c=a.indexOf("\n")>-1?"\n":"\r",d=a.split(c),e=d[0].split(","),f={},g=0;e.forEach(function(a,b){e[b]=a.trim(),'"'===a[0]&&'"'===a[a.length-1]&&(a=a.slice(1,-1)),e[b]=a.trim(),""===a&&(e[b]="(empty_"+g++ +")")}),e=b(e),e.forEach(function(a){f[a]=[]});for(var h=1;h<d.length;h++){var i=d[h].split(",");if(i.length>1){for(var j=0;j<i.length;j++){var k=i[j];'"'===k[0]&&'"'===k[k.length-1]&&(k=k.slice(1,-1)),k=k.trim(),isNaN(k)||(k=parseFloat(k)),isNaNfast(k)&&(k=null),i[j]=k}i=b(i);for(var j=0;j<e.length;j++)f[e[j]].push(i[j])}}return f},valueTypes:function(a){var b=[];return a.forEach(function(a){var c=parseFloat(a);b.push(isNaN(c)?"string":a.indexOf(".")>-1?"float":"int")}),b},getSize:function(a){var b=numProperties(a[0]),c=numProperties(a);return[b,c]}},dtm.load=function(input,fn){if(isString(input)){var url=input;return new Promise(function(resolve){var ext=url.split(".").pop();if("jsonp"===ext){var cbName="jsonp_callback_"+Math.round(1e5*Math.random());window[cbName]=function(a){delete window[cbName],document.body.removeChild(script);var b=Object.keys(a);b.forEach(function(b){"response"!==b&&(params.coll=a[b],params.keys=Object.keys(params.coll[0]),setArrays(),setTypes(),setSize(),resolve(data))}),"undefined"!=typeof cb&&cb(data)};var script=document.createElement("script");script.src=url+(url.indexOf("?")>=0?"&":"?")+"callback="+cbName,document.body.appendChild(script)}else{var xhr=new XMLHttpRequest;switch(xhr.open("GET",url,!0),ext){case"txt":case"csv":break;case"json":break;case"wav":case"aif":case"aiff":case"ogg":case"mp3":xhr.responseType="arraybuffer";break;case"png":case"jpg":case"jpeg":xhr.responseType="blob"}xhr.onreadystatechange=function(){if(4===xhr.readyState&&200===xhr.status)if("arraybuffer"===xhr.responseType)dtm.wa.isOn&&dtm.wa.actx.decodeAudioData(xhr.response,function(a){for(var b=dtm.data(),c=[],d=0;d<a.numberOfChannels;d++){var e=a.getChannelData(d);c.push(dtm.data(Array.prototype.slice.call(e)).label("ch_"+d).parent(b))}isEmpty(fn)||fn(b.set(c)),resolve(b.set(c))});else if("blob"===xhr.responseType){var img=new Image;img.onload=function(){var a=document.createElement("canvas");a.width=img.width,a.height=img.height;var b=a.getContext("2d");b.drawImage(img,0,0);for(var c=[],d=b.getImageData(0,0,img.width,img.height).data,e=0;e<img.width;e++)c.push(d.filter(function(a,b){return b%(4*img.width)===e}));console.log(c)},img.src=window.URL.createObjectURL(xhr.response)}else{var keys=[];if("csv"===ext){var data=dtm.data(),arrays=[];objForEach(dtm.parser.csvToCols(xhr.response),function(a,b){var c=dtm.data(a).label(b).parent(data);arrays.push(c)})}else if("json"===ext){var res=xhr.responseText;try{res=JSON.parse(res)}catch(e){try{res=eval(res)}catch(e){console.log("Could not parse the JSON file. Maybe the format is not right.")}}if(url.indexOf("wunderground")>-1){var obj=JSON.parse(xhr.response);params.coll=obj[Object.keys(obj)[1]],params.coll.constructor===Array?keys=Object.keys(params.coll[0]):(keys=Object.keys(params.coll),params.coll=[params.coll])}else{var second=res[Object.keys(res)[0]];keys=Object.keys(second.constructor===Array?second[0]:second),params.coll=res}}else params.coll=second;isEmpty(fn)||fn(data.set(arrays)),resolve(data.set(arrays))}},xhr.send()}})}var elem_file=input,fileType=null,reader=new FileReader;return elem_file[0].name.match(/.+\.json/gi)?fileType="json":elem_file.name.match(/.+\.csv/gi)&&(fileType="csv"),reader.readAsText(elem_file),new Promise(function(a){reader.onload=function(b){if("json"===fileType)a(JSON.parse(b.target.result));else if("csv"===fileType){var c=dtm.data(),d=[];objForEach(dtm.parser.csvToCols(b.target.result),function(a,b){var e=dtm.data(a).label(b).parent(c);d.push(e)}),isEmpty(fn)||fn(c.set(d)),a(c.set(d))}}})},dtm.file=function(a,b){var c=null,d=new FileReader;return a.name.match(/.+\.json/gi)?c="json":a.name.match(/.+\.csv/gi)&&(c="csv"),d.readAsText(a),new Promise(function(a){d.onload=function(d){if("json"===c)a(JSON.parse(d.target.result));else if("csv"===c){var e=dtm.data(),f=[];objForEach(dtm.parser.csvToCols(d.target.result),function(a,b){var c=dtm.data(a).label(b).parent(e);f.push(c)}),isEmpty(b)||b(e.set(f)),a(e.set(f))}}})},dtm.csv=function(a,b){if(isString(a)){if(isURL(a,".csv")){var c=new Promise(function(c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.onreadystatechange=function(){if(4===d.readyState&&200===d.status){var a=dtm.data(),e=[];objForEach(dtm.parser.csvToCols(d.response),function(b,c){var d=dtm.data(b).label(c).parent(a);e.push(d)}),isEmpty(b)||b(a.set(e)),c(e)}},d.send()}),d=dtm.data();return c.then(function(a){d.set(a)}),d}}else isFile(a)&&loadFileObject(a,function(a){var c=dtm.data(),d=[];objForEach(dtm.parser.csvToCols(a),function(a,b){var e=dtm.data(a).label(b).parent(c);d.push(e)}),isEmpty(b)||b(c.set(d))})},dtm.json=function(a){isString(a)?isURL(a,".json"):isFile(a)},dtm.text=function(a,b){if(isString(a)){if(isURL(a,".txt")){var c=new Promise(function(c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.onreadystatechange=function(){if(4===d.readyState&&200===d.status){var a=dtm.data();if(!isString(d.response))throw new TypeError("the file content is not text");a.set(d.response),isEmpty(b)||b(a),c(d.response)}},d.send()}),d=dtm.data();return c.then(function(a){c=d.set(a)}),d}}else isFile(a)&&loadFileObject(a,function(a){var c=dtm.data();isString(a)&&c.set(a),isEmpty(b)||b(c)})},dtm.txt=dtm.text,dtm.web=function(a,b){return new Promise(function(c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.onreadystatechange=function(){function e(a){var b=Object.keys(a[0]),c=b.map(function(b){var c=a.map(function(a){return a[b]}),d=dtm.data(c).label(b);return isParsableNumArray(c)&&d.tonum(),d});return dtm.data(c)}if(4===d.readyState&&200===d.status){var f=dtm.data();if(a.indexOf("wunderground")>-1){var g=JSON.parse(d.response);f.label("hourly_forecast");var h=g.hourly_forecast,i=Object.keys(h[0]),j=[];i.forEach(function(a){var b=h.map(function(b){return b[a]});isObjArray(b)&&(b=e(b));var c=dtm.data(b).label(a).parent(f);isParsableNumArray(b)&&c.tonum(),j.push(c)})}else var h=JSON.parse(d.response).matches;isEmpty(b)||b(f.set(j)),c(f.set(j))}},d.send()})},dtm.image=function(a,b,c){if(isString(a)){var d=a;return isString(c)||(c="brightness"),new Promise(function(e){var f=new Image,g=dtm.data();if(f.onload=function(){var a=document.createElement("canvas");a.width=f.width,a.height=f.height;var d=a.getContext("2d");d.drawImage(f,0,0);var h=d.getImageData(0,0,f.width,f.height).data;if("brightness"===c){for(var i=new Float32Array(h.length/4),j=0;j<h.length;j+=4){var k=.34*h[j]+.5*h[j+1]+.16*h[j+2];i[j/4]=k/255}g.set(i).block(f.width).label("brightness")}else if("hue"===c){for(var l,m,n,o,p,q,r=new Float32Array(h.length/4),j=0;j<h.length;j+=4)l=h[j]/255,m=h[j+1]/255,n=h[j+2]/255,p=Math.max(l,m,n),q=Math.min(l,m,n),o=p===l?(m-n)/(p-q):p===m?2+(n-l)/(p-q):4+(l-m)/(p-q),o*=60,0>o&&(o+=360),r[j/4]=o;g.set(r).block(f.width).label("hue")}else if("heatmap"===c){for(var l,m,n,o,p,q,r=new Float32Array(h.length/4),j=0;j<h.length;j+=4)l=h[j]/255,m=h[j+1]/255,n=h[j+2]/255,p=Math.max(l,m,n),q=Math.min(l,m,n),o=p===l?(m-n)/(p-q):p===m?2+(n-l)/(p-q):4+(l-m)/(p-q),o*=60,-30>o&&(o+=360),0>o&&(o=0),o>300&&(o=300),.15>l+m+n&&(o=300),isNaN(o)&&(o=0),r[j/4]=1-o/300;g.set(r).block(f.width).label("hue")}else if("rgb"===c){for(var s=new Float32Array(h.length/4),t=new Float32Array(h.length/4),u=new Float32Array(h.length/4),j=0;j<h.length;j+=4)s[j/4]=h[j]/255,t[j/4]=h[j+1]/255,u[j/4]=h[j+2]/255;g.set(s).block(f.width).label("red")}isEmpty(b)||b(g),e(g)},isURL(a)){var h=new XMLHttpRequest;h.responseType="blob",h.open("GET",d,!0),h.onreadystatechange=function(){4===h.readyState&&200===h.status&&(f.src=window.URL.createObjectURL(h.response))},h.send()}else isDataURL(a)&&(f.src=a)})}isFile(a)&&loadFileObject(a,function(a){dtm.image(a,b,c)})},dtm.pic=dtm.img=dtm.image,dtm.cam=function(a,b){var c,d,e=400,f=300;isDtmArray(a)?c=a:isFunction(a)&&(d=a),isEmpty(c)&&(c=dtm.data(0)),(!isNumber(b)||0>b)&&(b=1),navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia?navigator.getUserMedia({audio:!1,video:{width:e,height:f}},function(a){var g;g=document.getElementById("cam")?document.getElementById("cam"):document.createElement("video"),g.src=window.URL&&window.URL.createObjectURL(a)||a;var h=document.createElement("canvas");h.width=e,h.height=f;var i=h.getContext("2d");i.fillRect(0,0,e,f),g.onloadedmetadata=function(){g.play(),g.muted="true"},dtm.music(function(){i.drawImage(g,0,0,e,f);for(var a=i.getImageData(0,0,e,f).data,b=new Float32Array(a.length/4),h=0;h<a.length;h+=4){var j=.34*a[h]+.5*a[h+1]+.16*a[h+2];b[h/4]=j/255}c.set(b).block(e),isEmpty(d)||d(c)}).interval(b).run()},function(a){console.log(a)}):console.log("getUserMedia not supported")},dtm.audio=function(a,b){isNumber(a)?b=a:isNumber(b)||(b=1024);var c=dtm.data(0);return dtm.params.stream=!0,navigator.getUserMedia=navigator.getUserMedia||navigator.webkitGetUserMedia||navigator.mozGetUserMedia||navigator.msGetUserMedia,navigator.getUserMedia&&navigator.getUserMedia({audio:{mandatory:{googEchoCancellation:"false",googAutoGainControl:"false",googNoiseSuppression:"false",googHighpassFilter:"false"},optional:[]},video:!1},function(d){var e=dtm.wa.actx,f=e.createMediaStreamSource(d),g=e.createScriptProcessor(b,1,1);g.onaudioprocess=function(b){if(dtm.params.stream){var d=b.inputBuffer.getChannelData(0);isDtmArray(a)?a.set(d):isFunction(a)?a(c.set(d)):c.set(d)}};var h=e.createGain();h.gain.setValueAtTime(0,0),f.connect(g).connect(h).connect(e.destination),dtm.cache.audioStream.push({audio:null,input:f,sp:g,gain:h})},function(a){console.error(a)}),c},dtm.stream=function(a,b,c){isNumber(b)?c=b:isNumber(c)||(c=1024);var d=dtm.data(0);dtm.params.stream=!0;var e=dtm.wa.actx,f=document.createElement("audio");f.src=a,f.crossOrigin="anonymous",f.play();var g=e.createMediaElementSource(f),h=e.createScriptProcessor(c,1,1);h.onaudioprocess=function(a){if(dtm.params.stream){var c=a.inputBuffer.getChannelData(0);isDtmArray(b)?b.set(c):isFunction(b)?b(d.set(c)):d.set(c)}};var i=e.createGain();i.gain.setValueAtTime(1,0),g.connect(h).connect(i).connect(e.destination),dtm.cache.audioStream.push({audio:f,input:g,sp:h,gain:i})},dtm.wav=function(a,b){if(isString(a)){if(isURL(a))return new Promise(function(c){var d=new XMLHttpRequest;d.open("GET",a,!0),d.onreadystatechange=function(){4===d.readyState&&200===d.status&&dtm.wa.isOn&&dtm.wa.actx.decodeAudioData(d.response,function(a){for(var d=dtm.data(),e=[],f=0;f<a.numberOfChannels;f++){var g=a.getChannelData(f);e.push(dtm.data(Array.prototype.slice.call(g)).label("ch_"+f).parent(d))}isEmpty(b)||b(d.set(e)),c(d.set(e))})}})}else isFile(a)&&loadFileObject(a,function(a){dtm.wa.isOn&&dtm.wa.actx.decodeAudioData(a,function(a){for(var c=dtm.data(),d=[],e=0;e<a.numberOfChannels;e++){var f=a.getChannelData(e);d.push(dtm.data(Array.prototype.slice.call(f)).label("ch_"+e).parent(c))}isEmpty(b)||b(c.set(d))})})},dtm.i=dtm.instr=function(){var a=new Instr;return a},Instr.prototype=Object.create(Function.prototype),dtm.instr.create=function(){},dtm.model=function(a,b){var c={name:null,categ:"none",categories:[],defaultCb:null,registering:!1,loading:!0,process:[],data:dtm.data(),clock:null,output:[]},d=function(){if(isFunction(c.defaultCb))return c.defaultCb.apply(this,arguments);if(d.caller.arguments[0]&&"dtm.clock"===d.caller.arguments[0].type&&(c.clock=d.caller.arguments[0]),1===arguments.length){var a=arguments[0];isNumber(a)?c.data.set(a):isString(a)?c.data.set(dtm.gen("s",a)).histo():isNumOrFloat32Array(a)?c.data.set(a):isDtmArray(a)?c.data.set(a):isFunction(a)}else arguments.length>1&&c.data.set.apply(this,arguments);c.process.forEach(function(a){a.method.apply(this,a.params)}),c.range?c.domain?c.data.range(c.range,c.domain):c.data.range(c.range):c.domain&&c.data.normalize(c.domain);var b=null;return c.output&&c.output.forEach(function(a){b=c.clock?a.method(c.data,c.clock):a.method(c.data)}),b?b:c.data};if(d.meta={type:"dtm.model"},d.parent={},d.siblings=[],d.mod={},d.param={},d.set={},d.map={},d.params={},d.models={},d.modes={literal:["literal","lit","l"],adapt:["adapt","adapted","adaptive","a"],preserve:["preserve","preserved","p","n"]},"string"==typeof a&&(c.name=a),"string"==typeof b&&(c.categ=b),d["default"]=function(a){"function"==typeof a&&(c.defaultCb=a)},d.get=function(a){switch(a){case"name":return c.name;case"category":case"categ":return c.categ;default:return c.output}},d.categ=function(a){return"string"==typeof a&&(c.categ=a),d},d.register=function(){var a=!1;for(var b in dtm.modelCallers)b===d.get("name")&&(dtm.log("model already registered: "+d.get("name")),a=!0,c.registering=!1);return a||(dtm.log("registering a new model: "+d.get("name")),dtm.modelCallers[d.get("name")]=d.register.caller,c.registering=!0),d},d.save=function(){return dtm.modelColl[d.get("name")]=d,d},d.toNumeric=function(a){switch(a){case"histo":case"histogram":c.process.push({method:function(){"number"!==c.data.get("type")&&c.data.histo()},params:null});break;case"class":c.process.push({method:function(){"number"!==c.data.get("type")&&c.data["class"]()},params:null});break;case"freq":case"frequency":case"appearance":}return d},d.domain=function(){if(1===arguments.length){var a=arguments[0];"object"==typeof a?a.constructor===Array?c.domain=a:isDtmArray(a)&&(c.domain=2===a.get("len")?a.get():a.get("extent")):"function"==typeof a&&c.process.push({method:function(){c.domain=a(c.data)},params:null})}else 2===arguments.length&&(c.domain=[arguments[0],arguments[1]]);return d},d.range=function(){if(1===arguments.length){var a=arguments[0];"object"==typeof a?a.constructor===Array?c.range=a:isDtmArray(a)&&(c.range=2===a.get("len")?a.get():a.get("extent")):"function"==typeof a&&c.process.push({method:function(){c.range=a(c.data)},params:null})}else 2===arguments.length&&(c.range=[arguments[0],arguments[1]]);return d},d.output=function(a){return c.output.push(isFunction(a)?{method:function(b,c){return a(b,c)},params:null}:{method:function(){return a},params:null}),d},d.start=function(){return d},d.stop=function(){return d},d.clone=function(){return clone(d)},d.assignMethods=function(a){return d.mod.forEach(function(b,c){a[c]=b,a.params.push(c)}),d.param.forEach(function(b,c){a[c]=b,a.params.push(c)}),d.set.forEach(function(b,c){a[c]=b,a.params.push(c)}),d.map.forEach(function(b,c){a[c]=b,a.params.push(c)}),d},isString(a)){isEmpty(dtm.model.caller)||(c.loading=dtm.model.caller.arguments[0]);var e,f;for(f in dtm.modelCallers)f===a&&c.loading!==!0&&(dtm.log("found a registered model: "+a),e=dtm.modelCallers[a](!0));if(isEmpty(e))for(f in dtm.modelColl)f===a&&d.load.caller.arguments[0]!==a&&(e=dtm.modelColl[a].clone());isEmpty(e)||(dtm.log("loading a registered / saved model: "+a),d=e)}else isFunction(a)&&c.output.push({method:function(b,c){return a(b,c)},params:null});return d},dtm.to=dtm.map=function(a,b){var c=a.clone();return b(c),c.params.processFn=b,c.params.isTarget=!0,c.attach=function(a,b){c.params.attachedFn=b.bind(a)},a.params.targets[c.params.id]=c,a.params.trace=!0,dtm.params.traced.push(a),a.meta.setInterceptor(function(b,d){if("function"==typeof b[d]&&-1===["hasOwnProperty","clone","print","plot","process"].indexOf(d)){var e=b[d];return function(){var b=arguments;return a.params.trace&&objForEach(a.params.targets,function(a){e.apply(a,b);var d=a.params.processFn(a);isDtmArray(d)?a.set(d.val):isEmpty(d)||a.set(d),a.params.attachedFn&&a.params.attachedFn(c.val)}),e.apply(this,b)}}return b[d]}),c},dtm.to.enable=function(a){return isBoolean(a)||(a=!0),Data.prototype.traceGlobal=a,dtm.to},dtm.to.enable(),dtm.m=dtm.music=function(){var a=new Music;return a.init.apply(a,arguments)},dtm.music.offline=function(a){isBoolean(a)?Music.prototype.offline=a:isEmpty(a)&&(Music.prototype.offline=!0)};var fx={Gain:function(a,b){var c=null,d=isBoolean(b)?b:a.params.rtFxOnly;isString(b)&&(d=!0,c=b),this.mult=new Float32Array([1]),this.run=function(b,e){var f=d?Music.prototype.actx:Music.prototype.octx;this["in"]=f.createGain(),this.gain=f.createGain(),this.out=f.createGain(),this["in"].connect(this.gain),this.gain.connect(this.out);var g=[];g.push({param:this.gain.gain,value:this.mult}),a.setParamCurve(b,e,g),isEmpty(c)||(a.params.named[c]=this.gain.gain)}},LPF:function(a,b){this.freq=new Float32Array([2e4]),this.q=new Float32Array([1]),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.lpf=e.createBiquadFilter(),this.out=e.createGain(),this["in"].connect(this.lpf),this.lpf.connect(this.out);var f=[];f.push({param:this.lpf.frequency,value:this.freq}),f.push({param:this.lpf.Q,value:this.q}),a.setParamCurve(c,d,f)}},HPF:function(a,b){this.freq=new Float32Array([30]),this.q=new Float32Array([1]),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.hpf=e.createBiquadFilter(),this.hpf.type="highpass",this.out=e.createGain(),this["in"].connect(this.hpf),this.hpf.connect(this.out);
var f=[];f.push({param:this.hpf.frequency,value:this.freq}),f.push({param:this.hpf.Q,value:this.q}),a.setParamCurve(c,d,f)}},BPF:function(a,b){this.freq=new Float32Array([30]),this.q=new Float32Array([1]),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.bpf=e.createBiquadFilter(),this.bpf.type="bandpass",this.out=e.createGain(),this["in"].connect(this.bpf),this.bpf.connect(this.out);var f=[];f.push({param:this.bpf.frequency,value:this.freq}),f.push({param:this.bpf.Q,value:this.q}),a.setParamCurve(c,d,f)}},APF:function(a,b){this.freq=new Float32Array([30]),this.q=new Float32Array([1]),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.apf=e.createBiquadFilter(),this.apf.type="allpass",this.out=e.createGain(),this["in"].connect(this.apf),this.apf.connect(this.out);var f=[];f.push({param:this.apf.frequency,value:this.freq}),f.push({param:this.apf.Q,value:this.q}),a.setParamCurve(c,d,f)}},Delay:function(a,b){this.mix=new Float32Array([.5]),this.time=new Float32Array([.3]),this.feedback=new Float32Array([.5]),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.delay=e.createDelay(),this.wet=e.createGain(),this.dry=e.createGain(),this.fb=e.createGain(),this.out=e.createGain(),this["in"].connect(this.delay),this.delay.connect(this.fb),this.fb.connect(this.delay),this.delay.connect(this.wet),this.wet.connect(this.out),this["in"].connect(this.dry),this.dry.connect(this.out);var f=[];f.push({param:this.wet.gain,value:this.mix}),f.push({param:this.delay.delayTime,value:this.time}),f.push({param:this.fb.gain,value:this.feedback}),a.setParamCurve(c,d,f)}},Reverb:function(a,b){this.mix=toFloat32Array(.5),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.verb=e.createConvolver(),this.wet=e.createGain(),this.dry=e.createGain(),this.out=e.createGain(),this["in"].connect(this.verb),this.verb.connect(this.wet),this.wet.connect(this.out),this["in"].connect(this.dry),this.dry.connect(this.out);var f=Music.prototype.verbIr.length,g=e.createBuffer(1,f,a.params.sr);if(g.copyToChannel)g.copyToChannel(Music.prototype.verbIr.get(),0);else{var h=g.getChannelData(0),i=Music.prototype.verbIr.get();h.forEach(function(a,b){h[b]=i[b]})}this.verb.buffer=g,this.dryLevel=this.mix.map(function(a){return.5>=a?1:1-2*(a-.5)}),this.wetLevel=this.mix.map(function(a){return a>=.5?1:2*a});var j=[];j.push({param:this.dry.gain,value:this.dryLevel}),j.push({param:this.wet.gain,value:this.wetLevel}),a.setParamCurve(c,d,j)}},Convolver:function(a,b){this.mix=toFloat32Array(1),this.tgt=toFloat32Array(1),this.run=function(c,d){var e=b?Music.prototype.actx:Music.prototype.octx;this["in"]=e.createGain(),this.conv=e.createConvolver(),this.wet=e.createGain(),this.dry=e.createGain(),this.out=e.createGain(),this["in"].connect(this.conv),this.conv.connect(this.wet),this.wet.connect(this.out),this["in"].connect(this.dry),this.dry.connect(this.out);var f=this.tgt.length,g=e.createBuffer(1,f,a.params.sr);g.copyToChannel(this.tgt,0),this.conv.buffer=g,this.dryLevel=this.mix.map(function(a){return.5>=a?1:1-2*(a-.5)}),this.wetLevel=this.mix.map(function(a){return a>=.5?1:2*a});var h=[];h.push({param:this.dry.gain,value:this.dryLevel}),h.push({param:this.wet.gain,value:this.wetLevel}),a.setParamCurve(c,d,h)}},BitQuantizer:function(a){this.bit=new Float32Array([16]);var b=this;this.run=function(c,d){var e=Music.prototype.actx;this["in"]=e.createGain(),this.out=e.createGain(),this["in"].connect(this.out);var f=d*a.params.sr/this.bit.length;this.bit.forEach(function(a,c){a>16?a=16:1>a&&(a=1),b.bit[c]=a}),Music.prototype.offline?a.params.rendered.forEach(function(c,d){var e=Math.floor(d/f);e>b.bit.length-1&&(e=b.bit.length-1);var g=Math.pow(2,b.bit[e]);a.params.rendered[d]=Math.round(c*g)/g}):a.params.wavetable.forEach(function(c,d){var e=Math.floor(d/f);e>b.bit.length-1&&(e=b.bit.length-1);var g=Math.pow(2,b.bit[e]);a.params.wavetable[d]=Math.round(c*g)/g})}},SampleHold:function(a){this.samps=new Float32Array([1]);var b=this;this.run=function(c,d){var e=Music.prototype.actx;this["in"]=e.createGain(),this.out=e.createGain(),this["in"].connect(this.out);var f=d*a.params.sr/this.samps.length;this.samps.forEach(function(a,c){a=Math.round(a),1>a&&(a=1),b.samps[c]=a}),Music.prototype.offline?a.params.rendered.forEach(function(c,d){var e=Math.floor(d/f);e>b.samps.length-1&&(e=b.samps.length-1);var g=b.samps[e],h=0;d%g===0&&(h=c),a.params.rendered[d]=h}):a.params.wavetable.forEach(function(c,d){var e=Math.floor(d/f);e>b.samps.length-1&&(e=b.samps.length-1);var g=b.samps[e],h=0;d%g===0&&(h=c),a.params.wavetable[d]=h})}}};Music.prototype=Object.create(Function.prototype),Music.prototype.actx=dtm.wa.actx||new(window.AudioContext||window.webkitAudioContext),Music.prototype.octx=null,Music.prototype.offline=!1,Music.prototype.dummyBuffer=Music.prototype.actx.createBuffer(1,1,44100),Music.prototype.defaultSize=512,Music.prototype.defaultWt=dtm.sine(Music.prototype.defaultSize),Music.prototype.verbIr=dtm.gen("noise").size(88200).mult(dtm.gen("decay").size(44100)),Music.prototype.defaults={intDur:dtm.data([[1]]),bpm:dtm.data([[60]]),time:dtm.data([[.25]]),offset:dtm.data([[0]]),amp:dtm.data([[.5]]),note:dtm.data([[69]]),freq:dtm.data([[440]]),pitch:dtm.data([[1]]),pan:dtm.data([[0]])},Music.prototype.init=function(){var a=this,b=Music.prototype.actx;return a.params.sr=b.sampleRate,a.params.tabLen=Music.prototype.defaultSize,isFunction(arguments[0])?a.params.onNoteCallback.push(arguments[0]):isInteger(arguments[0])&&arguments[0]>0&&(a.params.tabLen=arguments[0]),a.params.baseTime=b.currentTime,a.params.wavetable=a.params.tabLen!==Music.prototype.defaultSize?dtm.sine(a.params.tabLen).get():Music.prototype.defaultWt.get(),a.params.dur.base=Music.prototype.defaults.intDur,a.params.interval.base=Music.prototype.defaults.intDur,a.params.bpm=Music.prototype.defaults.bpm,a.params.time=Music.prototype.defaults.time,a.params.offset=Music.prototype.defaults.offset,a.params.amp.base=Music.prototype.defaults.amp,a.params.note.base=Music.prototype.defaults.note,a.params.freq.base=Music.prototype.defaults.freq,a.params.pitch.base=Music.prototype.defaults.pitch,a.params.pan.base=Music.prototype.defaults.pan,a},Music.prototype.size=Music.prototype.len=function(a){var b=this;return isInteger(a)&&a>0&&(b.params.tabLen=a),b},Music.prototype.mode=function(){return this},Music.prototype.clone=function(){var a=dtm.music(),b={},c={};try{objForEach(this.params,function(a,c){["amp","note","freq","pitch","pan"].indexOf(c)>-1?(b[c]={},b[c].base=a.base.params.id!==Music.prototype.defaults[c].params.id?a.base.clone():Music.prototype.defaults[c],b[c].isFinal=a.isFinal):b[c]=a}),objForEach(this.nodes,function(a,b){c[b]=a})}catch(d){console.log(d)}return b.voiceId=Math.random(),a.meta.setParams(b).meta.setNodes(c)},Music.prototype.get=function(a){switch(a){case"dur":case"duration":return this.params.dur;case"source":return this.params.source;case"tabLen":return this.params.tabLen;case"wavetable":return this.params.wavetable;case"id":return this.params.voiceId;default:return this}},Music.prototype.play=Music.prototype.p=function(a){var b=this,c=Music.prototype.actx,d=0;return isEmpty(a)||isNumber(a)||b.offset.apply(b,arguments),b.params.pending?(console.log("what is this"),b.params.pending=!1,b.params.promise.then(function(){return b.play(),b}),b):(setTimeout(function(){b.params.lengthFixed||(b.params.lengthFixed=!0);var d=b.params.sequence?b.params.sequence[mod(b.params.iteration,b.params.sequence.length)]:b.params.iteration;(isEmpty(a)||!isNumber(a))&&b.params.offset(d).each(function(c,d,e){var f=b.params.sequence?b.params.sequence[mod(b.params.iteration+d,b.params.sequence.length)]:b.params.iteration+d;0===d?a=e.get(f):b.clone().iter(f).play(e.get(f))});var e,f=b.params.amp.base.get(d).val,g=b.params.pan.base.get(d).val;e=b.params.note.isFinal?b.params.note.base.get(d).val.map(function(a){return b.freqToPitch(mtof(a))}):b.params.freq.isFinal?b.params.freq.base.get(d).val.map(function(a){return b.freqToPitch(a)}):b.params.pitch.base.get(d).val;var h,i;h=getInterval.call(b,d),0>=h&&(h=0),!b.params.dur.auto&&b.params.interval.auto?h=i=b.params.dur.base.get(d).val[0]:b.params.dur.auto&&0!==h?"sample"===b.params.dur.auto?(b.params.tabLen=b.params.wavetable.length,i=0,e.forEach(function(a){i+=b.params.tabLen/b.params.sr/a/e.length})):i=h:i=b.params.dur.base.get(d).val[0],0>=i&&(i=.001),b.params.repeat.resetNext&&(b.params.repeat.current=b.params.repeat.max,b.params.repeat.resetNext=!1);var j;if(dtm.master.addVoice(b),Music.prototype.offline){b.params.onNoteCallback.forEach(function(a){a(b,d)});var k=new OfflineAudioContext(1,(a+4*i)*b.params.sr,b.params.sr);a+=k.currentTime,b.nodes.src=k.createBufferSource(),b.nodes.amp=k.createGain(),b.nodes.out=k.createGain(),b.nodes.fx[0].out=k.createGain(),b.nodes.src.connect(b.nodes.amp),b.nodes.amp.connect(b.nodes.fx[0].out),b.nodes.out.connect(k.destination);for(var l=1;l<b.nodes.fx.length;l++)b.nodes.fx[l].run(a,i),b.nodes.fx[l-1].out.connect(b.nodes.fx[l]["in"]);if(b.nodes.fx[l-1].out.connect(b.nodes.out),"noise"===b.params.source){b.nodes.src.buffer=k.createBuffer(1,b.params.sr/2,b.params.sr);var m=b.nodes.src.buffer.getChannelData(0);m.forEach(function(a,b){m[b]=2*Math.random()-1}),b.nodes.src.loop=!0}else b.nodes.src.buffer=k.createBuffer(1,b.params.tabLen,b.params.sr),b.nodes.src.buffer.copyToChannel(b.params.wavetable,0),b.nodes.src.loop=!0;j=[],j.push({param:b.nodes.src.playbackRate,value:e}),j.push({param:b.nodes.amp.gain,value:f}),b.setParamCurve(a,i,j),b.nodes.fx[0].out.gain.setValueAtTime(0,0),b.nodes.out.gain.setValueAtTime(.3,0),b.nodes.src.start(a),b.nodes.src.stop(a+i),k.startRendering(),k.oncomplete=function(d){b.params.rendered=d.renderedBuffer.getChannelData(0),a+=b.params.baseTime,b.nodes.rtSrc=c.createBufferSource(),b.nodes.pFx[0].out=c.createGain(),b.nodes.pan=c.createStereoPanner();var e=c.createGain();b.nodes.rtSrc.connect(b.nodes.pFx[0].out);for(var f=1;f<b.nodes.pFx.length;f++)b.nodes.pFx[f].run(a,i),b.nodes.pFx[f-1].out.connect(b.nodes.pFx[f]["in"]);b.nodes.pFx[f-1].out.connect(b.nodes.pan),b.nodes.pan.connect(e),e.connect(c.destination);var h=c.createBuffer(1,b.params.rendered.length,b.params.sr);h.copyToChannel(b.params.rendered,0),b.nodes.rtSrc.buffer=h,b.nodes.rtSrc.loop=!1,b.nodes.rtSrc.start(a),b.nodes.rtSrc.stop(a+b.nodes.rtSrc.buffer.length),b.setParamCurve(a,i,[{param:b.nodes.pan.pan,value:g}]),e.gain.setValueAtTime(1,0),b.nodes.rtSrc.onended=function(){h=void 0;try{b.nodes.rtSrc.buffer=Music.prototype.dummyBuffer}catch(a){}b.nodes.rtSrc.disconnect(0),b.nodes.rtSrc.onended=void 0,b.nodes.rtSrc=void 0,dtm.master.removeVoice(b),b.params.repeat.current>1?(b.play(),b.params.repeat.current--):b.params.repeat.resetNext=!0}}}else{var n=c.createGain();n.gain.setValueAtTime(1,0),0!==a?(b.nodes.preSrc=c.createBufferSource(),b.nodes.preSrc.buffer=Music.prototype.dummyBuffer,b.nodes.preSrc.loop=!0,b.nodes.preSrc.connect(n),b.nodes.preSrc.onended=function(){b.params.onNoteCallback.forEach(function(a){a(b,d)})},b.nodes.preSrc.start(c.currentTime),b.nodes.preSrc.stop(c.currentTime+a)):b.params.onNoteCallback.forEach(function(a){a(b,d)}),a+=b.params.repeat.nextTime?b.params.repeat.nextTime:c.currentTime,b.params.repeat.nextTime=a+h,b.params.startTime=a,b.nodes.src=c.createBufferSource(),b.nodes.amp=c.createGain(),b.nodes.pFx[0].out=c.createGain(),c.createStereoPanner?b.nodes.pan=c.createStereoPanner():(b.nodes.left=c.createGain(),b.nodes.right=c.createGain(),b.nodes.merger=c.createChannelMerger(2));var o=c.createGain(),p=c.createGain();b.nodes.src.connect(b.nodes.amp),b.nodes.amp.connect(o),o.connect(b.nodes.pFx[0].out);for(var l=1;l<b.nodes.pFx.length;l++)b.nodes.pFx[l].run(a,i),b.nodes.pFx[l-1].out.connect(b.nodes.pFx[l]["in"]);c.createStereoPanner?(b.nodes.pFx[l-1].out.connect(b.nodes.pan),b.nodes.pan.connect(p)):(b.nodes.pFx[l-1].out.connect(b.nodes.left),b.nodes.pFx[l-1].out.connect(b.nodes.right),b.nodes.left.connect(b.nodes.merger,0,0),b.nodes.right.connect(b.nodes.merger,0,1),b.nodes.merger.connect(p)),b.nodes.itvSrc=c.createBufferSource(),b.nodes.itvSrc.buffer=Music.prototype.dummyBuffer,b.nodes.itvSrc.loop=!0,b.nodes.itvSrc.connect(n),n.connect(p);var q=c.createBuffer(1,b.params.tabLen,b.params.sr);if(q.copyToChannel)q.copyToChannel(b.params.wavetable,0);else{var r=q.getChannelData(0);r.forEach(function(a,c){r[c]=b.params.wavetable[c]})}if(b.nodes.src.buffer=q,b.nodes.src.loop="sample"!==b.params.type,b.params.monitor.process||p.connect(c.destination),b.params.monitor.state){b.nodes.monitor=c.createScriptProcessor(b.params.monitor.block,1,1);var s=dtm.data();b.nodes.monitor.onaudioprocess="phasor"===b.params.mode?function(){var a=b.phase();b.params.phasor.base&&(a=b.params.phasor.base(d).get(a*b.params.phasor.base.get(d).length)),isFunction(b.params.monitor.grab)?b.params.monitor.grab(s.set(a),d):b.params.monitor.grab.set(a)}:function(a){var c=a.inputBuffer.getChannelData(0);if(isFunction(b.params.monitor.grab)){var d=b.params.monitor.grab(s.set(c));if(b.params.monitor.process){var e=a.outputBuffer.getChannelData(0);d!==e.length&&d.fit(e.length);for(var f=0,g=e.length;g>f;f++)e[f]=d.get(f)}}else b.params.monitor.grab.set(c)};var t=c.createGain();t.gain.setValueAtTime(b.params.monitor.process?1:0,0),p.connect(b.nodes.monitor).connect(t).connect(c.destination)}var u=new Promise(function(a){b.nodes.itvSrc.onended=function(){h>=i&&dtm.master.removeVoice(b),b.params.repeat.current>1?(b.play(),b.params.repeat.current--):(b.params.repeat.resetNext=!0,b.params.monitor.state),b.params.offNoteCallback.forEach(function(a){a(b,d)})},b.nodes.src.onended=function(){i>h&&dtm.master.removeVoice(b),b.params.monitor.state&&(b.nodes.monitor.onaudioprocess=null,b.nodes.monitor.disconnect(),b.nodes.monitor=null),b.params.playing=!1},a()});if(u.then(function(){b.nodes.itvSrc.start(a),b.nodes.itvSrc.stop(a+h),b.nodes.src.start(a+1e-5),b.nodes.src.stop(a+i+1e-5),b.params.playing=!0}),j=[],j.push({param:b.nodes.src.playbackRate,value:e}),j.push({param:b.nodes.amp.gain,value:f}),b.setParamCurve(a,i,j),c.createStereoPanner)b.setParamCurve(a,i,[{param:b.nodes.pan.pan,value:g}]);else{var v=g.map(function(a){return 0>a?.5:.5-.5*a}),w=g.map(function(a){return 0>a?.5+.5*a:.5});b.setParamCurve(a,i,[{param:b.nodes.left.gain,value:v}]),b.setParamCurve(a,i,[{param:b.nodes.right.gain,value:w}])}b.nodes.pFx[0].out.gain.setValueAtTime(1,0),p.gain.setValueAtTime(1,0);var x=.002;o.gain.setValueAtTime(0,a),o.gain.linearRampToValueAtTime(1,a+x),o.gain.setTargetAtTime(0,a+i-x,.3*x)}b.params.iteration++},d),b)},Music.prototype.start=function(){return this.interval.apply(this,arguments),this.rep().play(),this},Music.prototype.trigger=Music.prototype.trig=Music.prototype.t=function(){return this.offset.apply(this,arguments),this.mute().play(),this},Music.prototype.run=Music.prototype.r=function(){return this.interval.apply(this,arguments),this.mute().rep().play(),this},Music.prototype.stop=Music.prototype.s=function(a){var b=this;return b.params.repeat.current=0,b.params.repeat.resetNext=!0,setTimeout(function(){isNumber(a)||(a=Music.prototype.actx.currentTime),b.nodes.src&&b.nodes.src.stop(a),b.nodes.itvSrc&&b.nodes.itvSrc.stop(a),b.nodes.rtSrc&&b.nodes.rtSrc.stop(a),b.params.monitor.state=!1,b.nodes.monitor&&(b.nodes.monitor.onaudioprocess=null,b.nodes.monitor.disconnect()),dtm.master.removeVoice(b)},b.meta.deferIncr),b},Music.prototype.aft=Music.prototype.after=Music.prototype.offset=function(){var a=argsToArray(arguments);return check(a)&&(this.params.offset=convert(a)),this},Music.prototype.mute=function(a){if(isBoolean(a)){var b=a?0:1;this.gain(b)}else this.gain(0);return this},Music.prototype.unmute=function(){return this.gain(1),this},Music.prototype.sync=Music.prototype.follow=function(a){return isDtmSynth(a)&&(this.interval(a),this.bpm(a),this.time(a),this.seq(a)),this},Music.prototype.mimic=function(a){return isDtmSynth(a)&&(this.interval(a),this.bpm(a),this.time(a),this.seq(a),this.note(a),this.amplitude(a),this.pan(a),this.wavetable(a)),this},Music.prototype.each=Music.prototype["do"]=Music.prototype.on=Music.prototype.onnote=function(a){return isFunction(a)&&this.params.onNoteCallback.push(a),this},Music.prototype.off=Music.prototype.offnote=function(a){return isFunction(a)&&this.params.offNoteCallback.push(a),this},Music.prototype.sequence=Music.prototype.seq=function(a){if(("reset"===a||"clear"===a||a===[])&&(this.params.sequence=null),isDtmSynth(a))this.params.sequence=[a.seq()];else if(argsAreSingleVals(arguments)&&arguments.length>1)isNumOrFloat32Array(argsToArray(arguments))&&(this.params.sequence=argsToArray(arguments));else if(isNumber(a))this.params.sequence=[a];else if(isNumOrFloat32Array(a))this.params.sequence=a;else{if(!isNumDtmArray(a))return this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;this.params.sequence=a.get()}return this},Music.prototype.iter=Music.prototype.incr=function(a){return isInteger(a)?(this.params.iteration=a,this):this.params.iteration},Music.prototype.scan=Music.prototype.phase=function(a,b){if(isDtmArray(a)||isFunction(a))return this.params.mode="phasor",isNumber(b)||(b=1024),this.params.monitor.state=!0,this.params.monitor.grab=a,this.params.monitor.block=b,this;var c;return c=!this.params.dur.auto&&this.params.interval.auto?this.params.dur.base:this.params.dur.auto||this.params.interval.auto?this.params.interval.base:this.params.interval.base,this.params.phase=(Music.prototype.actx.currentTime-this.params.startTime)/c(this.seq()).get(0),this.params.phase<0?this.params.phase=0:this.params.phase>1&&(this.params.phase=1),this.params.phase},Music.prototype.repeat=Music.prototype.rep=function(a){return isInteger(a)&&a>0?this.params.repeat.max=a:(isEmpty(a)||1/0===a||a===!0)&&(this.params.repeat.max=1/0),this.params.repeat.resetNext=!0,this},Music.prototype.every=Music.prototype.at=Music.prototype.interval=Music.prototype["int"]=Music.prototype.i=function(){var a=2;if(0===arguments.length)return this.params.interval.base();var b;if(isDtmSynth(arguments[0]))b=arguments[0].interval(),this.params.interval.base=check(b,a)?convertShallow(b):this.params.interval.base;else if(isFunction(arguments[0]))b=arguments[0](this.params.interval.base,this),this.params.interval.base=check(b,a)?convertShallow(b):this.params.interval.base;else{var c=argsToArray(arguments);this.params.interval.base=check(c)?convertShallow(c):this.params.interval.base}return this.params.interval.auto=!1,this.params.dur.auto&&(this.params.dur.auto="interval"),this},Music.prototype.bpm=function(){if(0===arguments.length)return this.params.bpm();var a,b=2;if(isDtmSynth(arguments[0]))a=arguments[0].bpm(),this.params.bpm=check(a,b)?convertShallow(a):this.params.bpm;else if(isFunction(arguments[0]))a=arguments[0](this.params.bpm,this),this.params.bpm=check(a,b)?convertShallow(a):this.params.bpm;else{var c=argsToArray(arguments);this.params.bpm=check(c)?convertShallow(c):this.params.bpm}return this.params.interval.auto=!1,this.params.dur.auto&&(this.params.dur.auto="interval"),this},Music.prototype.time=function(){if(0===arguments.length)return this.params.time();var a,b=2;if(isDtmSynth(arguments[0]))a=arguments[0].time(),this.params.time=check(a,b)?convertShallow(a):this.params.time;else if(isFunction(arguments[0]))a=arguments[0](this.params.time,this),this.params.time=check(a,b)?convertShallow(a):this.params.time;else{var c=argsToArray(arguments);this.params.time=check(c)?convertShallow(c):this.params.time}return this},Music.prototype["for"]=Music.prototype.duration=Music.prototype.dur=Music.prototype.d=function(){var a=this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;if(0===arguments.length)return this.params.dur.auto?this.params.interval.base(a):this.params.dur.base(a);var b,c=2;if(isDtmSynth(arguments[0]))b=arguments[0].duration(),this.params.dur.base=check(b,c)?convertShallow(b):this.params.dur.base;else if(isFunction(arguments[0]))b=arguments[0](this.params.dur.base,this),this.params.dur.base=check(b,c)?convertShallow(b):this.params.dur.base;else{var d=argsToArray(arguments);this.params.dur.base=check(d)?convertShallow(d):this.params.dur.base}return this.params.dur.auto=!1,this},Music.prototype.amplitude=Music.prototype.amp=Music.prototype.a=function(){var a=this,b=this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;if(0===arguments.length)return this.params.amp.base(b);if(isDtmSynth(arguments[0]))return this.amplitude(arguments[0].amp());if(this.mapParam(arguments,this.params.amp),a.params.playing){a.nodes.amp.gain.cancelScheduledValues(a.params.startTime);var c,d,e=a.params.amp.base.get(b).val;c=getInterval.call(a,b),0>=c&&(c=0),d=a.params.dur.auto&&0!==c?"sample"===a.params.dur.auto?c:c:a.params.dur.base.get(b).val[0],0>=d&&(d=.001),a.setParamCurve(a.params.startTime,d,[{param:a.nodes.amp.gain,value:e}])}return this},Music.prototype.frequency=Music.prototype.freq=Music.prototype.f=function(){var a=this,b=a.params.sequence?a.params.sequence[mod(a.params.iteration,a.params.sequence.length)]:a.params.iteration;if(0===arguments.length)return a.params.freq.base(b);if(isDtmSynth(arguments[0]))return a.frequency(arguments[0].freq());if(a.mapParam(arguments,a.params.freq),a.setFinal("freq"),a.params.playing){a.nodes.src.playbackRate.cancelScheduledValues(a.params.startTime);var c,d,e=a.params.freq.base.get(b).val.map(function(b){return a.freqToPitch(b)});c=getInterval.call(a,b),0>=c&&(c=0),a.params.dur.auto&&0!==c?"sample"===a.params.dur.auto?(a.params.tabLen=a.params.wavetable.length,d=0,e.forEach(function(b){d+=a.params.tabLen/a.params.sr/b/e.length})):d=c:d=a.params.dur.base.get(b).val[0],0>=d&&(d=.001),a.setParamCurve(a.params.startTime,d,[{param:a.nodes.src.playbackRate,value:e}])}return a},Music.prototype.notenum=Music.prototype.note=Music.prototype.nn=Music.prototype.n=function(){var a=this,b=a.params.sequence?a.params.sequence[mod(a.params.iteration,a.params.sequence.length)]:a.params.iteration;if(0===arguments.length)return a.params.note.base(b);if(isDtmSynth(arguments[0]))return a.note(arguments[0].note());if(1===arguments.length&&isDtmArray(arguments[0])&&arguments[0].params.isTarget&&arguments[0].attach(a,a.note),a.mapParam(arguments,a.params.note),a.setFinal("note"),a.params.playing){a.nodes.src.playbackRate.cancelScheduledValues(a.params.startTime);var c,d,e=a.params.note.base.get(b).val.map(function(b){return a.freqToPitch(mtof(b))});c=getInterval.call(a,b),0>=c&&(c=0),a.params.dur.auto&&0!==c?"sample"===a.params.dur.auto?(a.params.tabLen=a.params.wavetable.length,d=0,e.forEach(function(b){d+=a.params.tabLen/a.params.sr/b/e.length})):d=c:d=a.params.dur.base.get(b).val[0],0>=d&&(d=.001),a.setParamCurve(a.params.startTime,d,[{param:a.nodes.src.playbackRate,value:e}])}return a},Music.prototype.pitch=function(){var a=this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;return 0===arguments.length?this.params.pitch.base(a):isDtmSynth(arguments[0])?this.pitch(arguments[0].pitch()):(this.mapParam(arguments,this.params.pitch),this.setFinal("pitch"),this)},Music.prototype.pan=function(){var a=this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;return 0===arguments.length?this.params.pan.base(a):isDtmSynth(arguments[0])?this.pan(arguments[0].pan()):(this.mapParam(arguments,this.params.pan),this)},Music.prototype.osc=Music.prototype.w=Music.prototype.wave=Music.prototype.wf=Music.prototype.waveform=Music.prototype.wt=Music.prototype.wavetable=function(a){var b=this;if(0===arguments.length)return dtm.data(b.params.wavetable);if(isDtmSynth(arguments[0]))return b.wavetable(arguments[0].wavetable());if(a=typeCheck(a),isFloat32Array(a)?b.params.lengthFixed?b.params.wavetable=b.params.tabLen!==a.length?dtm.data(a).step(b.params.tabLen).get():a:(b.params.wavetable=a,b.params.tabLen=a.length):isFunction(a)?b.params.promise?b.params.promise.then(function(){b.params.wavetable=toFloat32Array(a(dtm.data(b.params.wavetable)))}):(b.params.wavetable=toFloat32Array(a(dtm.data(b.params.wavetable))),b.params.tabLen=b.params.wavetable.length):(b.params.wavetable=new Float32Array(b.params.tabLen),b.params.wavetable.forEach(function(a,c){b.params.wavetable[c]=Math.sin(2*Math.PI*c/b.params.tabLen)})),1===arguments.length&&isDtmArray(arguments[0])&&arguments[0].params.isTarget&&arguments[0].attach(b,b.wavetable),b.params.playing)if(b.params.wavetable.length!==b.params.tabLen&&(b.params.wavetable=dtm.data(b.params.wavetable).step(b.params.tabLen).get()),b.nodes.src.buffer.copyToChannel)b.nodes.src.buffer.copyToChannel(b.params.wavetable,0);else{var c=b.nodes.src.buffer.getChannelData(0);c.forEach(function(a,d){c[d]=b.params.wavetable[d]})}return b},Music.prototype.sample=Music.prototype.load=function(a){var b=this;if("noise"===a)b.params.wavetable=dtm.gen("noise").size(44100).get(),b.freq(1);else if(isString(a)){b.params.pending=!0,b.params.source=a,b.params.type="sample",b.pitch(1);var c=new XMLHttpRequest;c.open("GET",a,!0),c.responseType="arraybuffer",b.params.promise=new Promise(function(a){c.onreadystatechange=function(){4==c.readyState&&200==c.status&&Music.prototype.actx.decodeAudioData(c.response,function(c){b.params.wavetable=c.getChannelData(0),b.params.dur.auto&&(b.params.dur.auto="sample"),a(b)})}}),c.send()}return b},Music.prototype.mapParam=function(a,b,c){var d,e;("base"===c||"undefined"==typeof c)&&(isFunction(a[0])?(d=a[0](b.base,this),b.base=check(d)?convert(d):b):(e=argsToArray(a),b.base=check(e)?convert(e):b))},Music.prototype.freqToPitch=function(a){var b=this;if(isFloat32Array(a)){var c=new Float32Array(a.length);return a.forEach(function(a,d){c[d]=a*b.params.tabLen/b.params.sr}),c}return isNumber(a)?a*b.params.tabLen/b.params.sr:void 0},Music.prototype.setParamCurve=function(a,b,c){var d=this;c.forEach(function(c){var e=100;d.params.curve||d.params.sr*b/c.value.length<e?(1===c.value.length&&c.value.push(c.value[0]),c.param.setValueCurveAtTime(toFloat32Array(c.value),a,b)):c.value.forEach(function(d,e){c.param.setValueAtTime(d,a+e/c.value.length*b),e===c.value.length-1&&c.param.setValueAtTime(d,a+b)})})},Music.prototype.setFinal=function(a){var b=this;["note","freq","pitch"].forEach(function(c){b.params[c].isFinal=c===a})},Music.prototype.gain=function(a,b){b=isBoolean(b)?b:this.params.rtFxOnly;var c=new fx.Gain(this,b);return a=typeCheck(a),a&&(c.mult=a),b?this.nodes.pFx.push(c):this.nodes.fx.push(c),this},Music.prototype.lpf=function(a,b,c){c=isBoolean(c)?c:this.params.rtFxOnly;var d=new fx.LPF(this,c);return a=typeCheck(a),a&&(d.freq=a),b=typeCheck(b),b&&(d.q=b),c?this.nodes.pFx.push(d):this.nodes.fx.push(d),this},Music.prototype.hpf=function(a,b,c){c=isBoolean(c)?c:this.params.rtFxOnly;var d=new fx.HPF(this,c);return a=typeCheck(a),a&&(d.freq=a),b=typeCheck(b),b&&(d.q=b),c?this.nodes.pFx.push(d):this.nodes.fx.push(d),this},Music.prototype.bpf=function(a,b,c){c=isBoolean(c)?c:this.params.rtFxOnly;var d=new fx.BPF(this,c);return a=typeCheck(a),a&&(d.freq=a),b=typeCheck(b),b&&(d.q=b),c?this.nodes.pFx.push(d):this.nodes.fx.push(d),this},Music.prototype.apf=function(a,b,c){c=isBoolean(c)?c:this.params.rtFxOnly;var d=new fx.APF(this,c);return a=typeCheck(a),a&&(d.freq=a),b=typeCheck(b),b&&(d.q=b),c?this.nodes.pFx.push(d):this.nodes.fx.push(d),this},Music.prototype.delay=function(a,b,c,d){d=isBoolean(d)?d:this.params.rtFxOnly;var e=new fx.Delay(this,d);return a=typeCheck(a),a&&(e.mix=a),b=typeCheck(b),b&&(e.time=b),c=typeCheck(c),c&&(e.feedback=c),d?this.nodes.pFx.push(e):this.nodes.fx.push(e),this},Music.prototype.reverb=Music.prototype.verb=function(a,b){b=isBoolean(b)?b:this.params.rtFxOnly;var c=new fx.Reverb(this,b);return a=typeCheck(a),a&&(c.mix=a),b?this.nodes.pFx.push(c):this.nodes.fx.push(c),this},Music.prototype.convolve=Music.prototype.conv=function(a,b,c){c=isBoolean(c)?c:this.params.rtFxOnly;var d=new fx.Convolver(this,c);return a=typeCheck(a),a&&(d.tgt=a),b=typeCheck(b),b&&(d.mix=b),c?this.nodes.pFx.push(d):this.nodes.fx.push(d),this},Music.prototype.bitquantize=Music.prototype.bq=function(a){var b=new fx.BitQuantizer(this);return a=typeCheck(a),a&&(b.bit=a),this.nodes.pFx.push(b),this},Music.prototype.samphold=Music.prototype.sh=function(a){var b=new fx.SampleHold(this);return a=typeCheck(a),a&&(b.samps=a),this.nodes.pFx.push(b),this},Music.prototype.monitor=function(a,b){return isNumber(b)||(b=1024),(isDtmArray(a)||isFunction(a))&&(this.params.monitor.state=!0,this.params.monitor.grab=a,this.params.monitor.block=b),this},Music.prototype.process=function(a,b){return isNumber(b)||(b=1024),(isDtmArray(a)||isFunction(a))&&(this.params.monitor.state=!0,this.params.monitor.process=!0,this.params.monitor.grab=a,this.params.monitor.block=b),this},Music.prototype.curve=Music.prototype.phasor=function(){var a=this.params.sequence?this.params.sequence[mod(this.params.iteration,this.params.sequence.length)]:this.params.iteration;return 0===arguments.length?this.params.phasor(a):isDtmSynth(arguments[0])?this.phasor(arguments[0].phasor()):(this.mapParam(arguments,this.params.phasor),this)},Music.prototype.fft=function(){return this},dtm.startWebAudio(),dtm.midi=function(){var a=new MIDI;return a.init.apply(a,arguments)},MIDI.prototype=Object.create(Function.prototype),MIDI.prototype.out=null,MIDI.prototype.defaults={note:dtm.data([[69]]),pitchbend:dtm.data([[0]]),velocity:dtm.data([[100]]),duration:dtm.data([[1]]),channel:dtm.data([[1]])},MIDI.prototype.synth=function(){},MIDI.prototype.notes={},MIDI.prototype.oninput=function(a){if(console.log(a),144===a.data[0])MIDI.prototype.notes[a.data[1]]=MIDI.prototype.synth(dtm.data(a.data[1]));else if(128===a.data[0])try{MIDI.prototype.notes[a.data[1]].stop(),delete MIDI.prototype.notes[a.data[1]]}catch(b){console.log(b)}},dtm.midi.input=function(a){MIDI.prototype.synth=a},MIDI.prototype.init=function(){var a=this;return isEmpty(MIDI.prototype.out)&&(navigator.requestMIDIAccess?navigator.requestMIDIAccess({sysex:!1}).then(function(a){for(var b=[],c=a.outputs.values(),d=c.next();d&&!d.done;d=c.next())b.push(d.value);MIDI.prototype.devices=b,MIDI.prototype.out=b[0]},null):console.log("No MIDI support in your browser.")),objForEach(MIDI.prototype.defaults,function(b,c){a.params[c]=b}),this},MIDI.prototype.play=function(){var a=this;if(MIDI.prototype.out){var b=MIDI.prototype.out;setTimeout(function(){var c=0,d=a.params.duration.get(c).get(0);a.params.pitchbend!==MIDI.prototype.defaults.pitchbend?dtm.music().phasor(function(d){var e=a.params.pitchbend(c).phase(d,"step").range(0,16383,-1,1).round().val[0],f=Math.floor(e/128),g=e-128*f;b.send([224,g,f])},256).trigger()["for"](d):b.send([224,0,64]);var e=a.params.note.get(c);d/=e.length;var f=a.params.channel.get(c);f.length!==e.length&&(f=f().step(e.length)),dtm.music().onnote(function(a,c){b.send([143+f(c).val[0],e(c).val[0],100])}).offnote(function(a,c){b.send([143+f(c).val[0],e(c).val[0],0])}).trigger().every(d).rep(e.length)})}return this},MIDI.prototype.stop=function(){return this},MIDI.prototype.note=function(){var a=argsToArray(arguments);return this.params.note=convert(a),this},MIDI.prototype.pitchbend=function(){var a=argsToArray(arguments);return this.params.pitchbend=convert(a),this},MIDI.prototype["for"]=function(){var a=argsToArray(arguments);return this.params.duration=convert(a),this},MIDI.prototype.ch=MIDI.prototype.channel=function(){var a=argsToArray(arguments);return this.params.channel=convert(a),this},dtm.startWebMidi(),dtm.master={type:"dtm.master",params:{data:null,index:0,level:.5,mute:!1,tempo:120,time:[4,4],beat:0,measure:0,section:0,scale:[0,1,2,3,4,5,6,7,8,9,10,11],cummulatedRhythm:null,transposition:0,chord:null,tonalFunc:null,maxNumVoices:500,voices:[]},totalComplexity:0,complexityLimit:10,numActiveModels:0,activeInstrs:[],voices:[],maxNumVoices:0,models:[],clock:null,start:function(){return dtm.master
},stop:function(){dtm.clocks.forEach(function(a){a.stop(),a.clear()}),dtm.master.activeInstrs.forEach(function(a){a.stop()}),dtm.clocks=[],dtm.master.voices=[],dtm.master.activeInstrs=[],dtm.params.traced.forEach(function(a){a.params.trace=!1}),dtm.cache.audioStream.forEach(function(a){a.audio&&a.audio.remove(),a.input.disconnect(),a.input=null,a.sp.onaudioprocess=null,a.sp.disconnect(),a.sp=null,a.gain.disconnect(),a.gain=null}),dtm.cache.audioStream=[]},transpose:function(a){return dtm.master.transposition=a,dtm.master},data:function(a){return isEmpty(a)||(dtm.master.params.data=a),dtm.master},model:function(){return dtm.master},get:function(a){switch(a){case"index":return dtm.master.params.index;case"clock":return dtm.master.clock;default:return null}},set:function(){return dtm.master},setNumVoices:function(a){return isInteger(a)&&a>0&&(dtm.master.params.maxNumVoices=a),dtm.master},suppressVoices:function(){return dtm.master.params.voices.length>dtm.master.params.maxNumVoices&&(dtm.master.params.voices[0].stop(),dtm.master.params.voices.splice(0,1),dtm.master.suppressVoices()),dtm.master},addVoice:function(a){return dtm.master.params.voices.push(a),dtm.master.suppressVoices(),dtm.master},removeVoice:function(a){return dtm.master.params.voices.forEach(function(b,c){b.get("id")===a.get("id")&&dtm.master.params.voices.splice(c,1)}),dtm.master},panic:function(){return dtm.master.params.voices.forEach(function(a){a.stop()}),dtm.master.params.voices=[],dtm.master},state:null,reset:null},dtm.stop=function(){dtm.master.stop(),dtm.master.panic()},function(){var a,b,c=dtm.model("unipolar").register(),d=dtm.data();return c["default"](function(){if(1===arguments.length){var c=arguments[0];isNumber(c)?d.set(c):"string"==typeof c?d.set(c).split().classify():isArray(c)?isNumOrFloat32Array(c)?d.set(c):d.set(c).split().classify():isDtmArray(c)&&(d=c.clone(),"string"===d.get("type")&&d.classify())}else if(arguments.length>1){var e=argsToArray(arguments);isNumOrFloat32Array(e)?d.set(e):isStringArray(e)&&d.set(e).split().classify()}return d.normalize(a,b)}),c.domain=function(){if(argsAreSingleVals(arguments)&&2==arguments.length){var c=argsToArray(arguments);isNumOrFloat32Array(c)&&(a=c[0],b=c[1])}else argIsSingleArray(arguments)&&isNumOrFloat32Array(arguments[0])&&2==arguments[0].length&&(a=arguments[0][0],b=arguments[0][1])},c}(),function(){var a,b,c=dtm.model("bipolar").register(),d=dtm.data();return c["default"](function(){if(1===arguments.length){var c=arguments[0];isNumber(c)?d.set(c):isString(c)?d.set(c).split().classify():isArray(c)?isNumOrFloat32Array(c)?d.set(c):d.set(c).split().classify():isDtmArray(c)&&(d=c.clone(),"string"===d.get("type")&&d.classify())}else if(arguments.length>1){var e=argsToArray(arguments);isNumArray(e)?d.set(e):isStringArray(e)&&d.set(e).split().classify()}return d.normalize(a,b).range(-1,1)}),c.domain=function(){if(argsAreSingleVals(arguments)&&2==arguments.length){var c=argsToArray(arguments);isNumArray(c)&&(a=c[0],b=c[1])}else argIsSingleArray(arguments)&&isNumArray(arguments[0])&&2==arguments[0].length&&(a=arguments[0][0],b=arguments[0][1])},c}(),function(){var a=dtm.model("huffman").register();return a.build=function(){return console.log("meow"),a},a}(),function(){var a,b,c,d=dtm.model("mtf").register(),e=dtm.data(),f=[];return d["default"](function(){var d=arguments[0];return a=d.get("classes"),d.forEach(function(d){c=a.indexOf(d),f.push(c),b=a.splice(c,1),a.unshift(b[0])}),e.set(f)}),d.getTable=function(){return a},d}(),function(){var a=dtm.model("image-scan").register(),b=dtm.data(),c=30,d=(dtm.data([0,4,5,7,10,14]),100);return a.data=function(c){return b=c.t(),a},a.play=function(){return setTimeout(function(){new Promise(function(a){var c=b().each.mean().flatten().range(0,70,0,1).save(),d=dtm.scale().filter(function(a){return"chromatic"!==a.get("name")}).max(function(a){return c().pq(a).snr().get(0)}).flatten();a(d)}).then(function(a){b.r(0,70,0,1).pq(a),b.forEach(function(a,e){e%Math.ceil(b.length/d)===0&&dtm.music().play().dur(c).amp(dtm.array(3/d).mult(dtm.rise())).nn(dtm.array(30).add(a).add(dtm.rand(1,-.2,.2))).pan(e/b.length*2-1).delay()})})},0),a},a.dur=function(b){return c=b,a},a.pq=function(b){return b=dtm.scale(b),a},a.scale=a.pq,a.numVoices=function(b){return d=b,a},a.voice=a.voices=a.numVoices,a}()}();