Sophie

Sophie

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

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>adsynt2</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="OpcodesTop.html" title="Orchestra Opcodes and Operators" />
    <link rel="prev" href="adsynt.html" title="adsynt" />
    <link rel="next" href="aftouch.html" title="aftouch" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">adsynt2</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="adsynt.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="aftouch.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="adsynt2">
      <a id="adsynt2"></a>
      <div class="titlepage"></div>
      <a id="IndexAdsynt2" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">adsynt2</span>
        </h2>
        <p>adsynt2 — 
      Performs additive synthesis with an arbitrary number of partials -not necessarily harmonic- with interpolation.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp13362632"></a>
        <h2>Description</h2>
        <p>
      Performs additive synthesis with an arbitrary number of partials, not necessarily harmonic. (see <a class="link" href="adsynt.html" title="adsynt"><em class="citetitle">adsynt</em></a> for detailed manual)
    </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp13373136"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ar <span class="command"><strong>adsynt2</strong></span> kamp, kcps, iwfn, ifreqfn, iampfn, icnt [, iphs]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp13374272"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>iwfn</em></span> -- table containing a waveform, usually a sine. Table values are not interpolated for performance reasons, so larger tables provide better quality.
    </p>
        <p>
      <span class="emphasis"><em>ifreqfn</em></span> -- table containing frequency values for each partial. <span class="emphasis"><em>ifreqfn</em></span> may contain beginning frequency values for each partial, but is usually used for generating parameters at runtime with <span class="emphasis"><em>tablew</em></span>. Frequencies must be relative to <span class="emphasis"><em>kcps</em></span>. Size must be at least <span class="emphasis"><em>icnt</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>iampfn</em></span> -- table containing amplitude values for each partial. <span class="emphasis"><em>iampfn</em></span> may contain beginning amplitude values for each partial, but is usually used for generating parameters at runtime with <span class="emphasis"><em>tablew</em></span>. Amplitudes must be relative to <span class="emphasis"><em>kamp</em></span>. Size must be at least <span class="emphasis"><em>icnt</em></span>.
    </p>
        <p>
      <span class="emphasis"><em>icnt</em></span> -- number of partials to be generated
    </p>
        <p>
      <span class="emphasis"><em>iphs</em></span> -- initial phase of each oscillator, if <span class="emphasis"><em>iphs</em></span> = -1, initialization is skipped. If <span class="emphasis"><em>iphs</em></span> &gt; 1, all phases will be initialized with a random value.
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp13417696"></a>
        <h2>Performance</h2>
        <p>
      <span class="emphasis"><em>kamp</em></span> -- amplitude of note
    </p>
        <p>
      <span class="emphasis"><em>kcps</em></span> -- base frequency of note. Partial frequencies will be relative to <span class="emphasis"><em>kcps</em></span>.
    </p>
        <p>
       Frequency and amplitude of each partial is given in the two tables provided. The purpose of this opcode is to have an instrument generate synthesis parameters at k-rate and write them to global parameter tables with the <span class="emphasis"><em>tablew</em></span> opcode.
    </p>
        <p>
    <span class="emphasis"><em>adsynt2</em></span> is identical to <span class="emphasis"><em>adsynt</em></span> (by Peter Neubäcker), except it provides linear interpolation for amplitude envelopes of each partial. It is a bit slower than <span class="emphasis"><em>adsynt</em></span>, but interpolation higly improves sound quality in fast amplitude envelope transients when <span class="emphasis"><em>kr</em></span> &lt; <span class="emphasis"><em>sr</em></span> (i.e. when <span class="emphasis"><em>ksmps</em></span> &gt; 1). No interpolation is provided for pitch envelopes, since in this case sound quality degradation is not so evident even with high values of <span class="emphasis"><em>ksmps</em></span>. It is not recommended when <span class="emphasis"><em>kr</em></span> = <span class="emphasis"><em>sr</em></span>, in this case <span class="emphasis"><em>adsynt</em></span> is better (since it is faster).
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp13423000"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the adsynt2 opcode. It uses the file <a class="ulink" href="examples/adsynt2.csd" target="_top"><em class="citetitle">adsynt2.csd</em></a>. These two instruments perform additive synthesis. The output of each sounds like a Tibetan bowl. The first one is static, as parameters are only generated at init-time. In the second one, parameters are continuously changed.

      </p>
        <div class="example">
          <a id="idp13424200"></a>
          <p class="title">
            <strong>Example 42. Example of the adsynt2 opcode.</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">;;;RT audio out</span>
<span class="comment">;-iadc    ;;;uncomment -iadc if RT audio input is needed too</span>
<span class="comment">; For Non-realtime ouput leave only the line below:</span>
<span class="comment">; -o adsynt2.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="comment">; Generate a sinewave table.</span>
giwave <span class="ohdr">ftgen</span> 1, 0, 1024, 10, 1
<span class="comment">; Generate two empty tables for adsynt2.</span>
gifrqs <span class="ohdr">ftgen</span> 2, 0, 32, 7, 0, 32, 0
<span class="comment">; A table for freqency and amp parameters.</span>
giamps <span class="ohdr">ftgen</span> 3, 0, 32, 7, 0, 32, 0
  
