| 1 | |
| 2 | <refentry id="kr"> |
| 3 | <indexterm id="IndexKr"><primary>kr</primary></indexterm> |
| 4 | <refentryinfo><title>Orchestra Syntax:Header</title></refentryinfo> |
| 5 | <refmeta> |
| 6 | <refentrytitle>kr</refentrytitle> |
| 7 | </refmeta> |
| 8 | |
| 9 | |
| 10 | |
| 11 | <refnamediv> |
| 12 | <refname>kr</refname> |
| 13 | |
| 14 | <refpurpose> |
| 15 | Sets the control rate. |
| 16 | </refpurpose> |
| 17 | </refnamediv> |
| 18 | |
| 19 | <refsect1> |
| 20 | <title>Description</title> |
| 21 | <para> |
| 22 | These statements are global value <link |
| 23 | linkend="assign"><citetitle>assignments</citetitle></link>, made |
| 24 | at the beginning of an orchestra, before any instrument block is |
| 25 | defined. Their function is to set certain <link |
| 26 | linkend="VariableTypes"><citetitle>reserved symbol |
| 27 | variables</citetitle></link> that are required for |
| 28 | performance. Once set, these reserved symbols can be used in |
| 29 | expressions anywhere in the orchestra. |
| 30 | </para> |
| 31 | </refsect1> |
| 32 | |
| 33 | <refsect1> |
| 34 | <title>Syntax</title> |
| 35 | <synopsis><command>kr</command> = iarg</synopsis> |
| 36 | </refsect1> |
| 37 | |
| 38 | <refsect1> |
| 39 | <title>Initialization</title> |
| 40 | <para> |
| 41 | <emphasis>kr</emphasis> = (optional) -- set control rate to <emphasis>iarg</emphasis> samples per second. The default value is 4410. |
| 42 | </para> |
| 43 | |
| 44 | <para> |
| 45 | In addition, any <link linkend="GlobalVariables"><citetitle>global variable</citetitle></link> can be initialized by an <emphasis>init-time assignment</emphasis> anywhere before the first <link linkend="instr"><citetitle>instr statement</citetitle></link>. All of the above assignments are run as instrument 0 (i-pass only) at the start of real performance. |
| 46 | </para> |
| 47 | |
| 48 | <para> |
| 49 | Beginning with Csound version 3.46, <emphasis>kr</emphasis> can be omitted. Csound will use the default values, or calculate <emphasis>kr</emphasis> from defined <link linkend="ksmps"><citetitle>ksmps</citetitle></link> and <link linkend="sr"><citetitle>sr</citetitle></link>. It is usually better to just specify <link linkend="ksmps"><citetitle>ksmps</citetitle></link> and <link linkend="sr"><citetitle>sr</citetitle></link> and let csound calculate <emphasis>kr</emphasis>. |
| 50 | </para> |
| 51 | </refsect1> |
| 52 | |
| 53 | <refsect1> |
| 54 | <title>Examples</title> |
| 55 | <para> |
| 56 | <informalexample> |
| 57 | <programlisting> |
| 58 | <emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 10000 |
| 59 | <emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 500 |
| 60 | <emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 20 |
| 61 | gi1 <emphasis role="op">=</emphasis> <emphasis role="ohdr">sr</emphasis><emphasis role="op">/</emphasis>2. |
| 62 | ga <emphasis role="opc">init</emphasis> 0 |
| 63 | itranspose <emphasis role="op">=</emphasis> <emphasis role="opc">octpch</emphasis>(.0l)</programlisting> |
| 64 | </informalexample> |
| 65 | </para> |
| 66 | </refsect1> |
| 67 | |
| 68 | <refsect1> |
| 69 | <title>Examples</title> |
| 70 | <para> |
| 71 | Here is an example of the kr opcode. It uses the file <ulink url="examples/kr.csd"><citetitle>kr.csd</citetitle></ulink>. |
| 72 | |
| 73 | <example> |
| 74 | <title>Example of the kr opcode.</title> |
| 75 | <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> |
| 76 | <xi:include href="examples-xml/kr.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/> |
| 77 | </example> |
| 78 | </para> |
| 79 | </refsect1> |
| 80 | |
| 81 | <refsect1> |
| 82 | <title>See also</title> |
| 83 | <para><link linkend="OrchHeader"><citetitle>Orchestra Header Statements</citetitle></link></para> |
| 84 | </refsect1> |
| 85 | |
| 86 | </refentry> |