| User-Defined Opcode Database |
|---|
Reports if a control signal has stayed at the same value for a certain time.
Download UDO FileOutputs 1 if kin has not changed since at least ksec seconds, otherwise outputs 0.
kout Stayed kin, ksec
kin - input signal
ksec - time in seconds for which kin is asked to have the same value or not
kout - 1 if the value has not changed since at least ksec seconds, otherwise 0
opcode Stayed, k, kk kin, ksec xin kout init 0 knumk = ksec * kr ;number of control cycles for ksec kinit init 1 kcount init 0 if kinit == 1 then ;just once, at the beginning kprevious = kin kinit = 0 endif if kin == kprevious then kcount = kcount + 1 else kcount = 0 kprevious = kin endif if kcount > knumk then kout = 1 else kout = 0 endif xout kout endop
<CsoundSynthesizer> <CsInstruments> ksmps = 4410 ;10 control cycles per second opcode Stayed, k, kk ;outputs 1 if kin has not changed since ksec seconds, otherwise outputs 0 kin, ksec xin kout init 0 knumk = ksec * kr ;number of control cycles for ksec kinit init 1 kcount init 0 if kinit == 1 then ;just once, at the beginning kprevious = kin kinit = 0 endif if kin == kprevious then kcount = kcount + 1 else kcount = 0 kprevious = kin endif if kcount > knumk then kout = 1 else kout = 0 endif xout kout endop instr 1 kval randh 10, 1, 2 ;new value once per second kout Stayed kval, .75 ;outputs 1 if kval has not changed since 0.75 seconds printk 0, kval printk 0, kout, 10 endin </CsInstruments> <CsScore> i 1 0 5 </CsScore> </CsoundSynthesizer>
joachim heintz 2010
| Previous | Home | Next |
| Statevar | stereoAsymmetry |