This discussion has been locked.
You can no longer post new replies to this discussion. If you have a question you can start a new discussion

Quadrature Oscillator

This quadrature oscillator might be useful for digital signal processing, graphics and anywhere you need to produce a sin/cos wave form more efficiently that actually calling the slow sin and cos functions:

https://groups.google.com/forum/#!topic/comp.dsp/GFAzbora6bE

const as single w=.005*(8*atn(1)) 'w= radians per step (so here 200 steps = 2*Pi radians =360 degrees)
dim as single u=0!,v=1!,k1=tan(w*.5),k2=2*k1/(1 + k1*k1)
for j as ulong =0 to 199  
   var tmp = u - k1*v
   v = v + k2*tmp
   u= tmp - k1*v   
   var i=j mod 800
   pset (i,225+200*v),rgb(255,0,255)
   pset (i,225+200*u),rgb(0,255,255)
   pset (400+100*v,225+100*u),rgb(255,255,255)
next