loop_ge

loop_ge — Looping constructions.

Description

Construction of looping operations.

Syntax

loop_ge  indx, idecr, imin, label
loop_ge  kndx, kdecr, kmin, label

Initialization

indx -- i-rate variable to count loop.

idecr -- value to decrement the loop.

imin -- minimum value of loop index.

Performance

kndx -- k-rate variable to count loop.

kdecr -- value to decrement the loop.

kmin -- minimum value of loop index.

The actions of loop_ge are equivalent to the code

         indx  =  indx - idecr
         if (indx >= imin) igoto label

or

         kndx  =  kndx - kdecr
         if (kndx >= kmin) kgoto label

[Note] Note
Adviced is to use the 'modern' while or until opcodes for looping constructions.

Examples

Here is a group example for all loop_xx opcodes, comparing the different loop_ opcodes. It uses the file loop_-group.csd.

Example 531. Group example of the loop_xx opcodes.

See the sections Real-time Audio and Command Line Flags for more information on using command line flags.

<CsoundSynthesizer>
<CsOptions>
-n
</CsOptions>
<CsInstruments>
;example by joachim heintz
sr     = 44100
ksmps  = 32
nchnls = 2
0dbfs  = 1

  instr 1 ;loop_lt: counts from 1 upwards and checks if < 10
icount    =         1
loop:
          print     icount
          loop_lt   icount, 1, 10, loop
          prints    "Instr 1 terminated!%n"
  endin

  instr 2 ;loop_le: counts from 1 upwards and checks if <= 10
icount    =         1
loop:
          print     icount
          loop_le   icount, 1, 10, loop
          prints    "Instr 2 terminated!%n"
  endin

  instr 3 ;loop_gt: counts from 10 downwards and checks if > 0
icount    =         10
loop:
          print     icount
          loop_gt   icount, 1, 0, loop
          prints    "Instr 3 terminated!%n"
  endin

  instr 4 ;loop_ge: counts from 10 downwards and checks if >= 0
icount    =         10
loop:
          print     icount
          loop_ge   icount, 1, 0, loop
          prints    "Instr 4 terminated!%n"
  endin

</CsInstruments>
<CsScore>
i 1 0 0
i 2 0 0
i 3 0 0
i 4 0 0
</CsScore>
</CsoundSynthesizer>


See also

Program Flow Control: Looping Constructions

More information on this opcode: http://www.csoundjournal.com/2006summer/controlFlow_part2.html written by Steven Yi, and in the Floss Manuals: https://flossmanual.csound.com/csound-language/control-structures

Credits

Istvan Varga. 2006

New in Csound version 5.01