Sophie

Sophie

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

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>GEN09</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="GEN08.html" title="GEN08" />
    <link rel="next" href="GEN10.html" title="GEN10" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">GEN09</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="GEN08.html">Prev</a> </td>
          <th width="60%" align="center">Score Statements and GEN Routines</th>
          <td width="20%" align="right"> <a accesskey="n" href="GEN10.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="GEN09">
      <a id="GEN09"></a>
      <div class="titlepage"></div>
      <a id="IndexGEN09" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">GEN09</span>
        </h2>
        <p>GEN09 — 
      Generate composite waveforms made up of weighted sums of simple sinusoids.
    </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp77393360"></a>
        <h2>Description</h2>
        <p>
      These subroutines generate composite waveforms made up of weighted sums of simple sinusoids. The specification of each contributing partial requires 3 p-fields using <span class="emphasis"><em>GEN09</em></span>.
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp77380128"></a>
        <h2>Syntax</h2>
        <pre class="synopsis"><span class="command"><strong>f</strong></span> # time size 9 pna stra phsa pnb strb phsb ...</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp77381200"></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 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>).
    </p>
        <p>
      <span class="emphasis"><em>pna, pnb</em></span>, etc. -- partial no. (relative to a fundamental that would occupy <span class="emphasis"><em>size</em></span> locations per cycle) of sinusoid a, sinusoid b, etc. Must be positive, but need not be a whole number, i.e., non-harmonic partials are permitted. Partials may be in any order.
    </p>
        <p>
      <span class="emphasis"><em>stra, strb</em></span>, etc. -- strength of partials <span class="emphasis"><em>pna, pnb</em></span>, etc. These are relative strengths, since the composite waveform may be rescaled later. Negative values are permitted and imply a 180 degree phase shift.
    </p>
        <p>
      <span class="emphasis"><em>phsa, phsb</em></span>, etc. -- initial phase of partials <span class="emphasis"><em>pna, pnb,</em></span> etc., expressed in degrees (0-360).
    </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>
              These subroutines generate stored functions as sums of sinusoids of different frequencies. The two major restrictions on <span class="emphasis"><em>GEN10</em></span> that the partials be harmonic and in phase do not apply to <span class="emphasis"><em>GEN09</em></span> or <span class="emphasis"><em>GEN19</em></span>.
            </p>
                      <p>
              In each case the composite wave, once drawn, is then rescaled to unity if p4 was positive. 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="idp77439704"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the GEN09 routine. It uses the files <a class="ulink" href="examples/gen09.csd" target="_top"><em class="citetitle">gen09.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp77440680"></a>
          <p class="title">
            <strong>Example 1045. Example of the GEN09 routine.</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 gen09.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

gi1 <span class="ohdr">ftgen</span> 1,0,2^10,9,  1,3,0,   3,1,0, 9,0.333,180		<span class="comment">;an approximation of a square wave</span>
gi2 <span class="ohdr">ftgen</span> 2,0,2^10,9,  1,3,180, 3,1,0, 9,0.333,0		<span class="comment">;same values as gi1, except some phase values</span>
gi3 <span class="ohdr">ftgen</span> 3,0,2^10,9,  1, .4, 0,   2.2, .5, 0,   3.8, 1, 0	<span class="comment">;inharmonic, but does not sound well --&gt; wave does not end at same point as where it begins --&gt; artefacts</span>
gi4 <span class="ohdr">ftgen</span> 4,0,2^10,9,  10, .4, 0,   22, .5, 0,   38, 1, 0	<span class="comment">;the same proportions, but value of partial number is multiplied 10 times --&gt;the sound is much clearer,</span>
								<span class="comment">;because the sudden "jump" like the one in gi3 will pop up only once in 10 repetitions</span>

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

kamp <span class="op">=</span> .6
kcps <span class="op">=</span> 220
ifn  <span class="op">=</span> p4

asig <span class="opc">poscil</span> kamp, kcps<span class="op">*</span>p5, ifn
     <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">i</span> 1 0 2 1 1	<span class="comment">;subtle difference between table 1 and 2</span>
<span class="stamnt">i</span> 1 3 2 2 1
<span class="stamnt">i</span> 1 7 2 3 1	<span class="comment">;big difference between table 3 and 4</span>
<span class="stamnt">i</span> 1 10 2 4 .1	<span class="comment">;p5 has to compensate for the 10 repetitions of gi4 as opposed to gi3 to get the same pitch</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 GEN09 routines, as used in the example:</span>

      </p>
        <div class="mediaobject">
          <img src="images/gen09_1.png" alt="gi1 ftgen 1,0,2^10,9, 1,3,0, 3,1,0, 9,0.333,180 - approximation of a square wave" />
          <div class="caption">
            <p>gi1 ftgen 1,0,2^10,9,  1,3,0,   3,1,0, 9,0.333,180 - approximation of a square wave</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen09_2.png" alt="gi2 ftgen 2,0,2^10,9, 1,3,180, 3,1,0, 9,0.333,0 - same values as gi1, except phase value" />
          <div class="caption">
            <p>gi2 ftgen 2,0,2^10,9,  1,3,180,   3,1,0, 9,0.333,0 - same values as gi1, except phase value</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen09_3.png" alt="gi3 ftgen 3,0,2^10,9, 1,2,0, 3,2,0, 9,0.333,180 - inharmonic partials, but with distortion due to the sudden jump in ending and beginning of the wave" />
          <div class="caption">
            <p>gi3 ftgen 3,0,2^10,9,  1,2,0,   3,2,0, 9,0.333,180 - inharmonic partials, but with distortion due to the sudden jump in ending and beginning of the wave</p>
          </div>
        </div>
        <p>

      </p>
        <div class="mediaobject">
          <img src="images/gen09_4.png" alt="gi4 ftgen 4,0,2^10,9, 1,2,180, 3,2,0, 9,0.333,0 - same ratio as gi3, except with less artefacts" />
          <div class="caption">
            <p>gi4 ftgen 4,0,2^10,9,  1,2,180,   3,2,0, 9,0.333,0 - same ratio as gi3, except with less artefacts</p>
          </div>
        </div>
        <p>

    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp77450704"></a>
        <h2>See Also</h2>
        <p>
       <a class="link" href="GEN10.html" title="GEN10"><em class="citetitle">GEN10</em></a>, 
       <a class="link" href="GEN19.html" title="GEN19"><em class="citetitle">GEN19</em></a>
     </p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="GEN08.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="GEN10.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">GEN08 </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> GEN10</td>
        </tr>
      </table>
    </div>
  </body>
</html>