loop_gt
Prev | Orchestra Opcodes and Operators | Next

## loop_gt

loop_gt — Looping constructions.

## Description

Construction of looping operations.

## Syntax

    loop_gt  indx, idecr, imin, label

    loop_gt  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_gt are equivalent to the code

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

or

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

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

## Examples

Here is an example of the loop_gt opcode. It uses the file loop_gt.csd.

Example 532. Example of the loop_gt opcode.

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

    <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_gt.wav -W ;;; for file output any platform

    ; By Stefano Cucchi - 2021

    </CsOptions>
    <CsInstruments>

    sr = 44100
    ksmps = 32
    nchnls = 2
    0dbfs  = 1

    gisaw  ftgen 3, 0, 16384, 10, 0, .2, 0, .4, 0, .6, 0, .8, 0, 1, 0, .8, 0, .6, 0, .4, 0,.2

    instr 1 ;master instrument

    indxFreq = p5

    loop:

    ifreq = p4 + indxFreq
    print ifreq
    iamp = 0.5/((p5-p7)/p6)
    event_i "i", 10, 0, p3, iamp, ifreq
    loop_gt indxFreq, p6, p7, loop

    endin

    instr 10

    asig  oscili p4, p5, gisaw
    asig butterhp asig, 50
    kdeclick linseg 0, 0.1, 1, p3-0.2, 1, 0.1, 0
    outs asig * kdeclick, asig * kdeclick

    endin

    </CsInstruments>
    <CsScore>

    i1 0 2 200 10 3 1

    i1 2 2 200 4 0.3 1

    i1 4 2 200 55 7 1

    i1 6 2 200 3 0.2 1

    e
    </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.

New in Csound version 5.01

Prev | Up | Next
loop_ge | Home | loop_le