Sophie

Sophie

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

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>GEN01</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="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="idp76484696"></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="idp76485480"></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="idp77084616"></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>
                    <li class="listitem">
                      <p>
              GEN01 also works with WAV and OGG and a dozen and more other sound formats; these file formats depend on libsndfile, see <a class="ulink" href="http://www.mega-nerd.com/libsndfile/" target="_top"><em class="citetitle">http://www.mega-nerd.com/libsndfile/</em></a>
            </p>
                    </li>
                  </ul>
                </div>
                <p>
      </p>
              </td>
            </tr>
          </table>
        </div>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp77096744"></a>
        <h2>Examples</h2>
        <p>
	    Here is an 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 several sound files.
      </p>
        <div class="example">
          <a id="idp77097768"></a>
          <p class="title">
            <strong>Example 1037. An example of the GEN01 routine.</strong>
          </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>
-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 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="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="oblock">instr</span> 1	<span class="comment">;plays deferred and non-deferred sounds with loscil</span>

ifn <span class="op">=</span> p4
ibas <span class="op">=</span> 1

asig <span class="opc">loscil</span> 1, 1, ifn, ibas
     <span class="opc">outs</span> asig, asig
    
<span class="oblock">endin</span>

<span class="oblock">instr</span> 2	<span class="comment">;plays only non-deffered sound            </span>

isnd  <span class="op">=</span> p4
aread <span class="opc">line</span>   <span class="ohdr">sr</span><span class="op">*</span>p3, p3, 0				<span class="comment">;play this backward</span>
asig  <span class="opc">tablei</span> aread, isnd				<span class="comment">;use table 1</span>
      <span class="opc">outs</span>   asig, asig
        
<span class="oblock">endin</span>
<span class="csdtag">&lt;/CsInstruments&gt;</span>
<span class="csdtag">&lt;CsScore&gt;</span>
<span class="stamnt">f</span> 1 0 131072 1 "beats.wav" 0 0 0			<span class="comment">;non-deferred sound</span>
<span class="stamnt">f</span> 2 0    0   1 "<span class="stamnt">f</span>lute.ai<span class="stamnt">f</span><span class="stamnt">f</span>" 0 0 0			<span class="comment">;&amp; deferred sounds in </span>
<span class="stamnt">f</span> 3 0    0   1 "beats.ogg" 0 0 0			<span class="comment">;different formats					</span>

<span class="stamnt">i</span> 1 0 1 1
<span class="stamnt">i</span> 1 + 1 2
<span class="stamnt">i</span> 1 + 1 3

<span class="stamnt">i</span> 2 4 2 1	<span class="comment">;non-deffered sound for instr. 2</span>
<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" />

        <span>These are the diagrams of the waveforms of the GEN01 routines, as used in the example:</span>

      </p>
        <div class="mediaobject">
          <img src="images/gen01_1.png" alt="f 1 0 131072 1 &quot;beats.wav&quot; 0 0 0 - non-deferred sound" />
          <div class="caption">
            <p>f 1 0 131072 1 "beats.wav" 0 0 0 - non-deferred sound</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen01_2.png" alt="f 2 0 0 1 &quot;flute.aiff&quot; 0 0 0 - deferred sound" />
          <div class="caption">
            <p>f 2 0 0 1 "flute.aiff" 0 0 0 - deferred sound</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen01_3.png" alt="f 3 0 0 1 &quot;beats.ogg&quot; 0 0 0 - deferred sound" />
          <div class="caption">
            <p>f 3 0 0 1 "beats.ogg" 0 0 0 - deferred sound</p>
          </div>
        </div>
        <p>

    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp77104392"></a>
        <h2>Credits</h2>
        <p>September 2003. Thanks goes to Dr. Richard Boulanger for pointing out the references to the AIFF file format.</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>