instr — Starts an instrument block.


Starts an instrument block.


instr i, j, ...


Starts an instrument block defining instruments i, j, ...

i, j, ... must be numbers, not expressions. Any positive integer is legal, and in any order, but excessively high numbers are best avoided.

[Note] Note

There may be any number of instrument blocks in an orchestra.

Instruments can be defined in any order (but they will always be both initialized and performed in ascending instrument number order, with the exception of notes triggered by real time events that are initialized in the order of being received but still performed in ascending instrument number order). Instrument blocks cannot be nested (i.e. one block cannot contain another).


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

Example 402. Example of the instr opcode.

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

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

; Initialize the global variables.
sr = 44100
kr = 4410
ksmps = 10
nchnls = 1

; Instrument #1.
instr 1
  iamp = 10000
  icps = 440
  iphs = 0

  a1 oscils iamp, icps, iphs
  out a1


; Play Instrument #1 for 2 seconds.
i 1 0 2


See Also

endin, in, out, opcode, endop, setksmps, xin, xout, subinstr, subinstrinit


Example written by Kevin Conder.