summaryrefslogtreecommitdiff
path: root/opcodes/kr.xml
blob: bf3416099d33261fef9119e5f875fb2124c01db3 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
<refentry id="kr">
<indexterm id="IndexKr"><primary>kr</primary></indexterm>
  <refentryinfo><title>Orchestra Syntax:Header</title></refentryinfo>
  <refmeta>
    <refentrytitle>kr</refentrytitle>
  </refmeta>



  <refnamediv>
    <refname>kr</refname>

    <refpurpose>
      Sets the control rate.
          </refpurpose>
  </refnamediv>
  
  <refsect1>
    <title>Description</title>
    <para> 
      These statements are global value <link linkend="assign"><citetitle>assignments</citetitle></link>, made at the beginning of an orchestra, before any instrument block is defined. Their function is to set certain <link linkend="VariableTypes"><citetitle>reserved symbol variables</citetitle></link> that are required for performance. Once set, these reserved symbols can be used in expressions anywhere in the orchestra.
    </para>
  </refsect1>

  <refsect1>
    <title>Syntax</title>
    <synopsis><command>kr</command> = iarg</synopsis>
  </refsect1>

  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>kr</emphasis> = (optional) -- set control rate to <emphasis>iarg</emphasis> samples per second. The default value is 4410.
    </para>

    <para>
      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.
    </para>

    <para>
      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>.
    </para>
  </refsect1>

  <refsect1>
    <title>Examples</title>
    <para>
      <informalexample>
        <programlisting>
<emphasis role="ohdr">sr</emphasis> <emphasis role="op">=</emphasis> 10000
<emphasis role="ohdr">kr</emphasis> <emphasis role="op">=</emphasis> 500
<emphasis role="ohdr">ksmps</emphasis> <emphasis role="op">=</emphasis> 20
gi1 <emphasis role="op">=</emphasis> <emphasis role="ohdr">sr</emphasis><emphasis role="op">/</emphasis>2.
ga <emphasis role="opc">init</emphasis> 0
itranspose <emphasis role="op">=</emphasis> <emphasis role="opc">octpch</emphasis>(.0l)</programlisting>
      </informalexample>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="ksmps"><citetitle>ksmps</citetitle></link>,
      <link linkend="nchnls"><citetitle>nchnls</citetitle></link>,
      <link linkend="nchnls_i"><citetitle>nchnls_i</citetitle></link>,
      <link linkend="sr"><citetitle>sr</citetitle></link>
    </para>
  </refsect1>
</refentry>