<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac ;;;realtime audio out;-iadc ;;;uncomment -iadc if RT audio input is needed too; For Non-realtime ouput leave only the line below:; -o loop_lt.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1seed0gisine=ftgen(0,0,2^10,10,1)instr1;master instrumentninstr:i=5;number of called instancesndx:i=0loop:prints("play instance %d\\n",ndx)Pan:i=random(0,1)freq:i=random(100,1000)amp:i=1/ninstreventi("i",10,0,p3,amp,freq,Pan)looplt(ndx,1,ninstr,loop)endininstr10Peak:i=random(0,1);where is the envelope peaksig:a=poscil3(p4,p5,gisine)env:a=transeg(0,p3*Peak,6,1,p3-p3*Peak,-6,0)aL,aR=pan2(sig*env,p6)out(aL,aR)endin</CsInstruments><CsScore>i1010e</CsScore></CsoundSynthesizer>
Here is an example of the loop_lt opcode. It uses the file loop_lt.csd.
<CsoundSynthesizer><CsOptions>; Select audio/midi flags here according to platform-odac ;;;realtime audio out;-iadc ;;;uncomment -iadc if RT audio input is needed too; For Non-realtime ouput leave only the line below:; -o loop_lt.wav -W ;;; for file output any platform</CsOptions><CsInstruments>sr=44100ksmps=32nchnls=20dbfs=1seed0gisineftgen0,0,2^10,10,1instr1;master instrumentininstr=5;number of called instancesindx=0loop:prints"play instance %d\\n",indxipanrandom0,1ifreqrandom100,1000iamp=1/ininstrevent_i"i",10,0,p3,iamp,ifreq,ipanloop_ltindx,1,ininstr,loopendininstr10ipeakrandom0,1;where is the envelope peakasigposcil3p4,p5,gisineaenvtranseg0,p3*ipeak,6,1,p3-p3*ipeak,-6,0aL,aRpan2asig*aenv,p6outsaL,aRendin</CsInstruments><CsScore>i1010e</CsScore></CsoundSynthesizer>
Its output should include a line like this:
play instance 0
play instance 1
play instance 2
play instance 3
play instance 4