| 1 | |
| 2 | <refentry id="cpuprc"> |
| 3 | <indexterm id="IndexCpuprc"><primary>cpuprc</primary></indexterm> |
| 4 | <refentryinfo><title>Instrument Control:Realtime Performance Control</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>cpuprc</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | <refnamediv> |
| 10 | <refname>cpuprc</refname> |
| 11 | <refpurpose> |
| 12 | Control allocation of cpu resources on a per-instrument basis, to optimize realtime output. |
| 13 | </refpurpose> |
| 14 | </refnamediv> |
| 15 | |
| 16 | <refsect1> |
| 17 | <title>Description</title> |
| 18 | <para> |
| 19 | Control allocation of cpu resources on a per-instrument basis, to optimize realtime output. |
| 20 | </para> |
| 21 | </refsect1> |
| 22 | |
| 23 | <refsect1> |
| 24 | <title>Syntax</title> |
| 25 | <synopsis><command>cpuprc</command> insnum, ipercent</synopsis> |
| 26 | <synopsis><command>cpuprc</command> Sinsname, ipercent</synopsis> |
| 27 | </refsect1> |
| 28 | |
| 29 | <refsect1> |
| 30 | <title>Initialization</title> |
| 31 | <para> |
| 32 | <emphasis>insnum</emphasis> -- instrument number or string |
| 33 | </para> |
| 34 | <para> |
| 35 | <emphasis>Sinsname</emphasis> -- instrument number or string |
| 36 | </para> |
| 37 | |
| 38 | <para> |
| 39 | <emphasis>ipercent</emphasis> -- percent of cpu processing-time to assign. Can also be expressed as a fractional value. |
| 40 | </para> |
| 41 | </refsect1> |
| 42 | |
| 43 | <refsect1> |
| 44 | <title>Performance</title> |
| 45 | <para> |
| 46 | <emphasis>cpuprc</emphasis> 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 <emphasis>ipercent</emphasis> 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. |
| 47 | </para> |
| 48 | |
| 49 | <para> |
| 50 | For example, if <emphasis>ipercent</emphasis> 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: |
| 51 | <literallayout> |
| 52 | cannot allocate last note because it exceeds 100% of cpu time |
| 53 | </literallayout> |
| 54 | </para> |
| 55 | |
| 56 | <para> |
| 57 | In order to avoid audio buffer underruns, it is suggested to set |
| 58 | the maximum number of voices slightly lower than the real |
| 59 | processing power of the computer. Sometimes an instrument can |
| 60 | require more processing time than normal. If, for example, the |
| 61 | instrument contains an oscillator which reads a table that does not 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. |
| 62 | </para> |
| 63 | |
| 64 | <para> |
| 65 | At the start, all instruments are set to a default value of <emphasis>ipercent</emphasis> = 0.0% (i.e. zero processing time or rather infinite cpu processing-speed). This setting is OK for deferred-time sessions. |
| 66 | </para> |
| 67 | |
| 68 | <para> |
| 69 | All instances of <emphasis>cpuprc</emphasis> must be defined in the header section, not in the instrument body. |
| 70 | </para> |
| 71 | </refsect1> |
| 72 | |
| 73 | <refsect1> |
| 74 | <title>Examples</title> |
| 75 | <para> |
| 76 | Here is an example of the cpuprc opcode. It uses the file <ulink url="examples/cpuprc.csd"><citetitle>cpuprc.csd</citetitle></ulink>. |
| 77 | |
| 78 | <example> |
| 79 | <title>Example of the cpuprc opcode.</title> |
| 80 | |
| 81 | |
| 82 | |
| 83 | <para>See the sections <link linkend="UsingRealTime"><citetitle>Real-time Audio</citetitle></link> and <link linkend="CommandFlags"><citetitle>Command Line Flags</citetitle></link> for more information on using command line flags.</para> |
| 84 | <xi:include href="examples-xml/cpuprc.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 85 | </example> |
| 86 | </para> |
| 87 | </refsect1> |
| 88 | |
| 89 | <refsect1> |
| 90 | <title>See also</title> |
| 91 | <para><link linkend="ControlRealtime"><citetitle>Real-time Performance Control</citetitle></link></para> |
| 92 | </refsect1> |
| 93 | |
| 94 | <refsect1> |
| 95 | <title>Credits</title> |
| 96 | <para> |
| 97 | <simplelist> |
| 98 | <member>Author: &namegabriel;</member> |
| 99 | <member>Italy</member> |
| 100 | <member>July, 1999</member> |
| 101 | </simplelist> |
| 102 | </para> |
| 103 | <para>New in Csound version 3.57; named instruments added version 5.13</para> |
| 104 | </refsect1> |
| 105 | </refentry> |