maxalloc — Limits the number of allocations of an instrument.
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. Play maxalloc.csd
Example 577. Example of the maxalloc 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 maxalloc.wav -W ;;; for file output any platform </CsOptions> <CsInstruments> 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 endin </CsInstruments> <CsScore> ; 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 e </CsScore> </CsoundSynthesizer>
Its output should contain messages like these:
WARNING: cannot allocate last note because it exceeds instr maxalloc