Sophie

Sophie

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

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>GEN01</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="ScoreGenRef.html" title="GEN Routines" />
    <link rel="next" href="GEN02.html" title="GEN02" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN01</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="ScoreGenRef.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN02.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="GEN01">
      <a id="GEN01"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN01" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN01</span>
        </h2>
        <p>GEN01 — 
      Transfers data from a soundfile into a function table.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="id3718220"></a>
        <h2>Description</h2>
        <p>
      This subroutine transfers data from a soundfile into a function table.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="id3718233"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span>#  time  size  1  filcod  skiptime  format  channel</pre>
      </div>
      <div class="refsect1" title="Performance">
        <a id="id3728866"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>size</em></span> -- number of points in the table. Ordinarily 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. The allocation of table memory can be <span class="emphasis"><em>deferred</em></span> by setting this parameter to 0; the size allocated is then the number of points in the file (probably not a power-of-2), and the table is not usable by normal oscillators, but it is usable by a <a class="link" href="loscil.html" title="loscil"><em class="citetitle">loscil</em></a> unit. The soundfile can also be mono or stereo.
    </p>
        <p>
      <span class="emphasis"><em>filcod</em></span> -- integer or character-string denoting the source soundfile name. An integer denotes the file <span class="emphasis"><em>soundin</em></span>.<span class="emphasis"><em>filcod</em></span> ; a character-string (in double quotes, spaces permitted) gives the filename itself, optionally a full pathname. If not a full path, the file is sought first in the current directory, then in that given by the environment variable <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SSDIR</em></a> (if defined) then by <a class="link" href="CommandEnvironment.html" title="Csound Environment Variables"><em class="citetitle">SFDIR</em></a>. See also <a class="link" href="soundin.html" title="soundin"><em class="citetitle">soundin</em></a>.
    </p>
        <p>
      <span class="emphasis"><em>skiptime</em></span> -- begin reading at <span class="emphasis"><em>skiptime</em></span> seconds into the file.
    </p>
        <p>
      <span class="emphasis"><em>channel</em></span> -- channel number to read in. 0 denotes read all channels.
    </p>
        <p>
      <span class="emphasis"><em>format</em></span> -- specifies the audio data-file format:
        </p>
        <div class="literallayout">
          <p><br />
1 - 8-bit signed character    4 - 16-bit short integers <br />
2 - 8-bit A-law bytes         5 - 32-bit long integers <br />
3 - 8-bit U-law bytes         6 - 32-bit floats<br />
        </p>
        </div>
        <p>
    </p>
        <p>
      If <span class="emphasis"><em>format</em></span> = 0 the sample format is taken from the soundfile header, or by default from the CSound <a class="link" href="CommandFlags.html#FlagsMinusLowerO"><em class="citetitle">-o</em></a> command-line flag.
    </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>
        </p>
                <div class="itemizedlist">
                  <ul class="itemizedlist" type="disc">
                    <li class="listitem">
                      <p>
              Reading stops at end-of-file or when the table is full. Table locations not filled will contain zeros.
            </p>
                    </li>
                    <li class="listitem">
                      <p>
              If p4 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.
            </p>
                    </li>
                  </ul>
                </div>
                <p>
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="id3729051"></a>
        <h2>Examples</h2>
        <p>
	    Here is a simple example of the GEN01 routine. It uses the files <a class="ulink" href="examples/gen01.csd" target="_top"><em class="citetitle">gen01.csd</em></a>, and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>. It uses the audio file <span class="quote">“<span class="quote">beats.wav</span>”</span>, here is its diagram:
      </p>
        <div class="mediaobject">
          <img src="images/gen01.png" alt="Diagram of the waveform generated by GEN01." />
          <div class="caption">
            <p>Diagram of the waveform generated by GEN01.</p>
          </div>
        </div>
        <p>

      </p>
        <div class="example">
          <a id="id3729108"></a>
          <p class="title">
            <b>Example 732. A simple example of the GEN01 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 gen01.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
   kamp <span class="op">=</span> 30000
   kcps <span class="op">=</span> 1
   ifn <span class="op">=</span> 1
   ibas <span class="op">=</span> 1

   <span class="comment">; Play the audio sample stored in Table #1.</span>
   a1 <span class="opc">loscil</span> kamp, kcps, ifn, ibas
   <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: read an audio file (using GEN01).</span>
<span class="stamnt">f</span> 1 0 131072 1 "beats.wav" 0 4 0

<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 GEN01 routine. Csound will automatically compute the tablesize because we have set it to 0. This example uses the files <a class="ulink" href="examples/gen01computed.csd" target="_top"><em class="citetitle">gen01computed.csd</em></a>, and <a class="ulink" href="examples/beats.wav" target="_top"><em class="citetitle">beats.wav</em></a>.

      </p>
        <div class="example">
          <a id="id3729143"></a>
          <p class="title">
            <b>Example 733. An example of the GEN01 routine with a computed tablesize.</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 gen01computed.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
   kamp <span class="op">=</span> 30000
   kcps <span class="op">=</span> 1
   ifn <span class="op">=</span> 1
   ibas <span class="op">=</span> 1

   <span class="comment">; Play the audio sample stored in Table #1.</span>
   a1 <span class="opc">loscil</span> kamp, kcps, ifn, ibas
   <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 audio file (using GEN01).</span>
<span class="comment">; Since our table size is 0, Csound will compute it.</span>
<span class="stamnt">f</span> 1 0 0 1 "beats.wav" 0 0 0

<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="Credits">
        <a id="id3729161"></a>
        <h2>Credits</h2>
        <p>Examples written by Kevin Conder</p>
        <p>December 2002. Thanks goes to Kanata Motohashi for fixing mistakes in the examples.</p>
        <p>September 2003. Thanks goes to Dr. Richard Boulanger for pointing out the references to the AIFF file format. GEN01 also works with WAV files.</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="ScoreGenRef.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="GEN02.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN Routines </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN02</td>
        </tr>
      </table>
    </div>
  </body>
</html>