<span class="comment">; Generates parameters at init time</span>
<span class="oblock">instr</span> 1
  <span class="comment">; Generate 10 voices.</span>
  icnt <span class="op">=</span> 10 
  <span class="comment">; Init loop index.</span>
  index <span class="op">=</span> 0 

<span class="comment">; Loop only executed at init time.</span>
<span class="olabel">loop</span><span class="op">:</span> 
  <span class="comment">; Define non-harmonic partials.</span>
  ifreq <span class="opc">pow</span> index <span class="op">+</span> 1, 1.5 
  <span class="comment">; Define amplitudes.</span>
  iamp <span class="op">=</span> 1 <span class="op">/</span> (index<span class="op">+</span>1) 
  <span class="comment">; Write to tables.</span>
  <span class="opc">tableiw</span> ifreq, index, gifrqs 
  <span class="comment">; Used by adsynt2.</span>
  <span class="opc">tableiw</span> iamp, index, giamps 
  
  index <span class="op">=</span> index <span class="op">+</span> 1
  <span class="comment">; Do loop/</span>
  <span class="octrl">if</span> (index <span class="op">&lt;</span> icnt) <span class="octrl">igoto</span> <span class="olabel">loop</span> 
  
  asig <span class="opc">adsynt2</span> 0.4, 150, giwave, gifrqs, giamps, icnt
  <span class="opc">outs</span> asig, asig
<span class="oblock">endin</span>

<span class="comment">; Generates parameters every k-cycle.</span>
<span class="oblock">instr</span> 2 
  <span class="comment">; Generate 10 voices.</span>
  icnt <span class="op">=</span> 10 
  <span class="comment">; Reset loop index.</span>
  kindex <span class="op">=</span> 0

<span class="comment">; Loop executed every k-cycle.</span>
<span class="olabel">loop</span><span class="op">:</span>
  <span class="comment">; Generate lfo for frequencies.</span>
  kspeed  <span class="opc">pow</span> kindex <span class="op">+</span> 1, 1.6
  <span class="comment">; Individual phase for each voice.</span>
  kphas <span class="opc">phasorbnk</span> kspeed <span class="op">*</span> 0.7, kindex, icnt
  klfo <span class="opc">table</span> kphas, giwave, 1
  <span class="comment">; Arbitrary parameter twiddling...</span>
  kdepth <span class="opc">pow</span> 1.4, kindex
  kfreq <span class="opc">pow</span> kindex <span class="op">+</span> 1, 1.5
  kfreq <span class="op">=</span> kfreq <span class="op">+</span> klfo<span class="op">*</span>0.006<span class="op">*</span>kdepth

  <span class="comment">; Write freqs to table for adsynt2.</span>
  <span class="opc">tablew</span> kfreq, kindex, gifrqs 
  
  <span class="comment">; Generate lfo for amplitudes.</span>
  kspeed  <span class="opc">pow</span> kindex <span class="op">+</span> 1, 0.8
  <span class="comment">; Individual phase for each voice.</span>
  kphas <span class="opc">phasorbnk</span> kspeed<span class="op">*</span>0.13, kindex, icnt, 2
  klfo <span class="opc">table</span> kphas, giwave, 1
  <span class="comment">; Arbitrary parameter twiddling...</span>
  kamp <span class="opc">pow</span> 1 <span class="op">/</span> (kindex <span class="op">+</span> 1), 0.4
  kamp <span class="op">=</span> kamp <span class="op">*</span> (0.3<span class="op">+</span>0.35<span class="op">*</span>(klfo<span class="op">+</span>1))

  <span class="comment">; Write amps to table for adsynt2.</span>
  <span class="opc">tablew</span> kamp, kindex, giamps
  
  kindex <span class="op">=</span> kindex <span class="op">+</span> 1
  <span class="comment">; Do loop.</span>
  <span class="octrl">if</span> (kindex <span class="op">&lt;</span> icnt) <span class="octrl">kgoto</span> <span class="olabel">loop</span>

  asig <span class="opc">adsynt2</span> 0.25, 150, giwave, gifrqs, giamps, icnt
  <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="comment">; Play Instrument #1 for 2.5 seconds.</span>
<span class="stamnt">i</span> 1 0 2.5
<span class="comment">; Play Instrument #2 for 2.5 seconds.</span>
<span class="stamnt">i</span> 2 3 2.5
<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="idp13426480"></a>
        <h2>Credits</h2>
        <p>Written by Gabriel Maldonado.</p>
        <p>New in Csound 5 (Previously available only on CsoundAV)</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="adsynt.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="aftouch.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">adsynt </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> aftouch</td>
        </tr>
      </table>
    </div>
  </body>
</html>