<?xml version="1.0" encoding="UTF-8" standalone="no"?> <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /> <title>tablekt</title> <link rel="stylesheet" type="text/css" href="csound.css" /> <link rel="stylesheet" type="text/css" href="syntax-highlighting.css" /> <meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /> <link rel="home" href="index.html" title="The Canonical Csound Reference Manual" /> <link rel="up" href="OpcodesTop.html" title="Orchestra Opcodes and Operators" /> <link rel="prev" href="tableiw.html" title="tableiw" /> <link rel="next" href="tablemix.html" title="tablemix" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">tablekt</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="tableiw.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="tablemix.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry"> <a id="tablekt"></a> <div class="titlepage"></div> <a id="IndexTablekt" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">tablekt</span> </h2> <p>tablekt — Provides k-rate control over table numbers. </p> </div> <div class="refsect1"> <a id="idm281472881178360"></a> <h2>Description</h2> <p> k-rate control over table numbers. </p> <p> The standard Csound opcode <a class="link" href="table.html" title="table"><em class="citetitle">table</em></a> when producing a k- or a-rate result, can only use an init-time variable to select the table number. <span class="emphasis"><em>tablekt</em></span> accepts k-rate control as well as i-time. In all other respects they are similar to the original opcodes. </p> </div> <div class="refsect1"> <a id="idm281472881132216"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>tablekt</strong></span> xndx, kfn [, ixmode] [, ixoff] [, iwrap]</pre> <pre class="synopsis">kres <span class="command"><strong>tablekt</strong></span> kndx, kfn [, ixmode] [, ixoff] [, iwrap]</pre> </div> <div class="refsect1"> <a id="idm281472881128536"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ixmode</em></span> -- if 0, <span class="emphasis"><em>xndx</em></span> and <span class="emphasis"><em>ixoff</em></span> ranges match the length of the table. if non-zero <span class="emphasis"><em>xndx</em></span> and <span class="emphasis"><em>ixoff</em></span> have a 0 to 1 range. Default is 0 </p> <p> <span class="emphasis"><em>ixoff</em></span> -- if 0, total index is controlled directly by <span class="emphasis"><em>xndx,</em></span> 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 (<span class="emphasis"><em>ixmode</em></span> = 0) or less than 1 (<span class="emphasis"><em>ixmode</em></span> not equal to 0). Default is 0. </p> <p> <span class="emphasis"><em>iwrap</em></span> -- if <span class="emphasis"><em>iwrap</em></span> = 0, <span class="emphasis"><em>Limit mode</em></span>: 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 <span class="emphasis"><em>iwrap</em></span> not equal to 0, <span class="emphasis"><em>Wrap mode</em></span>: 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, <span class="emphasis"><em>xndx</em></span> = 5 and <span class="emphasis"><em>ixoff</em></span> = 6 gives a total index of 11, which wraps to a final index of 3. Default is 0. </p> </div> <div class="refsect1"> <a id="idm281472881118888"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>kndx</em></span> -- Index into table, either a positive number range matching the table length (<span class="emphasis"><em>ixmode</em></span> = 0) or a 0 to 1 range (<span class="emphasis"><em>ixmode</em></span> not equal to 0). </p> <p> <span class="emphasis"><em>xndx</em></span> -- matching the table length (<span class="emphasis"><em>ixmode</em></span> = 0) or a 0 to 1 range (<span class="emphasis"><em>ixmode</em></span> not equal to 0) </p> <p> <span class="emphasis"><em>kfn</em></span> -- Table number. Must be >= 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 (<a class="link" href="GEN01.html" title="GEN01"><em class="citetitle">GEN01</em></a>) then an error will result and the instrument will be de-activated. </p> <div class="caution" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Caution: Caution with k-rate table numbers"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Caution]" src="images/caution.png" /> </td> <th align="left">Caution with k-rate table numbers</th> </tr> <tr> <td align="left" valign="top"> <p> At k-rate, if a table number of < 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. <span class="emphasis"><em>kfn</em></span> must be initialized at the appropriate rate using <a class="link" href="init.html" title="init"><em class="citetitle">init</em></a>. Attempting to load an i-rate value into <span class="emphasis"><em>kfn</em></span> will result in an error. </p> </td> </tr> </table> </div> </div> <div class="refsect1"> <a id="idm281472881108664"></a> <h2>Examples</h2> <p> Here is an example of the tablekt opcode. It uses the file <a class="ulink" href="examples/tablekt.csd" target="_top"><em class="citetitle">tablekt.csd</em></a>. </p> <div class="example"> <a id="idm281472881106888"></a> <p class="title"> <strong>Example 982. Example of the tablekt opcode.</strong> </p> <div class="example-contents"> <p>See the sections <a class="link" href="UsingRealTime.html" title="Real-Time Audio"><em class="citetitle">Real-time Audio</em></a> and <a class="link" href="CommandFlags.html" title="Csound command line"><em class="citetitle">Command Line Flags</em></a> for more information on using command line flags.</p> <div class="refsect1"> <a id="idm281472702439528"></a> <pre class="programlisting"> <span class="nt"><CsoundSynthesizer></span> <span class="nt"><CsOptions></span> <span class="c1">; Select audio/midi flags here according to platform</span> -odac <span class="c1">;;;realtime audio out</span> <span class="c1">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o tablekt.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="vg">sr</span> <span class="o">=</span> <span class="mi">44100</span> <span class="vg">ksmps</span> <span class="o">=</span> <span class="mi">32</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">2</span> <span class="vg">0dbfs</span> <span class="o">=</span> <span class="mi">1</span> <span class="nb">seed</span> <span class="mi">0</span> gi<span class="n">ft1</span> <span class="nb">ftgen</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1024</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">1</span> <span class="c1">;sine wave</span> gi<span class="n">ft2</span> <span class="nb">ftgen</span> <span class="mi">2</span><span class="p">,</span> <span class="mi">0</span><span class="p">,</span> <span class="mi">1024</span><span class="p">,</span> <span class="mi">10</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span><span class="p">,</span> <span class="mi">1</span> <span class="c1">;pulse</span> <span class="kd">instr</span> <span class="nf">1</span> a<span class="n">ndx</span> <span class="nb">phasor</span> <span class="mi">400</span> <span class="c1">;phasor for reading the index</span> k<span class="n">fn</span> <span class="nb">init</span> <span class="mi">1</span> <span class="c1">;initialize the choice of the function table</span> k<span class="n">metro</span> <span class="nb">init</span> <span class="mi">1</span> <span class="c1">;initialize the frequency of the metro</span> k<span class="n">newft</span> <span class="nb">metro</span> k<span class="n">metro</span> <span class="c1">;make a new choice for selecting the function table once a second</span> <span class="k">if</span> k<span class="n">newft</span> <span class="o">==</span> <span class="mi">1</span> <span class="k">then</span> k<span class="n">fn</span> <span class="o">=</span> <span class="p">(</span>k<span class="n">fn</span> <span class="o">==</span> <span class="mi">1</span> <span class="p">?</span> <span class="mi">2</span> <span class="p">:</span> <span class="mi">1</span><span class="p">)</span> <span class="c1">;switch between 1 and 2</span> k<span class="n">metro</span> <span class="nb">random</span> <span class="mf">.5</span><span class="p">,</span> <span class="mi">2</span> <span class="c1">;create new metro frequency</span> <span class="nb">printk2</span> k<span class="n">fn</span> <span class="k">endif</span> a<span class="n">res</span> <span class="nb">tablekt</span> a<span class="n">ndx</span><span class="p">,</span> k<span class="n">fn</span><span class="p">,</span> <span class="mi">1</span> <span class="nb">outs</span> a<span class="n">res</span><span class="p">,</span> a<span class="n">res</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">i</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">10</span> <span class="nb">e</span> <span class="nt"></CsScore></span> <span class="nt"></CsoundSynthesizer></span> </pre> </div> </div> </div> <p><br class="example-break" /> Its output should include lines like these: </p> <pre class="screen"> i1 2.00000 i1 1.00000 i1 2.00000 i1 1.00000 .... </pre> <p> </p> </div> <div class="refsect1"> <a id="idm281472881101800"></a> <h2>See Also</h2> <p> <a class="link" href="tableikt.html" title="tableikt"><em class="citetitle">tableikt</em></a> </p> </div> <div class="refsect1"> <a id="idm281472881099720"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Robin Whittle</td> </tr> <tr> <td>Australia</td> </tr> <tr> <td>May 1997</td> </tr> </table> <p> </p> <p>New in version 3.47</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="tableiw.html">Prev</a> </td> <td width="20%" align="center"> <a accesskey="u" href="OpcodesTop.html">Up</a> </td> <td width="40%" align="right"> <a accesskey="n" href="tablemix.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">tableiw </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> tablemix</td> </tr> </table> </div> </body> </html>