
  uses minwin
  uses waves.h
  uses waves.inc
  '
  WaveOut w
  '
  w.WavoStart 
  '
  double v
  single a,amp,freq,nfreq,basefreq,phase,phdis,vphase
  single reverba,nreverba,filt,filtpr,filtba
  sys b,bufo,d1,d2,i,p,q,decay,reverbt
  sys k1,k2,pc,opc,pcf,qq
  '

  'REVERB SETTINGS

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

  amp=2000
  basefreq=200
  freq=basefreq
  filtba=1
  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
  '
  v=freq*q*ipuls-phdis
  phase=frac(v)
  pc=v-phase 'wave counter
  if pcf then opc=pc : pcf=0
  '
  'NEW WAVE OR PULSE
  '
  if pc>opc then
    pcf=1
    vphase=frac(8*ipuls*q)
    'basefreq+=.02
    freq=basefreq
    '
    'VIBRATO (frequency modulation)
    '
    v=sin(pi2*vphase)*basefreq*.1
    freq+=v
    '
    'SYNC PHASE
    '
    phdis=frac(freq*q*ipuls)-phase
    '
  end if
  '
  'a+=amp*noiseInterp(pc,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=.1
  filt=filt*(1-filtpr)+a*filtpr
  single lp=filt       'low pass
  'hp=a-filt     'high pass
  'a=lp*filtba + hp*(1-filtba) 'moving filter mix
  'a=lp*2 'boosted
  '
  'TREMOLO (amplitude modulation)
  '
  a=a*(0+(1+sin(pi2*vphase)))*.5
  '
  'POST WITH REVERB
  '
  SendToBuffer 'macro
  a=0
  '
  next

  if ++d1=10 then
    d1=0
    'decay=0
    'amp=4000
    basefreq*=1.0625
    if basefreq>1000 then amp*=.90
    if basefreq>22050 then exit do
    if ++d2=8 then
      d2=0
      'if filtba<=0 then exit do
    end if
  end if

  end if

  enddo
  '
  w.WavoEnd

   
