Sophie

Sophie

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

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>adsr</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="active.html" title="active" />
    <link rel="next" href="adsyn.html" title="adsyn" />
  </head>
  <body>
    <div class="navheader">
      <table width="100%" summary="Navigation header">
        <tr>
          <th colspan="3" align="center">adsr</th>
        </tr>
        <tr>
          <td width="20%" align="left"><a accesskey="p" href="active.html">Prev</a> </td>
          <th width="60%" align="center">Orchestra Opcodes and Operators</th>
          <td width="20%" align="right"> <a accesskey="n" href="adsyn.html">Next</a></td>
        </tr>
      </table>
      <hr />
    </div>
    <div class="refentry" title="adsr">
      <a id="adsr"></a>
      <div class="titlepage"></div>
      <a id="IndexAdsr" class="indexterm"></a>
      <div class="refnamediv">
        <h2>
          <span class="refentrytitle">adsr</span>
        </h2>
        <p>adsr — 
      Calculates the classical ADSR envelope using linear segments.
          </p>
      </div>
      <div class="refsect1" title="Description">
        <a id="idp13196920"></a>
        <h2>Description</h2>
        <p>
      Calculates the classical ADSR envelope using linear segments.
   </p>
      </div>
      <div class="refsect1" title="Syntax">
        <a id="idp13197680"></a>
        <h2>Syntax</h2>
        <pre class="synopsis">ares <span class="command"><strong>adsr</strong></span> iatt, idec, islev, irel [, idel]</pre>
        <pre class="synopsis">kres <span class="command"><strong>adsr</strong></span> iatt, idec, islev, irel [, idel]</pre>
      </div>
      <div class="refsect1" title="Initialization">
        <a id="idp13295480"></a>
        <h2>Initialization</h2>
        <p>
      <span class="emphasis"><em>iatt</em></span> -- duration of attack phase
    </p>
        <p>
      <span class="emphasis"><em>idec</em></span> -- duration of decay
    </p>
        <p>
      <span class="emphasis"><em>islev</em></span> -- level for sustain phase
    </p>
        <p>
      <span class="emphasis"><em>irel</em></span> -- duration of release phase
    </p>
        <p>
      <span class="emphasis"><em>idel</em></span> -- period of zero before the envelope starts
    </p>
      </div>
      <div class="refsect1" title="Performance">
        <a id="idp13298368"></a>
        <h2>Performance</h2>
        <p>
      The envelope generated is the range 0 to 1 and may need to be scaled 
      further, depending on the amplitude required. If using 
      <a class="link" href="Zerodbfs.html" title="0dbfs"><em class="citetitle">0dbfs</em></a> = 1, scaling down
      will probably be required since playing more than one note might result in clipping.
      If not using <a class="link" href="Zerodbfs.html" title="0dbfs"><em class="citetitle">0dbfs</em></a>, scaling
       to a large amplitude (e.g. 32000) might be required.
      </p>
        <p>
      The envelope may be described as:
      </p>
        <div class="mediaobject">
          <img src="images/adsr.png" alt="Picture of an ADSR envelope." />
          <div class="caption">
            <p>Picture of an ADSR envelope.</p>
          </div>
        </div>
        <p>
    </p>
        <p>
       The length of the sustain is calculated from the length of the note. This means <span class="emphasis"><em>adsr</em></span> is not suitable for use with MIDI events. The opcode <a class="link" href="madsr.html" title="madsr"><em class="citetitle">madsr</em></a> uses the <a class="link" href="linsegr.html" title="linsegr"><em class="citetitle">linsegr</em></a> mechanism, and so can be used in MIDI applications.
    </p>
        <p>
      <span class="emphasis"><em>adsr</em></span> is new in Csound version 3.49.
    </p>
      </div>
      <div class="refsect1" title="Examples">
        <a id="idp13304400"></a>
        <h2>Examples</h2>
        <p>
      Here is an example of the adsr opcode. It uses the file <a class="ulink" href="examples/adsr.csd" target="_top"><em class="citetitle">adsr.csd</em></a>.

      </p>
        <div class="example">
          <a id="idp13305376"></a>
          <p class="title">
            <strong>Example 39. Example of the adsr 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 adsr.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

iatt  <span class="op">=</span> p5
idec  <span class="op">=</span> p6  
islev <span class="op">=</span> p7
irel  <span class="op">=</span> p8

kenv	<span class="opc">adsr</span> iatt, idec, islev, irel
kcps <span class="op">=</span>  <span class="opc">cpspch</span>(p4) 	  <span class="comment">;frequency</span>

asig	<span class="opc">vco2</span>  kenv <span class="op">*</span> 0.8, kcps
	<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  1  7.00  .0001  1  .01  .001 <span class="comment">; short attack</span>
<span class="stamnt">i</span> 1  2  1  7.02  1  .5  .01  .001    <span class="comment">; long attack</span>
<span class="stamnt">i</span> 1  4  2  6.09  .0001  1 .1  .7     <span class="comment">; long release</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" />
    </p>
      </div>
      <div class="refsect1" title="See Also">
        <a id="idp13307672"></a>
        <h2>See Also</h2>
        <p>
      <a class="link" href="madsr.html" title="madsr"><em class="citetitle">madsr</em></a>,
      <a class="link" href="mxadsr.html" title="mxadsr"><em class="citetitle">mxadsr</em></a>,
      <a class="link" href="xadsr.html" title="xadsr"><em class="citetitle">xadsr</em></a>
    </p>
      </div>
      <div class="refsect1" title="Credits">
        <a id="idp13309696"></a>
        <h2>Credits</h2>
        <p>Author: John ffitch</p>
        <p>New in version 3.49</p>
      </div>
    </div>
    <div class="navfooter">
      <hr />
      <table width="100%" summary="Navigation footer">
        <tr>
          <td width="40%" align="left"><a accesskey="p" href="active.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="adsyn.html">Next</a></td>
        </tr>
        <tr>
          <td width="40%" align="left" valign="top">active </td>
          <td width="20%" align="center">
            <a accesskey="h" href="index.html">Home</a>
          </td>
          <td width="40%" align="right" valign="top"> adsyn</td>
        </tr>
      </table>
    </div>
  </body>
</html>