Sophie

Sophie

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

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>GEN02</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="ScoregensTop.html" title="Score Statements and GEN Routines" />
    <link rel="prev" href="GEN01.html" title="GEN01" />
    <link rel="next" href="GEN03.html" title="GEN03" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN02</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN01.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN03.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="GEN02">
      <a id="GEN02"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN02" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN02</span>
        </h2>
        <p>GEN02 — 
      Transfers data from immediate pfields into a function table.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="id3728648"></a>
        <h2>Description</h2>
        <p>
      This subroutine transfers data from immediate pfields into a function table.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="id3728662"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 2 v1 v2 v3 ...</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="id3729626"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>size</em></span> -- number of points in the table. Must be a power of 2 or a power-of-2 plus 1 (see <a class="link" href="f.html" title="f Statement (or Function Table Statement)"><em class="citetitle">f statement</em></a>). The maximum tablesize is 16777216 (2<sup>24</sup>) points.
    </p>
        <p>
      <span class="emphasis"><em>v1, v2, v3,</em></span> etc. -- values to be copied directly into the table space. The number of values is limited by the compile-time variable <span class="emphasis"><em>PMAX</em></span>, which controls the maximum pfields (currently 1000). The values copied may include the table guard point; any table locations not filled will contain zeros.
    </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>
        If p4 (the GEN routine number is positive, the table will be
        post-normalized (rescaled to a maximum absolute value of 1 after
        generation). A negative p4 will cause rescaling to be skipped. You will
        usually want to use -2 with this GEN function, so that your values are
        not normalized.
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="id3729694"></a>
        <h2>Examples</h2>
        <p>
      Here is a simple example of the GEN02 routine. It uses the files <a class="ulink" href="examples/gen02.csd" target="_top"><em class="citetitle">gen02.csd</em></a>. It places 12 values plus an explicit wrap-around guard value into a table of size next-highest power of 2. Rescaling is inhibited. Here is its diagram:

      </p>
        <div class="mediaobject">
          <img src="images/gen02.png" alt="Diagram of the waveform generated by GEN02." />
          <div class="caption">
            <p>Diagram of the waveform generated by GEN02.</p>
          </div>
        </div>
        <p>

      </p>
        <div class="example">
          <a id="id3729743"></a>
          <p class="title">
            <b>Example 734. A simple example of the GEN02 routine.</b>
          </p>
          <div class="example-contents">
            <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 gen02.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">; Instrument #1.</span>
<span class="oblock">instr</span> 1
  <span class="comment">; Create an index over the length of our entire note.</span>
  kcps <span class="opc">init</span> 1<span class="op">/</span>p3
  kndx <span class="opc">phasor</span> kcps

  <span class="comment">; Read Table #1 with our index.</span>
  ifn <span class="op">=</span> 1
  ixmode <span class="op">=</span> 1
  kamp <span class="opc">tablei</span> kndx, ifn, ixmode

  <span class="comment">; Create a sine wave, use the Table #1 values to control</span>
  <span class="comment">; the amplitude. This creates a sound with a long attack.</span>
  a1 <span class="opc">oscil</span> kamp<span class="op">*</span>30000, 440, 2
  <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">; Table #1: an envelope with a long attack (using GEN02).</span>
<span class="stamnt">f</span> 1 0 16 2 0 1 2 3 4 5 6 7 8 9 10 11 0
<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">&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="id3729760"></a>
        <h2>See Also</h2>
        <p>
       <a class="link" href="GEN17.html" title="GEN17"><em class="citetitle">GEN17</em></a>
     </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="id3729778"></a>
        <h2>Credits</h2>
        <p>December 2002. Thanks to Rasmus Ekman, corrected the limit of the <span class="emphasis"><em>PMAX</em></span> variable.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN01.html">Prev</a> </td>
          <td width="20%" align="center">
            <a accesskey="u" href="ScoregensTop.html">Up</a>
          </td>
          <td width="40%" align="right"> <a accesskey="n" href="GEN03.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN01 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN03</td>
        </tr>
      </table>
    </div>
  </body>
</html>