/*! osc.js 2.0.3, Copyright 2016 Colin Clark | github.com/colinbdclark/osc.js */ !function(a,b){"object"==typeof exports?(a.osc=exports,b(exports,require("slip"),require("EventEmitter"),require("long"))):"function"==typeof define&&define.amd?define(["exports","slip","EventEmitter","long"],function(c,d,e,f){return a.osc=c,a.osc,b(c,d,e,f)}):(a.osc={},b(a.osc,slip,EventEmitter))}(this,function(a,b,c,d){var e=e||{};!function(){"use strict";e.SECS_70YRS=2208988800,e.TWO_32=4294967296,e.defaults={metadata:!1,unpackSingleArgs:!0},e.isBufferEnv="undefined"!=typeof Buffer,e.isCommonJS="undefined"!=typeof module&&module.exports,e.isNode=e.isCommonJS&&"undefined"==typeof window,e.isArray=function(a){return a&&"[object Array]"===Object.prototype.toString.call(a)},e.isTypedArrayView=function(a){return a.buffer&&a.buffer instanceof ArrayBuffer},e.isBuffer=function(a){return e.isBufferEnv&&a instanceof Buffer};var a="undefined"!=typeof dcodeIO?dcodeIO.Long:"undefined"!=typeof a?a:e.isNode?require("long"):void 0;e.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)},e.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)},e.nativeBuffer=function(a){return e.isBufferEnv&&e.isNode?e.isBuffer(a)?a:new Buffer(a.buffer?a:new Uint8Array(a)):e.isTypedArrayView(a)?a:new Uint8Array(a)},e.copyByteArray=function(a,b,c){if(e.isTypedArrayView(a)&&e.isTypedArrayView(b))b.set(a,c);else for(var d=void 0===c?0:c,f=Math.min(b.length-c,a.length),g=0,h=d;f>g;g++,h++)b[h]=a[g];return b},e.readString=function(a,b){for(var c=[],d=b.idx;dd?void 0:e.writePrimitive(d,b,"setUint32",4,c)},e.readBlob=function(a,b){var c=e.readInt32(a,b),d=c+3&-4,f=new Uint8Array(a.buffer,b.idx,c);return b.idx+=d,f},e.writeBlob=function(a){a=e.byteArray(a);var b=a.byteLength,c=b+3&-4,d=4,f=c+d,g=new Uint8Array(f),h=new DataView(g.buffer);return e.writeInt32(b,h),g.set(a,d),g},e.readMIDIBytes=function(a,b){var c=new Uint8Array(a.buffer,b.idx,4);return b.idx+=4,c},e.writeMIDIBytes=function(a){a=e.byteArray(a);var b=new Uint8Array(4);return b.set(a),b},e.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}},e.writeColor=function(a){var b=Math.round(255*a.a),c=new Uint8Array([a.r,a.g,a.b,b]);return c},e.readTrue=function(){return!0},e.readFalse=function(){return!1},e.readNull=function(){return null},e.readImpulse=function(){return 1},e.readTimeTag=function(a,b){var c=e.readPrimitive(a,"getUint32",4,b),d=e.readPrimitive(a,"getUint32",4,b),f=0===c&&1===d?Date.now():e.ntpToJSTime(c,d);return{raw:[c,d],"native":f}},e.writeTimeTag=function(a){var b=a.raw?a.raw:e.jsToNTPTime(a["native"]),c=new Uint8Array(8),d=new DataView(c.buffer);return e.writeInt32(b[0],d,0),e.writeInt32(b[1],d,4),c},e.timeTag=function(a,b){a=a||0,b=b||Date.now();var c=b/1e3,d=Math.floor(c),f=c-d,g=Math.floor(a),h=a-g,i=f+h;if(i>1){var j=Math.floor(i),k=i-j;g+=j,i=k}var l=d+g+e.SECS_70YRS,m=Math.round(e.TWO_32*i);return{raw:[l,m]}},e.ntpToJSTime=function(a,b){var c=a-e.SECS_70YRS,d=b/e.TWO_32,f=1e3*(c+d);return f},e.jsToNTPTime=function(a){var b=a/1e3,c=Math.floor(b),d=b-c,f=c+e.SECS_70YRS,g=Math.round(e.TWO_32*d);return[f,g]},e.readArguments=function(a,b,c){var d=e.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 f=d.substring(1).split(""),g=[];return e.readArgumentsIntoArray(g,f,d,a,b,c),g},e.readArgument=function(a,b,c,d,f){var g=e.argumentTypes[a];if(!g)throw new Error("'"+a+"' is not a valid OSC type tag. Type tag string was: "+b);var h=g.reader,i=e[h](c,f);return d.metadata&&(i={type:a,value:i}),i},e.readArgumentsIntoArray=function(a,b,c,d,f,g){for(var h=0;hl)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 m=k.slice(0,l);i=e.readArgumentsIntoArray([],m,c,d,f,g),h+=l+2}else i=e.readArgument(j,c,d,f,g),h++;a.push(i)}return a},e.writeArguments=function(a,b){var c=e.collectArguments(a,b);return e.joinParts(c)},e.joinParts=function(a){for(var b=new Uint8Array(a.byteLength),c=a.parts,d=0,f=0;f