;======================================;
; Template Orchestra for Final Project ;
;======================================;
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
;======================================
; Global Control Instruments (1 - 10)
;Use the first block of instrument numbers
;for instruments that contain global variables
;used for effects sends or external parameter
;control (phrase envelopes, etc.) Any schedule
;instruments should be in this block, as well.
;======================================
instr 1 ;effects sends
gasend1 = 0 ;zero here, at start
gasnd2L = 0 ;of each new k-pass
gasnd2R = 0
endin
instr 2 ;example control vars
imax1 = p4 ;max control value 1
ifunc1 = p5 ;control function 1
imax2 = p6 ;max control value 2
ifunc2 = p7 ;control function 2
;use an oscil1 to read control function 1
gkvar1 oscil1i 0,1,p3,ifunc1 ;a global control
;use a line/table combination for control 2
kindex line 0,p3,1
kvar2 tablei kindex,ifunc2,1 ;normalized index
gkvar2 = kvar2 * imax2 ;scale as needed
endin
instr 3 ;example event scheduler
ipkamp = p4 ;peak amp for all events
ievthz = p5 ;frequency of events
itable = p6 ;number of parameter table
iseed = p7 ;seed for random numbers
insno = p8 ;slave instrument number
idry = p9 ;dry output factor (0-1)
isend1 = p10 ;send1 factor (0-1)
isend2 = p11 ;send2 factor (0-1)
krndno rand .5,iseed,1,.5
ievtdur = 1/ievthz
kprev init 1 ;initialize previous phase
kphase phasor ievthz ;event "clock"
if (kphase > kprev) kgoto wait
event "i",insno,0,ievtdur,ipkamp,krndno,itable,idry,isend1,isend2
wait:
kprev = kphase ;remember last phase value
endin
;==========================================;
; Sound producing instruments (11-50) ;
;Put the instruments that generate sound ;
;here, so that they can use global vars ;
;being initialized and/or controlled above ;
;==========================================;
instr 11 ;example playback instr
igain = p4 ;gain factor
irndno = p5 ;random value
itable = p6 ;param table
idry = p7 ;dry signal factor
isend1 = p8 ;amp factor for send1
isend2 = p9 ;amp factor for send2
isnds table 0,itable ;get number of sounds
index = 2+int(isnds*irndno)*2
isound table index,itable ;get the soundin number
idur table index+1,itable ;get the duration
p3 = idur ;adjust p3 to actual sound dur
asig soundin isound ;play the sound
asig = asig*igain*gkvar1 ;apply global amp control
adry = asig*idry ;signal for direct (dry) outputs
kleft = sqrt(gkvar2) ;left pan factor
kright = sqrt(1-gkvar2) ;right pan factor
aleft = adry*kleft ;apply global pan control
aright = adry*kright
outs aleft,aright
if (isend1 == 0) kgoto send2
gasend1 = gasend1+asig*isend1
send2: if (isend2 == 0) kgoto end
gasnd2L = gasnd2L+aleft*isend2
gasnd2R = gasnd2R+aright*isend2
end: endin
;==========================================;
; Global effects instruments (51-99) ;
;Put the instruments that generate sound ;
;here, so that they can use global vars ;
;being initialized and/or controlled above ;
;==========================================;
instr 51 ;stereo slapback delay
idel1 = p4
ilvl1 = p5
ipan1 = p6
ifeed1 = p7 ;feedback factor1 (0-1)
idel2 = p8
ilvl2 = p9
ipan2 = p10
ifeed2 = p11 ;feedback factor2 (0-1)
isend2 = p12 ;amount to send on to reverb
atap1 init 0 ;initialize outputs
atap2 init 0
atap1 delay gasend1+atap1*ifeed1,idel1
atap2 delay gasend1+atap2*ifeed2,idel2
ileft1 = sqrt(ipan1)
iright1 = sqrt(1-ipan1)
ileft2 = sqrt(ipan2)
iright2 = sqrt(1-ipan2)
aleft = atap1*ileft1 + atap2*ileft2
aright = atap1*iright1 + atap2*iright2
outs aleft,aright
if (isend2 == 0) kgoto end
gasnd2L = gasnd2L+aleft*isend2
gasnd2R = gasnd2R+aright*isend2
end: endin
instr 52 ;stereo reverb
igain = p4 ;reverb gain factor
irvt = p5 ;reverb time
idiff = p6 ;reverb2 diffusion factor
aleft reverb2 gasnd2L,irvt,idiff
aright reverb2 gasnd2R,irvt,idiff
outs aleft,aright
endin
;global amp control function
f01 0 8192 7 .5 4096 1 4096 .5
;global pan control function
f02 0 8192 7 .5 2048 1 4096 0 2048 .5
;soundin data table
f03 0 16 -2 4 0
; snd# dur
36 .176 ;bass drum
37 1.291 ;bell (53)
38 .142 ;high hat (42)
39 1.128 ;tom tom (43)
;global sends instrument (run always to zero global sends variables)
i01 0 10
;global control instrument
; st dur maxval1 func1 maxval2 func2
i02 0 10 1 1 1 2
;schedule instrument
; st dur amp evthz table seed insno idry isend1 isend2
i03 0 10 1 8 3 .531 11 1 0 0
s
f0 1
s
;Play it again with reverb
;global sends instrument (run always to zero global sends variables)
i01 0 13
;global control instrument
; st dur maxval1 func1 maxval2 func2
i02 0 10 1 1 1 2
;schedule instrument
; st dur amp evthz table seed insno idry isend1 isend2
i03 0 10 1 8 3 .135 11 .8 0 .2
; st dur gain rvt diff
i52 0 13 .5 2 .25
s
f0 1
s
;Now try some slapback delay in the opposite channel
;global pan control function
f02 0 2 -2 1 1
;global sends instrument (run always to zero global sends variables)
i01 0 12
;global control instrument
; st dur maxval1 func1 maxval2 func2
i02 0 10 1 1 1 2
;schedule instrument
; st dur amp evthz table seed insno idry isend1 isend2
i03 0 10 1 8 3 .351 11 .8 .6 0
; st dur idel1 ilvl1 ipan1 ifeed1 idel2 ilvl2 ipan2 ifeed2 isend2
i51 0 12 .125 .25 .35 .5 .5 .125 0 .5 0
s
f0 1
s
;Delay plus reverb
;global sends instrument (run always to zero global sends variables)
i01 0 15
;global control instrument
; st dur maxval1 func1 maxval2 func2
i02 0 10 1 1 1 2
;schedule instrument
; st dur amp evthz table seed insno idry isend1 isend2
i03 0 10 1 8 3 .555 11 .8 .6 .2
; st dur idel1 ilvl1 ipan1 ifeed1 idel2 ilvl2 ipan2 ifeed2 isend2
i51 0 12 .125 .25 .35 .5 .5 .125 0 .5 .2
; st dur gain rvt diff
i52 0 15 .125 2 .25
e