Sophie

Sophie

distrib > Mageia > 5 > x86_64 > media > core-release > by-pkgid > b707d9a4ee443103660a75ccb6e51334 > files > 2396

csound-doc-5.19.01-10.mga5.noarch.rpm

<?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>ptablei</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="ptable.html" title="ptable" />
    <link rel="next" href="ptable3.html" title="ptable3" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ptablei</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ptable.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ptable3.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="ptablei">
      <a id="ptablei"></a>
      <div class="titlepage"></div>
      <a id="IndexPtablei" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ptablei</span>
        </h2>
        <p>ptablei — 
      Accesses table values by direct indexing with linear interpolation.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp37362968"></a>
        <h2>Description</h2>
        <p>
      Accesses table values by direct indexing with linear interpolation.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp37460400"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>ptablei</strong></span> andx, ifn [, ixmode] [, ixoff] [, iwrap]</pre>
        <pre class="synopsis">ires <span class="command"><strong>ptablei</strong></span> indx, ifn [, ixmode] [, ixoff] [, iwrap]</pre>
        <pre class="synopsis">kres <span class="command"><strong>ptablei</strong></span> kndx, ifn [, ixmode] [, ixoff] [, iwrap]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp37462992"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>ifn</em></span> -- function table number.  The table
      need not be a power of 2 long.
    </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 &lt; 0 treated as index=0; index &gt; 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="idp37467280"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>ptablei</em></span> is a interpolating unit in which
      the fractional part of index is used to interpolate between
      adjacent table entries. The smoothness gained by interpolation
      is at some small cost in execution time (see also <a class="link" href="oscili.html" title="oscili"><em class="citetitle">oscili</em></a>, etc.),
      but the interpolating and non-interpolating units are otherwise
      interchangeable.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp37468888"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the ptablei opcode. It uses the file <a class="ulink" href="examples/ptablei.csd" target="_top"><em class="citetitle">ptablei.csd</em></a>.
      </p>
        <div class="example">
          <a id="idp37469864"></a>
          <p class="title">
            <strong>Example 624. Example of the ptablei 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">&lt;CsoundSynthesizer&gt;</span>
<span class="csdtag">&lt;CsOptions&gt;</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 realtime audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o tablei.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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	<span class="comment">;generate new values every time the instr is played</span>

<span class="oblock">instr</span> 1

ifn <span class="op">=</span> p4
isize <span class="op">=</span> p5
ithresh <span class="op">=</span> 0.5
    
itemp <span class="ohdr">ftgen</span> ifn, 0, isize, 21, 2

iwrite_value <span class="op">=</span> 0
i_index <span class="op">=</span> 0
    
<span class="olabel">loop_start</span><span class="op">:</span>
    iread_value <span class="opc">ptablei</span> i_index, ifn
    
    <span class="octrl">if</span> iread_value <span class="op">&gt;</span> ithresh <span class="octrl">then</span>
         iwrite_value <span class="op">=</span> 1
    <span class="octrl">else</span>
         iwrite_value <span class="op">=</span> <span class="op">-</span>1
    <span class="octrl">endif</span>
<span class="opc">ptableiw</span> iwrite_value, i_index, ifn
<span class="octrl">loop_lt</span> i_index, 1, isize, <span class="olabel">loop_start</span>
    <span class="opc">turnoff</span>

<span class="oblock">endin</span>

<span class="oblock">instr</span> 2

ifn <span class="op">=</span> p4
isize <span class="op">=</span> <span class="opc">ftlen</span>(ifn)    
<span class="opc">prints</span> "Index\tValue\n"
    
i_index <span class="op">=</span> 0
<span class="olabel">loop_start</span><span class="op">:</span>
    ivalue <span class="opc">tablei</span> i_index, ifn
    <span class="opc">prints</span> "<span class="op">%</span>d<span class="op">:</span>\t<span class="op">%</span>f\n", i_index, ivalue

  <span class="octrl">loop_lt</span> i_index, 1, isize, <span class="olabel">loop_start</span>		<span class="comment">;read table 1 with our index</span>

aout <span class="opc">oscili</span> .5, 100, ifn			<span class="comment">;use table to play the polypulse</span>
     <span class="opc">outs</span>   aout, aout

<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">i</span> 1 0 1 100 16
<span class="stamnt">i</span> 2 0 2 100
<span class="stamnt">e</span>
<span class="csdtag">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp37472144"></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="ptable.html" title="ptable"><em class="citetitle">ptable</em></a>,
      <a class="link" href="ptable3.html" title="ptable3"><em class="citetitle">ptable3</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>
        <p> More information on this opcode: <a class="ulink" href="http://www.csounds.com/journal/issue12/genInstruments.html" target="_top"><em class="citetitle">http://www.csounds.com/journal/issue12/genInstruments.html</em></a>  , written by Jacob Joaquin </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp37477296"></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="ptable.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="ptable3.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">ptable </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ptable3</td>
        </tr>
      </table>
    </div>
  </body>
</html>