var webkit_audio=!1;window.webkitAudioContext&&(webkit_audio=!0);var context,microphone,localAudio,lineIn;window.addEventListener("load",loadContext,!1);function loadContext(){window.AudioContext=window.AudioContext||window.webkitAudioContext;navigator.getUserMedia=navigator.getUserMedia||navigator.mozGetUserMedia||navigator.webkitGetUserMedia;context=new AudioContext;microphone="";listPedals();listAmplifiers();listCabinets();loadPedals()}
function connectIn(a){if("mic"==a)""!=microphone?microphone.connect(lineIn):navigator.getUserMedia({video:!1,audio:!0},function(a){microphone=context.createMediaStreamSource(a);microphone.connect(lineIn)},function(a){alert("An error occured! "+a)});else{var b=new XMLHttpRequest;b.open("GET",a,!0);b.responseType="arraybuffer";b.onload=function(){context.decodeAudioData(b.response,function(a){localAudio=context.createBufferSource();localAudio.buffer=a;localAudio.loop=!0;localAudio.connect(lineIn);localAudio.start(0)})};
b.send()}}function disconnectIn(a){"mic"==a?null!=microphone&&microphone.disconnect():localAudio.stop(0)}
function loadEffects(a){try{var b=a.length}catch(d){b=0}for(var e=[],g=0,f=0;f<b;f++)null==a[f].ON&&(a[f].ON=!0),a[f].cabinet&&(a[f].ON=cabinetON),a[f].ON&&(e[g]=a[f],g++),a[f].out.disconnect();if(0==g)lineIn=context.destination;else{lineIn=e[0]["in"];for(f=0;f<g-1;f++)e[f].out.connect(e[f+1]["in"]);e[g-1].out.connect(context.destination)}null!=localAudio&&localAudio.connect(lineIn);""!=microphone&&microphone.connect(lineIn)}
function loadIR(a){a.conv=context.createConvolver();a["in"]=context.createGain();a.process=context.createGain();a.out=context.createGain();a.cabinet&&(a.process.gain.value=10);a["in"].connect(a.out);a["in"].connect(a.process);a.process.connect(a.conv);a.conv.connect(a.out);var b=new XMLHttpRequest;b.open("GET",a.irPath,!0);b.responseType="arraybuffer";b.onload=function(){context.decodeAudioData(b.response,function(b){a.conv.buffer=b})};b.send()};function showAmp(){"-"==id("ampcab").innerHTML?(id("ampcab").innerHTML="+",translate(id("amp-options"),-322,0)):(id("ampcab").innerHTML="-",translate(id("amp-options"),0,0))}var sliderEl;function loadSliders(){sliderEl=document.getElementsByTagName("slider");for(var a=0;a<sliderEl.length;a++)slider(sliderEl[a])}
function slider(a){a.innerHTML="<slider2></slider2><tagSlider></tagSlider>";a.t=a.getAttribute("type");a.min=parseFloat(a.getAttribute("min"));a.max=parseFloat(a.getAttribute("max"));a.length=parseInt(a.getAttribute("length"));a.value=parseFloat(a.getAttribute("value"));a.eval=a.getAttribute("eval");"vertical"==a.t?(a.style.height=a.length+"px",a.children[1].className="tagV"):(a.style.width=a.length+"px",a.children[1].className="tagH");window.onmouseup=window.ontouchend=function(){for(var a=0;a<sliderEl.length;a++)sliderEl[a].enabled=
!1};a.ondragstart=function(){return!1};var b=!0;try{eval("a.connect="+a.getAttribute("connect"))}catch(d){b=!1}void 0===a.connect&&(b=!1);b?(a.onmousedown=function(a){this.enabled=!0;this.onmousemove(a)},a.ontouchstart=a.ontouchmove=a.onmousemove=function(a){var b=a.layerX,d=a.layerY,h=a.target,l=a.type;if("touchstart"==l||"touchmove"==l)d=a.changedTouches[0].clientY-a.changedTouches[0].target.clientTop,b=a.changedTouches[0].clientX-a.changedTouches[0].target.clientLeft,h=a.changedTouches[0].target,
this.enabled=!0;this.enabled&&"SLIDER"==h.tagName&&(a=(this.length-16)/this.length*b,h=(this.length-16)/this.length*d,"vertical"==this.t?(0<=d&&d<=this.length&&(this.children[1].style.top=h+"px",translate(this.children[0],0,h)),b=this.min+(this.max-this.min)/this.length*d):(0<=b&&b<=this.length&&translate(this.children[0],a,0),b=this.min+(this.max-this.min)/this.length*b),this.slide(b))},a.slide=function(a){a>this.max&&(a=this.max);a<this.min&&(a=this.min);"linear"==this.eval?eval(this.getAttribute("connect")+
"="+a):eval(this.getAttribute("connect")+"("+a+")");this.value=a;this.children[1].innerHTML=a.toFixed(2)},a.onmousedown({type:"",layerX:a.length/((a.max-a.min)/(a.value-a.min)),layerY:a.length/((a.max-a.min)/(a.value-a.min)),target:{tagName:"SLIDER"}}),a.enabled=!1,a.style.background="",a.children[1].style.display=""):(a.style.background="gray",a.children[1].style.display="none")}
window.addEventListener("message",function(a){a=a.data;a.substring&&-1==a.search("name")?("recorder"==a?recorderP="recorder":pedals=a+",",loadPedals(!0),"es"==lang?alert("Tiene 30 segundos para probarlo"):alert("You have 30 seconds to try it"),setTimeout(endTry,3E4),tryModeOn=!0):(localStorage.purch=JSON.stringify(a),listPedals())});var tryModeOn=!1,endTry=function(){pedals=localStorage.lastPedals;recorderP=localStorage.recorder;tryModeOn=!1;loadPedals();"es"==lang?alert("Tiempo Terminado"):alert("Time finished")};
if(null==localStorage.lastPedals){localStorage.lastPedals="overdrive,";var firstTime=!0}null==localStorage.limiter&&(localStorage.limiter="limiter,");null==localStorage.compressor&&(localStorage.compressor="");null==localStorage.recorder&&(localStorage.recorder="");null==localStorage.amplifier&&(localStorage.amplifier="rpr");null==localStorage.amplifierN&&(localStorage.amplifierN="RPR");null==localStorage.cabinet&&(localStorage.cabinet="vinuk");
null==localStorage.cabinetN&&(localStorage.cabinetN="Vintage UK");
function generatePedal(a,b,d,e,g,f,h,l,v,w){var x='<td><div class="pedal" id="'+a.toLowerCase()+b.toLowerCase()+'">';if("analyser"==d)u="<div id='analyser-note'></div>";else if("rec"==d)u="<div id='recorder-icon'><img src='img/rec.png' /></div>";else for(var q=null!=v?4:null!=h?3:null!=g?2:1,u="",r=0;r<q;r++){var m,t,p;1==q?(m="middle",t=e,p=d):2==q&&0==r?(m="left",t=e,p=d):2==q&&1==r?(m="right",t=f,p=g):3==q&&0==r?(m="top-middle",t=e,p=d):3==q&&1==r?(m="left-middle",t=f,p=g):3==q&&2==r?(m="right-middle",
t=l,p=h):4==q&&0==r?(m="right-top",t=e,p=d):4==q&&1==r?(m="right-bottom",t=f,p=g):4==q&&2==r?(m="left-top",t=l,p=h):4==q&&3==r&&(m="left-bottom",t=w,p=v);u+='<dial class="control-'+m+' controls" id="'+a.toLowerCase()+b.toLowerCase()+"-"+p+'" start="'+t+'" min="0" max="1"></dial>';u+='<label class="label-'+m+' controls">'+p.toUpperCase()+"</label>"}return x+u+("<name>"+a+"</name><subname>"+b+"</subname>")+"<switch></switch></div></td>"}var optionsVisible=!1;
function showOptions(){optionsVisible?(translate(id("options-button"),0,0),translate(id("options"),0,0)):(translate(id("options-button"),-240,0),translate(id("options"),-240,0));optionsVisible=!optionsVisible}function changeBufferSize(a){localStorage.bufferSize=a;BufferLength=parseInt(a);loadPedals()}
var pedals=localStorage.lastPedals,limiterP=localStorage.limiter,recorderP=localStorage.recorder,compressorP=localStorage.compressor,cabinetON=!1,amplifierON=!0,amp=localStorage.amplifier,cab=localStorage.cabinet,pedalsN=0,effectsArray=[],ctx,board,sterefy,flangerstereo,flangersilver,thebytter,theripper,compressor,recorder,digitalizer,overdrive,flangerdarkmouth,flangermanhattan,eqpeak,flangerclassic,eqmid,eqhigh,eqlow,fuxxboz,autoreverb,doppler,tremolo,chorusclassic,delaystereo,delaymono,chorussupercharger,
eq3band,r_classic,r_catedral,r_smallroom,limiter,cabinet,amplifier,convolver,fuzz1,ringring,overscream;
function loadPedals(a){if(!tryModeOn){!0!=firstTime&&(id("shareNow").style.display=id("msg").style.display="none");try{recorder.rec.onaudioprocess=function(a){}}catch(b){}for(var d=0;d<effectsArray.length;d++)effectsArray[d].out.disconnect();try{microphone.disconnect()}catch(e){}try{localAudio.disconnect()}catch(g){}id("buffer-length").value=localStorage.bufferSize;id("add-pedals").innerHTML="";id("del-pedals").innerHTML="";null!=amplifier&&(amplifier.out.disconnect(),amplifierON=amplifier.ON?!0:
!1);null!=cabinet&&(cabinet.out.disconnect(),cabinetON=cabinet.ON?!0:!1);overdrive=sterefy=flangerstereo=flangersilver=thebytter=theripper=compressor=recorder=digitalizer=flangerclassic=flangerdarkmouth=flangermanhattan=eqpeak=eqmid=eqhigh=eqlow=autoreverb=fuxxboz=doppler=delaystereo=tremolo=chorusclassic=delaymono=r_classic=r_catedral=chorussupercharger=eq3band=r_smallroom=limiter=cabinet=convolver=fuzz1=ringring=overscream=null;"vinus"==cab&&(cabinet=new effects.VinUs);"vinuk"==cab&&(cabinet=new effects.VinUk);
"clean"==cab&&(cabinet=new effects.Clean);"bass"==cab&&(cabinet=new effects.Bass);"deep"==cab&&(cabinet=new effects.Deep);"stereo"==cab&&(cabinet=new effects.Stereo);"alien"==cab&&(cabinet=new effects.Alien);"metal"==cab&&(cabinet=new effects.Metal);"noisy"==cab&&(cabinet=new effects.Noisy);"feedy"==cab&&(cabinet=new effects.Feedy);"peaker"==cab&&(cabinet=new effects.Peaker);"power"==cab&&(cabinet=new effects.Power);"modger"==amp&&(amplifier=new effects.ModernGer);"eqg"==amp&&(amplifier=new effects.EQG);
"bassman"==amp&&(amplifier=new effects.Bassman);"rpr"==amp&&(amplifier=new effects.RPR);"crusher"==amp&&(amplifier=new effects.Crusher);var f=0;-1!=pedals.search("sterefy")&&(d=generatePedal("Sterefy","","level","1","separation","0.5"),sterefy=new effects.Sterefy,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("sterefy"));-1!=pedals.search("flangerstereo")&&(d=generatePedal("Flanger","Stereo","level","1","frequency","0.5","cutoff","0.5"),flangerstereo=new effects.FlangerStereo,f++,
id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("flangerstereo"));-1!=pedals.search("flangersilver")&&(d=generatePedal("Flanger","Silver","level","1","frequency","0.5","cutoff","0.5"),flangersilver=new effects.FlangerSilver,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("flangersilver"));-1!=pedals.search("thebytter")&&(d=generatePedal("The-Bytter","","level","1","drive","0.5","cutoff","0.5"),thebytter=new effects.TheBytter,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("thebytter"));-1!=pedals.search("theripper")&&(d=generatePedal("The-Ripper","","level","1","drive","0.5","cutoff","0.5"),theripper=new effects.TheRipper,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("theripper"));-1!=compressorP.search("compressor")&&(d=generatePedal("Compressor","","level","1"),compressor=new effects.Compressor,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("compressor"));-1!=recorderP.search("recorder")&&(d=generatePedal("Recorder","",
"rec"),recorder=new effects.Recorder,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("recorder"));-1!=pedals.search("digitalizer")&&(d=generatePedal("Digitalizer","","level","1"),digitalizer=new effects.Digitalizer,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("digitalizer"));-1!=pedals.search("bitcrusher")&&(d=generatePedal("Bitcrusher","","level","1","frequency","1","bits","0.2"),bitcrusher=new effects.Bitcrusher,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("bitcrusher"));-1!=pedals.search("flangerdarkmouth")&&(d=generatePedal("Flanger","Darkmouth","level","1","frequency","0.5","speed","0.25"),flangerdarkmouth=new effects.FlangerDarkmouth,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("flangerdarkmouth"));-1!=pedals.search("flangermanhattan")&&(d=generatePedal("Flanger","Manhattan","level","1","frequency","0.5"),flangermanhattan=new effects.FlangerManhattan,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("flangermanhattan"));
-1!=pedals.search("flangerclassic")&&(d=generatePedal("Flanger","Classic","level","1","speed","0.5","dry/wet","0.5"),flangerclassic=new effects.FlangerClassic,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("flangerclassic"));-1!=pedals.search("eqlow")&&(d=generatePedal("EQ","Low","level","1","gain","0.5","frequency","0.5"),eqlow=new effects.EqLow,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("eqlow"));-1!=pedals.search("eqhigh")&&(d=generatePedal("EQ","High","level",
"1","gain","0.5","frequency","0.5"),eqhigh=new effects.EqHigh,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("eqhigh"));-1!=pedals.search("eqpeak")&&(d=generatePedal("EQ","Peak","level","1","gain","0.5","quality","0.5","frequency","0.5"),eqpeak=new effects.EqPeak,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("eqpeak"));-1!=pedals.search("eqmid")&&(d=generatePedal("EQ","Mid","level","1","gain","0.5","quality","0.5"),eqmid=new effects.EqMid,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("eqmid"));-1!=pedals.search("fuzzbit")&&(d=generatePedal("Fuzz","Bit","level","1","tone","0.5","drive","0.5"),fuzzbit=new effects.FuzzBit,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("fuzzbit"));-1!=pedals.search("fuxxboz")&&(d=generatePedal("Fuxx","Boz","level","1","tone","0.5","drive","0.5"),fuxxboz=new effects.FuxxBoz,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("fuxxboz"));-1!=pedals.search("autoreverb")&&(d=generatePedal("AutoReverb","","decay","0.5",
"length","0.5","offset","0"),autoreverb=new effects.AutoReverb,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("autoreverb"));-1!=pedals.search("doppler")&&(d=generatePedal("Doppler","","level","1","velocity","0.5","distance","0.5"),doppler=new effects.Doppler,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("doppler"));-1!=pedals.search("analyser")&&(d=generatePedal("Analyser","","analyser"),analyser=new effects.Analyser,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("analyser"));-1!=pedals.search("tremolo")&&(d=generatePedal("Tremolo","","level","1","frequency","0.5"),tremolo=new effects.Tremolo,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("tremolo"));-1!=pedals.search("chorusclassic")&&(d=generatePedal("Chorus","Classic","level","1"),chorusclassic=new effects.ChorusClassic,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("chorusclassic"));-1!=pedals.search("chorussupercharger")&&(d=generatePedal("Chorus","Supercharger",
"level","1.0","gain","0.5"),chorussupercharger=new effects.ChorusSupercharger,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("chorussupercharger"));-1!=pedals.search("eq3band")&&(d=generatePedal("Equalizer","3Band","level","1.0","mid","0.5","high","0.5","low","0.5"),eq3band=new effects.Eq3,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("eq3band"));-1!=pedals.search("delaystereo")&&(d=generatePedal("Delay","Stereo","level","1.0","dry/wet","0.5","feedback","0.5","time",
"0.5"),delaystereo=new effects.DelayStereo,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("delaystereo"));-1!=pedals.search("delaymono")&&(d=generatePedal("Delay","Mono","level","1.0","dry/wet","0.5","feedback","0.5","time","0.5"),delaymono=new effects.Delay,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("delaymono"));-1!=pedals.search("overdrive")&&(d=generatePedal("Overdrive","","level","1","tone","0.5","drive","0.5"),overdrive=new effects.Overdrive,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("overdrive"));-1!=pedals.search("r_classic")&&(d=generatePedal("Reverb","Classic","level","1"),r_classic=new effects.ReverbClassic,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("r_classic"));-1!=pedals.search("overscream")&&(d=generatePedal("Overscream","","level","1","drive","0.5"),overscream=new effects.Overscream,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("overscream"));-1!=pedals.search("fuzz1")&&(d=generatePedal("Fuzz","","level","1","tone","0.5",
"drive","0.5"),fuzz1=new effects.Fuzz,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("fuzz1"));-1!=limiterP.search("limiter")&&(d=generatePedal("Limiter","","level","1"),limiter=new effects.Limiter,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("limiter"));-1!=pedals.search("convolver")&&(d=generatePedal("Convolver","","level","1"),convolver=new effects.Convolver,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("convolver"));-1!=pedals.search("ringring")&&
(d=generatePedal("RingRing","","level","1"),ringring=new effects.RingRing,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("ringring"));-1!=pedals.search("r_catedral")&&(d=generatePedal("Reverb","Catedral","level","1"),r_catedral=new effects.ReverbCatedral,f++,id("add-pedals").insertAdjacentHTML("afterbegin",d),addDel("r_catedral"));-1!=pedals.search("r_smallroom")&&(d=generatePedal("Reverb","SmallRoom","level","1"),r_smallroom=new effects.ReverbSmallRoom,f++,id("add-pedals").insertAdjacentHTML("afterbegin",
d),addDel("r_smallroom"));id("pedals").style.width=309*f+"px";for(d=0;d<id("add-pedals").children.length;d++)id("add-pedals").children[d].style.width=100/f+"%";try{eval("effectsArray=["+pedals+"amplifier,cabinet,"+compressorP+limiterP+recorderP+"]"),loadEffects(effectsArray)}catch(h){localStorage.lastPedals=pedals="",localStorage.limiter=limiterP="",localStorage.recorder=recorderP="",localStorage.compressor=compressorP="",localStorage.amplifier=amp="rpr",localStorage.cabinet=cab="vinuk",localStorage.amplifierN=
"RPR",localStorage.cabinetN="Vintage UK",console.log(h)}load();null==a&&(localStorage.lastPedals=pedals,localStorage.recorder=recorderP,localStorage.limiter=limiterP,localStorage.compressor=compressorP,localStorage.amplifier=amp,localStorage.cabinet=cab)}}function swCab(a){cabinet.ON?(a.innerHTML="OFF",a.style.background="#f00"):(a.innerHTML="ON",a.style.background="#0f0");cabinetON=!cabinetON;try{cabinet.ON=!cabinet.ON,loadEffects(effectsArray)}catch(b){console.log(b)}}
function swAmp(a){amplifier.ON?(a.innerHTML="OFF",a.style.background="#f00"):(a.innerHTML="ON",a.style.background="#0f0");amplifierON=!amplifierON;try{amplifier.ON=!amplifier.ON,loadEffects(effectsArray)}catch(b){console.log(b)}}function selectCabinet(a,b){"0"!=a&&(cab=a,localStorage.cabinetN=b,loadPedals());translate(id("cabinets-list"),-241,0)}function selectAmplifier(a,b){"0"!=a&&(amp=a,localStorage.amplifierN=b,loadPedals());translate(id("amplifiers-list"),-241,0)}
function addDel(a){id("del-pedals").insertAdjacentHTML("afterbegin","<td onclick=\"delPedal('"+a+"',this)\"><div>Delete</div></td>")}function delPedal(a){"limiter"==a?limiterP="":"recorder"==a?recorderP="":"compressor"==a?compressorP="":pedals=pedals.replace(a+",","");window[a].out.disconnect();loadPedals()}
function addPedal(a){"0"!=a&&-1==pedals.search(a)&&"limiter"!=a&&"recorder"!=a&&"compressor"!=a?(pedals+=a+",",loadPedals()):"limiter"==a?(limiterP="limiter,",loadPedals()):"recorder"==a?(recorderP="recorder",loadPedals()):"compressor"==a&&(compressorP="compressor,",loadPedals());translate(id("pedals-list"),-241,0)}
function listPedals(a){if(a)translate(id("pedals-list"),0,0);else{translate(id("pedals-list"),-241,0);a="0 overdrive overscream fuzz1 limiter delaymono delaystereo eq3band chorusclassic chorussupercharger tremolo analyser doppler fuxxboz fuzzbit eqmid eqhigh eqpeak eqlow flangerclassic flangermanhattan flangerdarkmouth bitcrusher digitalizer recorder r_classic r_catedral r_smallroom ringring autoreverb convolver compressor theripper thebytter flangersilver flangerstereo sterefy 0".split(" ");for(var b=
"close;Overdrive;Overscream;Fuzz;Limiter;Delay-Mono;Delay-Stereo;3Band-EQ;Chorus-Classic;Chorus-Supercharger;Tremolo;Analyser-Tuner;Doppler;Fuxx-Boz;Fuzz-Bit;EQ-Mid;EQ-High;EQ-Peak;EQ-Low;Flanger-Classic;Flanger-Manhattan;Flanger-Darkmouth;Bitcrusher;Digitalizer;Recorder;Reverb-Classic;Reverb-Catedral;Reverb-Small Room;RingRing;AutoReverb;Convolver;Compressor;The-Ripper;The-Bytter;Flanger-Silver;Flanger-Stereo;Sterefy;close".split(";"),d="",e=0;e<a.length;e++){var g="";"0"==a[e]&&(g="pedal-sel-close");
d+="<div onclick='addPedal(\""+a[e]+"\")' class='pedal-select "+g+"'>"+b[e]+"</div>"}id("pedals-list").innerHTML=d}}function checkP(a,b){for(var d=!1,e=0;e<b.length;e++)a==b[e].id&&(d=!0);return d}var mic_on=!1;function playLineIn(){mic_on?(id("mic").style.background="red",disconnectIn("mic"),mic_on=!1):(connectIn("mic"),id("mic").style.background="#0f0",mic_on=!0)}
function playDemo(){"Play Demo"==id("demo").innerHTML?(connectIn("demo/Demo.ogg"),id("demo").innerHTML="Stop Demo",id("demo").style.background="#0f0"):(disconnectIn("d"),id("demo").innerHTML="Play Demo",id("demo").style.background="red")}function posPedals(){var a=window.innerHeight;id("div-pedals").style.height=a-58+"px";scale(id("pedals"),(a-58)/550)}
function loadDials(){for(var a=0;a<tag("dial").length;a++)start=parseFloat(tag("dial")[a].getAttribute("start")),min=parseInt(tag("dial")[a].getAttribute("min")),max=parseInt(tag("dial")[a].getAttribute("max")),createDial(tag("dial")[a],start,min,max,1E4,document.body)}
function load(){null==localAudio&&(readData("demo/Demo.ogg"),tag("loading")[0].style.display="none");posPedals();loadDials();loadSliders();id("cabinet-s2").innerHTML=localStorage.cabinetN;id("amplifier-s2").innerHTML=localStorage.amplifierN;for(var a=0;a<tag("switch").length;a++){switch(tag("switch")[a].parentNode.id){case "recorder":var b=!1;break;default:b=!0}b?tag("switch")[a].parentNode.style.backgroundImage="url(img/pedal-on.png)":tag("switch")[a].parentNode.style.backgroundImage="url(img/pedal-off.png)";
tag("switch")[a].onclick=function(){for(var a=this.parentNode.id,b=0;b<effectsArray.length;b++)effectsArray[b].out.disconnect();try{microphone.disconnect()}catch(g){}try{localAudio.disconnect()}catch(f){}switch(a){case "fuzz":a=fuzz1.ON=!fuzz1.ON;break;case "reverbsmallroom":a=!0;break;case "reverbclassic":a=!0;break;case "reverbcatedral":a=!0;break;case "the-ripper":a=theripper.ON=!theripper.ON;break;case "the-bytter":a=thebytter.ON=!thebytter.ON;break;case "recorder":a=recorder.ON=!recorder.ON;
recorder.ON?(iniRecorder(),id("recorder-icon").style.WebkitAnimation=id("recorder-icon").style.animation="2s recAnim infinite"):(id("recorder-icon").style.WebkitAnimation=id("recorder-icon").style.animation="",exportWAV());break;default:a=window[a].ON=!window[a].ON}loadEffects(effectsArray);this.parentNode.style.backgroundImage=a?"url(img/pedal-on.png)":"url(img/pedal-off.png)"}}}function id(a){return document.getElementById(a)}function tag(a){return document.getElementsByTagName(a)}
function className(a){return document.getElementsByClassName(a)}Element.prototype.remove=function(){this.parentElement.removeChild(this)};NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var a=0,b=this.length;a<b;a++)this[a]&&this[a].parentElement&&this[a].parentElement.removeChild(this[a])};var numDial=0,dialEnabled,s2,x1,x2,num,mouseM=[],s=[],c=[],ma=[],mi=[],dV=[],se=[],element,cX,cY,y2,x3,y3,x4,y4;
function createDial(a,b,d,e,g,f){s[numDial]=a;s[numDial].innerHTML='<div style="width:100%;height:100%"></div>';ma[numDial]=e;mi[numDial]=d;dV[numDial]=b;se[numDial]=g;c[numDial]=270/(ma[numDial]-mi[numDial]);s[numDial].children[0].style["-webkit-transform"]="rotate("+(dV[numDial]-mi[numDial])*c[numDial]+"deg)";s[numDial].children[0].style["-moz-transform"]="rotate("+(dV[numDial]-mi[numDial])*c[numDial]+"deg)";s[numDial].children[0].style.transform="rotate("+(dV[numDial]-mi[numDial])*c[numDial]+"deg)";
s[numDial].onmousedown=function(a){x1=a.clientX;dialEnabled=1;s2=this};s[numDial].addEventListener("touchstart",function(a){x1=a.changedTouches[0].clientX;dialEnabled=1;s2=this},!1);f.onmouseup=function(){dialEnabled=0;s2=null};f.addEventListener("touchend",function(){dialEnabled=0;s2=null},!1);a=function(a){1==dialEnabled&&a.preventDefault();for(var b=0;b<numDial;b++)s[b]==s2&&(num=b);dV[num]<mi[num]&&(dV[num]=mi[num],dialEnabled=0,x3=(dV[num]-mi[num])*c[num],s2.children[0].style["-webkit-transform"]=
"rotate("+x3+"deg)",s2.children[0].style["-moz-transform"]="rotate("+x3+"deg)",s2.children[0].style.transform="rotate("+x3+"deg)",s2.value=dV[num]);dV[num]>ma[num]&&(dV[num]=ma[num],dialEnabled=0,x3=(dV[num]-mi[num])*c[num],s2.children[0].style["-webkit-transform"]="rotate("+x3+"deg)",s2.children[0].style["-moz-transform"]="rotate("+x3+"deg)",s2.children[0].style.transform="rotate("+x3+"deg)",s2.value=dV[num]);if(1==dialEnabled&&dV[num]>=mi[num]&&dV[num]<=ma[num]){try{x2=(a.changedTouches[0].clientX-
x1)/se[num]}catch(d){x2=(a.clientX-x1)/se[num]}x3=(dV[num]-mi[num])*c[num];s2.children[0].style["-webkit-transform"]="rotate("+(x3+x2)+"deg)";s2.children[0].style["-moz-transform"]="rotate("+(x3+x2)+"deg)";s2.children[0].style.transform="rotate("+(x3+x2)+"deg)";dV[num]+=x2;s2.value=dV[num]}if(null!=num&&null!=s2)switch(a=parseFloat(dV[num].toFixed(2)),b=controls,s2.id){case "convolver-level":convolver.process.gain.value=a;break;case "limiter-level":limiter.out.gain.value=a;break;case "reverbclassic-level":r_classic.process.gain.value=
a;break;case "ringring-level":ringring.process.gain.value=a;break;case "reverbcatedral-level":r_catedral.process.gain.value=a;break;case "reverbsmallroom-level":r_smallroom.process.gain.value=a;break;case "overdrive-level":overdrive.out.gain.value=a;break;case "overdrive-drive":overdrive.drive(1E3*a);break;case "overdrive-tone":overdrive["in"].frequency.value=6E3*a;break;case "overscream-level":overscream.out.gain.value=a;break;case "overscream-drive":overscream.drive(400-400*a);break;case "fuzz-level":fuzz1.out.gain.value=
a;break;case "fuzz-drive":fuzz1.drive(2E3*a);break;case "fuzz-tone":fuzz1["in"].frequency.value=6E3*a;break;case "delaymono-level":delaymono.out.gain.value=a;break;case "delaymono-dry/wet":delaymono.wetLevel.gain.value=a;break;case "delaymono-feedback":delaymono.feedback.gain.value=.8*a;break;case "delaymono-time":delaymono.delay.delayTime.value=.5*a+.05;break;case "delaystereo-level":delaystereo.out.gain.value=a;break;case "delaystereo-dry/wet":delaystereo.wetLevel.gain.value=a;break;case "delaystereo-feedback":delaystereo.feedbackL.gain.value=
delaystereo.feedbackR.gain.value=.8*a;break;case "delaystereo-time":delaystereo.delayR.delayTime.value=.5*a+.05;delaystereo.delayL.delayTime.value=.94*(.5*a+.05);break;case "equalizer3band-low":eq3band["in"].gain.value=20*a-10;break;case "equalizer3band-mid":eq3band.midEq.gain.value=20*a-10;break;case "equalizer3band-high":eq3band.highEq.gain.value=20*a-10;break;case "equalizer3band-level":eq3band.out.gain.value=a;break;case "chorussupercharger-level":chorussupercharger.out.gain.value=a;break;case "chorussupercharger-gain":chorussupercharger.attenuator.gain.value=
a;break;case "chorusclassic-level":chorusclassic.out.gain.value=a;break;case "tremolo-frequency":tremolo.osc.frequency.value=20*a;break;case "tremolo-level":tremolo.out.gain.value=a;break;case "doppler-velocity":b.doppler.pannerVel=1.8*a;break;case "doppler-distance":b.doppler.pannerDistMax=1+3*a;break;case "doppler-level":doppler.out.gain.value=a;break;case "autoreverb-length":autoreverb.length=a*context.sampleRate*2;autoreverb.updateimpulse();break;case "autoreverb-decay":autoreverb.decay=6*a;autoreverb.updateimpulse();
break;case "autoreverb-offset":autoreverb.reverse=a;autoreverb.updateimpulse();break;case "fuxxboz-level":fuxxboz.out.gain.value=a;break;case "fuxxboz-drive":fuxxboz.drive(2*a);break;case "fuxxboz-tone":fuxxboz.lowEq.gain.value=10-20*a;fuxxboz.midEq.gain.value=20*a-10;fuxxboz.highEq.gain.value=20*a-10;break;case "fuzzbit-level":fuzzbit.out.gain.value=a;break;case "fuzzbit-drive":fuzzbit.drive(.1*a);break;case "fuzzbit-tone":fuzzbit.lowEq.gain.value=10-20*a;fuzzbit.midEq.gain.value=20*a-10;fuzzbit.highEq.gain.value=
20*a-10;break;case "eqmid-level":eqmid.out.value.gain=a;break;case "eqmid-quality":eqmid["in"].Q.value=2*a;break;case "eqmid-gain":eqmid["in"].gain.value=80*a-40;break;case "eqhigh-level":eqhigh.out.value.gain=a;break;case "eqhigh-frequency":eqhigh["in"].frequency.value=700*a;break;case "eqhigh-gain":eqhigh["in"].gain.value=80*a-40;break;case "eqlow-level":eqlow.out.value.gain=a;break;case "eqlow-frequency":eqlow["in"].frequency.value=700*a;break;case "eqlow-gain":eqlow["in"].gain.value=80*a-40;break;
case "eqpeak-level":eqpeak.out.gain.value=a;break;case "eqpeak-frequency":eqpeak["in"].frequency.value=700*a;break;case "eqpeak-quality":eqpeak["in"].Q.value=2*a;break;case "eqpeak-gain":eqpeak["in"].gain.value=80*a-40;break;case "flangerclassic-dry/wet":b.flangerclassic.level=1-a;break;case "flangerclassic-speed":b.flangerclassic.speed=.4*a;break;case "flangerclassic-level":flangerclassic.out.gain.value=a;break;case "flangermanhattan-frequency":b.flangermanhattan.freq=1+10*a;break;case "flangermanhattan-level":flangermanhattan.out.gain.value=
a;break;case "flangerdarkmouth-speed":b.flangerdarkmouth.speed=a;break;case "flangerdarkmouth-frequency":b.flangerdarkmouth.freq=1+10*a;break;case "flangerdarkmouth-level":flangerdarkmouth.out.gain.value=a;break;case "bitcrusher-level":bitcrusher.out.gain.value=a;break;case "bitcrusher-bits":b.bitcrusher.speed=parseInt(10*a);b.bitcrusher.step=Math.pow(.5,b.bitcrusher.speed);break;case "bitcrusher-frequency":b.bitcrusher.normfreq=a/10;break;case "digitalizer-level":digitalizer.out.gain.value=a;break;
case "compressor-level":compressor.out.gain.value=a;break;case "the-ripper-level":theripper.out.gain.value=a;break;case "the-ripper-drive":theripper.drive(18-16*a);break;case "the-ripper-cutoff":theripper["in"].frequency.value=100+200*a;break;case "the-bytter-level":thebytter.out.gain.value=a;break;case "the-bytter-drive":thebytter.drive(18-16*a);break;case "the-bytter-cutoff":thebytter["in"].frequency.value=100+200*a;break;case "flangersilver-level":flangersilver.out.gain.value=a;break;case "flangersilver-cutoff":flangersilver.cut.frequency.value=
2E3*a;break;case "flangersilver-frequency":flangersilver.osc.frequency.value=10*a;break;case "flangerstereo-level":flangerstereo.out.gain.value=a;break;case "flangerstereo-cutoff":flangerstereo.cut.frequency.value=2E3*a;break;case "flangerstereo-frequency":flangerstereo.oscR.frequency.value=flangerstereo.oscL.frequency.value=10*a;break;case "sterefy-level":sterefy.out.gain.value=a;break;case "sterefy-separation":sterefy.delayR.delayTime.value=a/10}};f.onmousemove=a;f.addEventListener("touchmove",
a,!1);numDial++}function rotate(a,b){transform(a,b,0,0,1)}function translate(a,b,d){transform(a,0,b,d,1)}function scale(a,b){transform(a,0,0,0,b)}function transform(a,b,d,e,g){null==b&&(b=0);null==d&&(d=0);null==e&&(e=0);null==g&&(g=1);b="rotate("+b+"deg) translate("+d+"px,"+e+"px) scale("+g+")";a.style["-ms-transform"]=b;a.style["-o-transform"]=b;a.style["-webkit-transform"]=b;a.style["-moz-transform"]=b;a.style.transform=b}Element.prototype.remove=function(){this.parentElement.removeChild(this)};
NodeList.prototype.remove=HTMLCollection.prototype.remove=function(){for(var a=0,b=this.length;a<b;a++)this[a]&&this[a].parentElement&&this[a].parentElement.removeChild(this[a])};var demoLoaded=!1;function readData(a){var b=new XMLHttpRequest;b.open("GET",a,!0);b.responseType="arraybuffer";b.onload=function(){id("demo").innerHTML="Play Demo";id("demo").disabled=!1;demoLoaded=!0};b.send(null)}
function share(a){var b="",d="";"web"==appType&&(d="guitar-effects.imagine5.com.ar");"android"==appType&&(d="play.google.com/store/apps/details?id=com.xtraid.guitareffects");switch(a){case "facebook":b="https://www.facebook.com/sharer/sharer.php?u="+d;break;case "twitter":b="https://twitter.com/home?status="+d;break;case "googleplus":b="https://plus.google.com/share?url="+d}window.open(b,"_blank").focus()};var controls={};null==localStorage.bufferSize&&(localStorage.bufferSize="2048");var BufferLength=parseInt(localStorage.bufferSize),effects={},noteStrings="B ;C ;C#;D ;D#;E ;F ;F#;G ;G#;A ;A#;B ;C ".split(";");function sign(a){return 0===a?1:Math.abs(a)/a}function tanh(a){var b=Math.exp(a);a=Math.exp(-a);return(b-a)/(b+a)}
effects.Sterefy=function(){this["in"]=context.createGain();this.splitter=context.createChannelSplitter(2);this.merger=context.createChannelMerger(2);this.delayR=context.createDelay();this.wetL=context.createGain();this.out=context.createGain();this.delayR.delayTime.value=.05;this["in"].connect(this.splitter);this.splitter.connect(this.wetL,0);this.splitter.connect(this.delayR,1);this.wetL.connect(this.merger,0,0);this.delayR.connect(this.merger,0,1);this.merger.connect(this.out)};
effects.FlangerStereo=function(){this["in"]=context.createGain();this.cut=context.createBiquadFilter();this.splitter=context.createChannelSplitter(2);this.merger=context.createChannelMerger(2);this.cut.type=webkit_audio?1:"highpass";this.cut.frequency.value=1E3;this.delay=context.createDelay();this.wetL=context.createGain();this.wetR=context.createGain();this.out=context.createGain();this.oscR=context.createOscillator();this.oscL=context.createOscillator();this.oscL.connect(this.wetL.gain);this.oscR.connect(this.wetR.gain);
this.oscL.frequency.value=this.oscR.frequency.value=5;this.oscL.start(0);this.oscR.start(.5);this.delay.delayTime.value=.06;this["in"].gain.value=.5;this["in"].connect(this.delay);this["in"].connect(this.out);this.delay.connect(this.cut);this.cut.connect(this.splitter);this.splitter.connect(this.wetL,0);this.splitter.connect(this.wetR,1);this.wetL.connect(this.merger,0,0);this.wetR.connect(this.merger,0,1);this.merger.connect(this.out)};
effects.FlangerSilver=function(){this["in"]=context.createGain();this.cut=context.createBiquadFilter();this.cut.type=webkit_audio?1:"highpass";this.cut.frequency.value=1E3;this.delay=context.createDelay();this.wet=context.createGain();this.out=context.createGain();this.osc=context.createOscillator();this.osc.connect(this.wet.gain);this.osc.frequency.value=5;this.osc.start(0);this.delay.delayTime.value=.06;this["in"].gain.value=.5;this["in"].connect(this.delay);this["in"].connect(this.out);this.delay.connect(this.cut);
this.cut.connect(this.wet);this.wet.connect(this.out)};effects.TheBytter=function(){this["in"]=context.createBiquadFilter();this["in"].type=0;this["in"].frequency.value=200;this.ws=context.createWaveShaper();this.out=context.createGain();this.drive=function(a){this.wsCurve=new Float32Array(512);for(var b=0;512>b;b+=1)this.wsCurve[b]=Math.sin(b/a);this.ws.curve=this.wsCurve};this.drive(10);this["in"].gain.value=.5;this["in"].connect(this.ws);this["in"].connect(this.out);this.ws.connect(this.out)};
effects.TheRipper=function(){this["in"]=context.createBiquadFilter();this["in"].type=0;this["in"].frequency.value=200;this.ws=context.createWaveShaper();this.out=context.createGain();this.drive=function(a){this.wsCurve=new Float32Array(256);for(var b=0;256>b;b+=1)this.wsCurve[b]=Math.cos(b/a);this.ws.curve=this.wsCurve};this.drive(10);this["in"].connect(this.ws);this.ws.connect(this.out)};effects.Compressor=function(){this.out=context.createGain();this["in"]=context.createDynamicsCompressor();this["in"].connect(this.out)};
effects.Limiter=function(){this.out=context.createGain();this["in"]=context.createGain();this["in"].connect(this.out)};
effects.Overdrive=function(){this["in"]=context.createBiquadFilter();this["in"].type=0;this["in"].frequency.value=3E3;this.ws=context.createWaveShaper();this.out=context.createGain();this.drive=function(a){this.wsCurve=new Float32Array(BufferLength);for(var b=Math.PI/180,d=0;d<BufferLength;d+=1){var e=2*d/BufferLength-1;this.wsCurve[d]=(3+a)*e*20*b/(Math.PI+a*Math.abs(e))}this.ws.curve=this.wsCurve};this.drive(500);this["in"].connect(this.ws);this.ws.connect(this.out)};
function writeString(a,b,d){for(var e=0;e<d.length;e++)a.setUint8(b+e,d.charCodeAt(e))}function mergeBuffers(a,b){for(var d=new Float32Array(b*BufferLength),e=0,g=0;g<a.length;g++)d.set(a[g],e),e+=a[g].length;return d}var sampleRate;
function encodeWAV(a){var b=new ArrayBuffer(44+2*a.length),b=new DataView(b);writeString(b,0,"RIFF");b.setUint32(4,32+2*a.length,!0);writeString(b,8,"WAVE");writeString(b,12,"fmt ");b.setUint32(16,16,!0);b.setUint16(20,1,!0);b.setUint16(22,2,!0);b.setUint32(24,sampleRate,!0);b.setUint32(28,4*sampleRate,!0);b.setUint16(32,4,!0);b.setUint16(34,16,!0);writeString(b,36,"data");b.setUint32(40,2*a.length,!0);floatTo16BitPCM(b,44,a);return b}
function floatTo16BitPCM(a,b,d){for(var e=0;e<d.length;e++,b+=2){var g=Math.max(-1,Math.min(1,d[e]));a.setInt16(b,0>g?32768*g:32767*g,!0)}}function interleave(a,b){for(var d=a.length+b.length,e=new Float32Array(d),g=0,f=0;g<d;)e[g++]=a[f],e[g++]=b[f],f++;return e}
function exportWAV(){var a=controls.recorder,b=mergeBuffers(a.samplesL,a.samplesL.length),a=mergeBuffers(a.samplesR,a.samplesR.length),b=interleave(b,a),b=encodeWAV(b);audioBlob=new Blob([b],{type:"audio/wav"});forceDownload();iniRecorder()}function iniRecorder(){var a=controls.recorder;a.samplesL=a.samplesR=[];a.s=0}
var audioBlob,forceDownload=function(){var a=(window.URL||window.webkitURL).createObjectURL(audioBlob),b=window.document.createElement("a");document.body.appendChild(b);b.style="display: none";b.href=a;b.target="_system";b.download="record-c"+parseInt(999999*Math.random())+".wav";b.click()};controls.recorder={samplesL:[],samplesR:[],s:0};
effects.Recorder=function(){sampleRate=context.sampleRate;this["in"]=context.createGain();this.rec=context.createScriptProcessor(BufferLength,2);this.out=context.createGain();this.ON=!1;this["in"].connect(this.rec);this["in"].connect(this.out);this.rec.onaudioprocess=function(a){var b=controls.recorder,d=a.inputBuffer.getChannelData(0);a=a.inputBuffer.getChannelData(1);b.samplesL[b.s]=d;b.samplesR[b.s]=a;b.s++}};
effects.Digitalizer=function(){this["in"]=context.createScriptProcessor(BufferLength,1,1);this.out=context.createGain();this["in"].connect(this.out);this["in"].onaudioprocess=function(a){var b=a.inputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(0);for(var d=0;d<BufferLength;d++)a[d]=Math.round(5*b[d])/5}};controls.flangerdarkmouth={last:[],cc:0,freq:6,speed:.1};
effects.FlangerDarkmouth=function(){this.out=context.createGain();this["in"]=context.createScriptProcessor(BufferLength,1,1);for(var a=0;a<BufferLength;a++)controls.flangerdarkmouth.last[a]=0;this["in"].onaudioprocess=function(a){var d=a.inputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(0);var e,g=controls.flangerdarkmouth,f=Math.PI/(256/g.freq);g.cc+=g.speed;for(var h=0;h<BufferLength;h++)e=d[h]*Math.sin(g.cc),a[h]=e+g.last[h]*Math.sin(h*f)*Math.sin(g.cc+1.5707),g.last[h]=d[h]*Math.sin(h*
f)};this["in"].connect(this.out)};controls.flangermanhattan={last:[],cc:0,freq:6};
effects.FlangerManhattan=function(){this.out=context.createGain();this["in"]=context.createScriptProcessor(BufferLength,1,1);for(var a=0;a<BufferLength;a++)controls.flangermanhattan.last[a]=0;this["in"].onaudioprocess=function(a){var d=a.inputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(0);for(var e,g=controls.flangermanhattan,f=Math.PI/(256/g.freq),h=0;h<BufferLength;h++)e=.5*d[h],a[h]=e+g.last[h]*Math.sin(h*f)*.5,g.last[h]=d[h]*Math.sin(h*f)};this["in"].connect(this.out)};
controls.flangerclassic={last:[],cc:0,speed:.5,level:.5};
effects.FlangerClassic=function(){this.out=context.createGain();this["in"]=context.createScriptProcessor(BufferLength,1,1);for(var a=0;a<BufferLength;a++)controls.flangerclassic.last[a]=0;this["in"].onaudioprocess=function(a){var d=a.inputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(0);var e,g=controls.flangerclassic,f=Math.PI/(BufferLength/12);g.cc+=g.speed;for(var h=0;h<BufferLength;h++)e=d[h],a[h]=e*g.level+(1-g.level)*g.last[h]*Math.sin(h*f)*Math.sin(g.cc+1.5707),g.last[h]=e*Math.sin(h*
f)};this["in"].connect(this.out)};controls.bitcrusher={bits:2,normfreq:.1,step:Math.pow(.5,2),phaser:0,last:0};
effects.Bitcrusher=function(){this.out=context.createGain();this["in"]=context.createScriptProcessor(BufferLength,1,1);this["in"].connect(this.out);this["in"].onaudioprocess=function(a){var b=a.inputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(0);for(var d=controls.bitcrusher,e=0;e<BufferLength;e++)d.phaser+=d.normfreq,1<=d.phaser&&(d.phaser-=1,d.last=d.step*Math.floor(b[e]/d.step+.5)),a[e]=d.last}};
effects.EqPeak=function(){this["in"]=context.createBiquadFilter();this.out=context.createGain();this["in"].type=webkit_audio?5:"peaking";this["in"].connect(this.out)};effects.EqLow=function(){this["in"]=context.createBiquadFilter();this.out=context.createGain();this["in"].type=webkit_audio?3:"lowshelf";this["in"].connect(this.out)};effects.EqHigh=function(){this["in"]=context.createBiquadFilter();this.out=context.createGain();this["in"].type=webkit_audio?4:"highshelf";this["in"].connect(this.out)};
effects.EqMid=function(){this["in"]=context.createBiquadFilter();this.out=context.createGain();this["in"].type=webkit_audio?5:"peaking";this["in"].connect(this.out)};
effects.FuxxBoz=function(){this["in"]=context.createGain();this.out=context.createGain();this.lowEq=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();webkit_audio?(this.lowEq.type=3,this.midEq.type=5,this.highEq.type=4):(this.lowEq.type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this.lowEq.gain.value=5;this.midEq.gain.value=1;this.highEq.gain.value=-5;this.ws=context.createWaveShaper();this.drive=function(a){this.wsCurve=
new Float32Array(2048);var b,d,e,g=.99<1-a?.99:1-a;for(a=0;2048>a;a++)b=2*a/2048-1,e=Math.abs(b),e<g?d=e:e>g?d=g+(e-g)/(1+Math.pow((e-g)/(1-g),2)):1<e&&(d=e),this.wsCurve[a]=sign(b)*d*(1/((g+1)/2));this.ws.curve=this.wsCurve};this.drive(1);this["in"].connect(this.lowEq);this.lowEq.connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.ws);this.ws.connect(this.out)};
effects.FuzzBit=function(){this["in"]=context.createGain();this.out=context.createGain();this.lowEq=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();webkit_audio?(this.lowEq.type=3,this.midEq.type=5,this.highEq.type=4):(this.lowEq.type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this.lowEq.gain.value=5;this.midEq.gain.value=1;this.highEq.gain.value=-5;this.ws=context.createWaveShaper();this.drive=function(a){this.wsCurve=
new Float32Array(512);a=2+Math.round(14*a);a=Math.round(Math.pow(2,a-1));var b,d;for(b=0;512>b;b++)d=2*b/512-1,this.wsCurve[b]=Math.round(d*a)/a;this.ws.curve=this.wsCurve};this.drive(.05);this["in"].connect(this.lowEq);this.lowEq.connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.ws);this.ws.connect(this.out)};controls.doppler={panner:null,pannerPos:0,pannerM:null,pannerDistMax:2.5,pannerVel:.9};
function setDoppler(){var a=controls.doppler;null==a.pannerM||a.pannerPos>=a.pannerDistMax?a.pannerM=!1:a.pannerPos<=-a.pannerDistMax&&(a.pannerM=!0);a.pannerPos=a.pannerM?a.pannerPos+a.pannerVel:a.pannerPos-a.pannerVel;a.panner.setPosition(a.pannerPos,0,0);a.panner.setVelocity(2*a.pannerPos,0,0);setTimeout(setDoppler,100)}
effects.Doppler=function(){this["in"]=context.createGain();this.panner=context.createPanner();this.out=context.createGain();controls.doppler.panner=this.panner;this["in"].connect(this.panner);this.panner.connect(this.out);setDoppler()};var freq,fLenght,currentPitch;
function getFreq(){var a=document.getElementById("analyser-note"),b=new Uint8Array(2048);freq.getByteTimeDomainData(b);autoCorrelate(b,fLenght);var b=noteFromPitch(currentPitch),b=b%12+1,d=centsOffFromPitch(currentPitch,b),d="<img id='detune-n' src='img/detune.png' style='transform:translateX("+d/400+"px);-webkit-transform:translateX("+d/400+"px)' />";100>b&&-100<b&&(a.innerHTML="<table id='note-a' ><tr><td style='color:#c00'>"+noteStrings[b-1]+"</td><td>"+noteStrings[b]+"</td><td style='color:#c00'>"+
noteStrings[b+1]+"</td></tr></table>"+d);setTimeout(getFreq,100)}function autoCorrelate(a,b){var d=-1,e=0,g=0;currentPitch=confidence=0;if(!(1996>a.length)){for(var f=0;1E3>f;f++)var h=(a[f]-128)/128,g=g+h*h;g=Math.sqrt(g/1E3);for(h=4;1E3>=h;h++){for(var l=0,f=0;1E3>f;f++)l+=Math.abs((a[f]-128)/128-(a[f+h]-128)/128);l=1-l/1E3;l>e&&(e=l,d=h)}.01<g&&.01<e&&(confidence=e*g*1E4,currentPitch=b/d)}}function noteFromPitch(a){a=12*(Math.log(a/440)/Math.log(2));return Math.round(a)+69}
function frequencyFromNoteNumber(a){return 440*Math.pow(2,(a-69)/12)}function centsOffFromPitch(a,b){return 1200*Math.log(a/frequencyFromNoteNumber(b))/Math.log(2)}effects.Analyser=function(){this["in"]=context.createGain();this.out=context.createGain();freq=this.analyser=context.createAnalyser();fLenght=context.sampleRate;this.analyser.fftSize=2048;this["in"].connect(this.analyser);this.analyser.connect(this.out);getFreq()};
effects.Tremolo=function(){this["in"]=context.createGain();this.out=context.createGain();this.osc=context.createOscillator();this.osc.connect(this.out.gain);this.osc.frequency.value=10;this.osc.start(0);this["in"].connect(this.out)};
effects.ChorusClassic=function(){this["in"]=context.createGain();this.delay1=context.createDelay();this.delay2=context.createDelay();this.delay3=context.createDelay();this.delay4=context.createDelay();this.delay5=context.createDelay();this.delay6=context.createDelay();this.delay7=context.createDelay();this.out=context.createGain();this.delay1.delayTime.value=0;this.delay2.delayTime.value=.01;this.delay3.delayTime.value=.02;this.delay4.delayTime.value=.04;this.delay5.delayTime.value=.06;this.delay6.delayTime.value=
.08;this.delay7.delayTime.value=.1;this["in"].connect(this.delay1);this["in"].connect(this.delay2);this["in"].connect(this.delay3);this["in"].connect(this.delay4);this["in"].connect(this.delay5);this["in"].connect(this.delay6);this["in"].connect(this.delay7);this.delay1.connect(this.out);this.delay2.connect(this.out);this.delay3.connect(this.out);this.delay4.connect(this.out);this.delay5.connect(this.out);this.delay6.connect(this.out);this.delay7.connect(this.out);this["in"].connect(this.out);this["in"].gain.value=
.5};
effects.ChorusSupercharger=function(){this["in"]=context.createGain();this.out=context.createGain();this.attenuator=context.createGain();this.splitter=context.createChannelSplitter(2);this.delayL=context.createDelay();this.delayR=context.createDelay();this.feedbackR=context.createGain();this.feedbackL=context.createGain();this.merger=context.createChannelMerger(2);this.waveShaperL=context.createWaveShaper();this.waveShaperR=context.createWaveShaper();this.lowPass=context.createBiquadFilter();this.lowPass.type=
webkit_audio?0:"lowpass";this.lowPass.frequency.value=700;this.feedbackL.gain.value=this.feedbackR.gain.value=.45;this.delayR.delayTime.value=this.delayL.delayTime.value=.05;this.attenuator.gain.value=.5;this["in"].connect(this.attenuator);this["in"].connect(this.out);this.attenuator.connect(this.out);this.attenuator.connect(this.splitter);this.splitter.connect(this.delayL,0);this.splitter.connect(this.delayR,1);this.delayL.connect(this.feedbackR);this.delayR.connect(this.feedbackL);this.feedbackR.connect(this.delayR);
this.feedbackL.connect(this.delayL);this.delayL.connect(this.merger,0,0);this.delayR.connect(this.merger,0,1);this.merger.connect(this.out);this.drive=function(){this.wsCurve=new Float32Array(2048);for(var a=0;2048>a;++a)this.wsCurve[a]=Math.sin(a/2048*Math.PI*2);this.waveShaperL.curve=this.wsCurve;for(var b,a=0;2048>a;++a)b=a/2048-.25,this.wsCurve[a]=1-4*Math.abs(Math.round(b)-b);this.waveShaperR.curve=this.wsCurve};this.drive()};
effects.Eq3=function(){this["in"]=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();this.out=context.createGain();webkit_audio?(this["in"].type=3,this.midEq.type=5,this.highEq.type=4):(this["in"].type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this["in"].connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.out)};
effects.DelayStereo=function(){this.delayL=context.createDelay();this.delayR=context.createDelay();this.splitter=context.createChannelSplitter(2);this.feedbackL=context.createGain();this.feedbackR=context.createGain();this.wetLevel=context.createGain();this.filterL=context.createBiquadFilter();this.filterR=context.createBiquadFilter();this.out=context.createGain();this["in"]=context.createGain();this.merger=context.createChannelMerger(2);this.filterR.type=6;this.filterR.frequency.value=4E3;this.filterL.type=
1;this.filterL.frequency.value=8E3;webkit_audio?(this.filterL.type=1,this.filterR.type=6):(this.filterL.type="highpass",this.filterR.type="notch");this["in"].connect(this.out);this["in"].connect(this.splitter);this.splitter.connect(this.delayL,0);this.splitter.connect(this.delayR,1);this.delayL.connect(this.filterL);this.delayR.connect(this.filterR);this.filterL.connect(this.feedbackL);this.filterR.connect(this.feedbackR);this.feedbackL.connect(this.delayL);this.feedbackR.connect(this.delayR);this.delayL.connect(this.merger,
0,0);this.delayR.connect(this.merger,0,1);this.merger.connect(this.wetLevel);this.wetLevel.connect(this.out);this.delayR.delayTime.value=.25;this.delayL.delayTime.value=.235;this.feedbackL.gain.value=this.feedbackR.gain.value=.4};
effects.Delay=function(){this.delay=context.createDelay();this.feedback=context.createGain();this.wetLevel=context.createGain();this.out=context.createGain();this["in"]=context.createGain();this["in"].connect(this.delay);this["in"].connect(this.out);this.delay.connect(this.feedback);this.delay.connect(this.wetLevel);this.feedback.connect(this.delay);this.wetLevel.connect(this.out);this.feedback.gain.value=.4;this.wetLevel.gain.value=.5;this.delay.delayTime.value=.25};
effects.Overscream=function(){this["in"]=context.createBiquadFilter();this["in"].type=0;this["in"].frequency.value=3E3;this.out=context.createGain();this.ws=context.createWaveShaper();this.drive=function(a){this.wsCurve=new Float32Array(10);for(var b=Math.PI/180,d=0;10>d;d+=1){var e=2*d/10-1;this.wsCurve[d]=1E4*e*b/(Math.PI-a*Math.abs(e))}this.ws.curve=this.wsCurve};this.drive(200);this["in"].connect(this.ws);this.ws.connect(this.out)};
effects.Fuzz=function(){this["in"]=context.createBiquadFilter();this["in"].type=0;this["in"].frequency.value=3E3;this.out=context.createGain();this.ws=context.createWaveShaper();this.drive=function(a){this.wsCurve=new Float32Array(512);for(var b=Math.PI/180,d=0;512>d;d+=1){var e=2*d/512-1;this.wsCurve[d]=(3+a)*e*20*b/(Math.PI+a*Math.abs(e))}this.ws.curve=this.wsCurve};this.drive(1E3);this["in"].connect(this.ws);this.ws.connect(this.out)};
effects.AutoReverb=function(){this["in"]=context.createGain();this.convolver=context.createConvolver();this.out=context.createGain();this.decay=3;this.reverse=0;this.length=context.sampleRate;this.impulse=context.createBuffer(2,this.length,context.sampleRate);this.impulseL=this.impulse.getChannelData(0);this.impulseR=this.impulse.getChannelData(1);this.counter=0;this.updateimpulse=function(){if(0==this.counter%20){for(i=0;i<this.length;i++)n=this.reverse?this.length-i:i,this.impulseL[i]=(2*Math.random()-
1)*Math.pow(1-n/this.length,this.decay),this.impulseR[i]=(2*Math.random()-1)*Math.pow(1-n/this.length,this.decay);this.convolver.buffer=this.impulse}this.counter++};this.updateimpulse();this["in"].connect(this.convolver);this.convolver.connect(this.out)};effects.RingRing=function(){this.irPath="audio/ir/reverb/ringring.ogg";this.cabinet=!1;loadIR(this)};effects.Convolver=function(){this.irPath="audio/ir/reverb/convolver.ogg";this.cabinet=!1;loadIR(this)};
effects.ReverbClassic=function(){this.irPath="audio/ir/reverb/classic.ogg";this.cabinet=!1;loadIR(this)};effects.ReverbCatedral=function(){this.irPath="audio/ir/reverb/catedral.ogg";this.cabinet=!1;loadIR(this)};effects.ReverbSmallRoom=function(){this.irPath="audio/ir/reverb/smallroom.ogg";this.cabinet=!1;loadIR(this)};function listAmplifiers(a){if(a)translate(id("amplifiers-list"),0,0);else{translate(id("amplifiers-list"),-241,0);a="0 eqg modger bassman rpr crusher 0".split(" ");for(var b="close EQG German Bassman RPR Crusher close".split(" "),d="",e=0;e<a.length;e++){var g="";"0"==a[e]&&(g="cabinet-sel-close");d+="<div onclick='selectAmplifier(\""+a[e]+'","'+b[e]+"\")' class='cabinet-select "+g+"'>"+b[e]+"</div>"}id("amplifiers-list").innerHTML=d}}
effects.Crusher=function(){this.ON=amplifierON;this.out=context.createGain();this["in"]=context.createWaveShaper();this.phaser=context.createBiquadFilter();this.lowEq=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();webkit_audio?(this.lowEq.type=3,this.midEq.type=5,this.highEq.type=4):(this.lowEq.type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this.phaser.frequency.value=600;this.drive=function(a){a/=10;k=5E3;this.wsCurve=
new Float32Array(k);for(var b=0;b<k;b++)this.wsCurve[b]=b<k/2?b/k*a:(k-b/k)*a;this["in"].curve=this.wsCurve};this["in"].connect(this.phaser);this.phaser.connect(this.lowEq);this.lowEq.connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.out)};
effects.RPR=function(){this.ON=amplifierON;this.out=context.createGain();this["in"]=context.createWaveShaper();this.phaser=context.createBiquadFilter();this.lowEq=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();webkit_audio?(this.phaser.type=1,this.lowEq.type=3,this.midEq.type=5,this.highEq.type=4):(this.phaser.type="highpass",this.lowEq.type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this.phaser.frequency.value=
220;this.drive=function(a){a-=17;this.wsCurve=new Float32Array(256);for(var b=0;256>b;b+=1)this.wsCurve[b]=Math.cos(b/a);this["in"].curve=this.wsCurve};this["in"].connect(this.phaser);this.phaser.connect(this.lowEq);this.lowEq.connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.out)};
effects.Bassman=function(){this.ON=amplifierON;this.out=context.createGain();this["in"]=context.createWaveShaper();this.low=context.createBiquadFilter();this.lowEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();webkit_audio?(this.lowEq.type=3,this.highEq.type=4):(this.lowEq.type="lowshelf",this.highEq.type="highshelf");this.low.frequency.value=880;this.drive=function(a){this.wsCurve=new Float32Array(1024);for(var b=0;1024>b;b+=1){var d=2*b/1024-1;this.wsCurve[b]=(1+a)*d/(1+
a*Math.abs(d))}this["in"].curve=this.wsCurve};this["in"].connect(this.low);this.low.connect(this.lowEq);this.lowEq.connect(this.highEq);this.highEq.connect(this.out)};
effects.EQG=function(){this.ON=amplifierON;this["in"]=context.createGain();this.lowEq=context.createBiquadFilter();this.midEq=context.createBiquadFilter();this.highEq=context.createBiquadFilter();this.out=context.createGain();webkit_audio?(this.lowEq.type=3,this.midEq.type=5,this.highEq.type=4):(this.lowEq.type="lowshelf",this.midEq.type="peaking",this.highEq.type="highshelf");this["in"].connect(this.lowEq);this.lowEq.connect(this.midEq);this.midEq.connect(this.highEq);this.highEq.connect(this.out)};
effects.ModernGer=function(){this.ON=amplifierON;this.out=context.createGain();this["in"]=context.createWaveShaper();this.drive=function(a){this.wsCurve=new Float32Array(512);for(var b=0;512>b;b+=1){var d=2*b/512-1;this.wsCurve[b]=(1+a)*d/(1+a*Math.abs(d))}this["in"].curve=this.wsCurve};this["in"].connect(this.out)};function listCabinets(a){if(a)translate(id("cabinets-list"),0,0);else{translate(id("cabinets-list"),-241,0);a="0 vinus vinuk clean bass deep stereo alien peaker noisy power feedy metal 0".split(" ");for(var b="close;Vintage US;Vintage UK;Clean;Bass;Deep;Stereo;Alien;Peaker;Noisy;Power;Feedy;Metal;close".split(";"),d="",e=0;e<a.length;e++){var g="";"0"==a[e]&&(g="cabinet-sel-close");d+="<div onclick='selectCabinet(\""+a[e]+'","'+b[e]+"\")' class='cabinet-select "+g+"'>"+b[e]+"</div>"}id("cabinets-list").innerHTML=
d}}effects.Peaker=function(){this.irPath="audio/ir/speaker/peaker.ogg";this.cabinet=!0;loadIR(this)};effects.Power=function(){this.irPath="audio/ir/speaker/power.ogg";this.cabinet=!0;loadIR(this)};effects.Noisy=function(){this.irPath="audio/ir/speaker/noisy.ogg";this.cabinet=!0;loadIR(this)};effects.Feedy=function(){this.irPath="audio/ir/speaker/feedy.ogg";this.cabinet=!0;loadIR(this)};effects.Metal=function(){this.irPath="audio/ir/speaker/metal.ogg";this.cabinet=!0;loadIR(this)};
effects.VinUs=function(){this.irPath="audio/ir/speaker/vintageus.ogg";this.cabinet=!0;loadIR(this)};effects.VinUk=function(){this.irPath="audio/ir/speaker/vintageuk.ogg";this.cabinet=!0;loadIR(this)};effects.Clean=function(){this.irPath="audio/ir/speaker/clean.wav";this.cabinet=!0;loadIR(this)};effects.Bass=function(){this.irPath="audio/ir/speaker/bass.wav";this.cabinet=!0;loadIR(this)};effects.Deep=function(){this.irPath="audio/ir/speaker/deep.wav";this.cabinet=!0;loadIR(this)};
effects.Stereo=function(){this.irPath="audio/ir/speaker/stereo.wav";this.cabinet=!0;loadIR(this)};effects.Alien=function(){this.irPath="audio/ir/speaker/alien.wav";this.cabinet=!0;loadIR(this)};