summaryrefslogtreecommitdiff
path: root/opcodes/tablekt.xml
blob: 9d453e1b3d2bb7e8cd88f8389e167df85716fc58 (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
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
<refentry id="tablekt">
<indexterm id="IndexTablekt"><primary>tablekt</primary></indexterm>
  <refentryinfo><title>Table Control:Dynamic Selection</title></refentryinfo>
  <refmeta>
    <refentrytitle>tablekt</refentrytitle>
  </refmeta>

  <refnamediv>
    <refname>tablekt</refname>
    <refpurpose>
      Provides k-rate control over table numbers.
    </refpurpose>
  </refnamediv>
 
  <refsect1>
    <title>Description</title>
    <para>
      k-rate control over table numbers.
    </para>

    <para>
      The standard Csound opcode <link linkend="table"><citetitle>table</citetitle></link> when producing a k- or a-rate result, can only use an init-time variable to select the table number. <emphasis>tablekt</emphasis> accepts k-rate control as well as i-time. In all other respects they are similar to the original opcodes.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Syntax</title>
    <synopsis>ares <command>tablekt</command> xndx, kfn [, ixmode] [, ixoff] [, iwrap]</synopsis>

    <synopsis>kres <command>tablekt</command> kndx, kfn [, ixmode] [, ixoff] [, iwrap]</synopsis>
  </refsect1>
 
  <refsect1>
    <title>Initialization</title>
    <para>
      <emphasis>ixmode</emphasis> -- if 0, <emphasis>xndx</emphasis> and <emphasis>ixoff</emphasis> ranges match the length of the table. if non-zero <emphasis>xndx</emphasis> and <emphasis>ixoff</emphasis> have a 0 to 1 range. Default is 0
    </para>

    <para>
      <emphasis>ixoff</emphasis> -- if 0, total index is controlled directly by <emphasis>xndx,</emphasis> ie. the indexing starts from the start of the table. If non-zero, start indexing from somewhere else in the table. Value must be positive and less than the table length (<emphasis>ixmode</emphasis> = 0) or less than 1 (<emphasis>ixmode</emphasis> not equal to 0). Default is 0.
    </para>

    <para>
      <emphasis>iwrap</emphasis> -- if <emphasis>iwrap</emphasis> = 0, <emphasis>Limit mode</emphasis>: when total index is below 0, then final index is 0.Total index above table length results in a final  index of the table length - high out of range total indexes stick at the upper limit of the table. If <emphasis>iwrap</emphasis> not equal to 0, <emphasis>Wrap mode</emphasis>: total index is wrapped  modulo the table length so that all total indexes map into the table. For instance, in a table of length 8, <emphasis>xndx</emphasis> = 5 and <emphasis>ixoff</emphasis> = 6 gives a total index of 11, which wraps to a final  index of 3. Default is 0.
    </para>
  </refsect1>
 
  <refsect1>
    <title>Performance</title>
    <para>
      <emphasis>kndx</emphasis> -- Index into table, either a positive number range matching the table length (<emphasis>ixmode</emphasis> = 0) or a 0 to 1 range (<emphasis>ixmode</emphasis> not equal to 0).
    </para>

    <para>
      <emphasis>xndx</emphasis> -- matching the table length (<emphasis>ixmode</emphasis> = 0) or a 0 to 1 range (<emphasis>ixmode</emphasis> not equal to  0)
    </para>

    <para>
      <emphasis>kfn</emphasis> -- Table number. Must be &gt;= 1. Floats are rounded down to an integer.  If a table number does not point to a valid table, or the table has not yet been loaded (<link linkend="GEN01"><citetitle>GEN01</citetitle></link>) then an error will result and the instrument will be de-activated.
    </para>

    <caution>
      <title>Caution with k-rate table numbers</title>
      <para>
        At k-rate, if a table number of &lt; 1 is given, or the table number points to a non-existent table, or to one which has a length of 0 (it is to be loaded from a file later) then an error will result and the instrument will be deactivated. <emphasis>kfn</emphasis> must be initialized at the appropriate rate using <link linkend="init"><citetitle>init</citetitle></link>. Attempting to load an i-rate value into <emphasis>kfn</emphasis> will result in an error.
      </para>
    </caution>
  </refsect1>
 
  <refsect1>
    <title>Examples</title>
    <para>
      Here is an example of the tablekt opcode. It uses the file <ulink url="examples/tablekt.csd"><citetitle>tablekt.csd</citetitle></ulink>.

      <example>
        <title>Example of the tablekt opcode.</title>
        <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>
          <xi:include href="examples-xml/tablekt.csd.xml" xmlns:xi="http://www.w3.org/2001/XInclude"/>
      </example>
      Its output should include lines like these:
      <screen>
 i1     2.00000
 i1     1.00000
 i1     2.00000
 i1     1.00000
....
      </screen>
    </para>
  </refsect1>

  <refsect1>
    <title>See Also</title>
    <para>
      <link linkend="tableikt"><citetitle>tableikt</citetitle></link>
    </para>
  </refsect1>

  <refsect1>
    <title>Credits</title>
    <para>
      <simplelist>
        <member>Author: Robin Whittle</member>
        <member>Australia</member>
        <member>May 1997</member>
      </simplelist>
    </para>
    <para>New in version 3.47</para>
  </refsect1>
</refentry>