<?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>ptable</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="pset.html" title="pset" /> <link rel="next" href="ptablei.html" title="ptablei" /> </head> <body> <div class="navheader"> <table width="100%" summary="Navigation header"> <tr> <th colspan="3" align="center">ptable</th> </tr> <tr> <td width="20%" align="left"><a accesskey="p" href="pset.html">Prev</a> </td> <th width="60%" align="center">Orchestra Opcodes and Operators</th> <td width="20%" align="right"> <a accesskey="n" href="ptablei.html">Next</a></td> </tr> </table> <hr /> </div> <div class="refentry" title="ptable"> <a id="ptable"></a> <div class="titlepage"></div> <a id="IndexPtable" class="indexterm"></a> <div class="refnamediv"> <h2> <span class="refentrytitle">ptable</span> </h2> <p>ptable — Accesses table values by direct indexing. </p> </div> <div class="refsect1" title="Description"> <a id="idp37392688"></a> <h2>Description</h2> <p> Accesses table values by direct indexing. </p> </div> <div class="refsect1" title="Syntax"> <a id="idp37393344"></a> <h2>Syntax</h2> <pre class="synopsis">ares <span class="command"><strong>ptable</strong></span> andx, ifn [, ixmode] [, ixoff] [, iwrap]</pre> <pre class="synopsis">ires <span class="command"><strong>ptable</strong></span> indx, ifn [, ixmode] [, ixoff] [, iwrap]</pre> <pre class="synopsis">kres <span class="command"><strong>ptable</strong></span> kndx, ifn [, ixmode] [, ixoff] [, iwrap]</pre> </div> <div class="refsect1" title="Initialization"> <a id="idp37420088"></a> <h2>Initialization</h2> <p> <span class="emphasis"><em>ifn</em></span> -- function table number. </p> <p> <span class="emphasis"><em>ixmode</em></span> (optional) -- index data mode. The default value is 0. </p> <div class="itemizedlist"> <ul class="itemizedlist" type="disc"> <li class="listitem"> <p>0 = raw index</p> </li> <li class="listitem"> <p>1 = normalized (0 to 1)</p> </li> </ul> </div> <p> </p> <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 .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>0 = nowrap (index < 0 treated as index=0; index > tablesize sticks at index=size)</p> </li> <li class="listitem"> <p>1 = wraparound.</p> </li> </ul> </div> <p> </p> </div> <div class="refsect1" title="Performance"> <a id="idp37424328"></a> <h2>Performance</h2> <p> <span class="emphasis"><em>ptable</em></span> invokes table lookup on behalf of init, control or audio indices. These indices can be raw entry numbers (0, 1, 2,... size - 1) or scaled values (0 to 1). Indices are first modified by the offset value then checked for range before table lookup (see <span class="emphasis"><em>iwrap</em></span>). If index is likely to be full scale, or if interpolation is being used, the table should have an extended guard point. <span class="emphasis"><em>table</em></span> indexed by a periodic phasor ( see <a class="link" href="phasor.html" title="phasor"><em class="citetitle">phasor</em></a>) will simulate an oscillator. </p> </div> <div class="refsect1" title="Examples"> <a id="idp37426480"></a> <h2>Examples</h2> <p> Here is an example of the ptable opcode. It uses the file <a class="ulink" href="examples/ptable.csd" target="_top"><em class="citetitle">ptable.csd</em></a>. </p> <div class="example"> <a id="idp37427448"></a> <p class="title"> <strong>Example 623. Example of the ptable 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 No messages</span> -odac -iadc -d <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 table.wav -W ;;; for file output any platform</span> <span class="csdtag"></CsOptions></span> <span class="csdtag"><CsInstruments></span> <span class="comment">; Initialize the global variables.</span> <span class="ohdr">sr</span> <span class="op">=</span> 44100 <span class="ohdr">kr</span> <span class="op">=</span> 4410 <span class="ohdr">ksmps</span> <span class="op">=</span> 10 <span class="ohdr">nchnls</span> <span class="op">=</span> 1 <span class="comment">; Instrument #1.</span> <span class="oblock">instr</span> 1 <span class="comment">; Vary our index linearly from 0 to 1.</span> kndx <span class="opc">line</span> 0, p3, 1 <span class="comment">; Read Table #1 with our index.</span> ifn <span class="op">=</span> 1 ixmode <span class="op">=</span> 1 kfreq <span class="opc">ptable</span> kndx, ifn, ixmode <span class="comment">; Generate a sine waveform, use our table values </span> <span class="comment">; to vary its frequency.</span> a1 <span class="opc">oscil</span> 20000, kfreq, 2 <span class="opc">out</span> a1 <span class="oblock">endin</span> <span class="csdtag"></CsInstruments></span> <span class="csdtag"><CsScore></span> <span class="comment">; Table #1, a line from 200 to 2,000.</span> <span class="stamnt">f</span> 1 0 1025 -7 200 1024 2000 <span class="comment">; Table #2, a sine wave.</span> <span class="stamnt">f</span> 2 0 16384 10 1 <span class="comment">; Play Instrument #1 for 2 seconds.</span> <span class="stamnt">i</span> 1 0 2 <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="See Also"> <a id="idp37429720"></a> <h2>See Also</h2> <p> <a class="link" href="table.html" title="table"><em class="citetitle">table</em></a>, <a class="link" href="tablei.html" title="tablei"><em class="citetitle">tablei</em></a>, <a class="link" href="table3.html" title="table3"><em class="citetitle">table3</em></a>, <a class="link" href="ptable3.html" title="ptable3"><em class="citetitle">ptable3</em></a>, <a class="link" href="ptablei.html" title="ptablei"><em class="citetitle">ptablei</em></a>, <a class="link" href="oscil1.html" title="oscil1"><em class="citetitle">oscil1</em></a>, <a class="link" href="oscil1i.html" title="oscil1i"><em class="citetitle">oscil1i</em></a>, <a class="link" href="osciln.html" title="osciln"><em class="citetitle">osciln</em></a> </p> </div> <div class="refsect1" title="Credits"> <a id="idp37434096"></a> <h2>Credits</h2> <p> </p> <table border="0" summary="Simple list" class="simplelist"> <tr> <td>Author: John ffitch</td> </tr> <tr> <td>Jan 2012</td> </tr> </table> <p> </p> <p>New in Csound version 5.16</p> </div> </div> <div class="navfooter"> <hr /> <table width="100%" summary="Navigation footer"> <tr> <td width="40%" align="left"><a accesskey="p" href="pset.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="ptablei.html">Next</a></td> </tr> <tr> <td width="40%" align="left" valign="top">pset </td> <td width="20%" align="center"> <a accesskey="h" href="index.html">Home</a> </td> <td width="40%" align="right" valign="top"> ptablei</td> </tr> </table> </div> </body> </html>