// Web Audio API Simulator // Copyright (c) 2013 g200kg // http://www.g200kg.com/ // Released under the MIT-License // http://opensource.org/licenses/MIT // // Great thanks : // FFT algo for AnalyserNode and Convolver is based on Takuya OOURA's explanation. // http://www.kurims.kyoto-u.ac.jp/~ooura/fftman/index.html if(typeof(waapisimLogEnable)==="undefined") var waapisimLogEnable=0; // Support Float32Array&Uint8Array if unavailable (for IE9) if(typeof(Float32Array)==="undefined") { Float32Array=function(n) { if(n instanceof Array) return n; var a=new Array(n); a.subarray=function(x,y) {return this.slice(x,y);}; a.set=function(x,off) {for(var i=0;i=32768) v0=v0-65536; if(v1>=32768) v1=v1-65536; if(mixtomono===true) v0=v1=(v0+v1)*0.5; this.buf[0][i]=v0/32768; this.buf[1][i]=v1/32768; j+=6; } else { v=inbuf[idx+j+9]+(inbuf[idx+j+10]<<8); if(v>=32768) v=v-65536; this.buf[0][i]=this.buf[1][i]=v/32768; j+=3; } } else if(wavbits==16) { if(wavch==2) { v0=inbuf[idx+j+8]+(inbuf[idx+j+9]<<8); v1=inbuf[idx+j+10]+(inbuf[idx+j+11]<<8); if(v0>=32768) v0=v0-65536; if(v1>=32768) v1=v1-65536; if(mixtomono===true) v0=v1=(v0+v1)*0.5; this.buf[0][i]=v0/32768; this.buf[1][i]=v1/32768; j+=4; } else { v=inbuf[idx+j+8]+(inbuf[idx+j+9]<<8); if(v>=32768) v=v-65536; this.buf[0][i]=this.buf[1][i]=v/32768; j+=2; } } else { if(wavch==2) { v0=inbuf[idx+j+8]/128-1; v1=inbuf[idx+j+9]/128-1; if(mixtomono===true) v0=v1=(v0+v1)*0.5; this.buf[0][i]=v0; this.buf[1][i]=v1; j+=2; } else { this.buf[0][i]=this.buf[1][i]=inbuf[idx+j+8]/128-1; j++; } } } } idx+=(chunksz+8); } } } } this.getChannelData=function(i) { return this.buf[i]; }; }; waapisimDummybuf=new waapisimAudioBuffer(2,waapisimBufSize,waapisimSampleRate); waapisimSetupOutBuf=function(offset) { var numctx=waapisimContexts.length; var l,i,j,k,n,node; for(l=(offset+waapisimBufSize)*2,i=offset*2;i0) { var buf=node._nodein[0].inbuf.buf; for(i=0;i0) { for(var i in scr) { if(scr[i].src && scr[i].src.match(/waapisim\.js$/)) { var s=scr[i].src; return s.substring(0,s.length-2)+"swf"; } } } return ""; }; waapisimAddFlashObj=function() { var div=document.createElement("DIV"); div.setAttribute("id","WAAPISIMFLASHOBJ"); div.setAttribute("style","background:#ff00ff;position:static;"); var body=document.getElementsByTagName("BODY"); body[0].appendChild(div); document.getElementById("WAAPISIMFLASHOBJ").innerHTML="
"; if(typeof(document.getElementById("waapisim_swf").SetReturnValue)==="undefined") document.getElementById("waapisim_swf").SetReturnValue=function(v){document.getElementById("waapisim_swf").impl.SetReturnValue(v);}; }; waapisimFlashOffset=function(pos) { waapisimUpdateCurrentTime(pos/1000); }; waapisimFlashGetData=function() { var s=""; var l; for(l=waapisimOutBufSize/waapisimBufSize,i=0;i0) successCallback(buf); else errorCallback(); }; this.createPeriodicWave=this.createWaveTable=function(real,imag) { return new waapisimPeriodicWave(real,imag); }; this._SortNode=function() { var i,j,k,n; for(i=0;i0) { for(j=0;j>1;k>(i^=k);k>>=1) ; } while(++jmax) max=v; } if(max==0) { for(i=0;i"+next.node._nodetype+next.node._nodeId); if(next===undefined) return; if(next.from.indexOf(this)!=-1) return; next.from.push(this); if(this.to.indexOf(next)==-1) this.to.push(next); if(next.node._targettype!==0) { if(this.node.context._RegisterNode(next.node)) { for(var i=0;i=0) { waapisimDebug(" :"+this.node._nodeId+"=>"+nodes[i]._nodeId); nodes[i]._nodein[ii].from.splice(j,1); } } } for(i=0;i0) this._bufferindex=off*waapisimSampleRate; this._endindex=this.buffer.length; if(dur>0) this._endindex=Math.min(this.buffer.length,(dur+off)*waapisimSampleRate); if(this.loop) { if((this.loopStart||this.loopEnd)&&this.loopStart>=0&&this.loopEnd>0&&this.loopStart=this._endindex) { if(this.playbackState==2) --this.context.activeSourceCount; this.playbackState=3; } if(this.playbackState==1 && this.context.currentTime>=this._whenstart) { this.playbackState=2; ++this.context.activeSourceCount; } if(this.playbackState==2 && this.context.currentTime>=this._whenstop) { this.playbackState=3; --this.context.activeSourceCount; } if(this.playbackState!=2) return; var b0=this.buffer.getChannelData(0); var b1=this.buffer.getChannelData(1); var rate=this.buffer.sampleRate/44100; if(this._nodeout[0].to.length>0) { for(var i=0;i=this._actualLoopEnd) this._bufferindex=this._actualLoopStart; } } this._nodeout[0].NodeEmitBuf(); this.playbackRate.Clear(true); } }; }; waapisimAudioBufferSource.UNSCHEDULED_STATE=waapisimAudioBufferSource.prototype.UNSCHEDULED_STATE=0; waapisimAudioBufferSource.SCHEDULED_STATE=waapisimAudioBufferSource.prototype.SCHEDULED_STATE=1; waapisimAudioBufferSource.PLAYING_STATE=waapisimAudioBufferSource.prototype.PLAYING_STATE=2; waapisimAudioBufferSource.FINISHED_STATE=waapisimAudioBufferSource.prototype.FINISHED_STATE=3; waapisimScriptProcessor=function(ctx,bufsize,inch,outch) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="ScrProc"; waapisimDebug("create "+this._nodetype+this._nodeId); this._targettype=2; this.context=ctx; this.playbackState=0; if(typeof(bufsize)!=="number") throw(new TypeError("ScriptProcessor:bufferSize")); if(typeof(inch)==="undefined") inch=2; if(typeof(outch)==="undefined") outch=2; this.bufferSize=bufsize; this._scrinbuf=new waapisimAudioBuffer(inch,bufsize,waapisimSampleRate); this._scroutbuf=new waapisimAudioBuffer(outch,bufsize,waapisimSampleRate); this._index=bufsize; this.onaudioprocess=null; this._Process=function() { var inb=this._nodein[0].inbuf; if(inb===null) inb=waapisimDummybuf; for(var i=0;i=this.bufferSize) { if(this.onaudioprocess) { var ev=new waapisimAudioProcessingEvent(); ev.node=this; ev.inputBuffer=this._scrinbuf; ev.outputBuffer=this._scroutbuf; this.onaudioprocess(ev); } this._index=0; } this._scrinbuf.buf[0][this._index]=inb.buf[0][i]; if(this._scrinbuf.numberOfChannels>=2) this._scrinbuf.buf[1][this._index]=inb.buf[1][i]; if(this._scroutbuf.numberOfChannels>=2) this._nodeout[0].NodeEmit(i,this._scroutbuf.buf[0][this._index],this._scroutbuf.buf[1][this._index]); else this._nodeout[0].NodeEmit(i,this._scroutbuf.buf[0][this._index],this._scroutbuf.buf[0][this._index]); this._index++; } this._nodein[0].NodeClear(); }; ctx._RegisterNode(this); }; waapisimBiquadFilter=webkitBiquadFilterNode=BiquadFilterNode=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="Filter"; waapisimDebug("create "+this._nodetype+this._nodeId); this.context=ctx; this.playbackState=0; this.type=0; this.frequency=new waapisimAudioParam(ctx,this,10,24000,350,0.5); this.detune=new waapisimAudioParam(ctx,this,-4800,4800,0,0.5); this.Q=new waapisimAudioParam(ctx,this,0.0001,1000,1,0.5); this.gain=new waapisimAudioParam(ctx,this,-40,40,0,0.5); this._a1=this._a2=0; this._b0=this._b1=this._b2=0; this._x1l=this._x1r=this._x2l=this._x2r=0; this._y1l=this._y1r=this._y2l=this._y2r=0; this._nodein[0].NodeClear(); this._Setup=function(fil) { var f=fil.frequency.Get(0)*Math.pow(2,fil.detune.Get(0)/1200); var q=Math.max(0.001,fil.Q.Get(0)); var alpha,ra0,g; var w0=2*Math.PI*f/fil.context.sampleRate; var cos=Math.cos(w0); switch(fil.type) { case "lowpass": case 0: q=Math.pow(10,q/20); alpha=Math.sin(w0)/(2*q); ra0=1/(1+alpha); fil._a1=-2*cos*ra0; fil._a2=(1-alpha)*ra0; fil._b0=fil._b2=(1-cos)/2*ra0; fil._b1=(1-cos)*ra0; break; case "highpass": case 1: q=Math.pow(10,q/20); alpha=Math.sin(w0)/(2*q); ra0=1/(1+alpha); fil._a1=-2*cos*ra0; fil._a2=(1-alpha)*ra0; fil._b0=fil._b2=(1+cos)/2*ra0; fil._b1=-(1+cos)*ra0; break; case "bandpass": case 2: alpha=Math.sin(w0)/(2*q); ra0=1/(1+alpha); fil._a1=-2*cos*ra0; fil._a2=(1-alpha)*ra0; fil._b0=alpha; fil._b1=0; fil._b2=-alpha; break; case "lowshelf": case 3: alpha=Math.sin(w0)/2*Math.sqrt(2); g=Math.pow(10,fil.gain.Get(0)/40); ra0=1/((g+1)+(g-1)*cos+2*Math.sqrt(g)*alpha); fil._a1=-2*((g-1)+(g+1)*cos)*ra0; fil._a2=((g+1)+(g-1)*cos-2*Math.sqrt(g)*alpha)*ra0; fil._b0=g*((g+1)-(g-1)*cos+2*Math.sqrt(g)*alpha)*ra0; fil._b1=2*g*((g-1)-(g+1)*cos)*ra0; fil._b2=g*((g+1)-(g-1)*cos-2*Math.sqrt(g)*alpha)*ra0; break; case "highshelf": case 4: alpha=Math.sin(w0)/2*Math.sqrt(2); g=Math.pow(10,fil.gain.Get(0)/40); ra0=1/((g+1)-(g-1)*cos+2*Math.sqrt(g)*alpha); fil._a1=2*((g-1)-(g+1)*cos)*ra0; fil._a2=((g+1)-(g-1)*cos-2*Math.sqrt(g)*alpha)*ra0; fil._b0=g*((g+1)+(g-1)*cos+2*Math.sqrt(g)*alpha)*ra0; fil._b1=-2*g*((g-1)+(g+1)*cos)*ra0; fil._b2=g*((g+1)+(g-1)*cos-2*Math.sqrt(g)*alpha)*ra0; break; case "peaking": case 5: alpha=Math.sin(w0)/(2*q); g=Math.pow(10,fil.gain.Get(0)/40); ra0=1/(1+alpha/g); fil._a1=-2*cos*ra0; fil._a2=(1-alpha/g)*ra0; fil._b0=(1+alpha*g)*ra0; fil._b1=-2*cos*ra0; fil._b2=(1-alpha*g)*ra0; break; case "notch": case 6: alpha=Math.sin(w0)/(2*q); ra0=1/(1+alpha); fil._a1=-2*cos*ra0; fil._a2=(1-alpha)*ra0; fil._b0=fil._b2=ra0; fil._b1=-2*cos*ra0; break; case "allpass": case 7: alpha=Math.sin(w0)/(2*q); ra0=1/(1+alpha); fil._a1=-2*cos*ra0; fil._a2=(1-alpha)*ra0; fil._b0=(1-alpha)*ra0; fil._b1=-2*cos*ra0; fil._b2=(1+alpha)*ra0; break; } }; this._Process=function() { var xl,xr,yl,yr; this.frequency._Process(); this.detune._Process(); this.Q._Process(); this.gain._Process(); this._Setup(this); var inbuf=this._nodein[0].inbuf.buf; var outbuf=this._nodeout[0].outbuf.buf; for(var i=0;i=this.context.sampleRate) offs=this.context.sampleRate-1; var deltaoff=(offs-this._offscur)/waapisimBufSize; for(var i=0;i=waapisimSampleRate) this._index=0; this._offscur+=deltaoff; } this._nodeout[0].NodeEmitBuf(); this._nodein[0].NodeClear(); this.delayTime.Clear(false); }; }; waapisimOscillator=webkitOscillatorNode=OscillatorNode=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,0,1); this._nodetype="Osc"; waapisimDebug("create "+this._nodetype+this._nodeId); this._targettype=3; this._order=0; this.context=ctx; this.type=0; this._wavtable=null; this.frequency=new waapisimAudioParam(ctx,this,1,20000,440,0.9995); this.detune=new waapisimAudioParam(ctx,this,-4800,4800,0,0.9995); this.playbackState=0; this._phase=0.5; this._whenstart=0; this._whenstop=Number.MAX_VALUE; this._init=0; this.start=this.noteOn=function(w) { this._whenstart=w; this.playbackState=1; this.context._RegisterNode(this); }; this.stop=this.noteOff=function(w) { this._whenstop=w; }; this.setPeriodicWave=this.setWaveTable=function(tab) { this.type=4; this._wavtable=tab; }; this._Process=function() { var i; if(this._init==0) { this.frequency.Init(); this.detune.Init(); this._init=1; } this.frequency._Process(); this.detune._Process(); if(this.playbackState==1 && this.context.currentTime>=this._whenstart) this.playbackState=2; if(this.playbackState==2 && this.context.currentTime>=this._whenstop) this.playbackState=3; if(this.playbackState!=2) { for(i=0;i1) out=1; if(out<-1) out=-1; obuf[0][i]=obuf[1][i]=out; } this._phase=ph; this._nodeout[0].NodeEmitBuf(); this.frequency.Clear(true); this.detune.Clear(true); }; }; waapisimOscillator.SINE=waapisimOscillator.prototype.SINE=0; waapisimOscillator.SQUARE=waapisimOscillator.prototype.SQUARE=1; waapisimOscillator.SAWTOOTH=waapisimOscillator.prototype.SAWTOOTH=2; waapisimOscillator.TRIANGLE=waapisimOscillator.prototype.TRIANGLE=3; waapisimOscillator.CUSTOM=waapisimOscillator.prototype.CUSTOM=4; waapisimOscillator.UNSCHEDULED_STATE=waapisimOscillator.prototype.UNSCHEDULED_STATE=0; waapisimOscillator.SCHEDULED_STATE=waapisimOscillator.prototype.SCHEDULED_STATE=1; waapisimOscillator.PLAYING_STATE=waapisimOscillator.prototype.PLAYING_STATE=2; waapisimOscillator.FINISHED_STATE=waapisimOscillator.prototype.FINISHED_STATE=3; waapisimAnalyser=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="Analyser"; waapisimDebug("create "+this._nodetype+this._nodeId); this.context=ctx; this.playbackState=0; this.fftSize=2048; this.frequencyBinCount=1024; this.minDecibels=-100; this.maxDecibels=-30; this.smoothingTimeConstant=0; this._fftInData=new Array(2048); this._fftOutData=new Array(2048); this._timeData=new Array(2048); this._fftIndex=0; this._fftCurrentSize=0; this._fftrev=new Array(256); this._fft=function(n,data,mag) { var nh=n>>1; var t=-2*Math.PI; var m,mh,mq,i,j,jr,ji,kr,ki,xr,xi; for(mh=1;(m=mh<<1)<=n;mh=m) { mq=mh>>1; t*=0.5; for(jr=0;jr>1;k>(i^=k);k>>=1) ; this._fftrev[j]=i; } } for(i=0;i=this._fftCurrentSize) { this._fftIndex=0; this._fft(this._fftCurrentSize,this._fftInData,this._fftOutData); } } this._nodein[0].NodeClear(); }; }; waapisimConvolver=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="Convolver"; waapisimDebug("create "+this._nodetype+this._nodeId); this.context=ctx; this.playbackState=0; this.buffer=null; this.normalize=true; this._scale=1; this._analyzed=null; this._dlybufsize=waapisimSampleRate*5; this._dlybuf=new waapisimAudioBuffer(2,this._dlybufsize,44100); this._dlyidx=0; this._tapsize=20; this._tap=[]; this._kernel=null; this._sum=[]; this._sum[0]=[]; this._sum[1]=[]; this._bitrev=[]; this._bitrev[0]=0; this._bitrev[waapisimBufSize-1]=waapisimBufSize-1; var i,j,k; for(i=0,j=1;j>1;k>(i^=k);k>>=1) ; this._bitrev[j]=i; } for(i=0;i<2;++i) for(j=0;j<2;++j) this._sum[i][j]=new Float32Array(waapisimSampleRate); this._Normalize=function(buffer) { var GainCalibration=0.00125; var GainCalibrationSampleRate=44100; var MinPower=0.000125; var numberOfChannels=2; var length=buffer.length; var power=0; for(var i=0;i>1;k>(i^=k);k>>=1) ; if(j>1; theta*=0.5; for(jr=0;jr>1;k>(i^=k);k>>=1) ; if(j1e-3) break; if(Math.abs(this.buffer.buf[1][i])>1e-3) break; } len=i+1; for(i=0,px=0;i0) { while(px=waapisimBufSize) { if(p>maxp) { this._kernel=kbuf[k]; maxp=p; } j=0; p=0; ++k; } } if(p>maxp||this._kernel===null) this._kernel=kbuf[k]; this._Fft(waapisimBufSize,this._kernel.buf[0]); this._Fft(waapisimBufSize,this._kernel.buf[1]); this._analyzed=this.buffer; } this._Fft(waapisimBufSize,inbuf[0]); this._Fft(waapisimBufSize,inbuf[1]); this._sum[0][0][0]=this._sum[1][0][0]=this._sum[0][1][0]=this._sum[1][1][0]=0; for(i=1,j=waapisimBufSize-1;i=this._dlybufsize) this._dlyidx=0; } } this._nodein[0].NodeClear(); }; }; waapisimDynamicsCompressor=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="DynComp"; waapisimDebug("create "+this._nodetype+this._nodeId); this.context=ctx; this.playbackState=0; this.threshold=new waapisimAudioParam(ctx,this,-100,0,-24); this.knee=new waapisimAudioParam(ctx,this,0,40,30); this.ratio=new waapisimAudioParam(ctx,this,1,20,12); this.reduction=new waapisimAudioParam(ctx,this,-20,0,0);//ReadOnly this.attack=new waapisimAudioParam(ctx,this,0,1,0.003); this.release=new waapisimAudioParam(ctx,this,0,1,0.25); this._maxl=0; this._maxr=0; this._gain=1; this._Process=function() { this.threshold._Process(); this.knee._Process(); this.ratio._Process(); this.attack._Process(); this.release._Process(); var inbuf=this._nodein[0].inbuf.buf; var relratio=this.release.Get(0)*waapisimSampleRate; relratio=Math.pow(1/3.16,1/relratio); var atkratio=this.attack.Get(0)*waapisimSampleRate; atkratio=Math.pow(1/3.16,1/atkratio); var reduc=this.reduction.value; var thresh=Math.pow(10,this.threshold.Get(0)/20); var knee=Math.pow(10,this.knee.Get(0)/20*0.5); var makeup=1/Math.sqrt(thresh)/Math.pow(10,this.knee.Get(0)/80); var maxratio=0.99105; var ratio=this.ratio.Get(0); if(ratio<=1) ratio=1; for(var i=0;ithresh) { var v=Math.pow(thresh*Math.min(knee,maxc/thresh)/maxc,1-1/ratio); this._gain=v+(this._gain-v)*atkratio; } else this._gain=1+(this._gain-1)*relratio; var g=this._gain*makeup; this._nodeout[0].NodeEmit(i,inbuf[0][i]*g,inbuf[1][i]*g); } this.reduction.value=this.reduction.computedValue=reduc; this._nodein[0].NodeClear(); this.threshold.Clear(false); this.knee.Clear(false); this.ratio.Clear(false); this.reduction.Clear(false); this.attack.Clear(false); this.release.Clear(false); }; }; waapisimPanner=webkitAudioPannerNode=AudioPannerNode=function(ctx) { waapisimAudioNode.call(this,waapisimBufSize,1,1); this._nodetype="Panner"; waapisimDebug("create "+this._nodetype+this._nodeId); this.context=ctx; this.playbackState=0; this.panningModel=0; this.distanceModel=1; this.refDistance=1; this.maxDistance=10000; this.rolloffFactor=1; this.coneInnerAngle=360; this.coneOuterAngle=360; this.coneOuterGain=0; this.px=0; this.py=0; this.pz=0; this.setPosition=function(x,y,z) {this.px=x;this.py=y;this.pz=z;}; this.setOrientation=function(x,y,z) {}; this.setVelocity=function(x,y,z) {}; this._Process=function() { var inbuf=this._nodein[0].inbuf.buf; var listener=this.context.listener; var dx=this.px-listener.px; var dy=this.py-listener.py; var dz=this.pz-listener.pz; var d=Math.max(1,Math.sqrt(dx*dx+dy*dy+dz*dz)); var dgain; switch(this.distanceModel) { case "linear": case 0: dgain=1-this.rolloffFactor*(d-this.refDistance)/(this.maxDistance-this.refDistance); break; case "inverse": case 1: dgain=this.refDistance/(this.refDistance+this.rolloffFactor*(d-this.refDistance)); break; case "exponential": case 2: dgain=Math.pow(d/this.refDistance,-this.rolloffFactor); break; } var rgain,lgain,tr; if(Math.abs(dz)<0.001) { lgain=rgain=1; } else { tr=Math.atan(dx/dz); if(dz<=0) { rgain=-tr+Math.PI*0.5; lgain=tr+Math.PI*0.5; } else { switch(this.panningModel) { case 0: case "equalpower": rgain=tr+Math.PI*0.5; lgain=-tr+Math.PI*0.5; break; default: if(dx>=0) { rgain=tr+Math.PI*0.5; lgain=-(-tr+Math.PI*0.5); } else { rgain=-(tr+Math.PI*0.5); lgain=-tr+Math.PI*0.5; } } } } var rl=Math.sqrt(rgain*rgain+lgain*lgain); rgain=rgain/rl; lgain=lgain/rl; var a=Math.sqrt(rgain*rgain+lgain*lgain); rgain=rgain/a*2*dgain; lgain=lgain/a*2*dgain; for(var i=0;i=0) { for(i=0;it) break; } this.automation.splice(i,0,ev); }; this.setValueAtTime=function(v,t) { this.AddEvent([t,0,v]); }; this.linearRampToValueAtTime=function(v,t) { this.AddEvent([t,1,v]); }; this.exponentialRampToValueAtTime=function(v,t) { this.AddEvent([t,2,v]); }; this.setTargetAtTime=this.setTargetValueAtTime=function(v,t,c) { this.AddEvent([t,3,v,c]); }; this.setValueCurveAtTime=function(values,t,d) { this.AddEvent([t,4,values,d]); }; this.cancelScheduledValues=function(t) { for(var l=this.automation.length,i=0;i=t) { this.automation.length=i; return; } } }; this._Process=function() { this.value+=this.deltaAdd; this.value=(this.value-this.deltaTarget)*this.deltaMul+this.deltaTarget; if(this.currentEvent!==null) { if(this.currentEvent[1]==4) { var i=(this.currentEvent[2].length-1)*(this.context.currentTime-this.currentEvent[0])/this.currentEvent[3]; this.value=this.currentEvent[2][Math.min(this.currentEvent[2].length-1,i)|0]; } } if(this.automation.length>0) { if(this.context.currentTime>=this.automation[0][0]) { this.deltaAdd=0; this.deltaMul=1; this.deltaTarget=0; this.currentEvent=this.automation.shift(); switch(this.currentEvent[1]) { case 0: case 1: case 2: this.value=this.currentEvent[2]; break; case 3: this.deltaMul=Math.pow(0.367879,1/(waapisimSampleRate/waapisimBufSize*this.currentEvent[3])); this.deltaTarget=this.currentEvent[2]; break; } if(this.automation.length>0) { var n=waapisimSampleRate/waapisimBufSize*(this.automation[0][0]-this.context.currentTime); switch(this.automation[0][1]) { case 1: this.deltaAdd=(this.automation[0][2]-this.value)/n; break; case 2: this.deltaMul=Math.pow(this.automation[0][2]/this.value,1/n); break; } } } } }; this.Init=function() { this.computedValue=parseFloat(this.value); } this.Get=function(n) { if(this.from.length>0) this.computedValue=parseFloat(this.value)+(this.inbuf.buf[0][n]+this.inbuf.buf[1][n])*0.5; else this.computedValue=this.computedValue*this.timeconst+(1-this.timeconst)*parseFloat(this.value); return this.computedValue; }; this.Clear=function(arate) { if(arate) { for(var i=0;i