<?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" /> <meta name="generator" content="DocBook XSL Stylesheets V1.76.1" /> <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" title="tablekt"> <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" title="Description"> <a id="idp47605080"></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" title="Syntax"> <a id="idp47667352"></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" title="Initialization"> <a id="idp47669240"></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" title="Performance"> <a id="idp47674544"></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" title="Caution with k-rate table numbers" 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" title="Examples"> <a id="idp47680336"></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="idp47681312"></a> <p class="title"> <strong>Example 855. 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> <pre class="programlisting"> <span class="csdtag"><CsoundSynthesizer></span> <span class="csdtag"><CsOptions></span> <span class="comment">; Select audio/midi flags here according to platform</span> -odac <span class="comment">;;;realtime audio out</span> <span class="comment">;-iadc ;;;uncomment -iadc if RT audio input is needed too</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o tablekt.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 32 <span class="ohdr">nchnls</span> <span class="op">=</span> 2 <span class="ohdr">0dbfs</span> <span class="op">=</span> 1 <span class="ohdr">seed</span> 0 gift1 <span class="ohdr">ftgen</span> 1, 0, 1024, 10, 1 <span class="comment">;sine wave</span> gift2 <span class="ohdr">ftgen</span> 2, 0, 1024, 10, 1, 1, 1, 1, 1, 1, 1, 1, 1 <span class="comment">;pulse</span> <span class="oblock">instr</span> 1 andx <span class="opc">phasor</span> 400 <span class="comment">;phasor for reading the index</span> kfn <span class="opc">init</span> 1 <span class="comment">;initialize the choice of the function table</span> kmetro <span class="opc">init</span> 1 <span class="comment">;initialize the frequency of the metro</span> knewft <span class="opc">metro</span> kmetro <span class="comment">;make a new choice for selecting the function table once a second</span> <span class="octrl">if</span> knewft <span class="op">==</span> 1 then kfn <span class="op">=</span> (kfn <span class="op">==</span> 1 <span class="op">?</span> 2 <span class="op">:</span> 1) <span class="comment">;switch between 1 and 2</span> kmetro <span class="opc">random</span> .5, 2 <span class="comment">;create new metro frequency</span> <span class="opc">printk2</span> kfn <span class="octrl">endif</span> ares <span class="opc">tablekt</span> andx, kfn, 1 <span class="opc">outs</span> ares, ares <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">i</span> 1 0 10 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </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" title="See Also"> <a id="idp47684056"></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" title="Credits"> <a id="idp47685096"></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>