lastcycle
Prev | Orchestra Opcodes and Operators | Next

## lastcycle

lastcycle — Indicates whether an event is in its last performance cycle.

## Description

Provides a way of knowing if an event is in its last performance cycle. Whether an event has a finite duration (p3 > 0) or a note is extended via a time extending opcode (like “linsegr” or “xtratim”), this opcode returns 1 if the event is currently at its last k-cycle. The only sitatuation where “lastcycle” does not detect that the event will not run for another cycle is when the note is turned off by another event (using “turnoff2”) and is not given the possibility of running through its release stage (using “turnoff2 instrnum, imode, 0”)

## Syntax

    kflag lastcycle

## Performance

kflag -- indicates whether the note is in its “last cycle”. (1 if this the last cycle, otherwise 0)

This opcode is useful for performing cleanup actions, signaling to other events that this event is finishing, etc. It works only at performance time.

## Examples

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

Example 499. Example of the lastcycle opcode.

    <CsoundSynthesizer>

    <CsOptions>
    ; Select audio/midi flags here according to platform
    ; Audio out   Audio in    Silent  MIDI in
    -odac
    -d
    </CsOptions>

    <CsInstruments>

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

    instr 1
      aenv linsegr 0, 0.1, 1, 0.1, 0
      asig =  oscili(0.1, 1000)
      asig += oscili(0.1, 1012)
      asig *= aenv
      if lastcycle() == 1 then
        schedulek p1, 0, p3
      endif
      outs asig, asig
    endin

    </CsInstruments>

    <CsScore>

    i 1 0 0.5
    f 0 3600

    </CsScore>

    </CsoundSynthesizer>

## See also

Event Extenders

## Credits

By: Eduardo Moguillansky 2020

New in Csound version 6.14 (2020)

Prev | Up | Next
lagud | Home | lenarray