<info>
i is ex5-6
ECMC Csound Tutorial example ex5-6
</info>
<tk_interface>
</tk_interface>
<mono>
;  #############################################################
;  soundfile ex5-6 : 5 band-pass filters for vowel-like formant resonances
;  #############################################################

instr 1
kamp envlpx p5,  p6,  p3,  p7,  1,  p8,  .01 ; amplitude envelope
; ==== get source audio signal, determined by p9 =======
if p9 > 0 goto pulse    ; if p9 is 0, use white noise for audio source signal
   asource  rand  kamp   ; white noise source signal
goto filter
  ; - - - - - - - - - - -
pulse:
if p9 = 2 goto soundfile
;      if p9 = 1 , generate a pulse train source signal :
   ipitch = cpspch(p4)  ; pitch for buzz
   if ipitch > 500 igoto hinote	;setting number of harmonics in buzz -
      iharmonics = 20             ; use 20 harmonics for pitches below Bb 4
      igoto makebuzz
   hinote:
       iharmonics = int((sr*.5)/ipitch)	;for higher pitches, as many partials as
				       ;possible up to the nyquist frequency
   makebuzz:
   asource  buzz  kamp, ipitch,  iharmonics, 100  ; pulse train source signal
   goto filter
  ; - - - - - - - - - - -
soundfile:     ; if p9 = 2 , use soundfile for source audio signal
    asource  soundin  p12 , p13
    asource = asource * (kamp/32767)  ; impose new envelope on soundfile
  ; - - - - - - - - - - -

filter:
;FILTER CENTER FREQUENCIES & RELATIVE AMPS. FROM FUNCTIONS 80-87, 90-94
iformant1 table 0, p10   ; 1st formant frequency
iformant2 table 1, p10   ; 2nd   "   "   "
iformant3 table 2, p10   ; 3rd   "   "   "
iformant4 table 3, p10   ; 4th   "   "   "
iformant5 table 4, p10   ; 5th   "   "   "
iamp1 table 5, p10   ; relative amplitude of 1st formant
iamp2 table 6, p10   ;    "    "    "    "   2nd
iamp3 table 7, p10  ;    "    "    "    "   3rd
iamp4 table 8, p10  ;    "    "    "    "   4th
iamp5 table 9, p10  ;    "    "    "    "   5th

;  5 BANDPASS FILTERS TO SUPPLY THE 5 FORMANTS
a2 reson iamp1*asource, iformant1, 1.2*p11 * iformant1,1	
a3 reson iamp2*asource, iformant2, 1.05*p11 * iformant2,1
a4 reson iamp3*asource, iformant3, .9*p11 * iformant3,1
a5 reson iamp4*asource, iformant4, .8*p11 * iformant4,1
a6 reson iamp5*asource, iformant5, .7*p11 * iformant5,1
aformants  = a2 + a3 + a4 + a5 + a6
aout   balance aformants , asource   ; restore amplitude lost in filtering
   out aout
endin
</mono>
<stereo>
</stereo>
<score>

                  SCORE-11, Version 1.4
Copyright (C) 1982, 1990, 1992, 1995 by Alexander R. Brinkman
     Eastman School of Music, University of Rochester

