<MacOptions>
Version: 1
Render: Real
Ask: Yes
Options: -b64 -A -oDotor Pato:test2.aif -s -m7 -B0 -Lstdin -R 
</MacOptions>
<MacGUI>
ioView nobackground {65535, 65535, 65535}
ioListing {0, 0} {400, 500}
</MacGUI>
<CsoundSynthesizer>
<CsInstruments>
sr = 44100
kr = 441
ksmps = 100
nchnls = 1

;========================================================
; Example FOF instrument 
;
;This uses 5 fof units to simulate vowel formants. The
;formant data is taken from the Dodge book, pp. 230-231
;RP
;========================================================


instr 1 ;basic vowel formant generation instrument
idur = p3
igain = p4 ;gain factor, usually between 0 - 1
ibasedb = dbamp(32767) ;max amp for 16-bit - use as 0dB reference
ifund = cpspch(p5)
ivibdel = p6
ivibwth = p7
ivibrte = p8
iform1 = p9  ;fof1 formant freq
iamp1 = ampdb(ibasedb+p10) ;amp relative to 0dB
ibw1 = p11
iform2 = p12  ;fof2 formant freq
iamp2 = ampdb(ibasedb+p13) ;amp relative to 0dB
ibw2 = p14
iform3 = p15  ;fof3 formant freq
iamp3 = ampdb(ibasedb+p16) ;amp relative to 0dB
ibw3 = p17
iform4 = p18  ;fof4 formant freq
iamp4 = ampdb(ibasedb+p19) ;amp relative to 0dB
ibw4 = p20
iform5 = p21  ;fof5 formant freq
iamp5 = ampdb(ibasedb+p22) ;amp relative to 0dB
ibw5 = p23
ilrise = p24  ;local envelope settings
ildur = p25
ildec = p26
irise = p27  ;global envelope settings

irise = 1.0 ; for a slow rise...

idecay = p28
iolaps = (p29 == 0 ? 10 * ifund*ildur+1 : p29) ;compute overlaps
ioct = p30  ;octaviation

knewpitch invalue "newpitch" ;k rate update of incoming pitch value -- added by Bob
krealpitch = cpspch(p5 + (knewpitch * 0.1))
kformant1 invalue "formant1"
kformant2 invalue "formant2"
kformant3 invalue "formant3"
kformant4 invalue "formant4"
kformant5 invalue "formant5"
kformant1amp invalue "formant1amp"
kformant2amp invalue "formant2amp"
kformant3amp invalue "formant3amp"
kformant4amp invalue "formant4amp"
kformant5amp invalue "formant5amp"
kvibdepth = ivibwth;

kenv linen igain,irise,idur,idecay
kvibctl oscil1i ivibdel,1,.25,3 ;fn3 is vib control function

kranddep randi 0.015, .5, p2/1000;
krandspeed randi 1.0, .3, p2/1000;

;kvib oscili kvibctl*ivibwth,kvibctl*ivibrte,1
kvib oscili kvibctl*(kvibdepth+ kranddep),kvibctl*(ivibrte+ krandspeed),1
kfund = (ifund + knewpitch)*(1+kvib)
ioct = 0.0

ar1 fof iamp1 + kformant1amp, kfund, kformant1, ioct, ibw1, ilrise, ildur, ildec, iolaps, 1, 2, idur
ar2 fof iamp1 + kformant2amp, kfund, kformant2, ioct, ibw2, ilrise, ildur, ildec, iolaps, 1, 2, idur
ar3 fof iamp1 + kformant3amp, kfund, kformant3, ioct, ibw3, ilrise, ildur, ildec, iolaps, 1, 2, idur
ar4 fof iamp1 + kformant4amp, kfund, kformant4, ioct, ibw4, ilrise, ildur, ildec, iolaps, 1, 2, idur
ar5 fof iamp1 + kformant5amp, kfund, kformant5, ioct, ibw5, ilrise, ildur, ildec, iolaps, 1, 2, idur
 out (ar1+ar2+ar3+ar4+ar5)*kenv
 endin 
</CsInstruments>
<CsScore>
;Test score for fofdemo orchestra. Test all the vowel formants from Dodge pp. 230-231. RP
f1 0 8192 10 1
;generate a "sigmoid" for use in local envelope rise/decay
f2 0 8192 19 .5 .5 270 .5
;linear rise for vibrato onset
f3 0 513 7 0 513 1
;male voice singing A
; st dur gain fund vibdel vibwth vibrte
;i01 0 2 .3 7.00 .25 .0175 5
; fmt1 amp1 bw1 fmt2 amp2 bw2 fmt3 amp3 bw3
; 609 0 100 1000 -6 100 2450 -12 100
; fmt4 amp4 bw4 fmt5 amp5 bw5 ilris ildur ildec
; 2700 -11 100 3240 -24 100 .003 .02 .007
; irise idecay iolaps ioct
; .1 .1 0 0
;i01 + . . 7.04
;i01 + . . 7.07
;i01 + . . 8.00
;i01 + . . 8.04
;i01 + . . 8.07
;s





f0 600				; null function to keep running for realtime events
e					; indicates the end of the score



</CsScore>

</CsoundSynthesizer>
