Csound Csound-dev Csound-tekno Search About

Sample and hold

Date1999-05-14 06:10
FromPatrick Pagano
SubjectSample and hold
Hi folks
can someone give me a basic sample and hold instr using  an oscili?
the example in the manual is hard for me to figure out and the blue cube
one
is close to what i would like to use but  I want it to have specific
frequencies
instr 4

krt=p6    ;this is the frq of the randh output & clk osc
isd=p4    ;p4 holds the value of the seed of randh UG
krn  randh 1000,krt,isd ;noise input to S&H;;;;;;;;;;;;;;;;;;;i would
like to specify frequencies but when I change the p6 to say 512
kclk oscil
400,krt,1;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;all I get
is noise
ksh samphold krn, kclk ;S&H
a2 oscil 450, ksh,1
a3 oscil a2,1/p3,1
kpan oscil 1,.04,1

this is the bluecube one
heres my full instrs
sr = 44100
kr = 4410
ksmps = 10
nchnls = 2
gasig init 0
garvbsig init 0
instr 1
     ksig1   linen 300, .1, p3, .1
     ksig2   linen 300, .2, p3, .2
     ksig3   linen 300, .3, p3, .3
     ksig4   linen 300, .4, p3, .4
     asig2   oscili ksig1, p4, 1
     asig5   oscili ksig2, p4, 1
     asig3   oscili ksig3, p4*5, 1
     asig4   oscili ksig4, p4*7, 1
     amix=asig2+asig5+asig3+asig4
     gasig =gasig+amix
     garvbsig=garvbsig+amix

endin
instr 2;
     kenv1   linen 300, .1,p3, .1
     kenv2   linen 350, .2,p3, .2
     kenv3   linen 375, .3,p3, .3
     kenv4   linen 380, .4,p3, .4
     kenv5   linen 385, .5,p3, .5
     asig1   oscili kenv1, 1024, 1
     asig3   oscili kenv2, 1334, 1
     asig5   oscili kenv3, 1632, 1
     asig2   oscili kenv4, 1152, 1
     asig4   oscili kenv5, 1360, 1
     amix=asig2+asig5+asig3+asig4+asig1
     gasig =gasig+amix
     garvbsig=garvbsig+amix

endin
instr 3;Begin: Untitled1
     asig1   randh 300, 20000
     kenv1   line 300, p3, 0
     afilt1   reson asig1, kenv1, 75
     amod1   balance afilt1, asig1
     amod1 = amod1*2
     outs amod1,amod1
endin
instr 4

krt=p6    ;this is the frq of the randh output & clk osc
isd=p4    ;p4 holds the value of the seed of randh UG
krn  randh 1000,krt,isd ;noise input to S&H
kclk oscil 400,krt,1
ksh samphold krn, kclk ;S&H
a2 oscil 450, ksh,1
a3 oscil a2,1/p3,1
kpan oscil 1,.04,1


asig1 = a3*kpan
asig2 = a3*(1-kpan)

 amix=asig1+asig2


garvbsig=garvbsig+(asig1+asig2)

endin

instr 99
                kDelaydecay     init            .32
                iDelaytime      init            2.0

                asig7            delayr          iDelaytime
                                delayw          kDelaydecay * (gasig+
asig7)
                                outs             asig7 + gasig,asig7
+gasig

                gasig           =               0
endin
instr 98

a1 reverb2 garvbsig, p4, p5
 outs     a1,a1

garvbsig=0

endin
Thanks for any help as always
Pat Pagano