<?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" /> <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="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"> <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"> <a id="idm281472880184744"></a> <h2>Description</h2> <p> Reads function tables with linear, cubic, or sinc interpolation. </p> </div> <div class="refsect1"> <a id="idm281472880140488"></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"> <a id="idm281472880138280"></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" style="list-style-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" style="list-style-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" 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" style="list-style-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" 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"> <a id="idm281472880119944"></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" 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"> <a id="idm281472880112376"></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="idm281472880110520"></a> <p class="title"> <strong>Example 987. 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> <div class="refsect1"> <a id="idm281472701731864"></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> <span class="c1">; Audio out Audio in</span> -odac -iadc <span class="c1">;;;RT audio I/O</span> <span class="c1">; For Non-realtime ouput leave only the line below:</span> <span class="c1">; -o tablexkt.wav -W ;;; for file output any platform</span> <span class="nt"></CsOptions></span> <span class="nt"><CsInstruments></span> <span class="c1">;Example by Jonathan Murphy</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">10</span> <span class="vg">nchnls</span> <span class="o">=</span> <span class="mi">1</span> <span class="kd">instr</span> <span class="nf">1</span> i<span class="n">fn</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1">; query f1 as to number of samples</span> i<span class="n">len</span> <span class="o">=</span> <span class="nb">nsamp</span><span class="p">(</span>i<span class="n">fn</span><span class="p">)</span> i<span class="n">trns</span> <span class="o">=</span> <span class="mi">4</span> <span class="c1">; transpose up 4 octaves</span> i<span class="n">lps</span> <span class="o">=</span> <span class="mi">16</span> <span class="c1">; allow iwsize/2 samples at start</span> i<span class="n">lpe</span> <span class="o">=</span> i<span class="n">len</span> <span class="o">-</span> <span class="mi">16</span> <span class="c1">; and at end</span> i<span class="n">mode</span> <span class="o">=</span> <span class="mi">3</span> <span class="c1">; loop forwards and backwards</span> i<span class="n">strt</span> <span class="o">=</span> <span class="mi">16</span> <span class="c1">; start 16 samples into loop</span> a<span class="n">lphs</span> <span class="nb">lphasor</span> i<span class="n">trns</span><span class="p">,</span> i<span class="n">lps</span><span class="p">,</span> i<span class="n">lpe</span><span class="p">,</span> i<span class="n">mode</span><span class="p">,</span> i<span class="n">strt</span> <span class="c1">; use lphasor as index</span> a<span class="n">ndx</span> <span class="o">=</span> a<span class="n">lphs</span> k<span class="n">fn</span> <span class="o">=</span> <span class="mi">1</span> <span class="c1">; read f1</span> k<span class="n">warp</span> <span class="o">=</span> <span class="mi">4</span> <span class="c1">; anti-aliasing, should be same value as itrns above</span> i<span class="n">wsize</span> <span class="o">=</span> <span class="mi">32</span> <span class="c1">; iwsize must be at least 8 * kwarp</span> a<span class="n">tab</span> <span class="nb">tablexkt</span> a<span class="n">ndx</span><span class="p">,</span> k<span class="n">fn</span><span class="p">,</span> k<span class="n">warp</span><span class="p">,</span> i<span class="n">wsize</span> a<span class="n">tab</span> <span class="o">=</span> a<span class="n">tab</span> <span class="o">*</span> <span class="mi">10000</span> <span class="nb">out</span> a<span class="n">tab</span> <span class="kd">endin</span> <span class="nt"></CsInstruments></span> <span class="nt"><CsScore></span> <span class="nb">f</span> <span class="mi">1</span> <span class="mi">0</span> <span class="mi">262144</span> <span class="mi">1</span> <span class="s">"beats.wav"</span> <span class="mi">0</span> <span class="mi">4</span> <span class="mi">1</span> <span class="nb">i</span><span class="mi">1</span> <span class="mi">0</span> <span class="mi">60</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" /> </p> </div> <div class="refsect1"> <a id="idm281472880106200"></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>