<commit_before>var WX=WX||{REVISION:2};console.log("Starting WAAX...(REVISION "+WX.REVISION+")");WX._Templates={};WX._Dictionary=Object.freeze({Fader:"Fader.unit",Oscil:"Oscil.unit",Noise:"Noise.unit",LFO:"LFO.unit",Sampler:"Sampler.unit",LPF:"LPF.unit",ADSR:"ADSR.unit",Compressor:"Compressor.unit",FeedbackDelay:"FeedbackDelay.unit",ConVerb:"ConVerb.unit"});WX._context=new webkitAudioContext;
WX._Unit=function(){Object.defineProperties(this,{_inlet:{value:WX._context.createGainNode(),enumerable:!1,writable:!1},_outlet:{value:WX._context.createGainNode(),enumerable:!1,writable:!1}})};
WX._Unit.prototype=Object.create(null,{to:{enumerable:!1,value:function(a){this._outlet.connect(a._inlet);return a}},cut:{enumerable:!1,value:function(){this._outlet.disconnect()}},toNode:{enumerable:!1,value:function(a){this._outlet.connect(a)}},gain:{enumerable:!0,get:function(){return this._outlet.gain.value},set:function(a){this._outlet.gain.value=a}},params:{enumerable:!1,get:function(){var a=Object.create(null),b;for(b in this)a[b]=this[b];return a},set:function(a){if("object"!==typeof a)WX.error(this,
"invalid JSON.");else for(var b in a)void 0!==this[b]?this[b]=a[b]:WX.error(this,b+" is not available.")}},label:{enumerable:!1,get:function(){return this._label}}});WX._customUnitBufferSize=512;WX._Internals={};(function(){var a=WX._context.sampleRate,b=5*a,c=new Float32Array(b);WX._Templates.whitenoise=WX._context.createBuffer(1,b,a);for(a=0;a<b;++a)c[a]=2*Math.random()-1;WX._Templates.whitenoise.getChannelData(0).set(c,0)})();WX.PI=Math.PI;WX.TWOPI=2*Math.PI;WX.EPS=Number.MIN_VALUE;WX.C5=261.262;WX.A4=440;WX.midi2freq=function(a){return 440*Math.pow(2,(Math.floor(a)-69)/12)};WX.freq2midi=function(a){return Math.floor(69+12*Math.log(a/440)/Math.log(2))};WX.random2f=function(a,b){return a+Math.random()*(b-a)};WX.random2=function(a,b){return Math.round(a+Math.random()*(b-a))};WX.lin2db=function(a){return 20*(1E-5<a?Math.log(a)/Math.LN10:-5)};WX.db2lin=function(a){return Math.pow(10,a/20)};
WX.error=function(a,b){console.log("[WX:"+a.label+"] "+b)};WX.Fader=function(){WX._Unit.call(this);Object.defineProperties(this,{_muted:{enumerable:!1,writable:!0,value:!1},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.Fader}});this._inlet.connect(this._outlet);this.params={gain:1}};
WX.Fader.prototype=Object.create(WX._Unit.prototype,{mute:{enumerable:!0,get:function(){return this._muted},set:function(a){!0===a?(this._muted=!0,this._inlet.gain.value=0):(this._muted=!1,this._inlet.gain.value=1)}},db:{enumerable:!0,get:function(){return WX.lin2db(this._outlet.gain.value)},set:function(a){this._outlet.gain.value=WX.db2lin(a)}},modulateWith:{value:function(a){a._outlet.connect(this._inlet.gain)}}});WX.Out=new WX.Fader;WX.Out.toNode(WX._context.destination);WX.Oscil=function(a){WX._Unit.call(this);Object.defineProperties(this,{_oscil:{enumerable:!1,writable:!1,value:WX._context.createOscillator()},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.Oscil}});this._inlet.connect(this._oscil.frequency);this._oscil.connect(this._outlet);this._oscil.noteOn(0);this.params=a||{frequency:440,type:"sine",gain:1}};
WX.Oscil.prototype=Object.create(WX._Unit.prototype,{frequency:{enumerable:!0,get:function(){return this._oscil.frequency.value},set:function(a){this._oscil.frequency.value=a}},type:{enumerable:!0,get:function(){return this._oscil.type},set:function(a){this._oscil.type=a}}});WX.Noise=function(a){WX._Unit.call(this);Object.defineProperties(this,{_node:{enumerable:!1,writable:!1,value:WX._context.createBufferSource()},_type:{enumerable:!1,writable:!0,value:"white"},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.Noise}});this._node.connect(this._outlet);this._node.buffer=WX._Templates.whitenoise;this._node.loop=1;this._node.noteOn(0);this.params=a};
WX.Noise.prototype=Object.create(WX._Unit.prototype,{type:{enumerable:!0,get:function(){return this._type},set:function(a){this._type=a}}});WX.Sampler=function(a){WX._Unit.call(this);Object.defineProperties(this,{_buffer:{enumerable:!1,writable:!0,value:void 0},_node:{enumerable:!1,writable:!0,value:void 0},_url:{enumerable:!1,writable:!0,value:""},_basePitch:{enumerable:!1,writable:!0,value:60},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.Sampler},_ready:{enumerable:!1,writable:!0,value:!1}});this.params=a};
WX.Sampler.prototype=Object.create(WX._Unit.prototype,{source:{enumerable:!0,get:function(){return this._url},set:function(a){if(void 0===a)return WX.error(this,"invalid audio file path."),!1;var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){try{b._buffer=WX._context.createBuffer(c.response,!0),b._ready=!0}catch(e){WX.error(b,"file loading error: "+a+" ("+e.message+")")}};c.send();this._url=a;return!0}},basePitch:{enumerable:!0,get:function(){return this._basePitch},
set:function(a){this._basePitch=a}},noteOn:{value:function(a){this._ready?(this._node=WX._context.createBufferSource(),this._node.buffer=this._buffer,this._node.connect(this._outlet),void 0!==a&&(a=Math.pow(2,(a-this._basePitch)/12),this._node.playbackRate.setValueAtTime(a,0)),this._node.start(0)):WX.error(this,"sampler is not ready.")}},noteOff:{value:function(){this._node&&this._node.stop(0)}}});WX.LFO=function(a){WX._Unit.call(this);Object.defineProperties(this,{_lfo:{enumerable:!1,writable:!1,value:WX._context.createOscillator()},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.LFO}});this._lfo.connect(this._outlet);this._lfo.frequency.value=5;this._lfo.noteOn(0);this.params=a};
WX.LFO.prototype=Object.create(WX._Unit.prototype,{rate:{enumerable:!0,get:function(){return this._lfo.frequency.value},set:function(a){a=Math.max(0,Math.min(20,a));this._lfo.frequency.value=a}},depth:{enumerable:!0,get:function(){return this._outlet.gain.value},set:function(a){this._outlet.gain.value=a}},shape:{enumerable:!0,get:function(){return this._lfo.type},set:function(a){this._lfo.type=a}}});WX.ADSR=function(a){WX._Unit.call(this);Object.defineProperties(this,{_a:{enumerable:!1,writable:!0,value:0.0050},_d:{enumerable:!1,writable:!0,value:0.015},_s:{enumerable:!1,writable:!0,value:0.35},_r:{enumerable:!1,writable:!0,value:0.015},_running:{enumerable:!1,writable:!0,value:!1},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.ADSR}});this._inlet.connect(this._outlet);this._inlet.gain.value=0;this.params=a};
WX.ADSR.prototype=Object.create(WX._Unit.prototype,{running:{enumerable:!0,get:function(){return this._running}},a:{enumerable:!0,get:function(){return this._a},set:function(a){this._a=a}},d:{enumerable:!0,get:function(){return this._d},set:function(a){this._d=a}},s:{enumerable:!0,get:function(){return this._s},set:function(a){this._s=a}},r:{enumerable:!0,get:function(){return this._r},set:function(a){this._r=a}},noteOn:{value:function(){var a=WX._context.currentTime;this._inlet.gain.cancelScheduledValues(a);
this._inlet.gain.setValueAtTime(this._inlet.gain.value,a);this._inlet.gain.linearRampToValueAtTime(0,a);this._inlet.gain.linearRampToValueAtTime(1,a+this._a);this._inlet.gain.linearRampToValueAtTime(this._s,a+this._a+this._d);this._running=!0}},noteOff:{value:function(){var a=WX._context.currentTime;this._inlet.gain.cancelScheduledValues(a);this._inlet.gain.setValueAtTime(this._inlet.gain.value,a);this._inlet.gain.linearRampToValueAtTime(0,a+this._r);this._running=!1}}});WX.LPF=function(a){WX._Unit.call(this);Object.defineProperties(this,{_lpf:{enumerable:!1,writable:!1,value:WX._context.createBiquadFilter()}});this._inlet.connect(this._lpf);this._lpf.connect(this._outlet);this._lpf.type=0;this.params=a};
WX.LPF.prototype=Object.create(WX._Unit.prototype,{cutoff:{enumerable:!0,get:function(){return this._lpf.frequency.value},set:function(a){this._lpf.frequency.value=a}},Q:{enumerable:!0,get:function(){return this._lpf.Q.value},set:function(a){this._lpf.Q.value=a}},modulateWith:{value:function(a){a._outlet.connect(this._lpf.frequency)}},getFrequencuResponse:{value:function(){return"not implemented yet"}}});WX.Comp=function(a){WX._Unit.call(this);Object.defineProperties(this,{_comp:{enumerable:!1,writable:!1,value:WX._context.createDynamicsCompressor()}});this._inlet.connect(this._comp);this._comp.connect(this._outlet);this.params=a};
WX.Comp.prototype=Object.create(WX._Unit.prototype,{threshold:{enumerable:!0,get:function(){return this._comp.threshold.value},set:function(a){this._comp.threshold.value=a}},ratio:{enumerable:!0,get:function(){return this._comp.ratio.value},set:function(a){this._comp.ratio.value=a}},knee:{enumerable:!0,get:function(){return this._comp.knee.value},set:function(a){this._comp.knee.value=a}},attack:{enumerable:!0,get:function(){return this._comp.attack.value},set:function(a){this._comp.attack.value=a}},
release:{enumerable:!0,get:function(){return this._comp.release.value},set:function(a){this._comp.release.value=a}}});WX.FeedbackDelay=function(a){WX._Unit.call(this);Object.defineProperties(this,{_delay:{enumerable:!1,writable:!1,value:WX._context.createDelay()},_fb:{enumerable:!1,writable:!1,value:WX._context.createGain()},_dry:{enumerable:!1,writable:!1,value:WX._context.createGain()},_wet:{enumerable:!1,writable:!1,value:WX._context.createGain()},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.FeedbackDelay}});this._inlet.connect(this._delay);this._inlet.connect(this._dry);this._delay.connect(this._fb);
this._delay.connect(this._wet);this._fb.connect(this._delay);this._dry.connect(this._outlet);this._wet.connect(this._outlet);this.params=a};
WX.FeedbackDelay.prototype=Object.create(WX._Unit.prototype,{delayTime:{enumerable:!0,get:function(){return this._delay.delayTime.value},set:function(a){this._delay.delayTime.value=a}},feedback:{enumerable:!0,get:function(){return this._fb.gain.value},set:function(a){this._fb.gain.value=a}},mix:{enumerable:!0,get:function(){return this._wet.gain.value},set:function(a){this._wet.gain.value=a;this._dry.gain.value=1-a}},modulateWith:{value:function(a){a._outlet.connect(this._delay.delayTime)}}});WX.ConVerb=function(a){WX._Unit.call(this);Object.defineProperties(this,{_convolver:{enumerable:!1,writable:!1,value:WX._context.createConvolver()},_dry:{enumerable:!1,writable:!1,value:WX._context.createGain()},_wet:{enumerable:!1,writable:!1,value:WX._context.createGain()},_url:{enumerable:!1,writable:!0,value:""},_label:{enumerable:!1,writable:!1,value:WX._Dictionary.ConVerb}});this._inlet.connect(this._convolver);this._convolver.connect(this._wet);this._inlet.connect(this._dry);this._dry.connect(this._outlet);
this._wet.connect(this._outlet);this.params=a};
WX.ConVerb.prototype=Object.create(WX._Unit.prototype,{source:{enumerable:!0,get:function(){return this._url},set:function(a){if(void 0===a)return WX.error(this,"invalid IR file path."),!1;var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){try{b._convolver.buffer=WX._context.createBuffer(c.response,!0)}catch(e){WX.error(b,"file loading error: "+a+" ("+e.message+")")}};c.send();this._url=a;return!0}},mix:{enumerable:!0,get:function(){return this._wet.gain.value},
set:function(a){this._wet.gain.value=a;this._dry.gain.value=1-a}}});WX.C2=function(a){WX._Unit.call(this);Object.defineProperties(this,{_threshold:{enumerable:!1,writable:!0,value:WX.db2lin(-12)},_ratio:{enumerable:!1,writable:!0,value:4},_iratio:{enumerable:!1,writable:!0,value:1/(this._ratio-1)},_makeup:{enumerable:!1,writable:!0,value:WX.db2lin(0)},_detector:{enumerable:!1,writable:!1,value:new WX._Internals.DualLevelDetector},_processor:{enumerable:!1,writable:!1,value:WX._context.createScriptProcessor(WX._customUnitBufferSize,2,2)}});var b=this;this._processor.onaudioprocess=
function(a){b._callback(a)};this._inlet.connect(this._processor);this._processor.connect(this._outlet);this.params=a};
WX.C2.prototype=Object.create(WX._Unit.prototype,{_callback:{value:function(a){var b,c=a.inputBuffer.getChannelData(0),e=a.inputBuffer.getChannelData(1),f=a.outputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(1);for(var d=0,g=WX._customUnitBufferSize;d<g;++d)b=Math.max(Math.abs(c[d]),Math.abs(e[d])),b=this._detector.process(b),b=WX.lin2db(b/this._threshold),b=0>=b?0:b*this._iratio,b=WX.db2lin(b),f[d]=c[d]*b*this._makeup,a[d]=e[d]*b*this._makeup}},threshold:{enumerable:!0,get:function(){return WX.lin2db(this._threshold)},
set:function(a){this._threshold=WX.db2lin(a)}},ratio:{enumerable:!0,get:function(){return this._ratio},set:function(a){this._ratio=a;this._iratio=1/(this._ratio-1)}},attack:{enumerable:!0,get:function(){return this._detector.attack},set:function(a){this._detector.attack=a}},release:{enumerable:!0,get:function(){return this._detector.release},set:function(a){this._detector.release=a}},makeup:{enumerable:!0,get:function(){return WX.lin2db(this._makeup)},set:function(a){this._makeup=WX.db2lin(a)}}});<commit_msg>r3 build, new default code for editor<commit_after>var WX=WX||Object.create(null,{_revision:{value:3},_context:{value:new webkitAudioContext},Types:{value:Object.freeze({Unit:"Unit.",Generator:"Generator.",Processor:"Processor.",Analyzer:"Analyzer."})},Template:{value:Object.create(null),writable:!0},Internal:{value:Object.create(null),writable:!0},Unit:{value:Object.create(null),writable:!0}});console.log("WAAX (r"+WX._revision+")");WX.Unit.Common=function(){Object.defineProperties(this,{_label:{value:WX.Types.Unit,enumerable:!1,writable:!0}})};
WX.Unit.Common.prototype=Object.create(null,{label:{enumerable:!1,get:function(){return this._label},set:function(a){this._label=a}},params:{enumerable:!1,get:function(){var a=Object.create(null),b;for(b in this)a[b]=this[b];return a},set:function(a){if("object"!==typeof a)WX.error(this,"invalid JSON.");else for(var b in a)void 0!==this[b]?this[b]=a[b]:WX.error(this,b+" is not available.")}},toString:{value:function(){var a=this.label;return a+=" <pre>"+JSON.stringify(this.params,null,2)+"</pre>"}}});
WX.Unit.Generator=function(){WX.Unit.Common.call(this);Object.defineProperties(this,{_outputGain:{value:WX._context.createGain()},_outlet:{value:WX._context.createGain()},_active:{value:!0,writable:!0}});this._outputGain.connect(this._outlet);this.label+=WX.Types.Generator};
WX.Unit.Generator.prototype=Object.create(WX.Unit.Common.prototype,{to:{value:function(a){if("[object GainNode]"===Object.prototype.toString.call(a._inlet))return this._outlet.connect(a._inlet),a;WX.error(this,"invalid inlet node in target unit.")}},cut:{value:function(){this._outlet.disconnect()}},connect:{value:function(a){this._outlet.connect(a)}},gain:{enumerable:!0,get:function(){return this._outputGain.gain.value},set:function(a){this._outputGain.gain.value=a}},active:{enumerable:!0,get:function(){return this._active},
set:function(a){"boolean"===typeof a&&((this._active=a)?this._outputGain.connect(this._outlet):this._outputGain.disconnect())}}});
WX.Unit.Processor=function(){WX.Unit.Common.call(this);Object.defineProperties(this,{_inlet:{value:WX._context.createGain()},_inputGain:{value:WX._context.createGain()},_outputGain:{value:WX._context.createGain()},_outlet:{value:WX._context.createGain()},_bypass:{value:!1,writable:!0}});this._inlet.connect(this._inputGain);this._outputGain.connect(this._outlet);this.label+=WX.Types.Processor};
WX.Unit.Processor.prototype=Object.create(WX.Unit.Common.prototype,{to:{value:function(a){if("[object GainNode]"===Object.prototype.toString.call(a._inlet))return this._outlet.connect(a._inlet),a;WX.error(this,"invalid inlet node in target unit.")}},cut:{value:function(){this._outlet.disconnect()}},connect:{value:function(a){this._outlet.connect(a)}},gain:{enumerable:!0,get:function(){return this._outputGain.gain.value},set:function(a){this._outputGain.gain.value=a}},bypass:{enumerable:!0,get:function(){return this._bypass},
set:function(a){"boolean"===typeof a&&((this._bypass=a)?(this._outputGain.disconnect(),this._inlet.connect(this._outlet)):(this._inlet.disconnect(),this._inlet.connect(this._inputGain),this._outputGain.connect(this._outlet)))}}});
WX.Unit.Analyzer=function(){WX.Unit.Common.call(this);Object.defineProperties(this,{_inlet:{value:WX._context.createGain()},_inputGain:{value:WX._context.createGain()},_analyzer:{value:WX._context.createAnalyser()},_active:{value:!0,writable:!0}});this._inlet.connect(this._inputGain);this._inputGain.connect(this._analyzer);this.label+=WX.Types.Analyzer};
WX.Unit.Analyzer.prototype=Object.create(WX.Unit.Common.prototype,{gain:{enumerable:!0,get:function(){return this._inputGain.gain.value},set:function(a){this._inputGain.gain.value=a}},active:{enumerable:!0,get:function(){return this._active},set:function(a){"boolean"===typeof a&&((this._active=a)?this._inlet.connect(this._inputGain):this._inlet.disconnect())}}});WX.link=function(){for(var a=arguments.length-1;1<=a;--a)arguments[a-1].to(arguments[a])};
WX.cut=function(){for(var a=arguments.length-1;0<=a;--a)arguments[a].cut()};Object.defineProperties(WX,{PI:{value:Math.PI},TWOPI:{value:2*Math.PI},EPS:{value:Number.MIN_VALUE},random2f:{value:function(a,b){return a+Math.random()*(b-a)}},random2:{value:function(a,b){return Math.round(a+Math.random()*(b-a))}},pitch2freq:{value:function(a){return 440*Math.pow(2,(Math.floor(a)-69)/12)}},freq2pitch:{value:function(a){return Math.floor(69+12*Math.log(a/440)/Math.log(2))}},lin2db:{value:function(a){return 20*(1E-5<a?Math.log(a)/Math.LN10:-5)}},db2lin:{value:function(a){return Math.pow(10,
a/20)}},_consoleDiv:{value:document.getElementById("wx-console"),writable:!0},log:{value:function(){for(var a=0,b=arguments.length;a<b;++a)WX._consoleDiv.innerHTML+=arguments[a].toString()+"<br>"}},info:{value:function(a,b){console.log("[WX:"+a.label+"] "+b)}},error:{value:function(a,b){console.log("[WX:"+a.label+"] "+b)}},NoteName:{value:{A0:21,B0:23,C1:24,D1:26,E1:28,F1:29,G1:31,A1:33,B1:35,C2:36,D2:38,E2:40,F2:41,G2:43,A2:45,B2:47,C3:48,D3:50,E3:52,F3:53,G3:55,A3:57,B3:59,C4:60,D4:62,E4:64,F4:65,
G4:67,A4:69,B4:71,C5:72,D5:74,E5:76,F5:77,G5:79,A5:81,B5:83,C6:84,D6:86,E6:88,F6:89,G6:91,A6:93,B6:95,C7:96,D7:98,E7:100,F7:101,G7:103,A7:105,B7:107,C8:108}}});WX.Internal.DualLevelDetector=function(){Object.defineProperties(this,{_fs:{enumerable:!1,writable:!1,value:WX._context.sampleRate},_attackFast:{enumerable:!1,writable:!0,value:1},_releaseFast:{enumerable:!1,writable:!0,value:1},_levelFast:{enumerable:!1,writable:!0,value:0},_attackSlow:{enumerable:!1,writable:!0,value:1},_releaseSlow:{enumerable:!1,writable:!0,value:1},_levelSlow:{enumerable:!1,writable:!0,value:0}});this.reset()};
WX.Internal.DualLevelDetector.prototype=Object.create(null,{attack:{enumerable:!0,get:function(){return this._attackFast},set:function(a){this._attackFast=1-Math.exp(-1/(a*this._fs))}},release:{enumerable:!0,get:function(){return this._releaseFast},set:function(a){this._releaseFast=1-Math.exp(-1/(a*this._fs))}},reset:{enumerable:!1,value:function(){this._attackFast=1-Math.exp(-1/(0.125*this._fs));this._releaseFast=1-Math.exp(-1/(0.5*this._fs));this._attackSlow=1-Math.exp(-1/(0.25*this._fs));this._releaseSlow=
1-Math.exp(-1/this._fs);this._levelSlow=this._levelFast=0}},process:{value:function(a){a=Math.abs(a);this._levelSlow=a>this._levelSlow?this._levelSlow+this._attackSlow*(a-this._levelSlow):this._levelSlow+this._releaseSlow*(a-this._levelSlow);return this._levelFast=a>this._levelFast?this._levelFast+this._attackFast*(a-this._levelFast):this._levelFast+this._releaseFast*(this._levelSlow-this._levelFast)}}});
WX.Internal.RingBuffer=function(a,b){var c=a||512;bn=b||8;Object.defineProperties(this,{_blockSize:{enumerable:!1,writable:!1,value:c},_bufferSize:{enumerable:!1,writable:!1,value:c*bn},_buffer:{enumerable:!1,writable:!0,value:void 0},_writer:{enumerable:!1,writable:!0,value:0},_reader:{enumerable:!1,writable:!0,value:0}});this._buffer=new Float32Array(this._bufferSize)};
WX.Internal.RingBuffer.prototype=Object.create(null,{writeBlock:{enumerable:!0,value:function(a){for(var b=this._writer+this._blockSize,c=0;this._writer<b;)this._buffer[this._writer++]=a[c++];this._writer==this._bufferSize&&(this._writer=0);this._reader=this._writer}}});(function(){var a=WX._context.sampleRate,b=5*a,c=new Float32Array(b);WX.Template.WhiteNoise=WX._context.createBuffer(1,b,a);for(a=0;a<b;++a)c[a]=2*Math.random()-1;WX.Template.WhiteNoise.getChannelData(0).set(c,0)})();WX.LFO=function(a){WX.Unit.Generator.call(this);Object.defineProperties(this,{_lfo:{enumerable:!1,writable:!1,value:WX._context.createOscillator()},_defaults:{value:{rate:5,shape:"sine",depth:1}}});this._lfo.connect(this._outputGain);this._lfo.noteOn(0);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="LFO"};
WX.LFO.prototype=Object.create(WX.Unit.Generator.prototype,{rate:{enumerable:!0,get:function(){return this._lfo.frequency.value},set:function(a){a=Math.max(0,Math.min(20,a));this._lfo.frequency.value=a}},depth:{enumerable:!0,get:function(){return this._outputGain.gain.value},set:function(a){this._outputGain.gain.value=a}},shape:{enumerable:!0,get:function(){return this._lfo.type},set:function(a){this._lfo.type=a}}});WX.Noise=function(a){WX.Unit.Generator.call(this);Object.defineProperties(this,{_source:{enumerable:!1,writable:!1,value:WX._context.createBufferSource()},_type:{enumerable:!1,writable:!0,value:"white"},_defaults:{value:{type:"white"}}});this._source.connect(this._outputGain);this._source.buffer=WX.Template.WhiteNoise;this._source.loop=1;this._source.noteOn(0);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="Noise"};
WX.Noise.prototype=Object.create(WX.Unit.Generator.prototype,{type:{enumerable:!0,get:function(){return this._type},set:function(a){this._type=a}}});WX.Oscil=function(a){WX.Unit.Generator.call(this);Object.defineProperties(this,{_oscil:{enumerable:!1,writable:!1,value:WX._context.createOscillator()},_defaults:{value:{frequency:440,type:"sine",gain:1}}});this._oscil.connect(this._outputGain);this._oscil.noteOn(0);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="Oscil"};
WX.Oscil.prototype=Object.create(WX.Unit.Generator.prototype,{frequency:{enumerable:!0,get:function(){return this._oscil.frequency.value},set:function(a){this._oscil.frequency.cancelScheduledValues(0);this._oscil.frequency.setValueAtTime(a,0)}},glide:{value:function(a,b){var c=WX._context.currentTime,d=this._oscil.frequency;d.setValueAtTime(d.value,c);d.linearRampToValueAtTime(a,c+b)}},pitch:{enumerable:!0,get:function(){return WX.freq2pitch(this._oscil.frequency.value)},set:function(a){this._oscil.frequency.value=
WX.pitch2freq(a)}},type:{enumerable:!0,get:function(){return this._oscil.type},set:function(a){this._oscil.type=a}}});WX.Sampler=function(a){WX.Unit.Generator.call(this);Object.defineProperties(this,{_buffer:{writable:!0,value:void 0},_player:{writable:!0,value:void 0},_url:{writable:!0,value:""},_basePitch:{writable:!0,value:60},_loaded:{writable:!0,value:!1},_defaults:{value:{basePitch:60}}});this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="Sampler"};
WX.Sampler.prototype=Object.create(WX.Unit.Generator.prototype,{source:{enumerable:!0,get:function(){return this._url},set:function(a){if(void 0===a)return WX.error(this,"invalid audio file path."),!1;var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){try{b._buffer=WX._context.createBuffer(c.response,!0),b._loaded=!0,WX.info(b,"loaded: "+a)}catch(d){WX.error(b,"file loading error: "+a+" ("+d.message+")")}};c.send();this._url=a;return!0}},basePitch:{enumerable:!0,
get:function(){return this._basePitch},set:function(a){this._basePitch=a}},noteOn:{value:function(a){this._loaded?(this._player=WX._context.createBufferSource(),this._player.buffer=this._buffer,this._player.connect(this._outputGain),void 0!==a&&(a=Math.pow(2,(a-this._basePitch)/12),this._player.playbackRate.setValueAtTime(a,0)),this._player.start(0)):WX.error(this,"sampler is not ready.")}},noteOff:{value:function(a){this._player&&this._player.stop(a||0)}}});WX.ADSR=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_a:{writable:!0,value:0.0050},_d:{writable:!0,value:0.015},_s:{writable:!0,value:0.35},_r:{writable:!0,value:0.015},_running:{writable:!0,value:!1},_defaults:{value:{a:0.015,d:0.015,s:0.3,r:0.05}}});this._inputGain.connect(this._outputGain);this._inputGain.gain.value=0;this.params=a||this._defaults;this.label+="ADSR"};
WX.ADSR.prototype=Object.create(WX.Unit.Processor.prototype,{a:{enumerable:!0,get:function(){return this._a},set:function(a){this._a=a}},d:{enumerable:!0,get:function(){return this._d},set:function(a){this._d=a}},s:{enumerable:!0,get:function(){return this._s},set:function(a){this._s=a}},r:{enumerable:!0,get:function(){return this._r},set:function(a){this._r=a}},running:{enumerable:!0,get:function(){return this._running}},noteOn:{value:function(){var a=WX._context.currentTime,b=this._inputGain.gain;
b.cancelScheduledValues(a);b.setValueAtTime(b.value,a);b.linearRampToValueAtTime(0,a);b.linearRampToValueAtTime(1,a+this._a);b.linearRampToValueAtTime(this._s,a+this._a+this._d);this._running=!0}},noteOff:{value:function(a){var b=WX._context.currentTime;a=b+(a||0);var c=this._inputGain.gain;c.cancelScheduledValues(a);c.setValueAtTime(c.value,b);c.linearRampToValueAtTime(0,a+this._r);this._running=!1}}});WX.C2=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_threshold:{enumerable:!1,writable:!0,value:WX.db2lin(-12)},_ratio:{enumerable:!1,writable:!0,value:4},_iratio:{enumerable:!1,writable:!0,value:1/(this._ratio-1)},_makeup:{enumerable:!1,writable:!0,value:WX.db2lin(0)},_detector:{enumerable:!1,writable:!1,value:new WX.Internal.DualLevelDetector},_processor:{enumerable:!1,writable:!1,value:WX._context.createScriptProcessor(256,2,2)},_defaults:{value:{threshold:-12,ratio:4,
attack:0.01,release:0.25,makeup:8}}});var b=this;this._processor.onaudioprocess=function(a){b._callback(a)};this._inputGain.connect(this._processor);this._processor.connect(this._outputGain);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="C2"};
WX.C2.prototype=Object.create(WX.Unit.Processor.prototype,{_callback:{value:function(a){var b,c=a.inputBuffer.getChannelData(0),d=a.inputBuffer.getChannelData(1),f=a.outputBuffer.getChannelData(0);a=a.outputBuffer.getChannelData(1);for(var e=0;256>e;++e)b=Math.max(Math.abs(c[e]),Math.abs(d[e])),b=this._detector.process(b),b=WX.lin2db(b/this._threshold),b=0>=b?0:b*this._iratio,b=WX.db2lin(b),f[e]=c[e]*b*this._makeup,a[e]=d[e]*b*this._makeup}},threshold:{enumerable:!0,get:function(){return WX.lin2db(this._threshold)},
set:function(a){this._threshold=WX.db2lin(a)}},ratio:{enumerable:!0,get:function(){return this._ratio},set:function(a){this._ratio=a;this._iratio=1/(this._ratio-1)}},attack:{enumerable:!0,get:function(){return this._detector.attack},set:function(a){this._detector.attack=a}},release:{enumerable:!0,get:function(){return this._detector.release},set:function(a){this._detector.release=a}},makeup:{enumerable:!0,get:function(){return WX.lin2db(this._makeup)},set:function(a){this._makeup=WX.db2lin(a)}}});WX.Comp=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_comp:{enumerable:!1,writable:!1,value:WX._context.createDynamicsCompressor()},_defaults:{value:{threshold:-12,ratio:4,knee:0.5,attack:0.01,release:0.25}}});this._inputGain.connect(this._comp);this._comp.connect(this._outputGain);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="Comp"};
WX.Comp.prototype=Object.create(WX.Unit.Processor.prototype,{threshold:{enumerable:!0,get:function(){return this._comp.threshold.value},set:function(a){this._comp.threshold.value=a}},ratio:{enumerable:!0,get:function(){return this._comp.ratio.value},set:function(a){this._comp.ratio.value=a}},knee:{enumerable:!0,get:function(){return this._comp.knee.value},set:function(a){this._comp.knee.value=a}},attack:{enumerable:!0,get:function(){return this._comp.attack.value},set:function(a){this._comp.attack.value=
a}},release:{enumerable:!0,get:function(){return this._comp.release.value},set:function(a){this._comp.release.value=a}}});WX.ConVerb=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_convolver:{enumerable:!1,writable:!1,value:WX._context.createConvolver()},_dry:{enumerable:!1,writable:!1,value:WX._context.createGain()},_wet:{enumerable:!1,writable:!1,value:WX._context.createGain()},_url:{enumerable:!1,writable:!0,value:"../data/ir/hall.wav"},_defaults:{value:{source:"../data/ir/hall.wav",mix:0.25}}});this._inputGain.connect(this._convolver);this._inputGain.connect(this._dry);this._convolver.connect(this._wet);
this._dry.connect(this._outputGain);this._wet.connect(this._outputGain);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="ConVerb"};
WX.ConVerb.prototype=Object.create(WX.Unit.Processor.prototype,{source:{enumerable:!0,get:function(){return this._url},set:function(a){if(void 0===a)return WX.error(this,"invalid IR file path."),!1;var b=this,c=new XMLHttpRequest;c.open("GET",a,!0);c.responseType="arraybuffer";c.onload=function(){try{b._convolver.buffer=WX._context.createBuffer(c.response,!0)}catch(d){WX.error(b,"file loading error: "+a+" ("+d.message+")")}};c.send();this._url=a;return!0}},mix:{enumerable:!0,get:function(){return this._wet.gain.value},
set:function(a){this._wet.gain.value=a;this._dry.gain.value=1-a}}});WX.Fader=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_muted:{enumerable:!1,writable:!0,value:!1},_defaults:{value:{db:0}}});this._inputGain.connect(this._outputGain);this.params=a||this._defaults;this.label+="Fader"};
WX.Fader.prototype=Object.create(WX.Unit.Processor.prototype,{mute:{enumerable:!0,get:function(){return this._muted},set:function(a){!0===a?(this._muted=!0,this._inputGain.gain.value=0):(this._muted=!1,this._inputGain.gain.value=1)}},db:{enumerable:!0,get:function(){return WX.lin2db(this._outputGain.gain.value)},set:function(a){this._outputGain.gain.value=WX.db2lin(a)}}});WX.DAC=new WX.Fader;WX.DAC.connect(WX._context.destination);WX.LPRez=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_lpf1:{enumerable:!1,writable:!1,value:WX._context.createBiquadFilter()},_lpf2:{enumerable:!1,writable:!1,value:WX._context.createBiquadFilter()},_cutoff:{writable:!0,value:1E3},_Q:{writable:!0,value:10},_a:{writable:!0,value:0.0050},_d:{writable:!0,value:0.015},_s:{writable:!0,value:0.35},_r:{writable:!0,value:0.015},_running:{writable:!0,value:!1},_range:{writable:!0,value:1E3},_defaults:{value:{cutoff:1E3,Q:10,range:1E3,
a:0.015,d:0.015,s:0.3,r:0.05}}});this._inputGain.connect(this._lpf1);this._lpf1.connect(this._lpf2);this._lpf2.connect(this._outputGain);this._lpf1.type=this._lpf2.type=0;this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="LPRez"};
WX.LPRez.prototype=Object.create(WX.Unit.Processor.prototype,{cutoff:{enumerable:!0,get:function(){return this._cutoff},set:function(a){this._cutoff=a}},Q:{enumerable:!0,get:function(){return this._Q},set:function(a){this._Q=a;this._lpf1.Q.value=this._Q;this._lpf2.Q.value=this._Q}},a:{enumerable:!0,get:function(){return this._a},set:function(a){this._a=a}},d:{enumerable:!0,get:function(){return this._d},set:function(a){this._d=a}},s:{enumerable:!0,get:function(){return this._s},set:function(a){this._s=
a}},r:{enumerable:!0,get:function(){return this._r},set:function(a){this._r=a}},running:{enumerable:!0,get:function(){return this._running}},range:{enumerable:!0,get:function(){return this._range},set:function(a){this._range=a}},noteOn:{value:function(){var a=WX._context.currentTime,b=this._lpf1.frequency,c=this._lpf2.frequency;b.cancelScheduledValues(a);b.setValueAtTime(this._cutoff,a);c.cancelScheduledValues(a);c.setValueAtTime(this._cutoff,a);b.linearRampToValueAtTime(this._cutoff+this._range,
a+this._a);b.linearRampToValueAtTime(this._cutoff+this._range*this._s,a+this._a+this._d);c.linearRampToValueAtTime(this._cutoff+this._range,a+this._a);c.linearRampToValueAtTime(this._cutoff+this._range*this._s,a+this._a+this._d);this._running=!0}},noteOff:{value:function(a){var b=WX._context.currentTime;a=b+(a||0);var c=this._lpf1.frequency,d=this._lpf2.frequency;c.cancelScheduledValues(a);c.setValueAtTime(c.value,b);d.cancelScheduledValues(a);d.setValueAtTime(d.value,b);c.linearRampToValueAtTime(this._cutoff,
a+this._r);d.linearRampToValueAtTime(this._cutoff,a+this._r);this._running=!1}}});WX.TwinDelay=function(a){WX.Unit.Processor.call(this);Object.defineProperties(this,{_delayL:{enumerable:!1,writable:!1,value:WX._context.createDelay()},_delayR:{enumerable:!1,writable:!1,value:WX._context.createDelay()},_merger:{enumerable:!1,writable:!1,value:WX._context.createChannelMerger(2)},_fbL:{enumerable:!1,writable:!1,value:WX._context.createGain()},_fbR:{enumerable:!1,writable:!1,value:WX._context.createGain()},_crosstalkL:{enumerable:!1,writable:!1,value:WX._context.createGain()},_crosstalkR:{enumerable:!1,
writable:!1,value:WX._context.createGain()},_dry:{enumerable:!1,writable:!1,value:WX._context.createGain()},_wet:{enumerable:!1,writable:!1,value:WX._context.createGain()},_defaults:{value:{delayTimeLeft:0.125,delayTimeRight:0.25,feedbackLeft:0.25,feedbackRight:0.25,crosstalk:0.1,mix:0.5}}});this._inputGain.connect(this._delayL);this._inputGain.connect(this._delayR);this._inputGain.connect(this._dry);this._delayL.connect(this._fbL);this._delayR.connect(this._fbR);this._fbL.connect(this._delayL);this._fbR.connect(this._delayR);
this._fbL.connect(this._crosstalkR);this._fbR.connect(this._crosstalkL);this._crosstalkR.connect(this._delayR);this._crosstalkL.connect(this._delayL);this._delayL.connect(this._merger,0,0);this._delayR.connect(this._merger,0,1);this._merger.connect(this._wet);this._dry.connect(this._outputGain);this._wet.connect(this._outputGain);this.params=this._defaults;"object"===typeof a&&(this.params=a);this.label+="TwinDelay"};
WX.TwinDelay.prototype=Object.create(WX.Unit.Processor.prototype,{delayTimeLeft:{enumerable:!0,get:function(){return this._delayL.delayTime.value},set:function(a){this._delayL.delayTime.value=a}},delayTimeRight:{enumerable:!0,get:function(){return this._delayR.delayTime.value},set:function(a){this._delayR.delayTime.value=a}},feedbackLeft:{enumerable:!0,get:function(){return this._fbL.gain.value},set:function(a){this._fbL.gain.value=a}},feedbackRight:{enumerable:!0,get:function(){return this._fbR.gain.value},
set:function(a){this._fbR.gain.value=a}},crosstalk:{enumerable:!0,get:function(){return this._crosstalkL.gain.value},set:function(a){this._crosstalkL.gain.value=a;this._crosstalkR.gain.value=a}},mix:{enumerable:!0,get:function(){return this._wet.gain.value},set:function(a){this._wet.gain.value=a;this._dry.gain.value=1-a}}});
{'fraction_non_alphanumeric': 0.2272857964347326, 'fraction_numerical': 0.026509488211615872, 'mean_word_length': 15.97462176671547, 'pattern_counts': {'":': 0, '<': 15, '<?xml version=': 0, '>': 11, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3258331', 'n_tokens_mistral': 13926, 'n_tokens_neox': 13418, 'n_words': 327}