Csound Csound-dev Csound-tekno Search About

loops

Date1998-07-01 11:51
FromPedro Batista
Subjectloops
Hey everyone :)

I've been away for a week, and seem to have lost 2 digests, so I dont know 
if anyone answered my question on goto and loops; anyway, during my absence, 
I had time to ponder on this subject, and came to the conclusion that the 
only way of running loops is at i-time; also if one needs to run one or 
several loops for each sample, it can easily be done, by using the zak's to 
send values between perf and init, and using reinit to control the program 
flux. I'll send an example using this technique next

Here's the deal:

     instr     1
; first time initializations here
; ....

; skip to performance
     igoto     perf

ini:
; following code will be executed for each sample

; read sample value
isig zir  1

; here you can process the sample at i-rate, with the assurance that
; loops will work, and igoto _does_ jump back and forth

; ...do *whatever* with isig

; write the output
     ziw  isig, 1

; return to performance
     rireturn

perf:     

; simple example with soundin
asig soundin   "c:\csound\samples\soundin.1"
ksig downsamp asig  ; I use ksmps=1 for this

; write sample value
     zkw  ksig, 1

; process sample at i-rate
     reinit    ini

; read and play the processed sample
kout zkr  1
aout interp    kout
     out  aout

     endin