f1 0 65 7 0 40 .75 4 .70 20 1.
f100 0 2048 10 1.
f80 0 16 -2 609 1000 2450 2700 3240 1. .25 .063 .07 .004
f81 0 16 -2 400 1700 2300 2900 3400 1. .125 .18 .07 .01
f82 0 16 -2 238 1741 2450 2900 4000 1. .01 .029 .01 .001
f83 0 16 -2 325 700 2550 2850 3100 1. .063 .002 .007 .002
f84 0 16 -2 360 750 2400 2675 2950 1. .063 .001 .003 .001
f85 0 16 -2 415 1400 2200 2800 3300 1. .063 .027 .015 .002
f86 0 16 -2 300 1600 2150 2700 3100 1. .037 .063 .031 .005
f87 0 16 -2 400 1050 2200 2650 3100 1. .064 .011 .009 .001
f90 0 16 -2 650 1100 2860 3300 4500 1. .16 .05 .063 .012
f91 0 16 -2 500 1750 2450 3350 5000 1. .125 .1 .041 .005
f92 0 16 -2 330 2000 2800 3650 5000 1. .042 .08 .11 .012
f93 0 16 -2 400 840 2800 3250 4500 1. .063 .003 .004 .001
f94 0 16 -2 280 650 2200 3450 4500 1. .015 .001 .001 .001
  i1 0.000 0.950 7.03 12000 0.200 0.300 0.700 0 80 0.050 8 0
  i1 1.000 0.950 7.03 12000 0.200 0.300 0.700 1 80 0.050 8 0
  i1 2.000 0.950 7.03 12000 0.200 0.300 0.700 2 80 0.050 8 0
  i1 3.000 0.950 7.03 12000 0.200 0.300 0.700 0 81 0.050 8 0
  i1 4.000 0.950 7.03 12000 0.200 0.300 0.700 1 81 0.050 8 0
  i1 5.000 0.950 7.03 12000 0.200 0.300 0.700 2 81 0.050 8 0
  i1 6.000 0.950 7.03 12000 0.200 0.300 0.700 0 82 0.050 8 0
  i1 7.000 0.950 7.03 12000 0.200 0.300 0.700 1 82 0.050 8 0
  i1 8.000 0.950 7.03 12000 0.200 0.300 0.700 2 82 0.050 8 0
  i1 9.000 0.950 7.03 12000 0.200 0.300 0.700 0 83 0.050 8 0
  i1 10.000 0.950 7.03 12000 0.200 0.300 0.700 1 83 0.050 8 0
  i1 11.000 0.950 7.03 12000 0.200 0.300 0.700 2 83 0.050 8 0
  i1 12.000 0.950 7.03 12000 0.200 0.300 0.700 0 84 0.050 8 0
  i1 13.000 0.950 7.03 12000 0.200 0.300 0.700 1 84 0.050 8 0
  i1 14.000 0.950 7.03 12000 0.200 0.300 0.700 2 84 0.050 8 0
  i1 15.000 0.950 7.03 12000 0.200 0.300 0.700 0 85 0.050 8 0
  i1 16.000 0.950 7.03 12000 0.200 0.300 0.700 1 85 0.050 8 0
  i1 17.000 0.950 7.03 12000 0.200 0.300 0.700 2 85 0.050 8 0
  i1 18.000 0.950 7.03 12000 0.200 0.300 0.700 0 86 0.050 8 0
  i1 19.000 0.950 7.03 12000 0.200 0.300 0.700 1 86 0.050 8 0
  i1 20.000 0.950 7.03 12000 0.200 0.300 0.700 2 86 0.050 8 0
  i1 21.000 0.950 7.03 12000 0.200 0.300 0.700 0 87 0.050 8 0
  i1 22.000 0.950 7.03 12000 0.200 0.300 0.700 1 87 0.050 8 0
  i1 23.000 0.950 7.03 12000 0.200 0.300 0.700 2 87 0.050 8 0
  i1 24.000 0.950 8.05 12000 0.200 0.300 0.700 0 90 0.050 8 0
  i1 25.000 0.950 8.05 12000 0.200 0.300 0.700 1 90 0.050 8 0
  i1 26.000 0.950 8.05 12000 0.200 0.300 0.700 2 90 0.050 8 0
  i1 27.000 0.950 8.05 12000 0.200 0.300 0.700 0 91 0.050 8 0
  i1 28.000 0.950 8.05 12000 0.200 0.300 0.700 1 91 0.050 8 0
  i1 29.000 0.950 8.05 12000 0.200 0.300 0.700 2 91 0.050 8 0
  i1 30.000 0.950 8.05 12000 0.200 0.300 0.700 0 92 0.050 8 0
  i1 31.000 0.950 8.05 12000 0.200 0.300 0.700 1 92 0.050 8 0
  i1 32.000 0.950 8.05 12000 0.200 0.300 0.700 2 92 0.050 8 0
  i1 33.000 0.950 8.05 12000 0.200 0.300 0.700 0 93 0.050 8 0
  i1 34.000 0.950 8.05 12000 0.200 0.300 0.700 1 93 0.050 8 0
  i1 35.000 0.950 8.05 12000 0.200 0.300 0.700 2 93 0.050 8 0
  i1 36.000 0.950 8.05 12000 0.200 0.300 0.700 0 94 0.050 8 0
  i1 37.000 0.950 8.05 12000 0.200 0.300 0.700 1 94 0.050 8 0
  i1 38.000 0.950 8.05 12000 0.200 0.300 0.700 2 94 0.050 8 0
e
</score>
