maxalloc
Prev | Orchestra Opcodes and Operators | Next

## maxalloc

maxalloc — Limits the number of allocations of an instrument.

## Description

Limits the number of allocations of an instrument.

## Syntax

    maxalloc insnum, icount

    maxalloc Sinsname, icount

## Initialization

insnum -- instrument number

Sinsname -- instrument name

icount -- number of instrument allocations

## Performance

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.

## Examples

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

Example 432. 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

## See Also

cpuprc, prealloc

## Credits

Author: Gabriel Maldonado
Italy
July 1999

New in Csound version 3.57

Prev | Up | Next
maxaccum | Home | max_k