
  uses minwin
  uses waves.h
  uses waves.inc
  '
  '
  WaveOut w
  '
  w.WavoStart 
  '
  single ipuls,a,amp,freq,phase,pi2
  sys b,bufo,d1,d2,p,q,decay
  '
  ipuls=1/44100
  pi2=2*pi
  '
  'note: pitch,volume,phase,envelopes

  amp=0
  freq=100
  do
    sleep 5
    if GetAsyncKeyState 27 then exit do
    p=w.wavopos
    if p+2000>q then 'ahead ~1/40 sec

  '
  'ENVELOPE
  int i
  for i=1 to 1000
  if amp>=1000 then decay=1
  if decay then
    'amp*=.9995
    if amp then amp-=.5
  else
    amp+=10
  end if
  '
  'SINEWAVE
  '
  phase=frac(freq*q*ipuls)
  a+=amp*sin(pi2*phase)
  'a+=amp*sin(pi2*phase*1.25) 'harmonic
  'a+=amp*sin(pi2*phase*1.5) 'harmonic
  a+=amp*sin(pi2*phase*3) 'harmonic
  '
  'POST
  '
  bufo=q and 0xffff
  mov ecx,w.buf
  add ecx,bufo
  fld dword a
  fistp word [ecx]
  fldz
  fstp dword a
  '
  q+=2
  next

  if ++d1=20 then
    d1=0
    freq*=1.25
    decay=0
    amp=0
    if ++d2=8 then
      d2=0
      freq=100
    end if
  end if

  end if

  enddo
  '
  w.WavoEnd

   
