; File: final.orc ; Author: Mike Heasley ; Computer Music final project: "What Did You Do to My Voice?" ; Copyright (C) 1995 Mike Heasley ; Unauthorized reproduction or modification of this file is strictly prohibited. ; ; final.orc orchestra file ; final.sco score file ; final.aiff output sound file ; soundin.9 sample file (also AIFF) ; soundin.22 sample file (also AIFF) sr = 44100 ; I wanted to have some audio-rate parameters in the kr = 44100 ; foscil function, but it only allows control rate ksmps = 1 ; stuff. Thus the high kr. nchnls = 2 ; in STEREO... ; initialize global variable for reverb garev init 0 ; Main instrument (a.k.a. the instrument from hell, with 36 parameters) ; ; p1-p5 = the usual stuff ; p6 = the carrier frequency for foscil, as a multiple of cpspch(p5) ; p7 = the modulating frequency for foscil, as a multiple of cpspch(p5) ; p8 = index of modulation for foscil ; p9 = beginning of volume envelope ; p10 = midpoint of the volume envelope ; p11 = endpoint of the volume envelope ; p12 = time at which the volume envelope reaches the midpoint ; p13 = depth of first "morphing" oscillator ; p14 = frequency of first "morphing" oscillator ; p15 = depth of second "morphing" oscillator ; p16 = frequency of second "morphing" oscillator ; p17 = depth of third "morphing" oscillator ; p18 = frequency of third "morphing" oscillator ; p19 = tone algorithm number ; p20 = frequency of first sample and hold oscillator ; p21 = frequency of second sample and hold oscillator ; p22 = frequency of gate oscillator for sample and hold ; p23 = reverb level ; p24 = panning algorithm number ; p25 = first panning parameter ; p26 = second panning paramter ; p27 = flange depth ; p28 = flange frequency ; p29 = max delay for flanging ; p30 = Time at which pitch bend starts ; p31 = Time at which pitch bend ends ; p32 = Pitch on which pitch bend ends ; p33 = Time at which index of modulation change starts ; p34 = Time at which index of modulation change ends ; p35 = Final index of modulation ; p36 = If 1, then make sound "choppy" (amplitude goes to 0 when kgate < 0) instr 1 imaxamp = 30000*p4 ireqfreq = cpspch(p5) iorigfreq = 440 itablesize = 1048576 ; soundin.9 itablesize2 = 524288 ; soundin.22 iphaseincr = ireqfreq*sr/(iorigfreq*itablesize) iphaseincr2 = sr/itablesize2 ; for tone algorithms 5 and 6 ; sample and hold stuff kphase phasor iphaseincr kustyn tablei kphase,2,1,0,0 karon tablei kphase,3,1,0,0 kmod oscil 1, p20, 1 kmods oscil 1, p21, 1 kgate oscil 1, p22 * (1 + kmod/2), 1 ksh1 samphold kustyn, kgate ;+(1 + kmods) ksh2 samphold karon, kgate ;+(1 + kmods) bend: if (p31 == 0) goto nobend kbend linseg cpspch(p5), p30, cpspch(p5), p31-p30, cpspch(p32), p3-p31+p30, cpspch(p32) goto mod nobend: kbend = cpspch(p5) mod: if (p34 == 0) goto nomod kmod linseg p8, p33, p8, p34-p33, p8*p35, p3-p34+p33, p8*p35 goto fm nomod: kmod = p8 fm: if (p19 == 2) goto alg2 if (p19 == 3) goto alg3 if (p19 == 4) goto alg4 if (p19 >= 5) goto alg5 ; No sample and hold stuff included anote1 foscil 1, kbend, p6, p7, kmod, 1 anote2 foscil 1, kbend, p6, p7, kmod, 1 goto morph alg2: ; Some sample and hold anote1 foscil 1, kbend, p6 * ksh1, p7, kmod, 1 anote2 foscil 1, kbend, p6, p7, kmod * ksh2, 1 goto chop alg3: ; More sample and hold anote1 foscil 1, kbend, p6 * ksh1, p7, kmod * ksh2, 1 anote2 foscil 1, kbend, p6 * ksh2, p7, kmod * ksh1, 1 goto chop alg4: ; Half sample and hold anote1 foscil 1, kbend, p6, p7, kmod, 1 anote2 foscil 1, kbend, p6 * ksh2, p7, kmod * ksh1, 1 goto chop alg5: ; Instead of 2 foscils, make one note just the original sample anote1 foscil 1, kbend, p6, p7, p8, 1 aphase phasor iphaseincr2 anote2 tablei aphase,p19-3,1,0,0 goto morph chop: if (p36 == 0) goto morph if (kgate < 0) goto morph anote1 = 0 anote2 = 0 ; "Morphing" using ring modulation, with anote1 and anote2 and the inputs ; Used several oscillators in series so it seems irregular morph: km1 oscil p13, p14, 1 km2 oscil p15, p16 + km1, 1 kmorph oscil p17, p18 + km2, 1 kvol linseg p9, p12, p10, p3-p12, p11 if (kmorph > 0) goto output2 aout = anote1 * (anote2 - kmorph)/(1 - kmorph) goto pan output2: aout = anote2 * (kmorph + anote1)/(1 + kmorph) ; Panning pan: if (p24 == 2) goto pan2 if (p24 == 3) goto pan3 if (p24 == 4) goto pan4 ; linear pan sweep kpan linseg p25, p3, p26 goto flange pan2: ; Oscillating pan kpan oscil 1, p25, 1 goto flange pan3: ; Panning corresponds to kmorph oscillator kpan = kmorph goto flange pan4: ; Same as pan3 until time specified by p25. Then it follows kmorph ; until it hits pan position p26, where it stays for the rest of the ; note. ktime linseg 0, p3, p3 if (ktime > p25) goto settle kpan = kmorph goto flange settle: if (kpan == p26) goto lock kpan = kmorph goto flange lock: kpan = p26 ; Simple flanging, based on the handout given in class flange: if (p27 == 0) goto doit afl1 delayr p29 aflange oscili p27/100, p28, 1 afl2 deltapi aflange+p29/2 atmp = aout delayw atmp aout = afl1+afl2 ; Finally, some output doit: kenv linseg 0, 0.02, 1.0, p3-0.22, 0.9, 0.2, 0 outs1 aout*((1 + kpan)/2)*kvol*kenv*(0.5 + (km2 * km2/2))*imaxamp outs2 aout*((1 - kpan)/2)*kvol*kenv*(0.5 + (km2 * km2/2))*imaxamp ; Update the reverb global variable garev = garev + aout*kenv*imaxamp*p23 endin ; ************************** ; Reverb instrument, adapted from an example in the csound manual instr 99 asig reverb garev, p4 outs1 asig outs2 asig garev = 0 endin