schedwhen
Prev | Orchestra Opcodes and Operators | Next

## schedwhen

schedwhen — Adds a new score event.

## Description

Adds a new score event.

## Syntax

    schedwhen ktrigger, kinsnum, kwhen, kdur [, ip4] [, ip5] [...]

    schedwhen ktrigger, "insname", kwhen, kdur [, ip4] [, ip5] [...]

## Initialization

ip4, ip5, ... -- Equivalent to p4, p5, etc., in a score i statement.

## Performance

kinsnum -- instrument number. Equivalent to p1 in a score i statement.

“insname” -- A string (in double-quotes) representing a named instrument.

ktrigger -- trigger value for new event

kwhen -- start time of the new event. Equivalent to p2 in a score i statement.

kdur -- duration of event. Equivalent to p3 in a score i statement.

schedwhen adds a new score event. The event is only scheduled when the k-rate value ktrigger is first non-zero. The arguments, including options, are the same as in a score. The kwhen time (p2) is measured from the time of this event.

If the duration is zero or negative the new event is of MIDI type, and inherits the release sub-event from the scheduling instruction.

| Note
Note that the schedwhen opcode can't accept string p-fields. If you need to pass strings when instantiating an instrument, use the scoreline or scoreline_i opcode.

## Examples

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

Example 745. Example of the schedwhen 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 realtime audio input is needed too
    ; For Non-realtime ouput leave only the line below:
    ; -o schedwhen.wav -W ;;; for file output any platform
    </CsOptions>
    <CsInstruments>

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

    instr 1

    kmtr metro 100				;produce 100 triggers per second
         schedwhen kmtr, 2, 1, .3		;but schedwhen plays instr. 2 only once

    endin

    instr 2

    aenv linseg 0, p3*.1, 1, p3*.3, 1, p3*.6, 0 ;envelope
    a1   poscil .3*aenv, 1000, 1
         outs a1, a1

    endin
    </CsInstruments>
    <CsScore>
    f 1 0 16384 10 1	;sine

    i 1 0 3
    i 1 3 5
    e
    </CsScore>
    </CsoundSynthesizer>

## See also

event, event_i, schedule, schedkwhen, schedkwhennamed, scoreline, scoreline_i

## Credits

Author: John ffitch
University of Bath/Codemist Ltd.
Bath, UK
November 1998

New in Csound version 3.491

Based on work by Gabriel Maldonado

Prev | Up | Next
schedule | Home | scoreline