<?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>tablexkt</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="tablewkt.html" title="tablewkt" /> <link rel="next" href="tablexseg.html" title="tablexseg" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">tablexkt</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="tablewkt.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="tablexseg.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="tablexkt"> <a id="tablexkt"></a> <div class="titlepage"></div> <a id="IndexTablexkt" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">tablexkt</span> </h2> <p>tablexkt — Reads function tables with linear, cubic, or sinc interpolation. </p> </div> <div class="refsect1" title="Description"> <a id="idp48134440"></a> <h2>Description</h2> <p> Reads function tables with linear, cubic, or sinc interpolation. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp48194720"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>tablexkt</strong></span> xndx, kfn, kwarp, iwsize [, ixmode] [, ixoff] [, iwrap]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp48195840"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>iwsize</em></span> -- This parameter controls the type of interpolation to be used: </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p><span class="emphasis"><em>2:</em></span> Use linear interpolation. This is the lowest quality, but also the fastest mode.</p> </li> <li class="listitem"> <p><span class="emphasis"><em>4:</em></span> Cubic interpolation. Slightly better quality than iwsize = 2, at the expense of being somewhat slower.</p> </li> <li class="listitem"> <p><span class="emphasis"><em>8 and above (up to 1024):</em></span> sinc interpolation with window size set to iwsize (should be an integer multiply of 4). Better quality than linear or cubic interpolation, but very slow. When transposing up, a kwarp value above 1 can be used for anti-aliasing (this is even slower).</p> </li> </ul> </div> <p> </p> <p> <span class="emphasis"><em>ixmode1</em></span> (optional) -- index data mode. The default value is 0. </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p><span class="emphasis"><em>0:</em></span> raw index</p> </li> <li class="listitem"> <p><span class="emphasis"><em>any non-zero value:</em></span> normalized (0 to 1)</p> </li> </ul> </div> <p> </p> <div class="note" title="Notes" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: Notes"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Notes</th> </tr> <tr> <td align="left" valign="top"> <p> if <span class="emphasis"><em>tablexkt</em></span> is used to play back samples with looping (e.g. table index is generated by lphasor), there must be at least iwsize / 2 extra samples after the loop end point for interpolation, otherwise audible clicking may occur (also, at least iwsize / 2 samples should be before the loop start point). </p> </td> </tr> </table> </div> <p> <span class="emphasis"><em>ixoff</em></span> (optional) -- amount by which index is to be offset. For a table with origin at center, use tablesize / 2 (raw) or 0.5 (normalized). The default value is 0. </p> <p> <span class="emphasis"><em>iwrap</em></span> (optional) -- wraparound index flag. The default value is 0. </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p><span class="emphasis"><em>0:</em></span> Nowrap (index < 0 treated as index = 0; index >= tablesize (or 1.0 in normalized mode) sticks at the guard point).</p> </li> <li class="listitem"> <p><span class="emphasis"><em>any non-zero value:</em></span> Index is wrapped to the allowed range (not including the guard point in this case).</p> </li> </ul> </div> <p> </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> <span class="emphasis"><em>iwrap</em></span> also applies to extra samples for interpolation. </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Performance"> <a id="idp48206216"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>ares</em></span> -- audio output </p> <p> <span class="emphasis"><em>xndx</em></span> -- table index </p> <p> <span class="emphasis"><em>kfn</em></span> -- function table number </p> <p> <span class="emphasis"><em>kwarp</em></span> -- if greater than 1, use sin (x / kwarp) / x function for sinc interpolation, instead of the default sin (x) / x. This is useful to avoid aliasing when transposing up (<span class="emphasis"><em>kwarp</em></span> should be set to the transpose factor in this case, e.g. 2.0 for one octave), however it makes rendering up to twice as slow. Also, <span class="emphasis"><em>iwsize</em></span> should be at least kwarp * 8. This feature is experimental, and may be optimized both in terms of speed and quality in new versions. </p> <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;"> <table border="0" summary="Note: Note"> <tr> <td rowspan="2" align="center" valign="top" width="25"> <img alt="[Note]" src="images/note.png" /> </td> <th align="left">Note</th> </tr> <tr> <td align="left" valign="top"> <p> <span class="emphasis"><em>kwarp</em></span> has no effect if it is less than, or equal to 1, or linear or cubic interpolation is used. </p> </td> </tr> </table> </div> </div> <div class="refsect1" title="Examples"> <a id="idp48210464"></a> <h2>Examples</h2> <p> Here is an example of the tablexkt opcode. It uses the file <a class="ulink" href="examples/tablexkt.csd" target="_top"><em class="citetitle">tablexkt.csd</em></a>. </p> <div class="example"> <a id="idp48211456"></a> <p class="title"> <strong>Example 860. Example of the tablexkt 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> <span class="comment">; Audio out Audio in</span> -odac -iadc <span class="comment">;;;RT audio I/O</span> <span class="comment">; For Non-realtime ouput leave only the line below:</span> <span class="comment">; -o tablexkt.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">;Example by Jonathan Murphy</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="oblock">instr</span> 1 ifn <span class="op">=</span> 1 <span class="comment">; query f1 as to number of samples</span> ilen <span class="op">=</span> <span class="opc">nsamp</span>(ifn) itrns <span class="op">=</span> 4 <span class="comment">; transpose up 4 octaves</span> ilps <span class="op">=</span> 16 <span class="comment">; allow iwsize/2 samples at start</span> ilpe <span class="op">=</span> ilen <span class="op">-</span> 16 <span class="comment">; and at end</span> imode <span class="op">=</span> 3 <span class="comment">; loop forwards and backwards</span> istrt <span class="op">=</span> 16 <span class="comment">; start 16 samples into loop</span> alphs <span class="opc">lphasor</span> itrns, ilps, ilpe, imode, istrt <span class="comment">; use lphasor as index</span> andx <span class="op">=</span> alphs kfn <span class="op">=</span> 1 <span class="comment">; read f1</span> kwarp <span class="op">=</span> 4 <span class="comment">; anti-aliasing, should be same value as itrns above</span> iwsize <span class="op">=</span> 32 <span class="comment">; iwsize must be at least 8 * kwarp</span> atab <span class="opc">tablexkt</span> andx, kfn, kwarp, iwsize atab <span class="op">=</span> atab <span class="op">*</span> 10000 <span class="opc">out</span> atab <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="stamnt">f</span> 1 0 262144 1 "beats.wav" 0 4 1 <span class="stamnt">i</span>1 0 60 <span class="stamnt">e</span> <span class="csdtag"></CsScore></span> <span class="csdtag"></CsoundSynthesizer></span> </pre> </div> </div> <p><br class="example-break" /> </p> </div> <div class="refsect1" title="Credits"> <a id="idp48213752"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: Istvan Varga</td> </tr> <tr> <td>January 2002</td> </tr> <tr> <td>Example by: Jonathan Murphy 2006</td> </tr> </table> <p> </p> <p>New in version 4.18</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="tablewkt.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="tablexseg.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">tablewkt </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> tablexseg</td> </tr> </table> </div> </body> </html>