Skip to content

schedule

Adds a new score event.

Syntax

schedule(insnum, iwhen, idur [, ip4] [, ip5] [...])
schedule("insname", iwhen, idur [, ip4] [, ip5] [...])
schedule(iPar[])
schedule(definition, iwhen, idur [, ip4, ip5, ...])
voice:Instr = schedule(definition, iwhen, idur [, ip4, ip5, ...])
schedule insnum, iwhen, idur [, ip4] [, ip5] [...]
schedule "insname", iwhen, idur [, ip4] [, ip5] [...]
schedule iPar[]
schedule definition, iwhen, idur [, ip4, ip5, ...]
voice:Instr schedule definition, iwhen, idur [, ip4, ip5, ...]

Initialization

insnum -- instrument number. Equivalent to p1 in a score i statement. insnum must be a number greater than the number of the calling instrument.

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

iwhen -- start time of the new event. Equivalent to p2 in a score i statement. iwhen must be nonnegative. If iwhen is zero, insum must be greater than or equal to the p1 of the current instrument.

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

iPar[] -- event parameters as an i-time array.

ip4, ip5, ... -- Equivalent to p4, p5, etc., in a score i statement. The opcode also accepts strings as arguments for p4-pN.

Instrument references in Csound 7

definition is an InstrDef, such as a named instrument without quotes or the result of create. The form with an Instr output also accepts an instrument number or name string.

voice receives the instance reference when the scheduled note initializes. Until then, it is unset, even if iwhen is 0. Do not pass it to state queries or instance controls before the note starts. Keep the output variable alive until that start time so Csound can store the reference.

Use play when you need an initialized reference immediately. The object guide explains the difference and shows how to control an instance.

Performance

schedule adds a new score event. The arguments, including options, are the same as in a score. The iwhen 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.

Examples

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

Example of the schedule opcode.
<CsoundSynthesizer>
<CsOptions>
; Select audio/midi flags here according to platform
; Audio out   Audio in
-odac           -iadc    ;;;RT audio I/O
; For Non-realtime ouput leave only the line below:
; -o schedule.wav -W ;;; for file output any platform
</CsOptions>
<CsInstruments>

; Initialize the global variables.
sr = 44100
ksmps = 10
nchnls = 1
0dbfs = 1

; Instrument #1 - oscillator with a high note.
instr 1
  ; Play Instrument #2 at the same time.
  schedule 2, 0, p3

  ; Play a high note.
  a1 oscils 0.3, 880, 1
  out a1
endin

; Instrument #2 - oscillator with a low note.
instr 2
  ; Play a low note.
  a1 oscils 0.3, 220, 1
  out a1
endin


</CsInstruments>
<CsScore>

; Table #1, a sine wave.
f 1 0 16384 10 1

; Play Instrument #1 for half a second.
i 1 0 0.5
; Play Instrument #1 for half a second.
i 1 1 0.5
e


</CsScore>
</CsoundSynthesizer>

See also

play, unschedule, unscheduleall, Instrument Invocation

More information on this opcode: http://www.csoundjournal.com/issue15/phrase_loops.html , written by Jim Aikin

Credits

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

Example written by Kevin Conder.

New in Csound version 3.491

Based on work by Gabriel Maldonado

Thanks goes to David Gladstein, for clarifying the iwhen parameter.