Use Non-Frames Version Previous Page Next Page
Instrument Control: Real-time Performance Control

cpuprc, maxalloc, prealloc

          cpuprc    insnum, ipercent

          maxalloc  insnum, icount

          prealloc  insnum, icount


Control allocation of cpu resources on a per-instrument basis, to optimize realtime output.


insnum – instrument number

ipercent – percent of cpu processing-time to assign. Can also be expressed as a fractional value.

icount – number of instrument allocations


cpuprc sets the cpu processing-time percent usage of an instrument, in order to avoid buffer underrun in realtime performances, enabling a sort of polyphony theshold. The user must set ipercent value for each instrument to be activated in realtime. Assuming that the total theoretical processing time of the cpu of the computer is 100%, this percent value can only be defined empirically, because there are too many factors that contribute to limiting realtime polyphony in different computers.

For example, if ipercent is set to 5% for instrument 1, the maximum number of voices that can be allocated in realtime, is 20 (5% * 20 = 100%). If the user attempts to play a further note while the 20 previous notes are still playing, Csound inhibits the allocation of that note and will display the following warning message:

  can't allocate last note because it exceeds 100% of cpu time

In order to avoid audio buffer underruns, it is suggested to set the maximum number of voices slightly lower than the real processing power of the computer. Sometimes an instrument can require more processing time than normal. If, for example, the instrument contains an oscillator which reads a table that doesn't fit in cache memory, it will be slower than normal. In addition, any program running concurrently in multitasking, can subtract processing power to varying degrees.

At the start, all instruments are set to a default value of ipercent = 0.0% (i.e. zero processing time or rather infinite cpu processing-speed). This setting is OK for deferred-time sessions.

maxalloc limits the number of allocations of an instrument. prealloc creates space for instruments but does not run them.

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


	sr     = 44100

	kr     = 441

	ksmps  = 100

	nchnls = 2

		cpuprc 1, 2.5       ; set instr 1 to 2.5% of processor power,

                                    ; i.e. maximum 40 voices (2.5% * 40 = 100%)

		cpuprc 2, 33.333    ; set instr 2 to 33.333% of processor power,

                                    ; i.e. maximum 3 voices (33.333% * 3 = 100%)


	instr 1




	instr 2




Gabriel Maldonado
July, 1999
New in Csound version 3.57

Use Non-Frames Version Previous Page Next Page
Instrument Control: Real-time Performance Control