<CsoundSynthesizer><CsOptions>-n
</CsOptions><CsInstruments>;example by joachim heintzsr=44100ksmps=32nchnls=20dbfs=1instr1;loop_lt: counts from 1 upwards and checks if < 10cnt:i=1loop:print(cnt)loop_lt(cnt,1,10,loop)prints("Instr 1 terminated!%n")endininstr2;loop_le: counts from 1 upwards and checks if <= 10cnt:i=1loop:print(cnt)loop_le(cnt,1,10,loop)prints("Instr 2 terminated!%n")endininstr3;loop_gt: counts from 10 downwards and checks if > 0cnt:i=10loop:print(cnt)loop_gt(cnt,1,0,loop)prints("Instr 3 terminated!%n")endininstr4;loop_ge: counts from 10 downwards and checks if >= 0cnt:i=10loop:print(cnt)loop_ge(cnt,1,0,loop)prints("Instr 4 terminated!%n")endin</CsInstruments><CsScore>i100i200i300i400</CsScore></CsoundSynthesizer>
Here is a group example for all loop_xx opcodes, comparing the different loop_ opcodes. It uses the file loop_-group.csd.
<CsoundSynthesizer><CsOptions>-n
</CsOptions><CsInstruments>;example by joachim heintzsr=44100ksmps=32nchnls=20dbfs=1instr1;loop_lt: counts from 1 upwards and checks if < 10icount=1loop:printicountloop_lticount,1,10,loopprints"Instr 1 terminated!%n"endininstr2;loop_le: counts from 1 upwards and checks if <= 10icount=1loop:printicountloop_leicount,1,10,loopprints"Instr 2 terminated!%n"endininstr3;loop_gt: counts from 10 downwards and checks if > 0icount=10loop:printicountloop_gticount,1,0,loopprints"Instr 3 terminated!%n"endininstr4;loop_ge: counts from 10 downwards and checks if >= 0icount=10loop:printicountloop_geicount,1,0,loopprints"Instr 4 terminated!%n"endin</CsInstruments><CsScore>i100i200i300i400</CsScore></CsoundSynthesizer>