| Hi,
Here is a bit of noise with a delay example mostly for Pat's benefit.
Hope this works,
Hans Mikelson
; ORCHESTRA
sr = 44100 ; Sample rate
kr = 22050 ; Control rate
ksmps = 2 ; Samples per control period
nchnls = 2 ; Number of channels = stereo
gaol init 0 ; Initialize the global variable for the left channel
gaor init 0 ; Initialie right global
instr 5
idur = p3 ; Duration
iamp = p4 ; Amplitude
ifqc = cpspch(p5) ; Convert pitch to frequency
ie1 = p6 ; Envelope 1 table
ie2 = p7 ; Envelope 2 table
ipanl = sqrt(p8) ; Equal power panning left
ipanr = sqrt(1-p8) ; Equal power panning right
kenv1 oscil 1, 1/idur, ie1 ; Use 1/idur trick to make a flexible envelope
kenv2 oscil 1, 1/idur, ie2 ; Do it again.
aamp linseg 0, .01, iamp, idur-.02, iamp, .005, 0, .005, 0 ; Declick
; be sure to leave it at zero a
; while at the end to
; avoid DC offset in the delay
; loop
aamp2 expseg .5, idur-.01, 1, .01, .1 ; Amplitude envelope, fade in
slow
; fade out fast.
achy cauchy kenv1 ; Cauchy random number generator
; Env1 controls the distribution
aout oscil 1, (achy+1)*ifqc*kenv2, 1 ; Frequency modulation by Cauchy
; Env2 controls FM amount
aol = aout*aamp*aamp2*ipanl ; Left out signal with pan
aor = aout*aamp*aamp2*ipanr ; Right out signal with pan
gaol = gaol+aol ; Accumlate in the globals
gaor = gaor+aor ; so polyphony is handled.
outs aol, aor ; Stereo out
endin
instr 50 ; Delay instrument
idur = p3 ; Duration
igainl = p4 ; Left feedback gain
itiml = p5 ; Left delay time
ifcol = p6 ; Left low frequency cut off
igainr = p7 ; Ditto for right side
itimr = p8
ifcor = p9
afltl init 0 ; Must initialize the loop back for
afltr init 0 ; delay feedback
aamp linseg 0, .005, 1, idur-.01, 1, .005, 0 ; Declick is needed here too
adell delay (gaol+afltl)*igainl, itiml ; Delay the global signals and
adelr delay (gaor+afltr)*igainr, itimr ; feedback the filtered signal
afltl butterlp adell, ifcol ; Low pass filter for mellower echo
afltr butterlp adelr, ifcor
gaol = 0 ; Zero out the globals so they don't blow up
gaor = 0
outs adell*aamp, adelr*aamp ; Declick and output
endin
; SCORE
f1 0 65536 10 1 ; High resolution sine wave
f6 0 1024 -5 .01 1024 100000 ; Controls width of random distribution
f7 0 1024 -5 1 1024 12 ; Pitch bend
; Sta Dur Amp Pitch Env1 Env2 Pan
i5 .00 .2 12000 6.00 6 7 .5
i5 .02 .4 . 6.01 6 7 .1
i5 .04 .6 . 6.02 6 7 .8
i5 .06 .8 . 6.03 6 7 .4
i5 2.00 .2 10000 7.00 6 7 .5
i5 2.02 .4 . 7.01 6 7 .1
i5 2.04 .6 . 7.02 6 7 .8
i5 2.06 .8 . 7.03 6 7 .4
i5 3.00 .1 8000 7.09 6 7 .5
i5 3.03 .4 . 7.05 6 7 .1
i5 3.05 .4 . 7.11 6 7 .8
i5 3.09 .9 . 8.04 6 7 .4
i5 3.20 .2 8000 6.00 6 7 .5
i5 3.32 1.4 . 5.01 6 7 .1
i5 3.44 .6 . 6.02 6 7 .8
i5 3.56 .8 . 7.03 6 7 .4
i5 3.60 1.5 7000 9.00 6 7 .5
i5 3.72 .8 . 7.01 6 7 .1
i5 3.94 .6 . 6.02 6 7 .8
i5 4.26 .2 . 7.03 6 7 .4
; Sta Dur FeedBk Time Fco FeedBk Time Fco
i50 0 6 .32 .20 700 .30 .21 720
|