Sophie

Sophie

distrib > Fedora > 15 > i386 > by-pkgid > 6ed14ebfd686aa32f7956e552aa2e21d > files > 1685

csound-manual-5.13.0-5.fc15.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>ftgen</title>
    <link rel="stylesheet" href="csound.css" type="text/css" />
    <meta name="generator" content="DocBook XSL Stylesheets V1.75.2" />
    <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="ftfree.html" title="ftfree" />
    <link rel="next" href="ftgenonce.html" title="ftgenonce" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">ftgen</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ftfree.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="ftgenonce.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="ftgen">
      <a id="ftgen"></a>
      <div class="titlepage"></div>
      <a id="IndexFtgen" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">ftgen</span>
        </h2>
        <p>ftgen — 
      Generate a score function table from within the orchestra.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="id2922564"></a>
        <h2>Description</h2>
        <p>Generate a score function table from within the orchestra.</p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="id2922583"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">gir <span class="command"><strong>ftgen</strong></span> ifn, itime, isize, igen, iarga [, iargb ] [...]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="id2922602"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>gir</em></span> -- either a requested or automatically assigned table number above 100.
    </p>
        <p> 
      <span class="emphasis"><em>ifn</em></span> -- requested table number If <span class="emphasis"><em>ifn</em></span> is zero, the number is assigned automatically and the value placed in <span class="emphasis"><em>gir</em></span>. Any other value is used as the table number
    </p>
        <p>
      <span class="emphasis"><em>itime</em></span> -- is ignored, but otherwise corresponds to p2 in the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>isize</em></span> -- table size. Corresponds to p3 of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>igen</em></span> -- function table <span class="emphasis"><em>GEN</em></span> routine. Corresponds to p4 of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>iarga, iargb, ...</em></span> -- function table arguments. Correspond to p5 through p<span class="emphasis"><em>n</em></span> of the score <span class="emphasis"><em>f statement</em></span>.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="id2922691"></a>
        <h2>Performance</h2>
        <p>
      This is equivalent to table generation in the score with the <span class="emphasis"><em>f statement</em></span>.
    </p>
        <div class="note" title="Note" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="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>Csound was originally designed to support tables with power of two sizes only. Though this has changed in recent versions (you can use any size by using a negative number), many opcodes will not accept them.</p>
              </td>
            </tr>
          </table>
        </div>
        <div class="warning" title="Warning" style="margin-left: 0.5in; margin-right: 0.5in;">
          <table border="0" summary="Warning: Warning">
            <tr>
              <td rowspan="2" align="center" valign="top" width="25">
                <img alt="[Warning]" src="images/warning.png" />
              </td>
              <th align="left">Warning</th>
            </tr>
            <tr>
              <td align="left" valign="top">
                <p>
        Although Csound will not protest if ftgen is used inside instr-endin statements, this is not the intended or supported use, and must be handled with care as it has global effects. (In particular, a different size usually leads to relocation of the table, which may cause a crash or otherwise erratic behaviour.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="id2923532"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the ftgen opcode. It uses the file <a class="ulink" href="examples/ftgen.csd" target="_top"><em class="citetitle">ftgen.csd</em></a>.

      </p>
        <div class="example">
          <a id="id2923548"></a>
          <p class="title">
            <b>Example 275. Example of the ftgen opcode.</b>
          </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>
<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 ftgen.wav -W ;;; for file output any platform</span>
<span class="csdtag">&lt;/CsOptions&gt;</span>
<span class="csdtag">&lt;CsInstruments&gt;</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">; Table #1, a sine wave using the GEN10 routine.</span>
gitemp <span class="ohdr">ftgen</span> 1, 0, 16384, 10, 1

<span class="comment">; Instrument #1 - a basic oscillator.</span>
<span class="oblock">instr</span> 1
  kamp <span class="op">=</span> 10000
  kcps <span class="op">=</span> 440
  <span class="comment">; Use Table #1.</span>
  ifn <span class="op">=</span> 1

  a1 <span class="opc">oscil</span> kamp, kcps, ifn
  <span class="opc">out</span> a1
<span class="oblock">endin</span>


<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>

<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">&lt;/CsScore&gt;</span>
<span class="csdtag">&lt;/CsoundSynthesizer&gt;</span>
</pre>
          </div>
        </div>
        <p><br class="example-break" />
    </p>
        <p>
      Here is another example of the ftgen opcode. It uses the file <a class="ulink" href="examples/ftgen-2.csd" target="_top"><em class="citetitle">ftgen-2.csd</em></a>.
      </p>
        <div class="example">
          <a id="id2923596"></a>
          <p class="title">
            <b>Example 276. Example of the ftgen opcode.</b>
          </p>
          <div class="example-contents">
            <p>
          This example queries a file for it length to create an f-table of the appropriate size.
        </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>
<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 ftgen-2.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>  48000
  <span class="ohdr">ksmps</span>	    <span class="op">=</span>  16
  <span class="ohdr">nchnls</span>    <span class="op">=</span>  2

<span class="comment">;Example by Jonathan Murphy 2007</span>

  <span class="ohdr">0dbfs</span>	    <span class="op">=</span>  1

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

  Sfile	    <span class="op">=</span>    "beats.wav"

  ilen	    <span class="opc">filelen</span>   Sfile  <span class="comment">; Find length</span>
  isr	    <span class="opc">filesr</span>    Sfile  <span class="comment">; Find sample rate</span>

  isamps    <span class="op">=</span>  ilen <span class="op">*</span> isr  <span class="comment">; Total number of samples</span>
  isize	    <span class="opc">init</span>      1

<span class="olabel">loop</span><span class="op">:</span>
  isize	    <span class="op">=</span>  isize <span class="op">*</span> 2
<span class="comment">; Loop until isize is greater than number of samples</span>
<span class="octrl">if</span> (isize <span class="op">&lt;</span> isamps) <span class="octrl">igoto</span> <span class="olabel">loop</span>

  itab	    <span class="ohdr">ftgen</span>     0, 0, isize, 1, Sfile, 0, 0, 0
	    <span class="opc">print</span>     isize
	    <span class="opc">print</span>     isamps

  <span class="opc">turnoff</span>
    <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 10
<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="id2923619"></a>
        <h2>See also</h2>
        <p>
      <a class="link" href="ScoreGenRef.html" title="GEN Routines"><em class="citetitle">GEN routine overview</em></a>, <a class="link" href="ftgentmp.html" title="ftgentmp"><em class="citetitle">ftgentmp</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="id2923644"></a>
        <h2>Credits</h2>
        <p>
      </p>
        <table border="0" summary="Simple list" class="simplelist">
          <tr>
            <td>Author: Barry L. Vercoe</td>
          </tr>
          <tr>
            <td>M.I.T., Cambridge, Mass</td>
          </tr>
          <tr>
            <td>1997</td>
          </tr>
        </table>
        <p>
    </p>
        <p>Example written by Kevin Conder.</p>
        <p>Added warning April 2002 by Rasmus Ekman</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="ftfree.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="ftgenonce.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">ftfree </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> ftgenonce</td>
        </tr>
      </table>
    </div>
  </body>
</html>