/*! osc.js 2.0.3, Copyright 2016 Colin Clark | github.com/colinbdclark/osc.js */ var osc=osc||{};!function(){"use strict";osc.SECS_70YRS=2208988800,osc.TWO_32=4294967296,osc.defaults={metadata:!1,unpackSingleArgs:!0},osc.isBufferEnv="undefined"!=typeof Buffer,osc.isCommonJS="undefined"!=typeof module&&module.exports,osc.isNode=osc.isCommonJS&&"undefined"==typeof window,osc.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},osc.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},osc.isBuffer=function(a){return osc.isBufferEnv&&a instanceof Buffer};var a="undefined"!=typeof dcodeIO?dcodeIO.Long:"undefined"!=typeof a?a:osc.isNode?require("long"):void 0;osc.dataView=function(a,b,c){return a.buffer?new DataView(a.buffer,b,c):a instanceof ArrayBuffer?new DataView(a,b,c):new DataView(new Uint8Array(a),b,c)},osc.byteArray=function(a){if(a instanceof Uint8Array)return a;var b=a.buffer?a.buffer:a;if(!(b instanceof ArrayBuffer||"undefined"!=typeof b.length&&"string"!=typeof b))throw new Error("Can't wrap a non-array-like object as Uint8Array. Object was: "+JSON.stringify(a,null,2));return new Uint8Array(b)},osc.nativeBuffer=function(a){return osc.isBufferEnv&&osc.isNode?osc.isBuffer(a)?a:new Buffer(a.buffer?a:new Uint8Array(a)):osc.isTypedArrayView(a)?a:new Uint8Array(a)},osc.copyByteArray=function(a,b,c){if(osc.isTypedArrayView(a)&&osc.isTypedArrayView(b))b.set(a,c);else for(var d=void 0===c?0:c,e=Math.min(b.length-c,a.length),f=0,g=d;e>f;f++,g++)b[g]=a[f];return b},osc.readString=function(a,b){for(var c=[],d=b.idx;dd?void 0:osc.writePrimitive(d,b,"setUint32",4,c)},osc.readBlob=function(a,b){var c=osc.readInt32(a,b),d=c+3&-4,e=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,e},osc.writeBlob=function(a){a=osc.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,e=c+d,f=new Uint8Array(e),g=new DataView(f.buffer);return osc.writeInt32(b,g),f.set(a,d),f},osc.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},osc.writeMIDIBytes=function(a){a=osc.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},osc.readColor=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4),d=c[3]/255;return b.idx+=4,{r:c[0],g:c[1],b:c[2],a:d}},osc.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},osc.readTrue=function(){return!0},osc.readFalse=function(){return!1},osc.readNull=function(){return null},osc.readImpulse=function(){return 1},osc.readTimeTag=function(a,b){var c=osc.readPrimitive(a,"getUint32",4,b),d=osc.readPrimitive(a,"getUint32",4,b),e=0===c&&1===d?Date.now():osc.ntpToJSTime(c,d);return{raw:[c,d],"native":e}},osc.writeTimeTag=function(a){var b=a.raw?a.raw:osc.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return osc.writeInt32(b[0],d,0),osc.writeInt32(b[1],d,4),c},osc.timeTag=function(a,b){a=a||0,b=b||Date.now();var c=b/1e3,d=Math.floor(c),e=c-d,f=Math.floor(a),g=a-f,h=e+g;if(h>1){var i=Math.floor(h),j=h-i;f+=i,h=j}var k=d+f+osc.SECS_70YRS,l=Math.round(osc.TWO_32*h);return{raw:[k,l]}},osc.ntpToJSTime=function(a,b){var c=a-osc.SECS_70YRS,d=b/osc.TWO_32,e=1e3*(c+d);return e},osc.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,e=c+osc.SECS_70YRS,f=Math.round(osc.TWO_32*d);return[e,f]},osc.readArguments=function(a,b,c){var d=osc.readString(a,c);if(0!==d.indexOf(","))throw new Error("A malformed type tag string was found while reading the arguments of an OSC message. String was: "+d," at offset: "+c.idx);var e=d.substring(1).split(""),f=[];return osc.readArgumentsIntoArray(f,e,d,a,b,c),f},osc.readArgument=function(a,b,c,d,e){var f=osc.argumentTypes[a];if(!f)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var g=f.reader,h=osc[g](c,e);return d.metadata&&(h={type:a,value:h}),h},osc.readArgumentsIntoArray=function(a,b,c,d,e,f){for(var g=0;gk)throw new Error("Invalid argument type tag: an open array type tag ('[') was found without a matching close array tag ('[]'). Type tag was: "+c);var l=j.slice(0,k);h=osc.readArgumentsIntoArray([],l,c,d,e,f),g+=k+2}else h=osc.readArgument(i,c,d,e,f),g++;a.push(h)}return a},osc.writeArguments=function(a,b){var c=osc.collectArguments(a,b);return osc.joinParts(c)},osc.joinParts=function(a){for(var b=new Uint8Array(a.byteLength),c=a.parts,d=0,e=0;e