sr = 44100
kr = 4410
ksmps = 10
nchnls = 2 ;apparently you can have nchnls = whatever you want
;but I am uncertain as to the implementation of
instr 1 ;anything over two
idur = p3
iamp = p4
icps = p5
ifn = p6
ih = p7
ihsp = p8
ips = p9
aharm randi ih, ihsp
apan randi 1, ips
a1 buzz iamp, icps, aharm, ifn
outs a1*apan, a1*(1-apan) ;if nchnls = 2,
endin ;the out opcode changes to: outs right, left
;The randi opcode takes two arguments: the highest possible random number to be
;computed (output is between this and 0), and how many times per second this number
;is to be replaced with a new random value. Randi also interpolates linearly between
;the old and new numbers, and as they are a-rate variables here there are 44100
;points of resolution per second between them.
;
;The aharm variable is used in the buzz opcode, where it determines the number of
;harmonic partials present at any given time. The largest number of variables
;is left to score file to define, as well as how quickly the random number changes
;
;The apan variable calculates a random number between zero and one, the speed at which
;the number changes being left up to the score file. This number is then applied to the
;output of the buzz opcode, which is a1. If we wanted a1 to appear in equal amplitudes
;in both channels, we would simply write:
;
; outs a1, a1
;
;Here, we calculate a number between 0 and one, and apply it untouched to one channel,
;and apply it to the other after subtracting it from 1. Multiplying a signal by a scalar
;in a range of 0 to one controls the amplitude of that signal between 0% and 100%. This method
;creates two different amplitudes in two different channels of the same signal, which are
;between 0% and 100%, and are also inversely proportional to each other. This gives a sort of
;spatializing effect: stereo. Because I have used randi, which generates new numbers at a
;certain rate and also interpolates between them, the effect heard is that of a single signal
;wandering around your head (if you are wearing headphones).
instr 2
idur = p3
iamp = p4
ifrq = p5
iatk = p6
idec = p7
icf1 = p8
icf2 = p9
ibw1 = p10
ibw2 = p11
kenv linen iamp, iatk, idur, idec
a1 rand ifrq
kcf expon icf1, idur, icf2
kbw line ibw1, idur, ibw2
a2 reson a1, kcf, kbw, 2
outs a2*kenv, a2*kenv
endin
instr 3
idur = p3
iamp = p4
ifrq = p5
iatk = p6
idec = p7
icf1 = p8
icf2 = p9
ibw1 = p10
ibw2 = p11
ipans = p12
kenv linen iamp, iatk, idur, idec
a1 rand ifrq
kpan randi 1, ipans
kcf expon icf1, idur, icf2
kbw expseg ibw1, idur/2, ibw2, idur/2, ibw2
a2 reson a1, kcf, kbw, 2
dispfft a2, idur, 4096
outs (a2*kenv)*ipans, (a2*kenv)*(1-ipans)
endin
instr 4
idur = p3
iamp = p4
icps = p5
ifn = p6
iharm = p7
icut1 = p8
icut2 = p9
iresgn = p10
kcut expon icut1, idur, icut2
a1 buzz iamp, icps, iharm, ifn
abpf butbp a1, kcut, kcut*.2
alpf butlp a1, kcut
amix = alpf+(abpf*iresgn)
amix balance amix, a1
outs amix, amix
endin