MIDI.js/build/MIDI.min.js
Michael Deal b9757cab9b grunt
2013-01-22 16:46:32 -08:00

1 line
63 KiB
JavaScript

if(typeof Color=="undefined")var Color={};typeof Color.Space=="undefined"&&(Color.Space={}),function(){"use strict";var useEval=!1,functions={},shortcuts={"HEX24>HSL":"HEX24>RGB>HSL","HEX32>HSLA":"HEX32>RGBA>HSLA","HEX24>CMYK":"HEX24>RGB>CMY>CMYK","RGB>CMYK":"RGB>CMY>CMYK"},root=Color.Space=function(color,route){shortcuts[route]&&(route=shortcuts[route]);var r=route.split(">");if(typeof color=="object"&&color[0]>=0){var type=r[0],tmp={};for(var i=0;i<type.length;i++){var str=type.substr(i,1);tmp[str]=color[i]}color=tmp}if(functions[route])return functions[route](color);var f="color";for(var pos=1,key=r[0];pos<r.length;pos++)pos>1&&(key=key.substr(key.indexOf("_")+1)),key+=(pos===0?"":"_")+r[pos],color=root[key](color),useEval&&(f="Color.Space."+key+"("+f+")");return useEval&&(functions[route]=eval("(function(color) { return "+f+" })")),color};root.RGB_W3=function(e){return"rgb("+(e.R>>0)+","+(e.G>>0)+","+(e.B>>0)+")"},root.RGBA_W3=function(e){var t=typeof e.A=="number"?e.A/255:1;return"rgba("+(e.R>>0)+","+(e.G>>0)+","+(e.B>>0)+","+t+")"},root.W3_RGB=function(e){var e=e.substr(4,e.length-5).split(",");return{R:parseInt(e[0]),G:parseInt(e[1]),B:parseInt(e[2])}},root.W3_RGBA=function(e){var e=e.substr(5,e.length-6).split(",");return{R:parseInt(e[0]),G:parseInt(e[1]),B:parseInt(e[2]),A:parseFloat(e[3])*255}},root.HSL_W3=function(e){return"hsl("+(e.H+.5>>0)+","+(e.S+.5>>0)+"%,"+(e.L+.5>>0)+"%)"},root.HSLA_W3=function(e){var t=typeof e.A=="number"?e.A/255:1;return"hsla("+(e.H+.5>>0)+","+(e.S+.5>>0)+"%,"+(e.L+.5>>0)+"%,"+t+")"},root.W3_HSL=function(e){var e=e.substr(4,e.length-5).split(",");return{H:parseInt(e[0]),S:parseInt(e[1]),L:parseInt(e[2])}},root.W3_HSLA=function(e){var e=e.substr(5,e.length-6).split(",");return{H:parseInt(e[0]),S:parseInt(e[1]),L:parseInt(e[2]),A:parseFloat(e[3])*255}},root.W3_HEX=root.W3_HEX24=function(e){return e.substr(0,1)==="#"&&(e=e.substr(1)),e.length===3&&(e=e[0]+e[0]+e[1]+e[1]+e[2]+e[2]),parseInt("0x"+e)},root.W3_HEX32=function(e){return e.substr(0,1)==="#"&&(e=e.substr(1)),e.length===6?parseInt("0xFF"+e):parseInt("0x"+e)},root.HEX_W3=root.HEX24_W3=function(e,t){t||(t=6),e||(e=0);var n=e.toString(16),r=n.length;while(r<t)n="0"+n,r++;var r=n.length;while(r>t)n=n.substr(1),r--;return"#"+n},root.HEX32_W3=function(e){return root.HEX_W3(e,8)},root.HEX_RGB=root.HEX24_RGB=function(e){return{R:e>>16,G:e>>8&255,B:e&255}},root.HEX32_RGBA=function(e){return{R:e>>>16&255,G:e>>>8&255,B:e&255,A:e>>>24}},root.RGBA_HEX32=function(e){return(e.A<<24|e.R<<16|e.G<<8|e.B)>>>0},root.RGB_HEX24=root.RGB_HEX=function(e){return e.R<0&&(e.R=0),e.G<0&&(e.G=0),e.B<0&&(e.B=0),e.R>255&&(e.R=255),e.G>255&&(e.G=255),e.B>255&&(e.B=255),e.R<<16|e.G<<8|e.B},root.RGB_CMY=function(e){return{C:1-e.R/255,M:1-e.G/255,Y:1-e.B/255}},root.RGBA_HSLA=root.RGB_HSL=function(e){var t=e.R/255,n=e.G/255,r=e.B/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=s-i,u,a,f=(s+i)/2;if(o===0)u=0,a=0;else{f<.5?a=o/(s+i):a=o/(2-s-i);var l=((s-t)/6+o/2)/o,c=((s-n)/6+o/2)/o,h=((s-r)/6+o/2)/o;t===s?u=h-c:n===s?u=1/3+l-h:r===s&&(u=2/3+c-l),u<0&&(u+=1),u>1&&(u-=1)}return{H:u*360,S:a*100,L:f*100,A:e.A}},root.RGBA_HSVA=root.RGB_HSV=function(e){var t=e.R/255,n=e.G/255,r=e.B/255,i=Math.min(t,n,r),s=Math.max(t,n,r),o=s-i,u,a,f=s;if(o===0)u=0,a=0;else{a=o/s;var l=((s-t)/6+o/2)/o,c=((s-n)/6+o/2)/o,h=((s-r)/6+o/2)/o;t===s?u=h-c:n===s?u=1/3+l-h:r===s&&(u=2/3+c-l),u<0&&(u+=1),u>1&&(u-=1)}return{H:u*360,S:a*100,V:f*100,A:e.A}},root.CMY_RGB=function(e){return{R:Math.max(0,(1-e.C)*255),G:Math.max(0,(1-e.M)*255),B:Math.max(0,(1-e.Y)*255)}},root.CMY_CMYK=function(e){var t=e.C,n=e.M,r=e.Y,i=Math.min(r,Math.min(n,Math.min(t,1)));return t=Math.round((t-i)/(1-i)*100),n=Math.round((n-i)/(1-i)*100),r=Math.round((r-i)/(1-i)*100),i=Math.round(i*100),{C:t,M:n,Y:r,K:i}},root.CMYK_CMY=function(e){return{C:e.C*(1-e.K)+e.K,M:e.M*(1-e.K)+e.K,Y:e.Y*(1-e.K)+e.K}},root.HSLA_RGBA=root.HSL_RGB=function(e){var t=e.H/360,n=e.S/100,r=e.L/100,i,s,o,u,a,f;return n===0?i=s=o=r:(r<.5?a=r*(1+n):a=r+n-n*r,u=2*r-a,f=t+1/3,f<0&&(f+=1),f>1&&(f-=1),6*f<1?i=u+(a-u)*6*f:2*f<1?i=a:3*f<2?i=u+(a-u)*(2/3-f)*6:i=u,f=t,f<0&&(f+=1),f>1&&(f-=1),6*f<1?s=u+(a-u)*6*f:2*f<1?s=a:3*f<2?s=u+(a-u)*(2/3-f)*6:s=u,f=t-1/3,f<0&&(f+=1),f>1&&(f-=1),6*f<1?o=u+(a-u)*6*f:2*f<1?o=a:3*f<2?o=u+(a-u)*(2/3-f)*6:o=u),{R:i*255,G:s*255,B:o*255,A:e.A}},root.HSVA_RGBA=root.HSV_RGB=function(e){var t=e.H/360,n=e.S/100,r=e.V/100,i,s,o,u,a,f;if(n===0)i=s=o=Math.round(r*255);else{t>=1&&(t=0),t=6*t,u=t-Math.floor(t),a=Math.round(255*r*(1-n)),o=Math.round(255*r*(1-n*u)),f=Math.round(255*r*(1-n*(1-u))),r=Math.round(255*r);switch(Math.floor(t)){case 0:i=r,s=f,o=a;break;case 1:i=o,s=r,o=a;break;case 2:i=a,s=r,o=f;break;case 3:i=a,s=o,o=r;break;case 4:i=f,s=a,o=r;break;case 5:i=r,s=a,o=o}}return{R:i,G:s,B:o,A:e.A}}}();if(typeof MIDI=="undefined")var MIDI={};(function(){"use strict";var e={},t=function(t){var n=new Audio,r=t.split(";")[0];n.id="audio",n.setAttribute("preload","auto"),n.setAttribute("audiobuffer",!0),n.addEventListener("canplaythrough",function(){e[r]=!0},!1),n.src="data:"+t,document.body.appendChild(n)};MIDI.audioDetect=function(n){if(typeof Audio=="undefined")return n({});var r=new Audio;if(typeof r.canPlayType=="undefined")return n(e);var i=r.canPlayType('audio/ogg; codecs="vorbis"');i=i==="probably"||i==="maybe";var s=r.canPlayType("audio/mpeg");s=s==="probably"||s==="maybe";if(!i&&!s){n(e);return}i&&t("audio/ogg;base64,T2dnUwACAAAAAAAAAADqnjMlAAAAAOyyzPIBHgF2b3JiaXMAAAAAAUAfAABAHwAAQB8AAEAfAACZAU9nZ1MAAAAAAAAAAAAA6p4zJQEAAAANJGeqCj3//////////5ADdm9yYmlzLQAAAFhpcGguT3JnIGxpYlZvcmJpcyBJIDIwMTAxMTAxIChTY2hhdWZlbnVnZ2V0KQAAAAABBXZvcmJpcw9CQ1YBAAABAAxSFCElGVNKYwiVUlIpBR1jUFtHHWPUOUYhZBBTiEkZpXtPKpVYSsgRUlgpRR1TTFNJlVKWKUUdYxRTSCFT1jFloXMUS4ZJCSVsTa50FkvomWOWMUYdY85aSp1j1jFFHWNSUkmhcxg6ZiVkFDpGxehifDA6laJCKL7H3lLpLYWKW4q91xpT6y2EGEtpwQhhc+211dxKasUYY4wxxsXiUyiC0JBVAAABAABABAFCQ1YBAAoAAMJQDEVRgNCQVQBABgCAABRFcRTHcRxHkiTLAkJDVgEAQAAAAgAAKI7hKJIjSZJkWZZlWZameZaouaov+64u667t6roOhIasBACAAAAYRqF1TCqDEEPKQ4QUY9AzoxBDDEzGHGNONKQMMogzxZAyiFssLqgQBKEhKwKAKAAAwBjEGGIMOeekZFIi55iUTkoDnaPUUcoolRRLjBmlEluJMYLOUeooZZRCjKXFjFKJscRUAABAgAMAQICFUGjIigAgCgCAMAYphZRCjCnmFHOIMeUcgwwxxiBkzinoGJNOSuWck85JiRhjzjEHlXNOSuekctBJyaQTAAAQ4AAAEGAhFBqyIgCIEwAwSJKmWZomipamiaJniqrqiaKqWp5nmp5pqqpnmqpqqqrrmqrqypbnmaZnmqrqmaaqiqbquqaquq6nqrZsuqoum65q267s+rZru77uqapsm6or66bqyrrqyrbuurbtS56nqqKquq5nqq6ruq5uq65r25pqyq6purJtuq4tu7Js664s67pmqq5suqotm64s667s2rYqy7ovuq5uq7Ks+6os+75s67ru2rrwi65r66os674qy74x27bwy7ouHJMnqqqnqq7rmarrqq5r26rr2rqmmq5suq4tm6or26os67Yry7aumaosm64r26bryrIqy77vyrJui67r66Ys67oqy8Lu6roxzLat+6Lr6roqy7qvyrKuu7ru+7JuC7umqrpuyrKvm7Ks+7auC8us27oxuq7vq7It/KosC7+u+8Iy6z5jdF1fV21ZGFbZ9n3d95Vj1nVhWW1b+V1bZ7y+bgy7bvzKrQvLstq2scy6rSyvrxvDLux8W/iVmqratum6um7Ksq/Lui60dd1XRtf1fdW2fV+VZd+3hV9pG8OwjK6r+6os68Jry8ov67qw7MIvLKttK7+r68ow27qw3L6wLL/uC8uq277v6rrStXVluX2fsSu38QsAABhwAAAIMKEMFBqyIgCIEwBAEHIOKQahYgpCCKGkEEIqFWNSMuakZM5JKaWUFEpJrWJMSuaclMwxKaGUlkopqYRSWiqlxBRKaS2l1mJKqcVQSmulpNZKSa2llGJMrcUYMSYlc05K5pyUklJrJZXWMucoZQ5K6iCklEoqraTUYuacpA46Kx2E1EoqMZWUYgupxFZKaq2kFGMrMdXUWo4hpRhLSrGVlFptMdXWWqs1YkxK5pyUzDkqJaXWSiqtZc5J6iC01DkoqaTUYiopxco5SR2ElDLIqJSUWiupxBJSia20FGMpqcXUYq4pxRZDSS2WlFosqcTWYoy1tVRTJ6XFklKMJZUYW6y5ttZqDKXEVkqLsaSUW2sx1xZjjqGkFksrsZWUWmy15dhayzW1VGNKrdYWY40x5ZRrrT2n1mJNMdXaWqy51ZZbzLXnTkprpZQWS0oxttZijTHmHEppraQUWykpxtZara3FXEMpsZXSWiypxNhirLXFVmNqrcYWW62ltVprrb3GVlsurdXcYqw9tZRrrLXmWFNtBQAADDgAAASYUAYKDVkJAEQBAADGMMYYhEYpx5yT0ijlnHNSKucghJBS5hyEEFLKnINQSkuZcxBKSSmUklJqrYVSUmqttQIAAAocAAACbNCUWByg0JCVAEAqAIDBcTRNFFXVdX1fsSxRVFXXlW3jVyxNFFVVdm1b+DVRVFXXtW3bFn5NFFVVdmXZtoWiqrqybduybgvDqKqua9uybeuorqvbuq3bui9UXVmWbVu3dR3XtnXd9nVd+Bmzbeu2buu+8CMMR9/4IeTj+3RCCAAAT3AAACqwYXWEk6KxwEJDVgIAGQAAgDFKGYUYM0gxphhjTDHGmAAAgAEHAIAAE8pAoSErAoAoAADAOeecc84555xzzjnnnHPOOeecc44xxhhjjDHGGGOMMcYYY4wxxhhjjDHGGGOMMcYYY0wAwE6EA8BOhIVQaMhKACAcAABACCEpKaWUUkoRU85BSSmllFKqFIOMSkoppZRSpBR1lFJKKaWUIqWgpJJSSimllElJKaWUUkoppYw6SimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaWUUkoppZRSSimllFJKKaVUSimllFJKKaWUUkoppRQAYPLgAACVYOMMK0lnhaPBhYasBAByAwAAhRiDEEJpraRUUkolVc5BKCWUlEpKKZWUUqqYgxBKKqmlklJKKbXSQSihlFBKKSWUUkooJYQQSgmhlFRCK6mEUkoHoYQSQimhhFRKKSWUzkEoIYUOQkmllNRCSB10VFIpIZVSSiklpZQ6CKGUklJLLZVSWkqpdBJSKamV1FJqqbWSUgmhpFZKSSWl0lpJJbUSSkklpZRSSymFVFJJJYSSUioltZZaSqm11lJIqZWUUkqppdRSSiWlkEpKqZSSUmollZRSaiGVlEpJKaTUSimlpFRCSamlUlpKLbWUSkmptFRSSaWUlEpJKaVSSksppRJKSqmllFpJKYWSUkoplZJSSyW1VEoKJaWUUkmptJRSSymVklIBAEAHDgAAAUZUWoidZlx5BI4oZJiAAgAAQABAgAkgMEBQMApBgDACAQAAAADAAAAfAABHARAR0ZzBAUKCwgJDg8MDAAAAAAAAAAAAAACAT2dnUwAEAAAAAAAAAADqnjMlAgAAADzQPmcBAQA="),s&&t("audio/mpeg;base64,/+MYxAAAAANIAUAAAASEEB/jwOFM/0MM/90b/+RhST//w4NFwOjf///PZu////9lns5GFDv//l9GlUIEEIAAAgIg8Ir/JGq3/+MYxDsLIj5QMYcoAP0dv9HIjUcH//yYSg+CIbkGP//8w0bLVjUP///3Z0x5QCAv/yLjwtGKTEFNRTMuOTeqqqqqqqqqqqqq/+MYxEkNmdJkUYc4AKqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqqq");var o=(new Date).getTime(),u=window.setInterval(function(){for(var t in e);var r=(new Date).getTime(),i=r-o>5e3;if(t||i)window.clearInterval(u),n(e)},1)}})();if(typeof MIDI=="undefined")var MIDI={};typeof MIDI.Soundfont=="undefined"&&(MIDI.Soundfont={}),function(){"use strict";var e=!1;MIDI.loadPlugin=function(e){typeof e=="function"&&(e={callback:e});var r=e.instruments||e.instrument||"acoustic_grand_piano";typeof r!="object"&&(r=[r]),r.map(function(e){return typeof e=="number"&&(e=MIDI.GeneralMIDI.byId[e]),e}),MIDI.soundfontUrl=e.soundfontUrl||MIDI.soundfontUrl||"./soundfont/",MIDI.audioDetect(function(i){var s="";typeof s=="undefined"&&(n[window.location.hash]?s=window.location.hash.substr(1):s=""),s===""&&(window.webkitAudioContext?s="webaudio":window.Audio?s="audiotag":s="flash");if(!t[s])return;var o=i["audio/ogg"]?"ogg":"mp3";t[s](o,r,e.callback)})};var t={};t.java=function(e,t,n){MIDI.loader&&MIDI.loader.message("Java API..."),MIDI.Java.connect(n)},t.flash=function(e,t,n){MIDI.loader&&MIDI.loader.message("Flash API..."),DOMLoader.script.add({src:"./inc/SoundManager2/script/soundmanager2.js",verify:"SoundManager",callback:function(){MIDI.Flash.connect(n)}})},t.audiotag=function(t,n,s){MIDI.loader&&MIDI.loader.message("HTML5 Audio API...");var o=i({items:n,getNext:function(n){e?DOMLoader.sendRequest({url:MIDI.soundfontUrl+n+"-"+t+".js",onprogress:r,onload:function(e){MIDI.Soundfont[n]=JSON.parse(e.responseText),MIDI.loader&&MIDI.loader.update(null,"Downloading",100),o.getNext()}}):DOMLoader.script.add({src:MIDI.soundfontUrl+n+"-"+t+".js",verify:n,callback:function(){MIDI.loader&&MIDI.loader.update(null,"Downloading...",100),o.getNext()}})},onComplete:function(){MIDI.AudioTag.connect(s)}})},t.webaudio=function(t,n,s){MIDI.loader&&MIDI.loader.message("Web Audio API...");var o=i({items:n,getNext:function(n){e?DOMLoader.sendRequest({url:MIDI.soundfontUrl+n+"-"+t+".js",onprogress:r,onload:function(e){MIDI.Soundfont[n]=JSON.parse(e.responseText),MIDI.loader&&MIDI.loader.update(null,"Downloading...",100),o.getNext()}}):DOMLoader.script.add({src:MIDI.soundfontUrl+n+"-"+t+".js",verify:"MIDI.Soundfont."+n,callback:function(){MIDI.loader&&MIDI.loader.update(null,"Downloading...",100),o.getNext()}})},onComplete:function(){MIDI.WebAudioAPI.connect(s)}})};var n={"#webaudio":!0,"#audiotag":!0,"#java":!0,"#flash":!0},r=function(e){this.totalSize||(this.getResponseHeader("Content-Length-Raw")?this.totalSize=parseInt(this.getResponseHeader("Content-Length-Raw")):this.totalSize=e.total);var t=this.totalSize?Math.round(e.loaded/this.totalSize*100):"";MIDI.loader&&MIDI.loader.update(null,"Downloading...",t)},i=function(e){var t={};t.queue=[];for(var n in e.items)t.queue.push(e.items[n]);return t.getNext=function(){if(!t.queue.length)return e.onComplete();e.getNext(t.queue.shift())},setTimeout(t.getNext,1),t}}();if(typeof MIDI=="undefined")var MIDI={};typeof MIDI.Player=="undefined"&&(MIDI.Player={}),function(){"use strict";var e=MIDI.Player;e.callback=undefined,e.currentTime=0,e.endTime=0,e.restart=0,e.playing=!1,e.timeWarp=1,e.start=e.resume=function(){e.currentTime<-1&&(e.currentTime=-1),f(e.currentTime)},e.pause=function(){var t=e.restart;l(),e.restart=t},e.stop=function(){l(),e.restart=0,e.currentTime=0},e.addListener=function(e){s=e},e.removeListener=function(){s=undefined},e.clearAnimation=function(){e.interval&&window.clearInterval(e.interval)},e.setAnimation=function(t){var n=typeof t=="function"?t:t.callback,r=t.interval||30,s=0,o=0,u=0;e.clearAnimation(),e.interval=window.setInterval(function(){if(e.endTime===0)return;e.playing?(s=u===e.currentTime?o-(new Date).getTime():0,e.currentTime===0?s=0:s=e.currentTime-s,u!==e.currentTime&&(o=(new Date).getTime(),u=e.currentTime)):s=e.currentTime;var t=e.endTime,r=s/t,a=s/1e3,f=a/60,l=a-f*60,c=f*60+l,h=t/1e3;if(h-c<-1)return;n({now:c,end:h,events:i})},r)},e.loadMidiFile=function(){e.replayer=new Replayer(MidiFile(e.currentData),e.timeWarp),e.data=e.replayer.getData(),e.endTime=a()},e.loadFile=function(t,n){e.stop();if(t.indexOf("base64,")!==-1){var r=window.atob(t.split(",")[1]);e.currentData=r,e.loadMidiFile(),n&&n(r);return}var i=t.split(" - ")[1]||t;document.getElementById("playback-title").innerHTML=i.replace(".mid","");var s=new XMLHttpRequest;s.open("GET",t),s.overrideMimeType("text/plain; charset=x-user-defined"),s.onreadystatechange=function(){if(this.readyState===4&&this.status===200){var t=this.responseText||"",r=[],i=t.length,s=String.fromCharCode;for(var o=0;o<i;o++)r[o]=s(t.charCodeAt(o)&255);var u=r.join("");e.currentData=u,e.loadMidiFile(),n&&n(u)}},s.send()};var t=[],n,r=0,i={},s=undefined,o=function(t,r,o,u,a,l){var c=window.setTimeout(function(){var u={channel:t,note:r,now:o,end:e.endTime,message:a,velocity:l};a===128?delete i[r]:i[r]=u,s&&s(u),e.currentTime=o,e.currentTime===n&&n<e.endTime&&f(n,!0)},o-u);return c},u=function(){return MIDI.lang==="WebAudioAPI"?MIDI.Player.ctx:(e.ctx||(e.ctx={currentTime:0}),e.ctx)},a=function(){var t=e.data,n=t.length,r=.5;for(var i=0;i<n;i++)r+=t[i][1];return r},f=function(i,s){if(!e.replayer)return;s||(typeof i=="undefined"&&(i=e.restart),e.playing&&l(),e.playing=!0,e.data=e.replayer.getData(),e.endTime=a());var f,c=0,h=0,p=e.data,d=u(),v=p.length;n=.5,r=d.currentTime;for(var m=0;m<v&&h<100;m++){n+=p[m][1];if(n<i){c=n;continue}i=n-c;var g=p[m][0].event;if(g.type!=="channel")continue;var y=g.channel;switch(g.subtype){case"noteOn":if(MIDI.channels[y].mute)break;f=g.noteNumber-(e.MIDIOffset||0),t.push({event:g,source:MIDI.noteOn(y,g.noteNumber,g.velocity,i/1e3+d.currentTime),interval:o(y,f,n,c,144,g.velocity)}),h++;break;case"noteOff":if(MIDI.channels[y].mute)break;f=g.noteNumber-(e.MIDIOffset||0),t.push({event:g,source:MIDI.noteOff(y,g.noteNumber,i/1e3+d.currentTime),interval:o(y,f,n,c,128)});break;default:}}},l=function(){var n=u();e.playing=!1,e.restart+=(n.currentTime-r)*1e3;while(t.length){var o=t.pop();window.clearInterval(o.interval);if(!o.source)continue;if(typeof o.source=="number")window.clearTimeout(o.source);else{var a=o.source;a.disconnect(0),a.noteOff(0)}}for(var f in i){var o=i[f];i[f].message===144&&s&&s({channel:o.channel,note:o.note,now:o.now,end:o.end,message:128,velocity:o.velocity})}i={}}}();if(typeof MIDI=="undefined")var MIDI={};typeof MIDI.Plugin=="undefined"&&(MIDI.Plugin={}),function(){"use strict";typeof MIDI.WebAudioAPI=="undefined"&&(MIDI.WebAudioAPI={}),(window.AudioContext||window.webkitAudioContext)&&function(){var e=window.AudioContext||window.webkitAudioContext,t=MIDI.WebAudioAPI,n,r={},i=1,s={},o=function(e,t,r,i,o){var u=MIDI.GeneralMIDI.byName[e],a=u.number,f=t[r],l=MIDI.Soundfont[e][f].split(",")[1],c=Base64Binary.decodeArrayBuffer(l);n.decodeAudioData(c,function(n){var l=f;while(l.length<3)l+="&nbsp;";typeof MIDI.loader!="undefined"&&MIDI.loader.update(null,u.instrument+"<br>Processing: "+(r/87*100>>0)+"%<br>"+l),n.id=f,i[r]=n;if(i.length===t.length){while(i.length){n=i.pop();if(!n)continue;var c=MIDI.keyToNote[n.id];s[a+""+c]=n}o(e)}})};t.setVolume=function(e){i=e},t.programChange=function(e,t){MIDI.channels[e].instrument=t},t.noteOn=function(e,t,o,u){if(!MIDI.channels[e])return;var a=MIDI.channels[e].instrument;if(!s[a+""+t])return;u<n.currentTime&&(u+=n.currentTime);var f=n.createBufferSource();r[e+""+t]=f,f.buffer=s[a+""+t],f.connect(n.destination);var l=n.createGainNode(),c=o/100*i*2-1;return l.connect(n.destination),l.gain.value=Math.max(-1,c),f.connect(l),f.noteOn(u||0),f},t.chordOn=function(e,n,r,i){var s={},o;for(var u=0,a=n.length;u<a;u++)s[o=n[u]]=t.noteOn(e,o,r,i);return s},t.noteOff=function(e,t,n){n=n||0;var i=r[e+""+t];if(!i)return;return i.gain.linearRampToValueAtTime(1,n),i.gain.linearRampToValueAtTime(0,n+.75),i.noteOff(n+.75),i},t.chordOff=function(e,n,r){var i={},s;for(var o=0,u=n.length;o<u;o++)i[s=n[o]]=t.noteOff(e,s,r);return i},t.connect=function(r){MIDI.lang="WebAudioAPI",MIDI.setVolume=t.setVolume,MIDI.programChange=t.programChange,MIDI.noteOn=t.noteOn,MIDI.noteOff=t.noteOff,MIDI.chordOn=t.chordOn,MIDI.chordOff=t.chordOff,MIDI.Player.ctx=n=new e;var i=[],s=MIDI.keyToNote;for(var u in s)i.push(u);var a=[],f={},l=function(e){delete f[e];for(var t in f)break;t||r()};for(var c in MIDI.Soundfont){f[c]=!0;for(var h=0;h<i.length;h++)o(c,i,h,a,l)}}}(),window.Audio&&function(){var e=MIDI.AudioTag={},t={},n=1,r=-1,i=[],s={};for(var o=0;o<12;o++)i[o]=new Audio;var u=function(e,t){if(!MIDI.channels[e])return;var o=MIDI.channels[e].instrument,u=MIDI.GeneralMIDI.byId[o].id,t=s[t];if(!t)return;var a=(r+1)%i.length,f=(new Date).getTime(),l=i[a];l.src=MIDI.Soundfont[u][t.id],l.volume=n,l.play(),r=a};e.programChange=function(e,t){MIDI.channels[e].instrument=t},e.setVolume=function(e){n=e},e.noteOn=function(e,n,r,i){var o=t[n];if(!s[o])return;if(i){var a=window.setTimeout(function(){u(e,o)},i*1e3);return a}u(e,o)},e.noteOff=function(e,t,n){},e.chordOn=function(e,n,r,i){for(var o in n){var a=n[o],f=t[a];if(!s[f])continue;u(e,f)}},e.chordOff=function(e,t,n){},e.stopAllNotes=function(){for(var e=0,t=i.length;e<t;e++)i[e].pause()},e.connect=function(n){var r={};for(var i in MIDI.keyToNote)t[MIDI.keyToNote[i]]=i,s[i]={id:i};MIDI.lang="AudioTag",MIDI.setVolume=e.setVolume,MIDI.programChange=e.programChange,MIDI.noteOn=e.noteOn,MIDI.noteOff=e.noteOff,MIDI.chordOn=e.chordOn,MIDI.chordOff=e.chordOff,n&&n()}}(),function(){var e=MIDI.Flash={},t={},n={};e.programChange=function(e,t){MIDI.channels[e].instrument=t},e.setVolume=function(e,t){},e.noteOn=function(e,r,i,s){if(!MIDI.channels[e])return;var o=MIDI.channels[e].instrument,u=MIDI.GeneralMIDI.byId[o].number;r=u+""+t[r];if(!n[r])return;if(s){var a=window.setTimeout(function(){n[r].play({volume:i*2})},s*1e3);return a}n[r].play({volume:i*2})},e.noteOff=function(e,t,n){},e.chordOn=function(e,r,i,s){if(!MIDI.channels[e])return;var o=MIDI.channels[e].instrument,u=MIDI.GeneralMIDI.byId[o].number;for(var a in r){var f=r[a],l=u+""+t[f];n[l]&&n[l].play({volume:i*2})}},e.chordOff=function(e,t,n){},e.stopAllNotes=function(){},e.connect=function(r){soundManager.flashVersion=9,soundManager.useHTML5Audio=!0,soundManager.url="../inc/SoundManager2/swf/",soundManager.useHighPerformance=!0,soundManager.wmode="transparent",soundManager.flashPollingInterval=1,soundManager.debugMode=!1,soundManager.onload=function(){var i=function(e,t,r){var i=MIDI.GeneralMIDI.byName[e],s=i.number;n[s+""+t]=soundManager.createSound({id:t,url:MIDI.soundfontUrl+e+"-mp3/"+t+".mp3",multiShot:!0,autoLoad:!0,onload:r})};for(var s in MIDI.Soundfont){var o=[],u=function(){o.push(this.sID);if(typeof MIDI.loader=="undefined")return;MIDI.loader.update(null,"Processing: "+this.sID)};for(var a=0;a<88;a++){var f=t[a+21];i(s,f,u)}}MIDI.lang="Flash",MIDI.setVolume=e.setVolume,MIDI.programChange=e.programChange,MIDI.noteOn=e.noteOn,MIDI.noteOff=e.noteOff,MIDI.chordOn=e.chordOn,MIDI.chordOff=e.chordOff;var l=window.setInterval(function(){if(o.length!==88)return;window.clearInterval(l),r&&r()},25)},soundManager.onerror=function(){};for(var i in MIDI.keyToNote)t[MIDI.keyToNote[i]]=i}}(),function(){var e=MIDI.Java={};e.connect=function(e){MIDI.Plugin=!1;if(!window.navigator.javaEnabled()){MIDI.Flash.connect(e);return}MIDI.Java.callback=e;var t=document.createElement("iframe");t.name="MIDIFrame",t.src="inc/midibridge/index.html",t.width=1,t.height=1,document.body.appendChild(t)},e.confirm=function(e){MIDI.programChange=function(t,n){e.sendMidiEvent(192,t,n,0)},MIDI.setVolume=function(e){},MIDI.noteOn=function(t,n,r,i){if(i){var s=window.setTimeout(function(){e.sendMidiEvent(144,t,n,r)},i*1e3);return s}e.sendMidiEvent(144,t,n,r)},MIDI.noteOff=function(t,n,r){if(r){var i=window.setTimeout(function(){e.sendMidiEvent(128,t,n,0)},r*1e3);return i}e.sendMidiEvent(128,t,n,0)},MIDI.chordOn=function(t,n,r,i){for(var s in n){var o=n[s];e.sendMidiEvent(144,t,o,100)}},MIDI.chordOff=function(t,n,r){for(var i in n){var s=n[i];e.sendMidiEvent(128,t,s,100)}},MIDI.stopAllNotes=function(){},MIDI.getInstruments=function(){return[]},e.ready?(MIDI.lang="Java",MIDI.Java.callback&&MIDI.Java.callback()):MIDI.Flash.connect(MIDI.Java.callback)}}(),MIDI.GeneralMIDI=function(e){var t=function(e){return e.replace(/[^a-z0-9 ]/gi,"").replace(/[ ]/g,"_").toLowerCase()},n={byName:{},byId:{},byCategory:{}};for(var r in e){var i=e[r];for(var s=0,o=i.length;s<o;s++){var u=i[s];if(!u)continue;var a=parseInt(u.substr(0,u.indexOf(" ")),10);u=u.replace(a+" ",""),n.byId[--a]=n.byName[t(u)]=n.byCategory[t(r)]={id:t(u),instrument:u,number:a,category:r}}}return n}({Piano:["1 Acoustic Grand Piano","2 Bright Acoustic Piano","3 Electric Grand Piano","4 Honky-tonk Piano","5 Electric Piano 1","6 Electric Piano 2","7 Harpsichord","8 Clavinet"],"Chromatic Percussion":["9 Celesta","10 Glockenspiel","11 Music Box","12 Vibraphone","13 Marimba","14 Xylophone","15 Tubular Bells","16 Dulcimer"],Organ:["17 Drawbar Organ","18 Percussive Organ","19 Rock Organ","20 Church Organ","21 Reed Organ","22 Accordion","23 Harmonica","24 Tango Accordion"],Guitar:["25 Acoustic Guitar (nylon)","26 Acoustic Guitar (steel)","27 Electric Guitar (jazz)","28 Electric Guitar (clean)","29 Electric Guitar (muted)","30 Overdriven Guitar","31 Distortion Guitar","32 Guitar Harmonics"],Bass:["33 Acoustic Bass","34 Electric Bass (finger)","35 Electric Bass (pick)","36 Fretless Bass","37 Slap Bass 1","38 Slap Bass 2","39 Synth Bass 1","40 Synth Bass 2"],Strings:["41 Violin","42 Viola","43 Cello","44 Contrabass","45 Tremolo Strings","46 Pizzicato Strings","47 Orchestral Harp","48 Timpani"],Ensemble:["49 String Ensemble 1","50 String Ensemble 2","51 Synth Strings 1","52 Synth Strings 2","53 Choir Aahs","54 Voice Oohs","55 Synth Choir","56 Orchestra Hit"],Brass:["57 Trumpet","58 Trombone","59 Tuba","60 Muted Trumpet","61 French Horn","62 Brass Section","63 Synth Brass 1","64 Synth Brass 2"],Reed:["65 Soprano Sax","66 Alto Sax","67 Tenor Sax","68 Baritone Sax","69 Oboe","70 English Horn","71 Bassoon","72 Clarinet"],Pipe:["73 Piccolo","74 Flute","75 Recorder","76 Pan Flute","77 Blown Bottle","78 Shakuhachi","79 Whistle","80 Ocarina"],"Synth Lead":["81 Lead 1 (square)","82 Lead 2 (sawtooth)","83 Lead 3 (calliope)","84 Lead 4 (chiff)","85 Lead 5 (charang)","86 Lead 6 (voice)","87 Lead 7 (fifths)","88 Lead 8 (bass + lead)"],"Synth Pad":["89 Pad 1 (new age)","90 Pad 2 (warm)","91 Pad 3 (polysynth)","92 Pad 4 (choir)","93 Pad 5 (bowed)","94 Pad 6 (metallic)","95 Pad 7 (halo)","96 Pad 8 (sweep)"],"Synth Effects":["97 FX 1 (rain)","98 FX 2 (soundtrack)","99 FX 3 (crystal)","100 FX 4 (atmosphere)","101 FX 5 (brightness)","102 FX 6 (goblins)","103 FX 7 (echoes)","104 FX 8 (sci-fi)"],Ethnic:["105 Sitar","106 Banjo","107 Shamisen","108 Koto","109 Kalimba","110 Bagpipe","111 Fiddle","112 Shanai"],Percussive:["113 Tinkle Bell","114 Agogo","115 Steel Drums","116 Woodblock","117 Taiko Drum","118 Melodic Tom","119 Synth Drum"],"Sound effects":["120 Reverse Cymbal","121 Guitar Fret Noise","122 Breath Noise","123 Seashore","124 Bird Tweet","125 Telephone Ring","126 Helicopter","127 Applause","128 Gunshot"]}),MIDI.channels=function(){var e={};for(var t=0;t<16;t++)e[t]={instrument:0,mute:!1,mono:!1,omni:!1,solo:!1};return e}(),MIDI.pianoKeyOffset=21,MIDI.keyToNote={},MIDI.noteToKey={},function(){var e=21,t=108,n=["C","Db","D","Eb","E","F","Gb","G","Ab","A","Bb","B"];for(var r=e;r<=t;r++){var i=(r-12)/12>>0,s=n[r%12]+i;MIDI.keyToNote[s]=r,MIDI.noteToKey[r]=s}}()}();var invertObject=function(e){if(e.length){var t={};for(var n=0;n<e.length;n++)t[e[n]]=n}else{var t={};for(var n in e)t[e[n]]=n}return t};typeof MusicTheory=="undefined"&&(MusicTheory={}),function(){var e=MusicTheory;e.key2number={A:0,"A#":1,Bb:1,B:2,C:3,"C#":4,Db:4,D:5,"D#":6,Eb:6,E:7,F:8,"F#":9,Gb:9,G:10,"G#":11,Ab:11},e.number2float={0:0,1:.5,2:1,3:2,4:2.5,5:3,6:3.5,7:4,8:5,9:5.5,10:6,11:6.5,12:7},e.number2key=invertObject(e.key2number),e.float2number=invertObject(e.number2float),e.getKeySignature=function(e){var t=["A","AB","B","C","CD","D","DE","E","F","FG","G","GA"],n=["F","C","G","D","A","E","B"],r={Fb:-8,Cb:-7,Gb:-6,Db:-5,Ab:-4,Eb:-3,Bb:-2,F:-1,C:0,G:1,D:2,A:3,E:4,B:5,"F#":6,"C#":7,"G#":8,"D#":9,"A#":10,"E#":11,"B#":12}[e];r<0?n=n.splice(7+r,-r).reverse().join(""):n=n.splice(0,r).join("");for(var i=0;i<t.length;i++)t[i].length>1&&(n.indexOf(t[i][0])!=-1||n.indexOf(t[i][1])!=-1?r>0?t[i]=t[i][0]+"#":t[i]=t[i][1]+"b":t[i]=t[i][0]+"#");Piano.keySignature=t},e.tempoFromTap=function(e){function t(e){var t={200:"Prestissimo",168:"Presto",140:"Vivace",120:"Allegro",112:"Allegretto",101:"Moderato",76:"Andante",66:"Adagio",60:"Larghetto",40:"Lento",0:"Larghissimo"};for(var n=0,r="";n<250;n++){t[n]&&(r=t[n]);if(e<n)return r}return"Prestissimo"}if(e.tap){var n=(new Date).getTime()-e.tap,r=1/(n/1e3)*60;Piano.tempo=r,console.log(t(r),r,n),document.getElementById("taptap").value=(r>>0)+"bmp "+t(r)}e.tap=(new Date).getTime()},e.findChord=function(e){function t(e){var t={};for(var n in e){var r={};for(var i in e[n])r[e[n][i]]=1;t[n]=r}return t}var n={},r="0 3".split(" "),i=t(Piano.chords);for(var s in i)for(var o=0,u=r.length;o<u;o++)if(isNaN(i[s][r[o]])){n[s]=1;break}var a=[];for(var s in i)n[s]||a.push(s);return document.getElementById("find").value=a,a},e.scaleInfo=function(e){var t=["r","b2","2","b3","3","4","b5","5","&#X266F;5","6","b7","7","8","b9","9","&#X266F;9","10","11","b12","12","&#X266F;12","13"],n="",r="",i="",s="",o="";for(var u in e){e[u]>0&&(i+="-"+(e[u]-a));var a=e[u],f=Piano.calculateNote(a)%12,l=Piano.keySignature[f],c=Piano.Color[Piano.HSL].english[f];s+=", "+MusicTheory.Solfege[l].syllable,o+=", "+a,n+=", "+l,r+=", "+t[a]}console.log("<b>notes:</b> "+n.substr(2)+"<br>"+"<b>solfege:</b> "+s.substr(2)+"<br>"+"<b>intervals:</b> "+r.substr(2)+"<br>"+"<b>keys:</b> "+o.substr(2)+"<br>"+"<b>gaps:</b> "+i.substr(1))}}();if(typeof MusicTheory=="undefined")var MusicTheory={};typeof MusicTheory.Synesthesia=="undefined"&&(MusicTheory.Synesthesia={}),function(e){e.data={"Isaac Newton (1704)":{ref:"Gerstner, p.167",english:["red",null,"orange",null,"yellow","green",null,"blue",null,"indigo",null,"violet"],0:[0,96,51],1:[0,0,0],2:[29,94,52],3:[0,0,0],4:[60,90,60],5:[135,76,32],6:[0,0,0],7:[248,82,28],8:[0,0,0],9:[302,88,26],10:[0,0,0],11:[325,84,46]},"Louis Bertrand Castel (1734)":{ref:"Peacock, p.400",english:["blue","blue-green","green","olive green","yellow","yellow-orange","orange","red","crimson","violet","agate","indigo"],0:[248,82,28],1:[172,68,34],2:[135,76,32],3:[79,59,36],4:[60,90,60],5:[49,90,60],6:[29,94,52],7:[360,96,51],8:[1,89,33],9:[325,84,46],10:[273,80,27],11:[302,88,26]},"George Field (1816)":{ref:"Klein, p.69",english:["blue",null,"purple",null,"red","orange",null,"yellow",null,"yellow green",null,"green"],0:[248,82,28],1:[0,0,0],2:[302,88,26],3:[0,0,0],4:[360,96,51],5:[29,94,52],6:[0,0,0],7:[60,90,60],8:[0,0,0],9:[79,59,36],10:[0,0,0],11:[135,76,32]},"D. D. Jameson (1844)":{ref:"Jameson, p.12",english:["red","red-orange","orange","orange-yellow","yellow","green","green-blue","blue","blue-purple","purple","purple-violet","violet"],0:[360,96,51],1:[14,91,51],2:[29,94,52],3:[49,90,60],4:[60,90,60],5:[135,76,32],6:[172,68,34],7:[248,82,28],8:[273,80,27],9:[302,88,26],10:[313,78,37],11:[325,84,46]},"Theodor Seemann (1881)":{ref:"Klein, p.86",english:["carmine","scarlet","orange","yellow-orange","yellow","green","green blue","blue","indigo","violet","brown","black"],0:[0,58,26],1:[360,96,51],2:[29,94,52],3:[49,90,60],4:[60,90,60],5:[135,76,32],6:[172,68,34],7:[248,82,28],8:[302,88,26],9:[325,84,46],10:[0,58,26],11:[0,0,3]},"A. Wallace Rimington (1893)":{ref:"Peacock, p.402",english:["deep red","crimson","orange-crimson","orange","yellow","yellow-green","green","blueish green","blue-green","indigo","deep blue","violet"],0:[360,96,51],1:[1,89,33],2:[14,91,51],3:[29,94,52],4:[60,90,60],5:[79,59,36],6:[135,76,32],7:[163,62,40],8:[172,68,34],9:[302,88,26],10:[248,82,28],11:[325,84,46]},"Bainbridge Bishop (1893)":{ref:"Bishop, p.11",english:["red","orange-red or scarlet","orange","gold or yellow-orange","yellow or green-gold","yellow-green","green","greenish-blue or aquamarine","blue","indigo or violet-blue","violet","violet-red","red"],0:[360,96,51],1:[1,89,33],2:[29,94,52],3:[50,93,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[163,62,40],8:[302,88,26],9:[325,84,46],10:[343,79,47],11:[360,96,51]},"H. von Helmholtz (1910)":{ref:"Helmholtz, p.22",english:["yellow","green","greenish blue","cayan-blue","indigo blue","violet","end of red","red","red","red","red orange","orange"],0:[60,90,60],1:[135,76,32],2:[172,68,34],3:[211,70,37],4:[302,88,26],5:[325,84,46],6:[330,84,34],7:[360,96,51],8:[10,91,43],9:[10,91,43],10:[8,93,51],11:[28,89,50]},"Alexander Scriabin (1911)":{ref:"Jones, p.104",english:["red","violet","yellow","steely with the glint of metal","pearly blue the shimmer of moonshine","dark red","bright blue","rosy orange","purple","green","steely with a glint of metal","pearly blue the shimmer of moonshine"],0:[360,96,51],1:[325,84,46],2:[60,90,60],3:[245,21,43],4:[211,70,37],5:[1,89,33],6:[248,82,28],7:[29,94,52],8:[302,88,26],9:[135,76,32],10:[245,21,43],11:[211,70,37]},"Adrian Bernard Klein (1930)":{ref:"Klein, p.209",english:["dark red","red","red orange","orange","yellow","yellow green","green","blue-green","blue","blue violet","violet","dark violet"],0:[0,91,40],1:[360,96,51],2:[14,91,51],3:[29,94,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[172,68,34],8:[248,82,28],9:[292,70,31],10:[325,84,46],11:[330,84,34]},"August Aeppli (1940)":{ref:"Gerstner, p.169",english:["red",null,"orange",null,"yellow",null,"green","blue-green",null,"ultramarine blue","violet","purple"],0:[0,96,51],1:[0,0,0],2:[29,94,52],3:[0,0,0],4:[60,90,60],5:[0,0,0],6:[135,76,32],7:[172,68,34],8:[0,0,0],9:[211,70,37],10:[273,80,27],11:[302,88,26]},"I. J. Belmont (1944)":{ref:"Belmont, p.226",english:["red","red-orange","orange","yellow-orange","yellow","yellow-green","green","blue-green","blue","blue-violet","violet","red-violet"],0:[360,96,51],1:[14,91,51],2:[29,94,52],3:[50,93,52],4:[60,90,60],5:[73,73,55],6:[135,76,32],7:[172,68,34],8:[248,82,28],9:[313,78,37],10:[325,84,46],11:[338,85,37]},"Steve Zieverink (2004)":{ref:"Cincinnati Contemporary Art Center",english:["yellow-green","green","blue-green","blue","indigo","violet","ultra violet","infra red","red","orange","yellow-white","yellow"],0:[73,73,55],1:[135,76,32],2:[172,68,34],3:[248,82,28],4:[302,88,26],5:[325,84,46],6:[326,79,24],7:[1,89,33],8:[360,96,51],9:[29,94,52],10:[62,78,74],11:[60,90,60]},"Circle of Fifths (2012)":{ref:"Stuart Wheatman",english:[],data:["#122400","#2E002E","#002914","#470000","#002142","#2E2E00","#290052","#003D00","#520029","#003D3D","#522900","#000080","#244700","#570057","#004D26","#7A0000","#003B75","#4C4D00","#47008F","#006100","#850042","#005C5C","#804000","#0000C7","#366B00","#80007F","#00753B","#B80000","#0057AD","#6B6B00","#6600CC","#008A00","#B8005C","#007F80","#B35900","#2424FF","#478F00","#AD00AD","#00994D","#F00000","#0073E6","#8F8F00","#8A14FF","#00AD00","#EB0075","#00A3A3","#E07000","#6B6BFF","#5CB800","#DB00DB","#00C261","#FF5757","#3399FF","#ADAD00","#B56BFF","#00D600","#FF57AB","#00C7C7","#FF9124","#9999FF","#6EDB00","#FF29FF","#00E070","#FF9999","#7ABDFF","#D1D100","#D1A3FF","#00FA00","#FFA3D1","#00E5E6","#FFC285","#C2C2FF","#80FF00","#FFA8FF","#00E070","#FFCCCC","#C2E0FF","#F0F000","#EBD6FF","#ADFFAD","#FFD6EB","#8AFFFF","#FFEBD6","#EBEBFF","#E0FFC2","#FFEBFF","#E5FFF2","#FFF5F5"]}},e.map=function(t){var n={},r=function(e,t){return[e[0]*.5+t[0]*.5+.5>>0,e[1]*.5+t[1]*.5+.5>>0,e[2]*.5+t[2]*.5+.5>>0]},i=e.data,s=i[t]||i["D. D. Jameson (1844)"];for(var o=0;o<=88;o++)if(s.data)n[o]={hsl:s.data[o],hex:s.data[o]};else{var u=s[(o+9)%12],a=u.H||u[0],f=u.S||u[1],l=u.L||u[2];a==f&&f==l&&(u=r(d,s[(o+10)%12]));var c=l/10,h=o/12>>0,p=l+c*h-3*c;n[o]={hsl:"hsla("+a+","+f+"%,"+p+"%, 1)",hex:Color.Space({H:a,S:f,L:p},"HSL>RGB>HEX>W3")};var d=u}return n}}(MusicTheory.Synesthesia);if(typeof widgets=="undefined")var widgets={};(function(){"use strict";var e=Math.PI,t=!document.createElement("canvas").getContext,n=400,r={id:"loader",bars:12,radius:0,lineWidth:20,lineHeight:70,timeout:0,display:!0};widgets.Loader=function(o){if(t)return;var u=this;typeof o=="string"&&(o={message:o}),typeof o=="boolean"&&(o={display:!1}),typeof o=="undefined"&&(o={}),o.container=o.container||document.body;if(!o.container)return;for(var a in r)typeof o[a]=="undefined"&&(o[a]=r[a]);var f=document.getElementById(o.id);if(!f){var l=document.createElement("div"),c=document.createElement("span");c.className="message",l.appendChild(c),l.className=r.id,l.style.cssText=i("opacity",n),this.span=c,this.div=l;var f=document.createElement("canvas");document.body.appendChild(f),f.id=o.id,f.style.cssText="opacity: 1; position: absolute; z-index: 10000;",l.appendChild(f),o.container.appendChild(l)}else this.span=f.parentNode.getElementsByTagName("span")[0];var h=o.delay,p=o.bars,d=o.radius,v=o.lineHeight+20,m=v*2+o.radius*2,g=s(o.container),y=g.width-m,b=g.height-m,w=window.devicePixelRatio||1;f.width=m*w,f.height=m*w;var E=0,S=f.getContext("2d");S.globalCompositeOperation="lighter",S.shadowOffsetX=1,S.shadowOffsetY=1,S.shadowBlur=1,S.shadowColor="rgba(0, 0, 0, 0.5)",this.messages={},this.message=function(e,t){return this.interval?this.add({message:e,onstart:t}):this.start(t,e)},this.update=function(e,t,n){if(!e)for(var e in this.messages);var r=this.messages[e];r.message=t,typeof n=="number"&&(r.span.innerHTML=n+"%"),t.substr(-3)==="..."?(r._message=t.substr(0,t.length-3),r.messageAnimate=[".&nbsp;&nbsp;","..&nbsp;","..."].reverse()):(r._message=t,r.messageAnimate=!1),r.element.innerHTML=t},this.add=function(e){typeof e=="string"&&(e={message:e});var t=o.background?o.background:"rgba(0,0,0,0.65)";this.span.style.cssText="background: "+t+";",this.div.style.cssText=i("opacity",n),this.stopPropagation?this.div.style.cssText+="background: rgba(0,0,0,0.25);":this.div.style.cssText+="pointer-events: none;",f.parentNode.style.opacity=1,f.parentNode.style.display="block",o.background&&(this.div.style.background=o.backgrond);var r=(new Date).getTime(),s=Math.abs(r*Math.random()>>0),u=e.message,a=document.createElement("div");a.style.cssText=i("opacity",500);var l=document.createElement("span");l.style.cssText="float: right; width: 50px;";var c=document.createElement("span");c.innerHTML=u,a.appendChild(c),a.appendChild(l);var h=this.messages[s]={seed:s,container:a,element:c,span:l,message:u,timeout:(e.timeout||o.timeout)*1e3,timestamp:r,getProgress:e.getProgress};return this.span.appendChild(a),this.span.style.display="block",this.update(h.seed,u),e.onstart&&window.setTimeout(e.onstart,50),this.center(),this.interval||(e.delay||N(),window.clearInterval(this.interval),this.interval=window.setInterval(N,30)),s},this.remove=function(e){E+=.07;var t=(new Date).getTime();typeof e=="object"&&(e=e.join(":")),e&&(e=":"+e+":");for(var n in this.messages){var r=this.messages[n];if(!e||e.indexOf(":"+r.seed+":")!==-1)delete this.messages[r.seed],r.container.style.color="#99ff88",T(r),r.getProgress&&(r.span.innerHTML="100%")}},this.start=function(e,t){if(!t&&!o.message)return;return this.add({message:t||o.message,onstart:e})},this.stop=function(){this.remove(),window.clearInterval(this.interval),delete this.interval,o.oncomplete&&o.oncomplete(),f&&f.style&&(l.style.cssText+="pointer-events: none;",window.setTimeout(function(){u.div.style.opacity=0},1),window.setTimeout(function(){if(u.interval)return;u.stopPropagation=!1,f.parentNode.style.display="none",S.clearRect(0,0,m,m)},n*1e3))},this.center=function(){var e=s(o.container),t=e.width-m,n=e.height-m;f.style.left=t/2+"px",f.style.top=n/2+"px",f.style.width=m+"px",f.style.height=m+"px",u.span.style.top=n/2+m-10+"px"};var x=document.createElement("style");x.innerHTML=".loader { color: #fff; position: fixed; left: 0; top: 0; width: 100%; height: 100%; z-index: 100000; opacity: 0; display: none; }.loader span.message { line-height: 1.5em; font-family: monospace; font-size: 14px; margin: auto; opacity: 1; display: none; border-radius: 10px; padding: 0px; width: 300px; text-align: center; position: absolute; z-index: 10000; left: 0; right: 0; }.loader span.message div { border-bottom: 1px solid #222; padding: 5px 10px; clear: both; text-align: left; opacity: 1; }.loader span.message div:last-child { border-bottom: none; }",document.head.appendChild(x);var T=function(e){window.setTimeout(function(){e.container.style.opacity=0},1),window.setTimeout(function(){e.container.parentNode.removeChild(e.container)},250)},N=function(){var t=(new Date).getTime();for(var n in u.messages){var r=u.messages[n],i=E/.07>>0;if(i%5===0&&r.getProgress){if(r.timeout&&r.timestamp&&t-r.timestamp>r.timeout){u.remove(r.seed);continue}var s=r.getProgress();if(s>=100){u.remove(r.seed);continue}r.span.innerHTML=(s>>0)+"%"}if(i%10===0&&r.messageAnimate){var a=r.messageAnimate.length,f=i/10%a,l=r._message+r.messageAnimate[f];r.element.innerHTML=l}}n||u.stop(),S.save(),S.clearRect(0,0,m*w,m*w),S.scale(w,w),S.translate(m/2,m/2);var c=360-360/p;for(var h=0;h<p;h++){var v=h/p*2*e+E;S.save(),S.translate(d*Math.sin(-v),d*Math.cos(-v)),S.rotate(v);var g=-o.lineWidth/2,y=0,b=o.lineWidth,x=o.lineHeight,T=b/2;S.beginPath(),S.moveTo(g+T,y),S.lineTo(g+b-T,y),S.quadraticCurveTo(g+b,y,g+b,y+T),S.lineTo(g+b,y+x-T),S.quadraticCurveTo(g+b,y+x,g+b-T,y+x),S.lineTo(g+T,y+x),S.quadraticCurveTo(g,y+x,g,y+x-T),S.lineTo(g,y+T),S.quadraticCurveTo(g,y,g+T,y);var N=h/(p-1)*c;S.fillStyle="hsla("+N+", 100%, 50%, 0.85)",S.fill(),S.restore()}S.restore(),E+=.07};return o.display===!1?this:(this.start(),this)};var i=function(e,t){return" -webkit-transition-property: "+e+"; -webkit-transition-duration: "+t+"ms; -moz-transition-property: "+e+"; -moz-transition-duration: "+t+"ms; -o-transition-property: "+e+"; -o-transition-duration: "+t+"ms; -ms-transition-property: "+e+"; -ms-transition-duration: "+t+"ms;"},s=function(e){if(window.innerWidth&&window.innerHeight)var t=window.innerWidth,n=window.innerHeight;else if(document.compatMode==="CSS1Compat"&&document.documentElement&&document.documentElement.offsetWidth)var t=document.documentElement.offsetWidth,n=document.documentElement.offsetHeight;else if(document.body&&document.body.offsetWidth)var t=document.body.offsetWidth,n=document.body.offsetHeight;if(e)var t=e.offsetWidth;return{width:t,height:n}}})();if(typeof DOMLoader=="undefined")var DOMLoader={};(function(){"use strict";DOMLoader.script=function(){return this.loaded={},this.loading={},this},DOMLoader.script.prototype.add=function(e){var t=this;typeof e=="string"&&(e={src:e});var n=e.srcs;typeof n=="undefined"&&(n=[{src:e.src,verify:e.verify}]);var r=document.getElementsByTagName("head")[0],i=function(e,n){if(t.loaded[e.src])return;if(n&&typeof window[n]=="undefined")return;t.loaded[e.src]=!0,t.loading[e.src]&&t.loading[e.src](),delete t.loading[e.src],e.callback&&e.callback(),typeof f!="undefined"&&f()},s=[],o=function(n){typeof n=="string"&&(n={src:n,verify:e.verify});if(/([\w\d.])$/.test(n.verify)){n.test=n.verify;if(typeof n.test=="object")for(var o in n.test)s.push(n.test[o]);else s.push(n.test)}if(t.loaded[n.src])return;var u=document.createElement("script");u.onreadystatechange=function(){if(this.readyState!=="loaded"&&this.readyState!=="complete")return;i(n)},u.onload=function(){i(n)},u.onerror=function(){},u.setAttribute("type","text/javascript"),u.setAttribute("src",n.src),r.appendChild(u),t.loading[n.src]=function(){}},u=function(t){if(t)i(t,t.test);else for(var r=0;r<n.length;r++)i(n[r],n[r].test);var o=!0;for(var r=0;r<s.length;r++){var a=s[r];if(a&&a.indexOf(".")!==-1){a=a.split(".");var f=window[a[0]];if(typeof f=="undefined")continue;a.length===2?typeof f[a[1]]=="undefined"&&(o=!1):a.length===3&&typeof f[a[1]][a[2]]=="undefined"&&(o=!1)}else typeof window[a]=="undefined"&&(o=!1)}!e.strictOrder&&o?e.callback&&e.callback():setTimeout(function(){u(t)},10)};if(e.strictOrder){var a=-1,f=function(){a++;if(!n[a])e.callback&&e.callback();else{var r=n[a],i=r.src;t.loading[i]?t.loading[i]=function(){r.callback&&r.callback(),f()}:t.loaded[i]?f():(o(r),u(r))}};f()}else{for(var a=0;a<n.length;a++)o(n[a]);u()}},DOMLoader.script=new DOMLoader.script})();if(typeof DOMLoader=="undefined")var DOMLoader={};if(typeof XMLHttpRequest=="undefined"){var XMLHttpRequest;(function(){var e=[function(){return new ActiveXObject("Msxml2.XMLHTTP")},function(){return new ActiveXObject("Msxml3.XMLHTTP")},function(){return new ActiveXObject("Microsoft.XMLHTTP")}];for(var t=0;t<e.length;t++){try{e[t]()}catch(n){continue}break}XMLHttpRequest=e[t]})()}if(typeof (new XMLHttpRequest).responseText=="undefined"){var IEBinaryToArray_ByteStr_Script="<!-- IEBinaryToArray_ByteStr -->\r\n<script type='text/vbscript'>\r\nFunction IEBinaryToArray_ByteStr(Binary)\r\n IEBinaryToArray_ByteStr = CStr(Binary)\r\nEnd Function\r\nFunction IEBinaryToArray_ByteStr_Last(Binary)\r\n Dim lastIndex\r\n lastIndex = LenB(Binary)\r\n if lastIndex mod 2 Then\r\n IEBinaryToArray_ByteStr_Last = Chr( AscB( MidB( Binary, lastIndex, 1 ) ) )\r\n Else\r\n IEBinaryToArray_ByteStr_Last = \"\"\r\n End If\r\nEnd Function\r\n</script>\r\n";document.write(IEBinaryToArray_ByteStr_Script),DOMLoader.sendRequest=function(e){function t(e){var t={};for(var n=0;n<256;n++)for(var r=0;r<256;r++)t[String.fromCharCode(n+r*256)]=String.fromCharCode(n)+String.fromCharCode(r);var i=IEBinaryToArray_ByteStr(e),s=IEBinaryToArray_ByteStr_Last(e);return i.replace(/[\s\S]/g,function(e){return t[e]})+s}var n=XMLHttpRequest();return n.open("GET",e.url,!0),e.responseType&&(n.responseType=e.responseType),e.onerror&&(n.onerror=e.onerror),e.onprogress&&(n.onprogress=e.onprogress),n.onreadystatechange=function(r){n.readyState===4&&(n.status===200?n.responseText=t(n.responseBody):n=!1,e.onload&&e.onload(n))},n.setRequestHeader("Accept-Charset","x-user-defined"),n.send(null),n}}else DOMLoader.sendRequest=function(e){var t=new XMLHttpRequest;return t.open(e.data?"POST":"GET",e.url,!0),t.overrideMimeType&&t.overrideMimeType("text/plain; charset=x-user-defined"),e.data&&t.setRequestHeader("Content-type","application/x-www-form-urlencoded"),e.responseType&&(t.responseType=e.responseType),e.onerror&&(t.onerror=e.onerror),e.onprogress&&(t.onprogress=e.onprogress),t.onreadystatechange=function(n){if(t.readyState===4){if(t.status!==200&&t.status!=304){e.onerror&&e.onerror(n,!1);return}e.onload&&e.onload(t)}},t.send(e.data),t};if(typeof Event=="undefined")var Event={};if(typeof eventjs=="undefined")var eventjs=Event;Event=function(e){"use strict";e.modifyEventListener=!1,e.modifySelectors=!1,e.add=function(e,t,r,i){return n(e,t,r,i,"add")},e.remove=function(e,t,r,i){return n(e,t,r,i,"remove")},e.stop=function(e){e.stopPropagation&&e.stopPropagation(),e.cancelBubble=!0,e.bubble=0},e.prevent=function(e){e.preventDefault&&e.preventDefault(),e.returnValue=!1},e.cancel=function(t){e.stop(t),e.prevent(t)},e.supports=function(e,t){typeof e=="string"&&(t=e,e=window),t="on"+t;if(t in e)return!0;e.setAttribute||(e=document.createElement("div"));if(e.setAttribute&&e.removeAttribute){e.setAttribute(t,"");var n=typeof e[t]=="function";return typeof e[t]!="undefined"&&(e[t]=null),e.removeAttribute(t),n}};var t=function(e){if(!e||typeof e!="object")return e;var n=new e.constructor;for(var r in e)!e[r]||typeof e[r]!="object"?n[r]=e[r]:n[r]=t(e[r]);return n},n=function(u,c,h,p,d,v){p=p||{};if(typeof u=="string"&&c==="ready"){var m=(new Date).getTime(),g=p.timeout,y=p.interval||1e3/60,b=window.setInterval(function(){(new Date).getTime()-m>g&&window.clearInterval(b),document.querySelector(u)&&(window.clearInterval(b),h())},y);return}if(typeof u=="string"){u=document.querySelectorAll(u);if(u.length===0)return i("Missing target on listener!");u.length===1&&(u=u[0])}var w,E={};if(u.length>0){for(var S=0,x=u.length;S<x;S++)w=n(u[S],c,h,t(p),d),w&&(E[S]=w);return r(E)}c.indexOf&&c.indexOf(" ")!==-1&&(c=c.split(" ")),c.indexOf&&c.indexOf(",")!==-1&&(c=c.split(","));if(typeof c!="string"){if(typeof c.length=="number")for(var T=0,N=c.length;T<N;T++)w=n(u,c[T],h,t(p),d),w&&(E[c[T]]=w);else for(var C in c)typeof c[C]=="function"?w=n(u,C,c[C],t(p),d):w=n(u,C,c[C].listener,t(c[C]),d),w&&(E[C]=w);return r(E)}if(typeof h!="function")return i("Listener is not a function!");var k=p.useCapture||!1,L=s(c)+a(u)+"."+a(h)+"."+(k?1:0);if(e.Gesture&&e.Gesture._gestureHandlers[c]){if(d==="remove"){if(!o[L])return;o[L].remove(),delete o[L]}else if(d==="add"){if(o[L])return o[L];if(p.useCall&&!e.modifyEventListener){var A=h;h=function(e,t){for(var n in t)e[n]=t[n];return A.call(u,e)}}p.gesture=c,p.target=u,p.listener=h,p.fromOverwrite=v,o[L]=e.proxy[c](p)}}else{c=s(c);if(d==="remove"){if(!o[L])return;u[l](c,h,k),delete o[L]}else if(d==="add"){if(o[L])return o[L];u[f](c,h,k),o[L]={type:c,target:u,listener:h,remove:function(){e.remove(u,c,h,p)}}}}return o[L]},r=function(e){return{remove:function(){for(var t in e)e[t].remove()},add:function(){for(var t in e)e[t].add()}}},i=function(e){if(typeof console=="undefined")return;if(typeof console.error=="undefined")return;console.error(e)},s=function(){var t={};return function(n){return e.pointerType||(window.navigator.msPointerEnabled?(e.pointerType="mspointer",t={mousedown:"MSPointerDown",mousemove:"MSPointerMove",mouseup:"MSPointerUp"}):e.supports("touchstart")?(e.pointerType="touch",t={mousedown:"touchstart",mouseup:"touchend",mousemove:"touchmove"}):e.pointerType="mouse"),t[n]&&(n=t[n]),document.addEventListener?n:"on"+n}}(),o={},u=0,a=function(e){return e===window?"#window":e===document?"#document":e?(e.uniqueID||(e.uniqueID="id"+u++),e.uniqueID):i("Missing target on listener!")},f=document.addEventListener?"addEventListener":"attachEvent",l=document.removeEventListener?"removeEventListener":"detachEvent";return e.createPointerEvent=function(t,n,r){var i=n.gesture,s=n.target,o=t.changedTouches||e.proxy.getCoords(t);if(o.length){var u=o[0];n.pointers=r?[]:o,n.pageX=u.pageX,n.pageY=u.pageY,n.x=n.pageX,n.y=n.pageY}var a=document.createEvent("Event");a.initEvent(i,!0,!0),a.originalEvent=t;for(var f in n)a[f]=n[f];s.dispatchEvent(a)},e.modifyEventListener&&function(){var t=function(t){var r=function(r){var i=r+"EventListener",o=t[i];t[i]=function(t,i,u){if(e.Gesture&&e.Gesture._gestureHandlers[t]){var a=u;typeof u=="object"?a.useCall=!0:a={useCall:!0,useCapture:u},n(this,t,i,a,r,!0),o.call(this,t,i,u)}else o.call(this,s(t),i,u)}};r("add"),r("remove")};navigator.userAgent.match(/Firefox/)?(t(HTMLDivElement.prototype),t(HTMLCanvasElement.prototype)):t(HTMLElement.prototype),t(document),t(window)}(),e.modifySelectors&&function(){var e=NodeList.prototype;e.removeEventListener=function(e,t,n){for(var r=0,i=this.length;r<i;r++)this[r].removeEventListener(e,t,n)},e.addEventListener=function(e,t,n){for(var r=0,i=this.length;r<i;r++)this[r].addEventListener(e,t,n)}}(),e}(Event);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.pointerSetup=function(e,t){e.doc=e.target.ownerDocument||e.target,e.minFingers=e.minFingers||e.fingers||1,e.maxFingers=e.maxFingers||e.fingers||Infinity,e.position=e.position||"relative",t=t||{},t.gesture=e.gesture,t.target=e.target,t.pointerType=Event.pointerType,Event.modifyEventListener&&e.fromOverwrite&&(e.listener=Event.createPointerEvent);var n=0,r=t.gesture.indexOf("pointer")===0&&Event.modifyEventListener?"pointer":"mouse";return t.proxy=function(n){t.defaultListener=e.listener,e.listener=n,n(e.event,t)},t.remove=function(){e.onPointerDown&&Event.remove(e.target,r+"down",e.onPointerDown),e.onPointerMove&&Event.remove(e.doc,r+"move",e.onPointerMove),e.onPointerUp&&Event.remove(e.doc,r+"up",e.onPointerUp)},t.resume=function(t){e.onPointerMove&&(!t||t.move)&&Event.add(e.doc,r+"move",e.onPointerMove),e.onPointerUp&&(!t||t.move)&&Event.add(e.doc,r+"up",e.onPointerUp),e.fingers=n},t.pause=function(t){n=e.fingers,e.onPointerMove&&(!t||t.move)&&Event.remove(e.doc,r+"move",e.onPointerMove),e.onPointerUp&&(!t||t.up)&&Event.remove(e.doc,r+"up",e.onPointerUp),e.fingers=0},t},e.pointerStart=function(t,n,r){var i=function(e,t){var n=r.bbox,i=o[t]={};switch(r.position){case"absolute":i.offsetX=0,i.offsetY=0;break;case"difference":i.offsetX=e.pageX,i.offsetY=e.pageY;break;case"move":i.offsetX=e.pageX-n.x1,i.offsetY=e.pageY-n.y1;break;default:i.offsetX=n.x1,i.offsetY=n.y1}if(r.position==="relative")var s=(e.pageX+n.scrollLeft-i.offsetX)*n.scaleX,u=(e.pageY+n.scrollTop-i.offsetY)*n.scaleY;else var s=e.pageX-i.offsetX,u=e.pageY-i.offsetY;i.rotation=0,i.scale=1,i.startTime=i.moveTime=(new Date).getTime(),i.move={x:s,y:u},i.start={x:s,y:u},r.fingers++};r.event=t,n.defaultListener&&(r.listener=n.defaultListener,delete n.defaultListener);var s=!r.fingers,o=r.tracker,u=t.changedTouches||e.getCoords(t),a=u.length;for(var f=0;f<a;f++){var l=u[f],c=l.identifier||Infinity;if(r.fingers){if(r.fingers>=r.maxFingers){var h=[];for(var c in r.tracker)h.push(c);return n.identifier=h.join(","),s}var p=0;for(var d in o){if(o[d].up){delete o[d],i(l,c),r.cancel=!0;break}p++}if(o[c])continue;i(l,c)}else o=r.tracker={},n.bbox=r.bbox=e.getBoundingBox(r.target),r.fingers=0,r.cancel=!1,i(l,c)}var h=[];for(var c in r.tracker)h.push(c);return n.identifier=h.join(","),s},e.pointerEnd=function(e,t,n,r){var i=e.touches||[],s=i.length,o={};for(var u=0;u<s;u++){var a=i[u];o[a.identifier||Infinity]=!0}for(var f in n.tracker){var l=n.tracker[f];!o[f]&&!l.up&&(r&&(e.changedTouches=[{pageX:l.pageX,pageY:l.pageY,identifier:f==="Infinity"?Infinity:f}],r(e,"up")),n.tracker[f].up=!0,n.fingers--)}if(n.fingers!==0)return!1;var c=[];n.gestureFingers=0;for(var h in n.tracker)n.gestureFingers++,c.push(h);return t.identifier=c.join(","),!0},e.getCoords=function(t){return typeof t.pageX!="undefined"?e.getCoords=function(e){return Array({type:"mouse",x:e.pageX,y:e.pageY,pageX:e.pageX,pageY:e.pageY,identifier:Infinity})}:e.getCoords=function(e){return e=e||window.event,Array({type:"mouse",x:e.clientX+document.documentElement.scrollLeft,y:e.clientY+document.documentElement.scrollTop,pageX:e.clientX+document.documentElement.scrollLeft,pageY:e.clientY+document.documentElement.scrollTop,identifier:Infinity})},e.getCoords(t)},e.getCoord=function(t){if("ontouchstart"in window){var n=0,r=0;e.getCoord=function(e){var t=e.changedTouches;return t.length?{x:n=t[0].pageX,y:r=t[0].pageY}:{x:n,y:r}}}else typeof t.pageX!="undefined"&&typeof t.pageY!="undefined"?e.getCoord=function(e){return{x:e.pageX,y:e.pageY}}:e.getCoord=function(e){return e=e||window.event,{x:e.clientX+document.documentElement.scrollLeft,y:e.clientY+document.documentElement.scrollTop}};return e.getCoord(t)},e.getBoundingBox=function(e){if(e===window||e===document)e=document.body;var t={x1:0,y1:0,x2:0,y2:0,scrollLeft:0,scrollTop:0};e===document.body?(t.height=window.innerHeight,t.width=window.innerWidth):(t.height=e.offsetHeight,t.width=e.offsetWidth),t.scaleX=e.width/t.width||1,t.scaleY=e.height/t.height||1;var n=e;while(n!==null)t.x1+=n.offsetLeft,t.y1+=n.offsetTop,n=n.offsetParent;var n=e.parentNode;while(n!==null){if(n===document.body)break;if(n.scrollTop===undefined)break;t.scrollLeft+=n.scrollLeft,t.scrollTop+=n.scrollTop,n=n.parentNode}return t.x2=t.x1+t.width,t.y2=t.y1+t.height,t},function(){var t=navigator.userAgent.toLowerCase(),n=t.indexOf("macintosh")!==-1;if(n&&t.indexOf("khtml")!==-1)var r={91:!0,93:!0};else if(n&&t.indexOf("firefox")!==-1)var r={224:!0};else var r={17:!0};e.isMetaKey=function(e){return!!r[e.keyCode]},e.metaTracker=function(t){r[t.keyCode]&&(e.metaKey=t.type==="keydown")}}(),e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.click=function(t){t.maxFingers=t.maxFingers||t.fingers||1;var n;t.onPointerDown=function(n){e.pointerStart(n,r,t)&&(Event.add(t.doc,"mousemove",t.onPointerMove).listener(n),Event.add(t.doc,"mouseup",t.onPointerUp))},t.onPointerMove=function(e){n=e},t.onPointerUp=function(i){if(e.pointerEnd(i,r,t)){Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp);if(n.cancelBubble&&++n.bubble>1)return;var s=n.changedTouches||e.getCoords(n),o=s[0],u=t.bbox,a=e.getBoundingBox(t.target);if(t.position==="relative")var f=(o.pageX+u.scrollLeft-u.x1)*u.scaleX,l=(o.pageY+u.scrollTop-u.y1)*u.scaleY;else var f=o.pageX-u.x1,l=o.pageY-u.y1;f>0&&f<u.width&&l>0&&l<u.height&&u.scrollTop===a.scrollTop&&t.listener(n,r)}};var r=e.pointerSetup(t);return r.state="click",Event.add(t.target,"mousedown",t.onPointerDown),r},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.click=e.click,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.dbltap=e.dblclick=function(t){t.maxFingers=t.maxFingers||t.fingers||1;var n=700,r,i,s,o,u;t.onPointerDown=function(f){var l=f.changedTouches||e.getCoords(f);r&&!i?(u=l[0],i=(new Date).getTime()-r):(o=l[0],r=(new Date).getTime(),i=0,clearTimeout(s),s=setTimeout(function(){r=0},n)),e.pointerStart(f,a,t)&&(Event.add(t.doc,"mousemove",t.onPointerMove).listener(f),Event.add(t.doc,"mouseup",t.onPointerUp))},t.onPointerMove=function(n){if(r&&!i){var a=n.changedTouches||e.getCoords(n);u=a[0]}var f=t.bbox;if(t.position==="relative")var l=(u.pageX+f.scrollLeft-f.x1)*f.scaleX,c=(u.pageY+f.scrollTop-f.y1)*f.scaleY;else var l=u.pageX-f.x1,c=u.pageY-f.y1;l>0&&l<f.width&&c>0&&c<f.height&&Math.abs(u.pageX-o.pageX)<=25&&Math.abs(u.pageY-o.pageY)<=25||(Event.remove(t.doc,"mousemove",t.onPointerMove),clearTimeout(s),r=i=0)},t.onPointerUp=function(o){e.pointerEnd(o,a,t)&&(Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp)),r&&i&&(i<=n&&!(o.cancelBubble&&++o.bubble>1)&&(a.state=t.gesture,t.listener(o,a)),clearTimeout(s),r=i=0)};var a=e.pointerSetup(t);return a.state="dblclick",Event.add(t.target,"mousedown",t.onPointerDown),a},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.dbltap=e.dbltap,Event.Gesture._gestureHandlers.dblclick=e.dblclick,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.dragElement=function(t,n){e.drag({event:n,target:t,position:"move",listener:function(e,n){t.style.left=n.x+"px",t.style.top=n.y+"px"}})},e.drag=function(t){t.gesture="drag",t.onPointerDown=function(r){e.pointerStart(r,n,t)&&(Event.add(t.doc,"mousemove",t.onPointerMove),Event.add(t.doc,"mouseup",t.onPointerUp)),t.onPointerMove(r,"down")},t.onPointerMove=function(r,i){var s=t.bbox,o=r.changedTouches||e.getCoords(r),u=o.length;for(var a=0;a<u;a++){var f=o[a],l=f.identifier||Infinity,c=t.tracker[l];if(!c)continue;c.pageX=f.pageX,c.pageY=f.pageY,n.state=i||"move",n.identifier=l,n.start=c.start,n.fingers=1,t.position==="relative"?(n.x=(c.pageX+s.scrollLeft-c.offsetX)*s.scaleX,n.y=(c.pageY+s.scrollTop-c.offsetY)*s.scaleY):(n.x=c.pageX-c.offsetX,n.y=c.pageY-c.offsetY),t.listener(r,n)}},t.onPointerUp=function(r){e.pointerEnd(r,n,t,t.onPointerMove)&&(Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp))};var n=e.pointerSetup(t);return t.event?t.onPointerDown(t.event):Event.add(t.target,"mousedown",t.onPointerDown),n},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.drag=e.drag,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";var t=Math.PI/180;return e.gesture=function(n){n.minFingers=n.minFingers||n.fingers||2,n.onPointerDown=function(t){var i=n.fingers;e.pointerStart(t,r,n)&&(Event.add(n.doc,"mousemove",n.onPointerMove),Event.add(n.doc,"mouseup",n.onPointerUp));if(n.fingers===n.minFingers&&i!==n.fingers){r.fingers=n.minFingers,r.scale=1,r.rotation=0,r.state="start";var s="";for(var o in n.tracker)s+=o;r.identifier=parseInt(s),n.listener(t,r)}},n.onPointerMove=function(i,s){var o=n.bbox,u=n.tracker,a=i.changedTouches||e.getCoords(i),f=a.length;for(var l=0;l<f;l++){var c=a[l],h=c.identifier||Infinity,p=u[h];if(!p)continue;n.position==="relative"?(p.move.x=(c.pageX+o.scrollLeft-o.x1)*o.scaleX,p.move.y=(c.pageY+o.scrollTop-o.y1)*o.scaleY):(p.move.x=c.pageX-o.x1,p.move.y=c.pageY-o.y1)}if(n.fingers<n.minFingers)return;var a=[],d=0,v=0,m=0,g=0,f=0;for(var h in u){var c=u[h];if(c.up)continue;m+=c.move.x,g+=c.move.y,f++}m/=f,g/=f;for(var h in u){var c=u[h];if(c.up)continue;var y=c.start;if(!y.distance){var b=y.x-m,w=y.y-g;y.distance=Math.sqrt(b*b+w*w),y.angle=Math.atan2(b,w)/t}var b=c.move.x-m,w=c.move.y-g,E=Math.sqrt(b*b+w*w);d+=E/y.distance;var S=Math.atan2(b,w)/t,x=(y.angle-S+360)%360-180;c.DEG2=c.DEG1,c.DEG1=x>0?x:-x,typeof c.DEG2!="undefined"&&(x>0?c.rotation+=c.DEG1-c.DEG2:c.rotation-=c.DEG1-c.DEG2,v+=c.rotation),a.push(c.move)}r.touches=a,r.fingers=n.fingers,r.scale=d/n.fingers,r.rotation=v/n.fingers,r.state="change",n.listener(i,r)},n.onPointerUp=function(t){var i=n.fingers;e.pointerEnd(t,r,n)&&(Event.remove(n.doc,"mousemove",n.onPointerMove),Event.remove(n.doc,"mouseup",n.onPointerUp)),i===n.minFingers&&n.fingers<n.minFingers&&(r.fingers=n.fingers,r.state="end",n.listener(t,r))};var r=e.pointerSetup(n);return Event.add(n.target,"mousedown",n.onPointerDown),r},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.gesture=e.gesture,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.pointerdown=e.pointermove=e.pointerup=function(t){if(t.target.isPointerEmitter)return;var n=!0;t.onPointerDown=function(e){n=!1,r.gesture="pointerdown",t.listener(e,r)},t.onPointerMove=function(e){r.gesture="pointermove",t.listener(e,r,n)},t.onPointerUp=function(e){n=!0,r.gesture="pointerup",t.listener(e,r,!0)};var r=e.pointerSetup(t);return Event.add(t.target,"mousedown",t.onPointerDown),Event.add(t.target,"mousemove",t.onPointerMove),Event.add(t.doc,"mouseup",t.onPointerUp),t.target.isPointerEmitter=!0,r},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.pointerdown=e.pointerdown,Event.Gesture._gestureHandlers.pointermove=e.pointermove,Event.Gesture._gestureHandlers.pointerup=e.pointerup,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.shake=function(e){var t={gesture:"devicemotion",acceleration:{},accelerationIncludingGravity:{},target:e.target,listener:e.listener,remove:function(){window.removeEventListener("devicemotion",f,!1)}},n=4,r=1e3,i=200,s=3,o=(new Date).getTime(),u={x:0,y:0,z:0},a={x:{count:0,value:0},y:{count:0,value:0},z:{count:0,value:0}},f=function(f){var l=.8,c=f.accelerationIncludingGravity;u.x=l*u.x+(1-l)*c.x,u.y=l*u.y+(1-l)*c.y,u.z=l*u.z+(1-l)*c.z,t.accelerationIncludingGravity=u,t.acceleration.x=c.x-u.x,t.acceleration.y=c.y-u.y,t.acceleration.z=c.z-u.z;if(e.gesture==="devicemotion"){e.listener(f,t);return}var h="xyz",p=(new Date).getTime();for(var d=0,v=h.length;d<v;d++){var m=h[d],g=t.acceleration[m],y=a[m],b=Math.abs(g);if(p-o<r)continue;if(b>n){var w=p*g/b,E=Math.abs(w+y.value);y.value&&E<i?(y.value=w,y.count++,y.count===s&&(e.listener(f,t),o=p,y.value=0,y.count=0)):(y.value=w,y.count=1)}}};if(!window.addEventListener)return;return window.addEventListener("devicemotion",f,!1),t},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.shake=e.shake,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";var t=Math.PI/180;return e.swipe=function(n){n.snap=n.snap||90,n.threshold=n.threshold||1,n.onPointerDown=function(t){e.pointerStart(t,r,n)&&(Event.add(n.doc,"mousemove",n.onPointerMove).listener(t),Event.add(n.doc,"mouseup",n.onPointerUp))},n.onPointerMove=function(t){var r=t.changedTouches||e.getCoords(t),i=r.length;for(var s=0;s<i;s++){var o=r[s],u=o.identifier||Infinity,a=n.tracker[u];if(!a)continue;a.move.x=o.pageX,a.move.y=o.pageY,a.moveTime=(new Date).getTime()}},n.onPointerUp=function(i){if(e.pointerEnd(i,r,n)){Event.remove(n.doc,"mousemove",n.onPointerMove),Event.remove(n.doc,"mouseup",n.onPointerUp);var s,o,u,a,f={x:0,y:0},l=0,c=0,h=0;for(var p in n.tracker){var d=n.tracker[p],v=d.move.x-d.start.x,m=d.move.y-d.start.y;l+=d.move.x,c+=d.move.y,f.x+=d.start.x,f.y+=d.start.y,h++;var g=Math.sqrt(v*v+m*m),y=d.moveTime-d.startTime,a=Math.atan2(v,m)/t+180,o=y?g/y:0;if(typeof u=="undefined")u=a,s=o;else{if(!(Math.abs(a-u)<=20))return;u=(u+a)/2,s=(s+o)/2}}s>n.threshold&&(f.x/=h,f.y/=h,r.start=f,r.x=l/h,r.y=c/h,r.angle=-(((u/n.snap+.5>>0)*n.snap||360)-360),r.velocity=s,r.fingers=n.gestureFingers,r.state="swipe",n.listener(i,r))}};var r=e.pointerSetup(n);return Event.add(n.target,"mousedown",n.onPointerDown),r},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.swipe=e.swipe,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.tap=e.longpress=function(t){t.delay=t.delay||500,t.timeout=t.timeout||250;var n,r;t.onPointerDown=function(s){if(e.pointerStart(s,i,t)){n=(new Date).getTime(),Event.add(t.doc,"mousemove",t.onPointerMove).listener(s),Event.add(t.doc,"mouseup",t.onPointerUp);if(t.gesture!=="longpress")return;r=setTimeout(function(){if(s.cancelBubble&&++s.bubble>1)return;var e=0;for(var n in t.tracker){if(t.tracker[n].end===!0)return;if(t.cancel)return;e++}i.state="start",i.fingers=e,t.listener(s,i)},t.delay)}},t.onPointerMove=function(n){var r=t.bbox,i=n.changedTouches||e.getCoords(n),s=i.length;for(var o=0;o<s;o++){var u=i[o],a=u.identifier||Infinity,f=t.tracker[a];if(!f)continue;if(t.position==="relative")var l=(u.pageX+r.scrollLeft-r.x1)*r.scaleX,c=(u.pageY+r.scrollTop-r.y1)*r.scaleY;else var l=u.pageX-r.x1,c=u.pageY-r.y1;if(!(l>0&&l<r.width&&c>0&&c<r.height&&Math.abs(l-f.start.x)<=25&&Math.abs(c-f.start.y)<=25)){Event.remove(t.doc,"mousemove",t.onPointerMove),t.cancel=!0;return}}},t.onPointerUp=function(s){if(e.pointerEnd(s,i,t)){clearTimeout(r),Event.remove(t.doc,"mousemove",t.onPointerMove),Event.remove(t.doc,"mouseup",t.onPointerUp);if(s.cancelBubble&&++s.bubble>1)return;if(t.gesture==="longpress"){i.state==="start"&&(i.state="end",t.listener(s,i));return}if(t.cancel)return;if((new Date).getTime()-n>t.timeout)return;i.state="tap",i.fingers=t.gestureFingers,t.listener(s,i)}};var i=e.pointerSetup(t);return Event.add(t.target,"mousedown",t.onPointerDown),i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.tap=e.tap,Event.Gesture._gestureHandlers.longpress=e.longpress,e}(Event.proxy);if(typeof Event=="undefined")var Event={};typeof Event.proxy=="undefined"&&(Event.proxy={}),Event.proxy=function(e){"use strict";return e.wheel=function(e){var t,n=e.timeout||150,r=0,i={gesture:"wheel",state:"start",wheelDelta:0,target:e.target,listener:e.listener,remove:function(){e.target[u](a,s,!1)}},s=function(s){s=s||window.event,i.state=r++?"change":"start",i.wheelDelta=s.detail?s.detail*-20:s.wheelDelta,e.listener(s,i),clearTimeout(t),t=setTimeout(function(){r=0,i.state="end",i.wheelDelta=0,e.listener(s,i)},n)},o=document.addEventListener?"addEventListener":"attachEvent",u=document.removeEventListener?"removeEventListener":"detachEvent",a=Event.supports("mousewheel")?"mousewheel":"DOMMouseScroll";return e.target[o](a,s,!1),i},Event.Gesture=Event.Gesture||{},Event.Gesture._gestureHandlers=Event.Gesture._gestureHandlers||{},Event.Gesture._gestureHandlers.wheel=e.wheel,e}(Event.proxy);