maxalloc — Limits the number of allocations of an instrument.


Limits the number of allocations of an instrument.


maxalloc insnum, icount
maxalloc Sinsname, icount


insnum -- instrument number

Sinsname -- instrument name

icount -- number of instrument allocations


maxalloc limits the number of simultaneous instances (notes) of an instrument. Any score events after the maximum has been reached, are ignored.

All instances of maxalloc must be defined in the header section, not in the instrument body.


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

Example 461. Example of the maxalloc 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
-odac      ;;;realtime audio out
;-iadc    ;;;uncomment -iadc if realtime audio input is needed too
; For Non-realtime ouput leave only the line below:
; -o maxalloc.wav -W ;;; for file output any platform

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

maxalloc 1, 3	; Limit to three instances.
instr 1

asig oscil .3, p4, 1
     outs asig, asig

; sine
f 1 0 32768 10 1

i 1 0 5 220	;1
i 1 1 4 440	;2
i 1 2 3 880	;3, limit is reached
i 1 3 2 1320	;is not played
i 1 4 1 1760	;is not played

Its output should contain messages like these:

WARNING: cannot allocate last note because it exceeds instr maxalloc

See Also

cpuprc, prealloc


Author: Gabriel Maldonado
July 1999

New in Csound version 3.57