  uses minwin
  uses waves.h
  uses waves.inc
  '
  WaveOut w
  '
  w.WavoStart 
  '
  single a,amp,freq,nfreq,phase,phdis
  single reverba,nreverba,filt,filtpr,filtba
  sys b,bufo,d1,d2,p,q,decay,reverbt
  sys k1,k2,ph
  '

  'REVERB

  reverba=.25
  nreverba=.75
  reverbt=0.3*88200 'max buffersize 64k
  '

  amp=16000
  nfreq=440 'A
  filtba=1
  do
    sleep 5
    if GetAsyncKeyState 27 then exit do
    p=w.wavopos
    if p+3000>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
  '

  'PHASE SYNC

  if nfreq<>freq
    freq=nfreq'+noise(q)*100
    phdis=frac(freq*q*ipuls)-phase
    nfreq=freq
  end if

  phase=frac(freq*q*ipuls-phdis)
  ph=freq*q*ipuls-phase '(trunc) wave counter

  
  a+=amp*noise(q)
  a+=amp*noiseInterp(ph,phase)
  'a+=amp*sawtooth(phase)
  'a+=amp*triangle(phase)
  'a+=amp*square(phase)
  'a+=amp*square(phase*1.5)
  'a+=amp*sin(pi2*phase) 'sine wave
  'a+=amp*sin(pi2*phase*1.25) 'harmonic
  'a+=amp*sin(pi2*phase*1.5) 'harmonic
  'a+=amp*sin(pi2*phase*3) 'harmonic
  '
  'FILTER
  '
  filtpr=.05
  filt=filt*(1-filtpr)+a*filtpr
  single lp=filt       'low pass
  single hp=a-filt     'high pass
  'a=lp*2 'boosted
  'a=hp
  a=lp*filtba + hp*(1-filtba) 'moving filter mix
  '
  'POST WITH REVERB
  '
  SendToBuffer 'macro
  a=0
  '
  next

  if ++d1=10 then
    d1=0
    'decay=0
    amp*=.95
    filtba-=.01
    if filtba<=0 then exit do
    if ++d2=8 then
      d2=0
    end if
  end if

  end if

  enddo
  '
  w.WavoEnd

   
